ICU-2906 liberalize escaped surrogate pair handling

X-SVN-Rev: 13343
This commit is contained in:
Alan Liu 2003-10-07 18:11:01 +00:00
parent 7fffbdf68f
commit 64c5a40289

View file

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/impl/Utility.java,v $
* $Date: 2003/10/07 17:22:14 $
* $Revision: 1.47 $
* $Date: 2003/10/07 18:11:01 $
* $Revision: 1.48 $
*
*****************************************************************************************
*/
@ -803,17 +803,15 @@ public final class Utility {
if (result < 0 || result >= 0x110000) {
return -1;
}
// If a 'u' escape sequence (16-bit) specifies a lead
// surrogate, see if there is a trail surrogate after it,
// either as a 'u' escape or as a literal. If so, join
// them up into a supplementary.
if (maxDig == 4 && offset < length &&
// If an escape sequence specifies a lead surrogate, see
// if there is a trail surrogate after it, either as an
// escape or as a literal. If so, join them up into a
// supplementary.
if (offset < length &&
UTF16.isLeadSurrogate((char) result)) {
c = s.charAt(offset); // [sic] get 16-bit code unit
int ahead = offset+1;
// ONLY parse backslash 'u', nothing else
if (c == '\\' && (offset+1) < length &&
s.charAt(offset+1) == 'u') {
c = s.charAt(offset); // [sic] get 16-bit code unit
if (c == '\\' && ahead < length) {
int o[] = new int[] { ahead };
c = unescapeAt(s, o);
ahead = o[0];