From: Dinger, Tom Date: Mon, 14 Jul 2003 05:35:15 +0000 (+0000) Subject: [perl #22946] Bug in Unicode surrogate pair conversion in Perl_utf16_to_utf8 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=30f84f9e5679c246d4f88beeae6ff40079b53e3a;p=p5sagit%2Fp5-mst-13.2.git [perl #22946] Bug in Unicode surrogate pair conversion in Perl_utf16_to_utf8 From: "Dinger, Tom" (via RT) Message-ID: p4raw-id: //depot/perl@20211 --- diff --git a/utf8.c b/utf8.c index e86b3fd7..21d0f08 100644 --- a/utf8.c +++ b/utf8.c @@ -831,7 +831,8 @@ Perl_utf16_to_utf8(pTHX_ U8* p, U8* d, I32 bytelen, I32 *newlen) continue; } if (uv >= 0xd800 && uv < 0xdbff) { /* surrogates */ - UV low = *p++; + UV low = (p[0] << 8) + p[1]; + p += 2; if (low < 0xdc00 || low >= 0xdfff) Perl_croak(aTHX_ "Malformed UTF-16 surrogate"); uv = ((uv - 0xd800) << 10) + (low - 0xdc00) + 0x10000;