mirror of
https://github.com/nginx/nginx.git
synced 2025-06-07 17:52:38 +08:00
Win32: support for UTF-16 surrogate pairs (ticket #457).
This commit is contained in:
parent
def37d254a
commit
eb60e1e26d
@ -799,13 +799,25 @@ ngx_utf8_to_utf16(u_short *utf16, u_char *utf8, size_t *len)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (u + 1 == last) {
|
||||||
|
*len = u - utf16;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
n = ngx_utf8_decode(&p, 4);
|
n = ngx_utf8_decode(&p, 4);
|
||||||
|
|
||||||
if (n > 0xffff) {
|
if (n > 0x10ffff) {
|
||||||
ngx_set_errno(NGX_EILSEQ);
|
ngx_set_errno(NGX_EILSEQ);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (n > 0xffff) {
|
||||||
|
n -= 0x10000;
|
||||||
|
*u++ = (u_short) (0xd800 + (n >> 10));
|
||||||
|
*u++ = (u_short) (0xdc00 + (n & 0x03ff));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
*u++ = (u_short) n;
|
*u++ = (u_short) n;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -838,12 +850,19 @@ ngx_utf8_to_utf16(u_short *utf16, u_char *utf8, size_t *len)
|
|||||||
|
|
||||||
n = ngx_utf8_decode(&p, 4);
|
n = ngx_utf8_decode(&p, 4);
|
||||||
|
|
||||||
if (n > 0xffff) {
|
if (n > 0x10ffff) {
|
||||||
free(utf16);
|
free(utf16);
|
||||||
ngx_set_errno(NGX_EILSEQ);
|
ngx_set_errno(NGX_EILSEQ);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (n > 0xffff) {
|
||||||
|
n -= 0x10000;
|
||||||
|
*u++ = (u_short) (0xd800 + (n >> 10));
|
||||||
|
*u++ = (u_short) (0xdc00 + (n & 0x03ff));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
*u++ = (u_short) n;
|
*u++ = (u_short) n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user