mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-08 06:53:45 +00:00
ICU-1629 Simplify UnicodeString creation
X-SVN-Rev: 7471
This commit is contained in:
parent
b497a53be5
commit
24fb5c7668
7 changed files with 38 additions and 17 deletions
|
@ -57,14 +57,35 @@ class StringSearch;
|
|||
* @stable
|
||||
*/
|
||||
#if U_SIZEOF_WCHAR_T==U_SIZEOF_UCHAR && U_CHARSET_FAMILY==U_ASCII_FAMILY
|
||||
# define UNICODE_STRING(cs, length) UnicodeString(TRUE, (UChar *)L ## cs, length)
|
||||
# define UNICODE_STRING(cs, length) UnicodeString(TRUE, (const UChar *)L ## cs, length)
|
||||
#elif U_SIZEOF_UCHAR==1 && U_CHARSET_FAMILY==U_ASCII_FAMILY
|
||||
# define UNICODE_STRING(cs, length) UnicodeString(TRUE, (UChar *)cs, length)
|
||||
# define UNICODE_STRING(cs, length) UnicodeString(TRUE, (const UChar *)cs, length)
|
||||
#else
|
||||
# define UNICODE_STRING(cs, length) UnicodeString(cs, length, "")
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Unicode String literals in C++.
|
||||
* Dependent on the platform properties, different UnicodeString
|
||||
* constructors should be used to create a UnicodeString object from
|
||||
* a string literal.
|
||||
* The macros are defined for improved performance.
|
||||
* They work only for strings that contain "invariant characters", i.e.,
|
||||
* only latin letters, digits, and some punctuation.
|
||||
* See utypes.h for details.
|
||||
*
|
||||
* The string parameter must be a C string literal.
|
||||
* @stable
|
||||
*/
|
||||
#if U_SIZEOF_WCHAR_T==U_SIZEOF_UCHAR && U_CHARSET_FAMILY==U_ASCII_FAMILY
|
||||
# define UNICODE_STRING_SIMPLE(cs) UnicodeString((const UChar *)L ## cs)
|
||||
#elif U_SIZEOF_UCHAR==1 && U_CHARSET_FAMILY==U_ASCII_FAMILY
|
||||
# define UNICODE_STRING_SIMPLE(cs) UnicodeString((const UChar *)cs)
|
||||
#else
|
||||
# define UNICODE_STRING_SIMPLE(cs) UnicodeString(cs, "")
|
||||
#endif
|
||||
|
||||
/**
|
||||
* UnicodeString is a string class that stores Unicode characters directly and provides
|
||||
* similar functionality as the Java String class.
|
||||
* It is a concrete implementation of the abstract class Replaceable (for transliteration).
|
||||
|
|
|
@ -97,7 +97,7 @@ CompoundTransliterator::CompoundTransliterator(const UnicodeString& newID,
|
|||
CompoundTransliterator::CompoundTransliterator(UTransDirection dir,
|
||||
UVector& list,
|
||||
UErrorCode& status) :
|
||||
Transliterator(UnicodeString("", ""), 0),
|
||||
Transliterator(UnicodeString(), 0),
|
||||
trans(0), compoundRBTIndex(-1)
|
||||
{
|
||||
init(list, dir, FALSE, status);
|
||||
|
|
|
@ -129,18 +129,18 @@ void NormalizationTransliterator::registerIDs() {
|
|||
return;
|
||||
}
|
||||
|
||||
Transliterator::_registerFactory(UnicodeString("Any-NFC", ""),
|
||||
Transliterator::_registerFactory(UNICODE_STRING_SIMPLE("Any-NFC"),
|
||||
_create, integerToken(UNORM_NFC));
|
||||
Transliterator::_registerFactory(UnicodeString("Any-NFKC", ""),
|
||||
Transliterator::_registerFactory(UNICODE_STRING_SIMPLE("Any-NFKC"),
|
||||
_create, integerToken(UNORM_NFKC));
|
||||
Transliterator::_registerFactory(UnicodeString("Any-NFD", ""),
|
||||
Transliterator::_registerFactory(UNICODE_STRING_SIMPLE("Any-NFD"),
|
||||
_create, integerToken(UNORM_NFD));
|
||||
Transliterator::_registerFactory(UnicodeString("Any-NFKD", ""),
|
||||
Transliterator::_registerFactory(UNICODE_STRING_SIMPLE("Any-NFKD"),
|
||||
_create, integerToken(UNORM_NFKD));
|
||||
Transliterator::_registerSpecialInverse(UnicodeString("NFC", ""),
|
||||
UnicodeString("NFD", ""), TRUE);
|
||||
Transliterator::_registerSpecialInverse(UnicodeString("NFKC", ""),
|
||||
UnicodeString("NFKD", ""), TRUE);
|
||||
Transliterator::_registerSpecialInverse(UNICODE_STRING_SIMPLE("NFC"),
|
||||
UNICODE_STRING_SIMPLE("NFD"), TRUE);
|
||||
Transliterator::_registerSpecialInverse(UNICODE_STRING_SIMPLE("NFKC"),
|
||||
UNICODE_STRING_SIMPLE("NFKD"), TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -697,7 +697,7 @@ UnicodeString& TransliterationRule::toRule(UnicodeString& rule,
|
|||
rule.append((UChar)36/*$*/);
|
||||
}
|
||||
|
||||
appendToRule(rule, UnicodeString(" > ", ""), TRUE, escapeUnprintable, quoteBuf);
|
||||
appendToRule(rule, UNICODE_STRING_SIMPLE(" > "), TRUE, escapeUnprintable, quoteBuf);
|
||||
|
||||
// Emit the output pattern
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@ void RemoveTransliterator::registerIDs() {
|
|||
|
||||
Transliterator::_registerFactory(::ID, _create, integerToken(0));
|
||||
|
||||
Transliterator::_registerSpecialInverse(UnicodeString("Remove", ""),
|
||||
UnicodeString("Null", ""), FALSE);
|
||||
Transliterator::_registerSpecialInverse(UNICODE_STRING_SIMPLE("Remove"),
|
||||
UNICODE_STRING_SIMPLE("Null"), FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -96,8 +96,8 @@ void TitlecaseTransliterator::handleTransliterate(
|
|||
Mutex lock(&MUTEX);
|
||||
if (SKIP == NULL) {
|
||||
UErrorCode ec = U_ZERO_ERROR;
|
||||
SKIP = new UnicodeSet(UnicodeString("[\\u00AD \\u2019 \\' [:Mn:] [:Me:] [:Cf:] [:Lm:] [:Sk:]]", ""), ec);
|
||||
CASED = new UnicodeSet(UnicodeString("[[:Lu:] [:Ll:] [:Lt:]]", ""), ec);
|
||||
SKIP = new UnicodeSet(UNICODE_STRING_SIMPLE("[\\u00AD \\u2019 \\' [:Mn:] [:Me:] [:Cf:] [:Lm:] [:Sk:]]"), ec);
|
||||
CASED = new UnicodeSet(UNICODE_STRING_SIMPLE("[[:Lu:] [:Ll:] [:Lt:]]"), ec);
|
||||
ucln_i18n_registerCleanup();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1018,7 +1018,7 @@ UnicodeString& Transliterator::toRules(UnicodeString& rulesSource,
|
|||
rulesSource = getID();
|
||||
}
|
||||
// KEEP in sync with rbt_pars
|
||||
rulesSource.insert(0, UnicodeString("::", ""));
|
||||
rulesSource.insert(0, UNICODE_STRING_SIMPLE("::"));
|
||||
rulesSource.append(ID_DELIM);
|
||||
return rulesSource;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue