diff --git a/icu4c/source/common/ucnv_err.c b/icu4c/source/common/ucnv_err.c index f88af72fea..75659fb571 100644 --- a/icu4c/source/common/ucnv_err.c +++ b/icu4c/source/common/ucnv_err.c @@ -245,11 +245,7 @@ UCNV_FROM_U_CALLBACK_ESCAPE ( case UCNV_PRV_ESCAPE_CSS2: valueString[valueStringLength++] = (UChar) UNICODE_RS_CODEPOINT; /* adding \ */ - if (length == 2) { - valueStringLength += uprv_itou (valueString + valueStringLength, VALUE_STRING_LENGTH - valueStringLength, codePoint, 16, 0); - } else { - valueStringLength += uprv_itou (valueString + valueStringLength, VALUE_STRING_LENGTH - valueStringLength, (uint16_t)codeUnits[0], 16, 0); - } + valueStringLength += uprv_itou (valueString + valueStringLength, VALUE_STRING_LENGTH - valueStringLength, codePoint, 16, 0); /* Always add space character, becase the next character might be whitespace, which would erroneously be considered the termination of the escape sequence. */ valueString[valueStringLength++] = (UChar) UNICODE_SPACE_CODEPOINT; diff --git a/icu4c/source/common/unicode/ucnv_err.h b/icu4c/source/common/unicode/ucnv_err.h index e52a39303f..6fde6966cd 100644 --- a/icu4c/source/common/unicode/ucnv_err.h +++ b/icu4c/source/common/unicode/ucnv_err.h @@ -140,9 +140,9 @@ typedef struct UConverter UConverter; #define UCNV_ESCAPE_UNICODE "U" /** - * FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to CSS2 conventions (\\X{XXXXX} followed by - * a space. - * @stable ICU 4.0 + * FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to CSS2 conventions (\\HH..H, that is, + * a backslash, 1..6 hex digits, and a space) + * @draft ICU 4.0 */ #define UCNV_ESCAPE_CSS2 "S" diff --git a/icu4c/source/test/testdata/conversion.txt b/icu4c/source/test/testdata/conversion.txt index f7691bccf5..9702dfba9e 100644 --- a/icu4c/source/test/testdata/conversion.txt +++ b/icu4c/source/test/testdata/conversion.txt @@ -917,6 +917,14 @@ conversion:table(nofallback) { :intvector{ -1,-1,-1,-1,0,1,2,2,2,3,3,5,5,5 }, :int{1}, :int{1}, "", "?\x00\x2f\x7e", "" } + // ISO-2022-KR + { + "ibm-25546", + "AB\uc88b\U00050005\uacccC", + :bin{ 1b24294341420e41410f5c3530303035200e306a0f43 }, + :intvector{ -1,-1,-1,-1,0,1,2,2,2,3,3,3,3,3,3,3,3,5,5,5,6,6 }, + :int{1}, :int{1}, "", "&S", "" + } // ISO-2022-JP-2 with G2 designator & SS2 shift {