mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
bug 732443 - handle surrogate pairs correctly in ClusterIterator. r=emk
This commit is contained in:
parent
30ad782016
commit
9e0b2f2f6c
@ -292,10 +292,13 @@ ClusterIterator::Next()
|
||||
|
||||
PRUint32 ch = *mPos++;
|
||||
|
||||
// Handle conjoining Jamo that make Hangul syllables
|
||||
if ((ch & ~0xff) == 0x1100 ||
|
||||
if (NS_IS_HIGH_SURROGATE(ch) && mPos < mLimit &&
|
||||
NS_IS_LOW_SURROGATE(*mPos)) {
|
||||
ch = SURROGATE_TO_UCS4(ch, *mPos++);
|
||||
} else if ((ch & ~0xff) == 0x1100 ||
|
||||
(ch >= 0xa960 && ch <= 0xa97f) ||
|
||||
(ch >= 0xac00 && ch <= 0xd7ff)) {
|
||||
// Handle conjoining Jamo that make Hangul syllables
|
||||
HSType hangulState = GetHangulSyllableType(ch);
|
||||
while (mPos < mLimit) {
|
||||
ch = *mPos;
|
||||
@ -337,16 +340,19 @@ ClusterIterator::Next()
|
||||
// Check for surrogate pairs; note that isolated surrogates will just
|
||||
// be treated as generic (non-cluster-extending) characters here,
|
||||
// which is fine for cluster-iterating purposes
|
||||
if (NS_IS_LOW_SURROGATE(ch) &&
|
||||
NS_IS_HIGH_SURROGATE(*(mPos - 1))) {
|
||||
ch = SURROGATE_TO_UCS4(*(mPos - 1), *mPos);
|
||||
mPos++;
|
||||
if (NS_IS_HIGH_SURROGATE(ch) && mPos < mLimit - 1 &&
|
||||
NS_IS_LOW_SURROGATE(*(mPos + 1))) {
|
||||
ch = SURROGATE_TO_UCS4(ch, *(mPos + 1));
|
||||
}
|
||||
|
||||
if (!IsClusterExtender(ch)) {
|
||||
break;
|
||||
}
|
||||
|
||||
mPos++;
|
||||
if (!IS_IN_BMP(ch)) {
|
||||
mPos++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user