wind: Support UTF-16–encoding non-BMP codepoints
View with ‘git show -b’. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
This commit is contained in:

committed by
Nico Williams

parent
821fac3648
commit
ba63461cd4
@@ -412,15 +412,30 @@ wind_utf8ucs2(const char *in, uint16_t *out, size_t *out_len)
|
|||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (u & 0xffff0000)
|
if (u >= 0x10000) {
|
||||||
return WIND_ERR_NOT_UTF16;
|
if (out) {
|
||||||
|
uint16_t high_ten_bits;
|
||||||
|
uint16_t low_ten_bits;
|
||||||
|
|
||||||
if (out) {
|
if (o + 2 > *out_len)
|
||||||
if (o >= *out_len)
|
return WIND_ERR_OVERRUN;
|
||||||
return WIND_ERR_OVERRUN;
|
|
||||||
out[o] = u;
|
u -= 0x10000;
|
||||||
|
high_ten_bits = (u >> 10) & 0x3ff;
|
||||||
|
low_ten_bits = u & 0x3ff;
|
||||||
|
|
||||||
|
out[o] = 0xd800 | high_ten_bits;
|
||||||
|
out[o+1] = 0xdc00 | low_ten_bits;
|
||||||
|
}
|
||||||
|
o += 2;
|
||||||
|
} else {
|
||||||
|
if (out) {
|
||||||
|
if (o >= *out_len)
|
||||||
|
return WIND_ERR_OVERRUN;
|
||||||
|
out[o] = u;
|
||||||
|
}
|
||||||
|
o++;
|
||||||
}
|
}
|
||||||
o++;
|
|
||||||
}
|
}
|
||||||
*out_len = o;
|
*out_len = o;
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user