silence MSVC warning about conversion to uint8 (fix #86)

This commit is contained in:
Steven G. Johnson 2016-11-30 10:09:18 -05:00
parent f5567f306a
commit 8da37e2892
2 changed files with 7566 additions and 7568 deletions

View File

@ -166,24 +166,24 @@ UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_encode_char(utf8proc_int32_t uc, ut
if (uc < 0x00) { if (uc < 0x00) {
return 0; return 0;
} else if (uc < 0x80) { } else if (uc < 0x80) {
dst[0] = uc; dst[0] = (utf8proc_uint8_t) uc;
return 1; return 1;
} else if (uc < 0x800) { } else if (uc < 0x800) {
dst[0] = 0xC0 + (uc >> 6); dst[0] = (utf8proc_uint8_t)(0xC0 + (uc >> 6));
dst[1] = 0x80 + (uc & 0x3F); dst[1] = (utf8proc_uint8_t)(0x80 + (uc & 0x3F));
return 2; return 2;
// Note: we allow encoding 0xd800-0xdfff here, so as not to change // Note: we allow encoding 0xd800-0xdfff here, so as not to change
// the API, however, these are actually invalid in UTF-8 // the API, however, these are actually invalid in UTF-8
} else if (uc < 0x10000) { } else if (uc < 0x10000) {
dst[0] = 0xE0 + (uc >> 12); dst[0] = (utf8proc_uint8_t)(0xE0 + (uc >> 12));
dst[1] = 0x80 + ((uc >> 6) & 0x3F); dst[1] = (utf8proc_uint8_t)(0x80 + ((uc >> 6) & 0x3F));
dst[2] = 0x80 + (uc & 0x3F); dst[2] = (utf8proc_uint8_t)(0x80 + (uc & 0x3F));
return 3; return 3;
} else if (uc < 0x110000) { } else if (uc < 0x110000) {
dst[0] = 0xF0 + (uc >> 18); dst[0] = (utf8proc_uint8_t)(0xF0 + (uc >> 18));
dst[1] = 0x80 + ((uc >> 12) & 0x3F); dst[1] = (utf8proc_uint8_t)(0x80 + ((uc >> 12) & 0x3F));
dst[2] = 0x80 + ((uc >> 6) & 0x3F); dst[2] = (utf8proc_uint8_t)(0x80 + ((uc >> 6) & 0x3F));
dst[3] = 0x80 + (uc & 0x3F); dst[3] = (utf8proc_uint8_t)(0x80 + (uc & 0x3F));
return 4; return 4;
} else return 0; } else return 0;
} }
@ -193,28 +193,28 @@ static utf8proc_ssize_t unsafe_encode_char(utf8proc_int32_t uc, utf8proc_uint8_t
if (uc < 0x00) { if (uc < 0x00) {
return 0; return 0;
} else if (uc < 0x80) { } else if (uc < 0x80) {
dst[0] = uc; dst[0] = (utf8proc_uint8_t)uc;
return 1; return 1;
} else if (uc < 0x800) { } else if (uc < 0x800) {
dst[0] = 0xC0 + (uc >> 6); dst[0] = (utf8proc_uint8_t)(0xC0 + (uc >> 6));
dst[1] = 0x80 + (uc & 0x3F); dst[1] = (utf8proc_uint8_t)(0x80 + (uc & 0x3F));
return 2; return 2;
} else if (uc == 0xFFFF) { } else if (uc == 0xFFFF) {
dst[0] = 0xFF; dst[0] = (utf8proc_uint8_t)0xFF;
return 1; return 1;
} else if (uc == 0xFFFE) { } else if (uc == 0xFFFE) {
dst[0] = 0xFE; dst[0] = (utf8proc_uint8_t)0xFE;
return 1; return 1;
} else if (uc < 0x10000) { } else if (uc < 0x10000) {
dst[0] = 0xE0 + (uc >> 12); dst[0] = (utf8proc_uint8_t)(0xE0 + (uc >> 12));
dst[1] = 0x80 + ((uc >> 6) & 0x3F); dst[1] = (utf8proc_uint8_t)(0x80 + ((uc >> 6) & 0x3F));
dst[2] = 0x80 + (uc & 0x3F); dst[2] = (utf8proc_uint8_t)(0x80 + (uc & 0x3F));
return 3; return 3;
} else if (uc < 0x110000) { } else if (uc < 0x110000) {
dst[0] = 0xF0 + (uc >> 18); dst[0] = (utf8proc_uint8_t)(0xF0 + (uc >> 18));
dst[1] = 0x80 + ((uc >> 12) & 0x3F); dst[1] = (utf8proc_uint8_t)(0x80 + ((uc >> 12) & 0x3F));
dst[2] = 0x80 + ((uc >> 6) & 0x3F); dst[2] = (utf8proc_uint8_t)(0x80 + ((uc >> 6) & 0x3F));
dst[3] = 0x80 + (uc & 0x3F); dst[3] = (utf8proc_uint8_t)(0x80 + (uc & 0x3F));
return 4; return 4;
} else return 0; } else return 0;
} }
@ -737,4 +737,3 @@ UTF8PROC_DLLEXPORT utf8proc_uint8_t *utf8proc_NFKC(const utf8proc_uint8_t *str)
UTF8PROC_COMPOSE | UTF8PROC_COMPAT); UTF8PROC_COMPOSE | UTF8PROC_COMPAT);
return retval; return retval;
} }

View File

@ -14383,4 +14383,3 @@ const utf8proc_uint16_t utf8proc_combinations[] = {
72, 75, 72, 75,
1, 53694, 1, 53696, 1, 53694, 1, 53696,
}; };