[nginx] Win32: support for UTF-16 surrogate pairs (ticket #457).
Maxim Dounin
mdounin at mdounin.ru
Fri Jan 3 23:49:11 UTC 2014
details: http://hg.nginx.org/nginx/rev/1cd23ca84a9b
branches:
changeset: 5501:1cd23ca84a9b
user: Maxim Dounin <mdounin at mdounin.ru>
date: Sat Jan 04 03:32:15 2014 +0400
description:
Win32: support for UTF-16 surrogate pairs (ticket #457).
diffstat:
src/os/win32/ngx_files.c | 23 +++++++++++++++++++++--
1 files changed, 21 insertions(+), 2 deletions(-)
diffs (51 lines):
diff --git a/src/os/win32/ngx_files.c b/src/os/win32/ngx_files.c
--- a/src/os/win32/ngx_files.c
+++ b/src/os/win32/ngx_files.c
@@ -799,13 +799,25 @@ ngx_utf8_to_utf16(u_short *utf16, u_char
continue;
}
+ if (u + 1 == last) {
+ *len = u - utf16;
+ break;
+ }
+
n = ngx_utf8_decode(&p, 4);
- if (n > 0xffff) {
+ if (n > 0x10ffff) {
ngx_set_errno(NGX_EILSEQ);
return NULL;
}
+ if (n > 0xffff) {
+ n -= 0x10000;
+ *u++ = (u_short) (0xd800 + (n >> 10));
+ *u++ = (u_short) (0xdc00 + (n & 0x03ff));
+ continue;
+ }
+
*u++ = (u_short) n;
}
@@ -838,12 +850,19 @@ ngx_utf8_to_utf16(u_short *utf16, u_char
n = ngx_utf8_decode(&p, 4);
- if (n > 0xffff) {
+ if (n > 0x10ffff) {
free(utf16);
ngx_set_errno(NGX_EILSEQ);
return NULL;
}
+ if (n > 0xffff) {
+ n -= 0x10000;
+ *u++ = (u_short) (0xd800 + (n >> 10));
+ *u++ = (u_short) (0xdc00 + (n & 0x03ff));
+ continue;
+ }
+
*u++ = (u_short) n;
}
More information about the nginx-devel
mailing list