runtime: Fix handling of surrogate pairs in string([]rune).

From-SVN: r205422
This commit is contained in:
Ian Lance Taylor 2013-11-26 23:27:29 +00:00
parent b168a8dfcc
commit 763d87526f

View File

@ -30,6 +30,8 @@ __go_int_array_to_string (const void* p, intgo len)
if (v < 0 || v > 0x10ffff)
v = 0xfffd;
else if (0xd800 <= v && v <= 0xdfff)
v = 0xfffd;
if (v <= 0x7f)
slen += 1;
@ -56,6 +58,8 @@ __go_int_array_to_string (const void* p, intgo len)
character. */
if (v < 0 || v > 0x10ffff)
v = 0xfffd;
else if (0xd800 <= v && v <= 0xdfff)
v = 0xfffd;
if (v <= 0x7f)
*s++ = v;