Fix bug in utf8 -> utf16 conversion with ncgen -l java.

re: issue https://github.com/Unidata/netcdf-c/issues/1171
ncgen was checking validity of the utf8->utf16 conversion
incorrectly.
This commit is contained in:
Dennis Heimbigner 2018-10-31 21:10:51 -06:00
parent 8d5e66ec5f
commit a2c3ae18ed

View File

@ -153,9 +153,9 @@ int nc_utf8_to_utf16(const unsigned char* s8, unsigned short** utf16p, size_t* l
goto done;
} else { /* move to next char */
/* Complain if top 16 bits not zero */
if((codepoint & 0x0000FFFF) != 0) {
ncstat = NC_EBADNAME;
goto done;
if((codepoint & 0xFFFF0000) != 0) {
ncstat = NC_EBADNAME;
goto done;
}
/* Truncate codepoint to 16 bits and store */
*p16++ = (unsigned short)(codepoint & 0x0000FFFF);