From 84d3915988bddbdf4f5304fa8f022d8f236c3a40 Mon Sep 17 00:00:00 2001 From: Yves Arrouye Date: Thu, 31 Jan 2002 17:49:00 +0000 Subject: [PATCH] ICU-1681 use U+XXXX as a name when there is no Unicode 2.0 name. Will be changed to use the Unicode 1.0 name too if that is what we decide. X-SVN-Rev: 7546 --- icu4c/source/i18n/uni2name.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/icu4c/source/i18n/uni2name.cpp b/icu4c/source/i18n/uni2name.cpp index f984ac1968b..062fc49643a 100644 --- a/icu4c/source/i18n/uni2name.cpp +++ b/icu4c/source/i18n/uni2name.cpp @@ -8,6 +8,8 @@ ********************************************************************** */ +#include + #include "uni2name.h" #include "unicode/unifilt.h" #include "unicode/uchar.h" @@ -89,20 +91,18 @@ void UnicodeNameTransliterator::handleTransliterate(Replaceable& text, UTransPos while (cursor < limit) { status = U_ZERO_ERROR; UChar32 c = text.char32At(cursor); - if ((len=u_charName(c, U_UNICODE_CHAR_NAME, buf, sizeof(buf), &status)) > 0 && - !U_FAILURE(status)) { - - str.truncate(1); - str.append(UnicodeString(buf, len, "")).append(closeDelimiter); - - int32_t clen = UTF_CHAR_LENGTH(c); - text.handleReplaceBetween(cursor, cursor+clen, str); - len += 2; // adjust for delimiters - cursor += len; // advance cursor and adjust for new text - limit += len-clen; // change in length - } else { - ++cursor; + if ((len=u_charName(c, U_UNICODE_CHAR_NAME, buf, sizeof(buf), &status)) <= 0 || U_FAILURE(status)) { + sprintf(buf, "U+%04lX", c); + len = strlen(buf); } + + str.truncate(1); + str.append(UnicodeString(buf, len, "")).append(closeDelimiter); + int32_t clen = UTF_CHAR_LENGTH(c); + text.handleReplaceBetween(cursor, cursor+clen, str); + len += 2; // adjust for delimiters + cursor += len; // advance cursor and adjust for new text + limit += len-clen; // change in length } offsets.contextLimit += limit - offsets.limit;