netcdf-c/ncdump/bom.c
dmh a189b98b0b 1. Any test that references nctestserver/NC_findtestserver
should be under ENABLE_DAP_REMOTE_TESTS.
   Fixed to make sure that this is so.
   Also attempted to fix ncdap_test/CMakeLists.txt,
   but probably got it wrong.
   HT to Nico Schlomer.
2. Attempted to reduce the number of conversion errors
   when -Wconversion is set. Fixed oc2, but
   rest of netcdf remains to be done.
   HT to Nico Schlomer.
3. When doing #2, I discovered an error in ncgen.y
   that has remained hidden. This required some other
   test case fixes.
2014-03-08 20:41:30 -07:00

34 lines
986 B
C

/*********************************************************************
* Copyright 1993, UCAR/Unidata
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
*********************************************************************/
#include <config.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
/* BOM Sequences */
static char* U8 = "\xEF\xBB\xBF"; /* UTF-8 */
static char* BE32 = "\x00\x00\xFE\xFF"; /* UTF-32; big-endian */
static char* LE32 = "\xFF\xFE"; /* UTF-32; little-endian */
static char* BE16 = "\xFE\xFF"; /* UTF-16; big-endian */
static char* LE16 = "\xFF\xFE"; /* UTF-16; little-endian */
int
main(int argc, char** argv)
{
char* bom = U8;
size_t bomlen = 3;
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);
}