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
This commit is contained in:
parent
f7a2025047
commit
84d3915988
@ -8,6 +8,8 @@
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#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;
|
||||
|
Loading…
Reference in New Issue
Block a user