2014-03-08 13:52:40 +08:00
|
|
|
/*********************************************************************
|
2018-12-07 06:36:53 +08:00
|
|
|
* Copyright 2018, UCAR/Unidata
|
2014-03-08 13:52:40 +08:00
|
|
|
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
|
|
|
*********************************************************************/
|
|
|
|
|
2017-03-09 08:01:10 +08:00
|
|
|
#include "config.h"
|
2014-03-08 13:52:40 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
2014-03-09 11:41:30 +08:00
|
|
|
#include <string.h>
|
2014-03-08 13:52:40 +08:00
|
|
|
|
|
|
|
/* BOM Sequences */
|
|
|
|
static char* U8 = "\xEF\xBB\xBF"; /* UTF-8 */
|
|
|
|
static char* BE32 = "\x00\x00\xFE\xFF"; /* UTF-32; big-endian */
|
2017-11-17 23:22:49 +08:00
|
|
|
/* static char* LE32 = "\xFF\xFE"; /\* UTF-32; little-endian *\/ */
|
2014-03-08 13:52:40 +08:00
|
|
|
static char* BE16 = "\xFE\xFF"; /* UTF-16; big-endian */
|
2017-11-17 23:22:49 +08:00
|
|
|
/* static char* LE16 = "\xFF\xFE"; /\* UTF-16; little-endian *\/ */
|
2014-03-08 13:52:40 +08:00
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char** argv)
|
|
|
|
{
|
|
|
|
char* bom = U8;
|
2014-03-09 11:41:30 +08:00
|
|
|
size_t bomlen = 3;
|
2014-03-08 13:52:40 +08:00
|
|
|
if(argc > 1 && strlen(argv[1]) > 0) {
|
|
|
|
char* which = argv[1];
|
|
|
|
switch (which[0]) {
|
|
|
|
case '1': bom = BE16; bomlen = 2; break;
|
|
|
|
case '3': bom = BE32; bomlen = 2; break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fwrite(bom,1,bomlen,stdout);
|
|
|
|
exit(0);
|
|
|
|
}
|