aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxim Dounin <mdounin@mdounin.ru>2014-01-04 03:32:15 +0400
committerMaxim Dounin <mdounin@mdounin.ru>2014-01-04 03:32:15 +0400
commiteb60e1e26d0fd90bff695cef359da1749bb00c59 (patch)
tree283a116915823f20db5153bc9f3ed9eb044734a4 /src
parentdef37d254aa4f9523b7bf82b1d26530e0b216842 (diff)
downloadnginx-eb60e1e26d0fd90bff695cef359da1749bb00c59.tar.gz
nginx-eb60e1e26d0fd90bff695cef359da1749bb00c59.zip
Win32: support for UTF-16 surrogate pairs (ticket #457).
Diffstat (limited to 'src')
-rw-r--r--src/os/win32/ngx_files.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/os/win32/ngx_files.c b/src/os/win32/ngx_files.c
index c1c749e36..32e28b5d4 100644
--- 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 *utf8, size_t *len)
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 *utf8, size_t *len)
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;
}