зеркало из https://github.com/mozilla/pjs.git
Fixing bug 394275. Fix problem with UTF16 to UTF8 character conversions when dealing with broken UTF16 characters. r+sr=jonas@sicking.cc
This commit is contained in:
Родитель
f4c26907b8
Коммит
c88ff4b755
|
@ -603,9 +603,16 @@ class ConvertUTF16toUTF8
|
||||||
++p;
|
++p;
|
||||||
if (p == end)
|
if (p == end)
|
||||||
{
|
{
|
||||||
NS_ERROR("Surrogate pair split between fragments");
|
// Treat broken characters as the Unicode
|
||||||
mBuffer = out;
|
// replacement character 0xFFFD (0xEFBFBD in
|
||||||
return N;
|
// UTF-8)
|
||||||
|
*out++ = 0xEF;
|
||||||
|
*out++ = 0xBF;
|
||||||
|
*out++ = 0xBD;
|
||||||
|
|
||||||
|
NS_WARNING("String ending in half a surrogate pair!");
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
c = *p;
|
c = *p;
|
||||||
|
|
||||||
|
@ -692,8 +699,14 @@ class CalculateUTF8Size
|
||||||
++p;
|
++p;
|
||||||
if (p == end)
|
if (p == end)
|
||||||
{
|
{
|
||||||
NS_ERROR("Surrogate pair split between fragments");
|
// Treat broken characters as the Unicode
|
||||||
return N;
|
// replacement character 0xFFFD (0xEFBFBD in
|
||||||
|
// UTF-8)
|
||||||
|
mSize += 3;
|
||||||
|
|
||||||
|
NS_WARNING("String ending in half a surrogate pair!");
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
c = *p;
|
c = *p;
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче