瀏覽代碼

Fix uescapes for combining characters

I had a silly direction mistake in a bit shift that was causing the high
portion of all combining characters to be printed as \uD800 which is
obviously wrong. This bug only affects people using the non-default
uescape option during encoding.
pull/21/head 0.4.1
Paul J. Davis 13 年之前
父節點
當前提交
12bf41ee61
共有 2 個文件被更改,包括 10 次插入2 次删除
  1. +1
    -1
      c_src/utf8.c
  2. +9
    -1
      test/004-strings.t

+ 1
- 1
c_src/utf8.c 查看文件

@ -234,7 +234,7 @@ unicode_uescape(int val, char* p)
n = val - 0x10000;
p[0] = '\\';
p[1] = 'u';
if(int_to_hex((0xD800 | ((n &lt;&lt; 10) & 0x03FF)), p+2) < 0) {
if(int_to_hex((0xD800 | ((n &gt;&gt; 10) & 0x03FF)), p+2) < 0) {
return -1;
}
p[6] = '\\';

+ 9
- 1
test/004-strings.t 查看文件

@ -6,7 +6,7 @@ main([]) ->
code:add_pathz("ebin"),
code:add_pathz("test"),
etap:plan(83),
etap:plan(87),
util:test_good(good()),
util:test_good(uescaped(), [uescape]),
util:test_errors(errors()),
@ -36,6 +36,14 @@ uescaped() ->
{
<<"\"\\u8CA8\\u5481\\u3002\\u0091\\u0091\"">>,
<<232,178,168,229,146,129,227,128,130,194,145,194,145>>
},
{
<<"\"\\uD834\\uDD1E\"">>,
<<240, 157, 132, 158>>
},
{
<<"\"\\uD83D\\uDE0A\"">>,
<<240, 159, 152, 138>>
}
].

Loading…
取消
儲存