#137657 html content serializer and nsISaveAsCharset does not handle surrogate correctly

handle surrogate pair
r=ftang, sr=blizzard
This commit is contained in:
shanjian%netscape.com 2002-08-26 20:23:14 +00:00
parent 8292d6678c
commit 6e05a86467

View File

@ -477,7 +477,14 @@ ConvertAndWrite(const nsAString& aString,
NS_ENSURE_SUCCESS(rv, rv);
nsCAutoString entString("&#");
entString.AppendInt(unicodeBuf[unicodeLength - 1]);
if (IS_HIGH_SURROGATE(unicodeBuf[unicodeLength - 1]) &&
unicodeLength < startLength && IS_LOW_SURROGATE(unicodeBuf[unicodeLength])) {
entString.AppendInt(SURROGATE_TO_UCS4(unicodeBuf[unicodeLength - 1],
unicodeBuf[unicodeLength]));
unicodeLength += 1;
}
else
entString.AppendInt(unicodeBuf[unicodeLength - 1]);
entString.Append(';');
rv = aStream->Write(entString.get(), entString.Length(), &written);