ICU-44 Update transliterator code to use Unicode::digit.
X-SVN-Rev: 232
This commit is contained in:
parent
aa63a0d413
commit
773518b3e0
@ -10,7 +10,7 @@
|
||||
#include "hextouni.h"
|
||||
#include "rep.h"
|
||||
#include "unifilt.h"
|
||||
#include "uniset.h" // For UnicodeSet::digit REMOVE LATER
|
||||
#include "unicode.h"
|
||||
|
||||
/**
|
||||
* ID for this transliterator.
|
||||
@ -80,7 +80,7 @@ void HexToUnicodeTransliterator::handleKeyboardTransliterate(Replaceable& text,
|
||||
|
||||
while (cursor <= maxCursor) {
|
||||
UChar c = filteredCharAt(text, cursor + 5);
|
||||
int32_t digit0 = UnicodeSet::digit(c, 16);
|
||||
int32_t digit0 = Unicode::digit(c, 16);
|
||||
if (digit0 < 0) {
|
||||
if (c == '\\') {
|
||||
cursor += 5;
|
||||
@ -97,7 +97,7 @@ void HexToUnicodeTransliterator::handleKeyboardTransliterate(Replaceable& text,
|
||||
|
||||
for (int32_t i=4; i>=2; --i) {
|
||||
c = filteredCharAt(text, cursor + i);
|
||||
int32_t digit = UnicodeSet::digit(c, 16);
|
||||
int32_t digit = Unicode::digit(c, 16);
|
||||
if (digit < 0) {
|
||||
if (c == 'U' || c == 'u' || c == '+') {
|
||||
cursor += i-1;
|
||||
|
@ -1,6 +1,7 @@
|
||||
/*
|
||||
**********************************************************************
|
||||
* Copyright (C) 1999 Alan Liu and others. All rights reserved.
|
||||
* Copyright (C) 1999, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
* Date Name Description
|
||||
* 10/20/99 alan Creation.
|
||||
@ -465,9 +466,7 @@ UnicodeString& UnicodeSet::parse(UnicodeString& pairsBuf /*result*/,
|
||||
}
|
||||
c = (UChar)0x0000;
|
||||
for (int32_t j=(++i)+4; i<j; ++i) { // [sic]
|
||||
// TO DO: Change this to use Unicode::digit()
|
||||
// when that method exists.
|
||||
int32_t digit = /*Unicode::*/UnicodeSet::digit(pattern.charAt(i), 16);
|
||||
int32_t digit = Unicode::digit(pattern.charAt(i), 16);
|
||||
if (digit<0) {
|
||||
status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return pairsBuf;
|
||||
@ -1122,20 +1121,3 @@ const UnicodeString& UnicodeSet::getCategoryPairs(int8_t cat) {
|
||||
UChar UnicodeSet::charAfter(const UnicodeString& str, int32_t i) {
|
||||
return ((++i) < str.length()) ? str.charAt(i) : (UChar)0xFFFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* TEMPORARY WORKAROUND UNTIL Unicode::digit() exists.
|
||||
* Return the digit value of the given UChar, or -1. The radix
|
||||
* value is ignored for now and hardcoded as 16.
|
||||
*/
|
||||
int8_t UnicodeSet::digit(UChar c, int8_t radix) {
|
||||
int32_t d = Unicode::digitValue(c);
|
||||
if (d < 0) {
|
||||
if (c >= (UChar)'a' && c <= (UChar)'f') {
|
||||
d = c - (UChar)('a' - 10);
|
||||
} else if (c >= (UChar)'A' && c <= (UChar)'F') {
|
||||
d = c - (UChar)('A' - 10);
|
||||
}
|
||||
}
|
||||
return (int8_t)d;
|
||||
}
|
||||
|
@ -595,14 +595,6 @@ private:
|
||||
* there is none.
|
||||
*/
|
||||
static UChar charAfter(const UnicodeString& str, int32_t i);
|
||||
|
||||
public: // Make public for HexToUnicodeTransliterator
|
||||
/**
|
||||
* TEMPORARY WORKAROUND UNTIL Unicode::digit() exists.
|
||||
* Return the digit value of the given UChar, or -1. The radix
|
||||
* value is ignored for now and hardcoded as 16.
|
||||
*/
|
||||
static int8_t digit(UChar c, int8_t radix);
|
||||
};
|
||||
|
||||
inline void UnicodeSet::applyPattern(const UnicodeString& pattern,
|
||||
|
Loading…
Reference in New Issue
Block a user