UBool
Appendable::appendCodePoint(UChar32 c) {
if(c<=0xffff) {
- return appendCodeUnit((UChar)c);
+ return appendCodeUnit((char16_t)c);
} else {
return appendCodeUnit(U16_LEAD(c)) && appendCodeUnit(U16_TRAIL(c));
}
}
UBool
-Appendable::appendString(const UChar *s, int32_t length) {
+Appendable::appendString(const char16_t *s, int32_t length) {
if(length<0) {
- UChar c;
+ char16_t c;
while((c=*s++)!=0) {
if(!appendCodeUnit(c)) {
return false;
}
}
} else if(length>0) {
- const UChar *limit=s+length;
+ const char16_t *limit=s+length;
do {
if(!appendCodeUnit(*s++)) {
return false;
return true;
}
-UChar *
+char16_t *
Appendable::getAppendBuffer(int32_t minCapacity,
int32_t /*desiredCapacityHint*/,
- UChar *scratch, int32_t scratchCapacity,
+ char16_t *scratch, int32_t scratchCapacity,
int32_t *resultCapacity) {
if(minCapacity<1 || scratchCapacity<minCapacity) {
*resultCapacity=0;
* Check for sufficient length for trail unit for each surrogate pair.
* Handle single surrogates as surrogate code points as usual in ICU.
*/
-const UChar *
-BMPSet::span(const UChar *s, const UChar *limit, USetSpanCondition spanCondition) const {
- UChar c, c2;
+const char16_t *
+BMPSet::span(const char16_t *s, const char16_t *limit, USetSpanCondition spanCondition) const {
+ char16_t c, c2;
if(spanCondition) {
// span
}
/* Symmetrical with span(). */
-const UChar *
-BMPSet::spanBack(const UChar *s, const UChar *limit, USetSpanCondition spanCondition) const {
- UChar c, c2;
+const char16_t *
+BMPSet::spanBack(const char16_t *s, const char16_t *limit, USetSpanCondition spanCondition) const {
+ char16_t c, c2;
if(spanCondition) {
// span
* It must be s<limit and spanCondition==0 or 1.
* @return The string pointer which limits the span.
*/
- const UChar *span(const UChar *s, const UChar *limit, USetSpanCondition spanCondition) const;
+ const char16_t *span(const char16_t *s, const char16_t *limit, USetSpanCondition spanCondition) const;
/*
* Span the trailing substring for which each character c has spanCondition==contains(c).
* It must be s<limit and spanCondition==0 or 1.
* @return The string pointer which starts the span.
*/
- const UChar *spanBack(const UChar *s, const UChar *limit, USetSpanCondition spanCondition) const;
+ const char16_t *spanBack(const char16_t *s, const char16_t *limit, USetSpanCondition spanCondition) const;
/*
* Span the initial substring for which each character c has spanCondition==contains(c).
UResourceBundle *b = ures_open(U_ICUDATA_BRKITR, "", &status);
b = ures_getByKeyWithFallback(b, "dictionaries", b, &status);
int32_t dictnlength = 0;
- const UChar *dictfname =
+ const char16_t *dictfname =
ures_getStringByKeyWithFallback(b, uscript_getShortName(script), &dictnlength, &status);
if (U_FAILURE(status)) {
ures_close(b);
}
CharString dictnbuf;
CharString ext;
- const UChar *extStart = u_memrchr(dictfname, 0x002e, dictnlength); // last dot
+ const char16_t *extStart = u_memrchr(dictfname, 0x002e, dictnlength); // last dot
if (extStart != nullptr) {
int32_t len = (int32_t)(extStart - dictfname);
ext.appendInvariantChars(UnicodeString(false, extStart + 1, dictnlength - len - 1), status);
m = new BytesDictionaryMatcher(characters, transform, file);
}
else if (trieType == DictionaryData::TRIE_TYPE_UCHARS) {
- const UChar *characters = (const UChar *)(data + offset);
+ const char16_t *characters = (const char16_t *)(data + offset);
m = new UCharsDictionaryMatcher(characters, file);
}
if (m == nullptr) {
char ext[4]={'\0'};
CharString actualLocale;
int32_t size;
- const UChar* brkfname = nullptr;
+ const char16_t* brkfname = nullptr;
UResourceBundle brkRulesStack;
UResourceBundle brkNameStack;
UResourceBundle *brkRules = &brkRulesStack;
if (U_SUCCESS(status) && brkfname) {
actualLocale.append(ures_getLocaleInternal(brkName, &status), -1, status);
- UChar* extStart=u_strchr(brkfname, 0x002e);
+ char16_t* extStart=u_strchr(brkfname, 0x002e);
int len = 0;
if (extStart != nullptr){
len = (int)(extStart-brkfname);
return elements[i].getStringLength(*strings);
}
-UChar
+char16_t
BytesTrieBuilder::getElementUnit(int32_t i, int32_t byteIndex) const {
return (uint8_t)elements[i].charAt(byteIndex, *strings);
}
}
int32_t
-BytesTrieBuilder::indexOfElementWithNextUnit(int32_t i, int32_t byteIndex, UChar byte) const {
+BytesTrieBuilder::indexOfElementWithNextUnit(int32_t i, int32_t byteIndex, char16_t byte) const {
char b=(char)byte;
while(b==elements[i].charAt(byteIndex, *strings)) {
++i;
permutations.setValueDeleter(uprv_deleteUObject);
basic.setValueDeleter(uprv_deleteUObject);
- UChar USeg[256];
+ char16_t USeg[256];
int32_t segLen = segment.extract(USeg, 256, status);
getEquivalents2(&basic, USeg, segLen, status);
return finalResult;
}
-Hashtable *CanonicalIterator::getEquivalents2(Hashtable *fillinResult, const UChar *segment, int32_t segLen, UErrorCode &status) {
+Hashtable *CanonicalIterator::getEquivalents2(Hashtable *fillinResult, const char16_t *segment, int32_t segLen, UErrorCode &status) {
if (U_FAILURE(status)) {
return nullptr;
* (with canonical rearrangement!)
* If so, take the remainder, and return the equivalents
*/
-Hashtable *CanonicalIterator::extract(Hashtable *fillinResult, UChar32 comp, const UChar *segment, int32_t segLen, int32_t segmentPos, UErrorCode &status) {
+Hashtable *CanonicalIterator::extract(Hashtable *fillinResult, UChar32 comp, const char16_t *segment, int32_t segLen, int32_t segmentPos, UErrorCode &status) {
//Hashtable *CanonicalIterator::extract(UChar32 comp, const UnicodeString &segment, int32_t segLen, int32_t segmentPos, UErrorCode &status) {
//if (PROGRESS) printf(" extract: %s, ", UToS(Tr(UnicodeString(comp))));
//if (PROGRESS) printf("%s, %i\n", UToS(Tr(segment)), segmentPos);
status = U_MEMORY_ALLOCATION_ERROR;
return nullptr;
}
- const UChar *decomp=decompString.getBuffer();
+ const char16_t *decomp=decompString.getBuffer();
int32_t decompLen=decompString.length();
// See if it matches the start of segment (at segmentPos)
}
void U_CALLCONV
-_set_addString(USet *set, const UChar *str, int32_t length) {
+_set_addString(USet *set, const char16_t *str, int32_t length) {
((UnicodeSet *)set)->add(icu::UnicodeString((UBool)(length<0), str, length));
}
// implementing first[32]PostInc() directly in a subclass should be faster
// but these implementations make subclassing a little easier
-UChar
+char16_t
CharacterIterator::firstPostInc(void) {
setToStart();
return nextPostInc();
return appendInvariantChars(s.getBuffer(), s.length(), errorCode);
}
-CharString &CharString::appendInvariantChars(const UChar* uchars, int32_t ucharsLen, UErrorCode &errorCode) {
+CharString &CharString::appendInvariantChars(const char16_t* uchars, int32_t ucharsLen, UErrorCode &errorCode) {
if(U_FAILURE(errorCode)) {
return *this;
}
UErrorCode &errorCode);
CharString &appendInvariantChars(const UnicodeString &s, UErrorCode &errorCode);
- CharString &appendInvariantChars(const UChar* uchars, int32_t ucharsLen, UErrorCode& errorCode);
+ CharString &appendInvariantChars(const char16_t* uchars, int32_t ucharsLen, UErrorCode& errorCode);
/**
* Appends a filename/path part, e.g., a directory name.
static
inline void
-uprv_arrayCopy(const UChar *src, int32_t srcStart,
- UChar *dst, int32_t dstStart, int32_t count)
+uprv_arrayCopy(const char16_t *src, int32_t srcStart,
+ char16_t *dst, int32_t dstStart, int32_t count)
{ uprv_memcpy(dst+dstStart, src+srcStart, (size_t)count * sizeof(*src)); }
/**
// TODO: turn this into a shared helper function
// Requires the major version to match, and then requires at least the minor version.
UBool udata_isAcceptableMajorMinor(
- const UDataInfo &info, const UChar *dataFormat, uint8_t major, uint8_t minor) {
+ const UDataInfo &info, const char16_t *dataFormat, uint8_t major, uint8_t minor) {
return
info.size >= 20 &&
info.isBigEndian == U_IS_BIG_ENDIAN &&
offset = inIndexes[i];
nextOffset = inIndexes[i + 1];
// Set/leave nullptr if there is no UCharsTrie.
- const UChar *p = nextOffset > offset ? (const UChar *)(inBytes + offset) : nullptr;
+ const char16_t *p = nextOffset > offset ? (const char16_t *)(inBytes + offset) : nullptr;
stringTries[getStringTrieIndex(i)] = p;
}
}
}
UBool
-EmojiProps::hasBinaryProperty(const UChar *s, int32_t length, UProperty which) {
+EmojiProps::hasBinaryProperty(const char16_t *s, int32_t length, UProperty which) {
UErrorCode errorCode = U_ZERO_ERROR;
const EmojiProps *ep = getSingleton(errorCode);
return U_SUCCESS(errorCode) && ep->hasBinaryPropertyImpl(s, length, which);
}
UBool
-EmojiProps::hasBinaryPropertyImpl(const UChar *s, int32_t length, UProperty which) const {
+EmojiProps::hasBinaryPropertyImpl(const char16_t *s, int32_t length, UProperty which) const {
if (s == nullptr && length != 0) { return false; }
if (length <= 0 && (length == 0 || *s == 0)) { return false; } // empty string
// The caller should have delegated single code points to hasBinaryProperty(c, which).
lastProp = UCHAR_RGI_EMOJI_ZWJ_SEQUENCE;
}
for (int32_t prop = firstProp; prop <= lastProp; ++prop) {
- const UChar *trieUChars = stringTries[prop - UCHAR_BASIC_EMOJI];
+ const char16_t *trieUChars = stringTries[prop - UCHAR_BASIC_EMOJI];
if (trieUChars != nullptr) {
UCharsTrie trie(trieUChars);
UStringTrieResult result = trie.next(s, length);
lastProp = UCHAR_RGI_EMOJI_ZWJ_SEQUENCE;
}
for (int32_t prop = firstProp; prop <= lastProp; ++prop) {
- const UChar *trieUChars = stringTries[prop - UCHAR_BASIC_EMOJI];
+ const char16_t *trieUChars = stringTries[prop - UCHAR_BASIC_EMOJI];
if (trieUChars != nullptr) {
UCharsTrie::Iterator iter(trieUChars, 0, errorCode);
while (iter.next(errorCode)) {
static const EmojiProps *getSingleton(UErrorCode &errorCode);
static UBool hasBinaryProperty(UChar32 c, UProperty which);
- static UBool hasBinaryProperty(const UChar *s, int32_t length, UProperty which);
+ static UBool hasBinaryProperty(const char16_t *s, int32_t length, UProperty which);
void addPropertyStarts(const USetAdder *sa, UErrorCode &errorCode) const;
void addStrings(const USetAdder *sa, UProperty which, UErrorCode &errorCode) const;
void load(UErrorCode &errorCode);
UBool hasBinaryPropertyImpl(UChar32 c, UProperty which) const;
- UBool hasBinaryPropertyImpl(const UChar *s, int32_t length, UProperty which) const;
+ UBool hasBinaryPropertyImpl(const char16_t *s, int32_t length, UProperty which) const;
UDataMemory *memory = nullptr;
UCPTrie *cpTrie = nullptr;
- const UChar *stringTries[6] = { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr };
+ const char16_t *stringTries[6] = { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr };
};
U_NAMESPACE_END
static const int32_t kMATCH = (1<<1); //< exact match - skip this one.
static const int32_t kSuppressInReverse = (1<<0);
static const int32_t kAddToForward = (1<<1);
-static const UChar kFULLSTOP = 0x002E; // '.'
+static const char16_t kFULLSTOP = 0x002E; // '.'
/**
* Shared data for SimpleFilteredSentenceBreakIterator
// Assume a space is following the '.' (so we handle the case: "Mr. /Brown")
if(utext_previous32(fText.getAlias())==u' ') { // TODO: skip a class of chars here??
// TODO only do this the 1st time?
- //if(debug2) u_printf("skipping prev: |%C| \n", (UChar)uch);
+ //if(debug2) u_printf("skipping prev: |%C| \n", (char16_t)uch);
} else {
- //if(debug2) u_printf("not skipping prev: |%C| \n", (UChar)uch);
+ //if(debug2) u_printf("not skipping prev: |%C| \n", (char16_t)uch);
utext_next32(fText.getAlias());
- //if(debug2) u_printf(" -> : |%C| \n", (UChar)uch);
+ //if(debug2) u_printf(" -> : |%C| \n", (char16_t)uch);
}
{
if(!USTRINGTRIE_HAS_NEXT(r)) {
break;
}
- //if(debug2) u_printf("rev< /%C/ cont?%d @%d\n", (UChar)uch, r, utext_getNativeIndex(fText.getAlias()));
+ //if(debug2) u_printf("rev< /%C/ cont?%d @%d\n", (char16_t)uch, r, utext_getNativeIndex(fText.getAlias()));
}
}
//if(bestValue >= 0) {
- //if(debug2) u_printf("rev<+/%C/+end of seq.. r=%d, bestPosn=%d, bestValue=%d\n", (UChar)uch, r, bestPosn, bestValue);
+ //if(debug2) u_printf("rev<+/%C/+end of seq.. r=%d, bestPosn=%d, bestValue=%d\n", (char16_t)uch, r, bestPosn, bestValue);
//}
if(bestPosn>=0) {
- //if(debug2) u_printf("rev< /%C/ end of seq.. r=%d, bestPosn=%d, bestValue=%d\n", (UChar)uch, r, bestPosn, bestValue);
+ //if(debug2) u_printf("rev< /%C/ end of seq.. r=%d, bestPosn=%d, bestValue=%d\n", (char16_t)uch, r, bestPosn, bestValue);
//if(USTRINGTRIE_MATCHES(r)) { // matched - so, now what?
//int32_t bestValue = iter.getValue();
- ////if(debug2) u_printf("rev< /%C/ matched, skip..%d bestValue=%d\n", (UChar)uch, r, bestValue);
+ ////if(debug2) u_printf("rev< /%C/ matched, skip..%d bestValue=%d\n", (char16_t)uch, r, bestValue);
if(bestValue == kMATCH) { // exact match!
//if(debug2) u_printf(" exact backward match\n");
UChar32 uch;
while((uch=utext_next32(fText.getAlias()))!=U_SENTINEL &&
USTRINGTRIE_HAS_NEXT(rfwd=iter.nextForCodePoint(uch))) {
- //if(debug2) u_printf("fwd> /%C/ cont?%d @%d\n", (UChar)uch, rfwd, utext_getNativeIndex(fText.getAlias()));
+ //if(debug2) u_printf("fwd> /%C/ cont?%d @%d\n", (char16_t)uch, rfwd, utext_getNativeIndex(fText.getAlias()));
}
if(USTRINGTRIE_MATCHES(rfwd)) {
- //if(debug2) u_printf("fwd> /%C/ == forward match!\n", (UChar)uch);
+ //if(debug2) u_printf("fwd> /%C/ == forward match!\n", (char16_t)uch);
// only full matches here, nothing to check
// skip the next:
return kExceptionHere;
} else {
- //if(debug2) u_printf("fwd> /%C/ no match.\n", (UChar)uch);
+ //if(debug2) u_printf("fwd> /%C/ no match.\n", (char16_t)uch);
// no match (no exception) -return the 'underlying' break
return kNoExceptionHere;
}
return kNoExceptionHere; // internal error and/or no forwards trie
}
} else {
- //if(debug2) u_printf("rev< /%C/ .. no match..%d\n", (UChar)uch, r); // no best match
+ //if(debug2) u_printf("rev< /%C/ .. no match..%d\n", (char16_t)uch, r); // no best match
return kNoExceptionHere; // No match - so exit. Not an exception.
}
}
UnicodeString&
Locale::getDisplayLanguage(const Locale &displayLocale,
UnicodeString &result) const {
- UChar *buffer;
+ char16_t *buffer;
UErrorCode errorCode=U_ZERO_ERROR;
int32_t length;
UnicodeString&
Locale::getDisplayScript(const Locale &displayLocale,
UnicodeString &result) const {
- UChar *buffer;
+ char16_t *buffer;
UErrorCode errorCode=U_ZERO_ERROR;
int32_t length;
UnicodeString&
Locale::getDisplayCountry(const Locale &displayLocale,
UnicodeString &result) const {
- UChar *buffer;
+ char16_t *buffer;
UErrorCode errorCode=U_ZERO_ERROR;
int32_t length;
UnicodeString&
Locale::getDisplayVariant(const Locale &displayLocale,
UnicodeString &result) const {
- UChar *buffer;
+ char16_t *buffer;
UErrorCode errorCode=U_ZERO_ERROR;
int32_t length;
UnicodeString&
Locale::getDisplayName(const Locale &displayLocale,
UnicodeString &result) const {
- UChar *buffer;
+ char16_t *buffer;
UErrorCode errorCode=U_ZERO_ERROR;
int32_t length;
const char* subTableKey,
const char *itemKey,
const char *substitute,
- UChar *dest, int32_t destCapacity,
+ char16_t *dest, int32_t destCapacity,
UErrorCode *pErrorCode) {
- const UChar *s = nullptr;
+ const char16_t *s = nullptr;
int32_t length = 0;
if(itemKey==nullptr) {
static int32_t
_getDisplayNameForComponent(const char *locale,
const char *displayLocale,
- UChar *dest, int32_t destCapacity,
+ char16_t *dest, int32_t destCapacity,
UDisplayNameGetter *getter,
const char *tag,
UErrorCode *pErrorCode) {
U_CAPI int32_t U_EXPORT2
uloc_getDisplayLanguage(const char *locale,
const char *displayLocale,
- UChar *dest, int32_t destCapacity,
+ char16_t *dest, int32_t destCapacity,
UErrorCode *pErrorCode) {
return _getDisplayNameForComponent(locale, displayLocale, dest, destCapacity,
uloc_getLanguage, _kLanguages, pErrorCode);
U_CAPI int32_t U_EXPORT2
uloc_getDisplayScript(const char* locale,
const char* displayLocale,
- UChar *dest, int32_t destCapacity,
+ char16_t *dest, int32_t destCapacity,
UErrorCode *pErrorCode)
{
UErrorCode err = U_ZERO_ERROR;
static int32_t
uloc_getDisplayScriptInContext(const char* locale,
const char* displayLocale,
- UChar *dest, int32_t destCapacity,
+ char16_t *dest, int32_t destCapacity,
UErrorCode *pErrorCode)
{
return _getDisplayNameForComponent(locale, displayLocale, dest, destCapacity,
U_CAPI int32_t U_EXPORT2
uloc_getDisplayCountry(const char *locale,
const char *displayLocale,
- UChar *dest, int32_t destCapacity,
+ char16_t *dest, int32_t destCapacity,
UErrorCode *pErrorCode) {
return _getDisplayNameForComponent(locale, displayLocale, dest, destCapacity,
uloc_getCountry, _kCountries, pErrorCode);
U_CAPI int32_t U_EXPORT2
uloc_getDisplayVariant(const char *locale,
const char *displayLocale,
- UChar *dest, int32_t destCapacity,
+ char16_t *dest, int32_t destCapacity,
UErrorCode *pErrorCode) {
return _getDisplayNameForComponent(locale, displayLocale, dest, destCapacity,
uloc_getVariant, _kVariants, pErrorCode);
U_CAPI int32_t U_EXPORT2
uloc_getDisplayName(const char *locale,
const char *displayLocale,
- UChar *dest, int32_t destCapacity,
+ char16_t *dest, int32_t destCapacity,
UErrorCode *pErrorCode)
{
- static const UChar defaultSeparator[9] = { 0x007b, 0x0030, 0x007d, 0x002c, 0x0020, 0x007b, 0x0031, 0x007d, 0x0000 }; /* "{0}, {1}" */
- static const UChar sub0[4] = { 0x007b, 0x0030, 0x007d , 0x0000 } ; /* {0} */
- static const UChar sub1[4] = { 0x007b, 0x0031, 0x007d , 0x0000 } ; /* {1} */
+ static const char16_t defaultSeparator[9] = { 0x007b, 0x0030, 0x007d, 0x002c, 0x0020, 0x007b, 0x0031, 0x007d, 0x0000 }; /* "{0}, {1}" */
+ static const char16_t sub0[4] = { 0x007b, 0x0030, 0x007d , 0x0000 } ; /* {0} */
+ static const char16_t sub1[4] = { 0x007b, 0x0031, 0x007d , 0x0000 } ; /* {1} */
static const int32_t subLen = 3;
- static const UChar defaultPattern[10] = {
+ static const char16_t defaultPattern[10] = {
0x007b, 0x0030, 0x007d, 0x0020, 0x0028, 0x007b, 0x0031, 0x007d, 0x0029, 0x0000
}; /* {0} ({1}) */
static const int32_t defaultPatLen = 9;
int32_t length; /* of formatted result */
- const UChar *separator;
+ const char16_t *separator;
int32_t sepLen = 0;
- const UChar *pattern;
+ const char16_t *pattern;
int32_t patLen = 0;
int32_t sub0Pos, sub1Pos;
- UChar formatOpenParen = 0x0028; // (
- UChar formatReplaceOpenParen = 0x005B; // [
- UChar formatCloseParen = 0x0029; // )
- UChar formatReplaceCloseParen = 0x005D; // ]
+ char16_t formatOpenParen = 0x0028; // (
+ char16_t formatReplaceOpenParen = 0x005B; // [
+ char16_t formatCloseParen = 0x0029; // )
+ char16_t formatReplaceCloseParen = 0x005D; // ]
UBool haveLang = true; /* assume true, set false if we find we don't have
a lang component in the locale */
* This is similar to how pattern is handled below.
*/
{
- UChar *p0=u_strstr(separator, sub0);
- UChar *p1=u_strstr(separator, sub1);
+ char16_t *p0=u_strstr(separator, sub0);
+ char16_t *p1=u_strstr(separator, sub1);
if (p0==nullptr || p1==nullptr || p1<p0) {
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
- separator = (const UChar *)p0 + subLen;
+ separator = (const char16_t *)p0 + subLen;
sepLen = static_cast<int32_t>(p1 - separator);
}
sub1Pos=defaultSub1Pos;
// use default formatOpenParen etc. set above
} else { /* non-default pattern */
- UChar *p0=u_strstr(pattern, sub0);
- UChar *p1=u_strstr(pattern, sub1);
+ char16_t *p0=u_strstr(pattern, sub0);
+ char16_t *p1=u_strstr(pattern, sub1);
if (p0==nullptr || p1==nullptr) {
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
return 0;
* adjust the parameters so padding is not added, and repeat.
*/
do {
- UChar* p=dest;
+ char16_t* p=dest;
int32_t patPos=0; /* position in the pattern, used for non-substitution portions */
int32_t langLen=0; /* length of language substitution */
int32_t langPos=0; /* position in output of language substitution */
if (len>0) {
/* we added a component, so add separator and write it if there's room. */
if(len+sepLen<=cap) {
- const UChar * plimit = p + len;
+ const char16_t * plimit = p + len;
for (; p < plimit; p++) {
if (*p == formatOpenParen) {
*p = formatReplaceOpenParen;
U_CAPI int32_t U_EXPORT2
uloc_getDisplayKeyword(const char* keyword,
const char* displayLocale,
- UChar* dest,
+ char16_t* dest,
int32_t destCapacity,
UErrorCode* status){
uloc_getDisplayKeywordValue( const char* locale,
const char* keyword,
const char* displayLocale,
- UChar* dest,
+ char16_t* dest,
int32_t destCapacity,
UErrorCode* status){
if(uprv_stricmp(keyword, _kCurrency)==0){
int32_t dispNameLen = 0;
- const UChar *dispName = nullptr;
+ const char16_t *dispName = nullptr;
icu::LocalUResourceBundlePointer bundle(
ures_open(U_ICUDATA_CURR, displayLocale, status));
UErrorCode status = U_ZERO_ERROR;
int32_t len = 0;
- const UChar *s = uloc_getTableStringWithFallback(path, locale.getName(),
+ const char16_t *s = uloc_getTableStringWithFallback(path, locale.getName(),
tableKey, subTableKey, itemKey,
&len, &status);
if (U_SUCCESS(status) && len > 0) {
UErrorCode status = U_ZERO_ERROR;
int32_t len = 0;
- const UChar *s = uloc_getTableStringWithFallback(path, locale.getName(),
+ const char16_t *s = uloc_getTableStringWithFallback(path, locale.getName(),
tableKey, subTableKey, itemKey,
&len, &status);
if (U_SUCCESS(status)) {
pattern = UnicodeString("{0} ({1})", -1, US_INV);
}
format.applyPatternMinMaxArguments(pattern, 2, 2, status);
- if (pattern.indexOf((UChar)0xFF08) >= 0) {
- formatOpenParen.setTo((UChar)0xFF08); // fullwidth (
- formatReplaceOpenParen.setTo((UChar)0xFF3B); // fullwidth [
- formatCloseParen.setTo((UChar)0xFF09); // fullwidth )
- formatReplaceCloseParen.setTo((UChar)0xFF3D); // fullwidth ]
+ if (pattern.indexOf((char16_t)0xFF08) >= 0) {
+ formatOpenParen.setTo((char16_t)0xFF08); // fullwidth (
+ formatReplaceOpenParen.setTo((char16_t)0xFF3B); // fullwidth [
+ formatCloseParen.setTo((char16_t)0xFF09); // fullwidth )
+ formatReplaceCloseParen.setTo((char16_t)0xFF3D); // fullwidth ]
} else {
- formatOpenParen.setTo((UChar)0x0028); // (
- formatReplaceOpenParen.setTo((UChar)0x005B); // [
- formatCloseParen.setTo((UChar)0x0029); // )
- formatReplaceCloseParen.setTo((UChar)0x005D); // ]
+ formatOpenParen.setTo((char16_t)0x0028); // (
+ formatReplaceOpenParen.setTo((char16_t)0x005B); // [
+ formatCloseParen.setTo((char16_t)0x0029); // )
+ formatReplaceCloseParen.setTo((char16_t)0x005D); // ]
}
UnicodeString ktPattern;
appendWithSep(resultRemainder, temp3);
} else {
appendWithSep(resultRemainder, temp)
- .append((UChar)0x3d /* = */)
+ .append((char16_t)0x3d /* = */)
.append(temp2);
}
}
UErrorCode sts = U_ZERO_ERROR;
UnicodeString ustrValue(value, -1, US_INV);
int32_t len;
- const UChar *currencyName = ucurr_getName(ustrValue.getTerminatedBuffer(),
+ const char16_t *currencyName = ucurr_getName(ustrValue.getTerminatedBuffer(),
locale.getBaseName(), UCURR_LONG_NAME, nullptr /* isChoiceFormat */, &len, &sts);
if (U_FAILURE(sts)) {
// Return the value as is on failure
U_CAPI int32_t U_EXPORT2
uldn_localeDisplayName(const ULocaleDisplayNames *ldn,
const char *locale,
- UChar *result,
+ char16_t *result,
int32_t maxResultSize,
UErrorCode *pErrorCode) {
if (U_FAILURE(*pErrorCode)) {
U_CAPI int32_t U_EXPORT2
uldn_languageDisplayName(const ULocaleDisplayNames *ldn,
const char *lang,
- UChar *result,
+ char16_t *result,
int32_t maxResultSize,
UErrorCode *pErrorCode) {
if (U_FAILURE(*pErrorCode)) {
U_CAPI int32_t U_EXPORT2
uldn_scriptDisplayName(const ULocaleDisplayNames *ldn,
const char *script,
- UChar *result,
+ char16_t *result,
int32_t maxResultSize,
UErrorCode *pErrorCode) {
if (U_FAILURE(*pErrorCode)) {
U_CAPI int32_t U_EXPORT2
uldn_scriptCodeDisplayName(const ULocaleDisplayNames *ldn,
UScriptCode scriptCode,
- UChar *result,
+ char16_t *result,
int32_t maxResultSize,
UErrorCode *pErrorCode) {
return uldn_scriptDisplayName(ldn, uscript_getName(scriptCode), result, maxResultSize, pErrorCode);
U_CAPI int32_t U_EXPORT2
uldn_regionDisplayName(const ULocaleDisplayNames *ldn,
const char *region,
- UChar *result,
+ char16_t *result,
int32_t maxResultSize,
UErrorCode *pErrorCode) {
if (U_FAILURE(*pErrorCode)) {
U_CAPI int32_t U_EXPORT2
uldn_variantDisplayName(const ULocaleDisplayNames *ldn,
const char *variant,
- UChar *result,
+ char16_t *result,
int32_t maxResultSize,
UErrorCode *pErrorCode) {
if (U_FAILURE(*pErrorCode)) {
U_CAPI int32_t U_EXPORT2
uldn_keyDisplayName(const ULocaleDisplayNames *ldn,
const char *key,
- UChar *result,
+ char16_t *result,
int32_t maxResultSize,
UErrorCode *pErrorCode) {
if (U_FAILURE(*pErrorCode)) {
uldn_keyValueDisplayName(const ULocaleDisplayNames *ldn,
const char *key,
const char *value,
- UChar *result,
+ char16_t *result,
int32_t maxResultSize,
UErrorCode *pErrorCode) {
if (U_FAILURE(*pErrorCode)) {
if (!U_FAILURE(*err)) {
int32_t resLen = 0;
- const UChar* s = nullptr;
+ const char16_t* s = nullptr;
UErrorCode tmpErr = U_ZERO_ERROR;
icu::LocalUResourceBundlePointer subtags(ures_openDirect(nullptr, "likelySubtags", &tmpErr));
if (U_SUCCESS(tmpErr)) {
* default locale because that would result in a mix of languages that is
* unpredictable to the programmer and most likely useless.
*/
-U_CAPI const UChar * U_EXPORT2
+U_CAPI const char16_t * U_EXPORT2
uloc_getTableStringWithFallback(const char *path, const char *locale,
const char *tableKey, const char *subTableKey,
const char *itemKey,
UErrorCode *pErrorCode)
{
/* char localeBuffer[ULOC_FULLNAME_CAPACITY*4];*/
- const UChar *item=nullptr;
+ const char16_t *item=nullptr;
UErrorCode errorCode;
char explicitFallbackName[ULOC_FULLNAME_CAPACITY] = {0};
/* still can't figure out ?.. try the fallback mechanism */
int32_t len = 0;
- const UChar* fallbackLocale = nullptr;
+ const char16_t* fallbackLocale = nullptr;
*pErrorCode = errorCode;
errorCode = U_ZERO_ERROR;
uloc_canonicalize(localeId, localeBuffer, sizeof(localeBuffer), status);
if (!U_FAILURE(*status)) {
- const UChar* const value =
+ const char16_t* const value =
uloc_getTableStringWithFallback(
nullptr,
localeBuffer,
static icu::UInitOnce LocaleUtilityInitOnce {};
static icu::Hashtable * LocaleUtility_cache = nullptr;
-#define UNDERSCORE_CHAR ((UChar)0x005f)
-#define AT_SIGN_CHAR ((UChar)64)
-#define PERIOD_CHAR ((UChar)46)
+#define UNDERSCORE_CHAR ((char16_t)0x005f)
+#define AT_SIGN_CHAR ((char16_t)64)
+#define PERIOD_CHAR ((char16_t)46)
/*
******************************************************************
n = end;
}
for (; i < n; ++i) {
- UChar c = result.charAt(i);
+ char16_t c = result.charAt(i);
if (c >= 0x0041 && c <= 0x005a) {
c += 0x20;
result.setCharAt(i, c);
}
}
for (n = end; i < n; ++i) {
- UChar c = result.charAt(i);
+ char16_t c = result.charAt(i);
if (c >= 0x0061 && c <= 0x007a) {
c -= 0x20;
result.setCharAt(i, c);
#if 0
// This code does a proper full level 2 canonicalization of id.
- // It's nasty to go from UChar to char to char to UChar -- but
+ // It's nasty to go from char16_t to char to char to char16_t -- but
// that's what you have to do to use the uloc_canonicalize
// function on UnicodeStrings.
int32_t prev, i;
prev = 0;
for(;;) {
- i = id.indexOf((UChar)0x40, prev);
+ i = id.indexOf((char16_t)0x40, prev);
if(i < 0) {
// no @ between prev and the rest of the string
id.extract(prev, INT32_MAX, buffer + prev, BUFLEN - prev, US_INV);
const char* path = cbundleID.isEmpty() ? nullptr : cbundleID.data();
icu::LocalUEnumerationPointer uenum(ures_openAvailableLocales(path, &status));
for (;;) {
- const UChar* id = uenum_unext(uenum.getAlias(), nullptr, &status);
+ const char16_t* id = uenum_unext(uenum.getAlias(), nullptr, &status);
if (id == nullptr) {
break;
}
~LSTMData();
UHashtable* fDict;
EmbeddingType fType;
- const UChar* fName;
+ const char16_t* fName;
ConstArray2D fEmbedding;
ConstArray2D fForwardW;
ConstArray2D fForwardU;
ures_getByKey(rb, "hunits", nullptr, &status));
if (U_FAILURE(status)) return;
int32_t hunits = ures_getInt(hunits_res.getAlias(), &status);
- const UChar* type = ures_getStringByKey(rb, "type", nullptr, &status);
+ const char16_t* type = ures_getStringByKey(rb, "type", nullptr, &status);
if (U_FAILURE(status)) return;
if (u_strCompare(type, -1, u"codepoints", -1, false) == 0) {
fType = CODE_POINTS;
int32_t stringLength;
for (int32_t idx = 0; idx < num_index; idx++) {
stringArray.getValue(idx, value);
- const UChar* str = value.getString(stringLength, status);
+ const char16_t* str = value.getString(stringLength, status);
uhash_putiAllowZero(fDict, (void*)str, idx, &status);
if (U_FAILURE(status)) return;
#ifdef LSTM_VECTORIZER_DEBUG
UVector32 &offsets, UVector32 &indices,
UErrorCode &status) const = 0;
protected:
- int32_t stringToIndex(const UChar* str) const {
+ int32_t stringToIndex(const char16_t* str) const {
UBool found = false;
int32_t ret = uhash_getiAndFound(fDict, (const void*)str, &found);
if (!found) {
if (U_FAILURE(status)) return;
utext_setNativeIndex(text, startPos);
int32_t current;
- UChar str[2] = {0, 0};
+ char16_t str[2] = {0, 0};
while (U_SUCCESS(status) &&
(current = (int32_t)utext_getNativeIndex(text)) < endPos) {
// Since the LSTMBreakEngine is currently only accept chars in BMP,
// we can ignore the possibility of hitting supplementary code
// point.
- str[0] = (UChar) utext_next32(text);
+ str[0] = (char16_t) utext_next32(text);
U_ASSERT(!U_IS_SURROGATE(str[0]));
offsets.addElement(current, status);
indices.addElement(stringToIndex(str), status);
}
int32_t last = startPos;
int32_t current = startPos;
- UChar str[MAX_GRAPHEME_CLSTER_LENGTH];
+ char16_t str[MAX_GRAPHEME_CLSTER_LENGTH];
while ((current = graphemeIter->next()) != BreakIterator::DONE) {
if (current >= endPos) {
break;
delete fVectorizer;
}
-const UChar* LSTMBreakEngine::name() const {
+const char16_t* LSTMBreakEngine::name() const {
return fData->fName;
}
delete data;
}
-U_CAPI const UChar* U_EXPORT2 LSTMDataName(const LSTMData* data)
+U_CAPI const char16_t* U_EXPORT2 LSTMDataName(const LSTMData* data)
{
return data->fName;
}
// Unicode character/code point constants ---------------------------------- ***
-static const UChar u_pound=0x23;
-static const UChar u_apos=0x27;
-static const UChar u_plus=0x2B;
-static const UChar u_comma=0x2C;
-static const UChar u_minus=0x2D;
-static const UChar u_dot=0x2E;
-static const UChar u_colon=0x3A;
-static const UChar u_lessThan=0x3C;
-static const UChar u_equal=0x3D;
-static const UChar u_A=0x41;
-static const UChar u_C=0x43;
-static const UChar u_D=0x44;
-static const UChar u_E=0x45;
-static const UChar u_H=0x48;
-static const UChar u_I=0x49;
-static const UChar u_L=0x4C;
-static const UChar u_N=0x4E;
-static const UChar u_O=0x4F;
-static const UChar u_P=0x50;
-static const UChar u_R=0x52;
-static const UChar u_S=0x53;
-static const UChar u_T=0x54;
-static const UChar u_U=0x55;
-static const UChar u_Z=0x5A;
-static const UChar u_a=0x61;
-static const UChar u_c=0x63;
-static const UChar u_d=0x64;
-static const UChar u_e=0x65;
-static const UChar u_f=0x66;
-static const UChar u_h=0x68;
-static const UChar u_i=0x69;
-static const UChar u_l=0x6C;
-static const UChar u_n=0x6E;
-static const UChar u_o=0x6F;
-static const UChar u_p=0x70;
-static const UChar u_r=0x72;
-static const UChar u_s=0x73;
-static const UChar u_t=0x74;
-static const UChar u_u=0x75;
-static const UChar u_z=0x7A;
-static const UChar u_leftCurlyBrace=0x7B;
-static const UChar u_pipe=0x7C;
-static const UChar u_rightCurlyBrace=0x7D;
-static const UChar u_lessOrEqual=0x2264; // U+2264 is <=
-
-static const UChar kOffsetColon[]={ // "offset:"
+static const char16_t u_pound=0x23;
+static const char16_t u_apos=0x27;
+static const char16_t u_plus=0x2B;
+static const char16_t u_comma=0x2C;
+static const char16_t u_minus=0x2D;
+static const char16_t u_dot=0x2E;
+static const char16_t u_colon=0x3A;
+static const char16_t u_lessThan=0x3C;
+static const char16_t u_equal=0x3D;
+static const char16_t u_A=0x41;
+static const char16_t u_C=0x43;
+static const char16_t u_D=0x44;
+static const char16_t u_E=0x45;
+static const char16_t u_H=0x48;
+static const char16_t u_I=0x49;
+static const char16_t u_L=0x4C;
+static const char16_t u_N=0x4E;
+static const char16_t u_O=0x4F;
+static const char16_t u_P=0x50;
+static const char16_t u_R=0x52;
+static const char16_t u_S=0x53;
+static const char16_t u_T=0x54;
+static const char16_t u_U=0x55;
+static const char16_t u_Z=0x5A;
+static const char16_t u_a=0x61;
+static const char16_t u_c=0x63;
+static const char16_t u_d=0x64;
+static const char16_t u_e=0x65;
+static const char16_t u_f=0x66;
+static const char16_t u_h=0x68;
+static const char16_t u_i=0x69;
+static const char16_t u_l=0x6C;
+static const char16_t u_n=0x6E;
+static const char16_t u_o=0x6F;
+static const char16_t u_p=0x70;
+static const char16_t u_r=0x72;
+static const char16_t u_s=0x73;
+static const char16_t u_t=0x74;
+static const char16_t u_u=0x75;
+static const char16_t u_z=0x7A;
+static const char16_t u_leftCurlyBrace=0x7B;
+static const char16_t u_pipe=0x7C;
+static const char16_t u_rightCurlyBrace=0x7D;
+static const char16_t u_lessOrEqual=0x2264; // U+2264 is <=
+
+static const char16_t kOffsetColon[]={ // "offset:"
u_o, u_f, u_f, u_s, u_e, u_t, u_colon
};
-static const UChar kOther[]={ // "other"
+static const char16_t kOther[]={ // "other"
u_o, u_t, u_h, u_e, u_r
};
for(int32_t i=count; i>0;) {
const Part &part=getPart(--i);
if(part.getType()==UMSGPAT_PART_TYPE_INSERT_CHAR) {
- modified.insert(part.index, (UChar)part.value);
+ modified.insert(part.index, (char16_t)part.value);
}
}
return modified;
if(index>=msg.length()) {
break;
}
- UChar c=msg.charAt(index++);
+ char16_t c=msg.charAt(index++);
if(c==u_apos) {
if(index==msg.length()) {
// The apostrophe is the last character in the pattern.
errorCode=U_UNMATCHED_BRACES;
return 0;
}
- UChar c=msg.charAt(index);
+ char16_t c=msg.charAt(index);
if(c==u_rightCurlyBrace) {
// all done
} else if(c!=u_comma) {
int32_t start=index;
int32_t nestedBraces=0;
while(index<msg.length()) {
- UChar c=msg.charAt(index++);
+ char16_t c=msg.charAt(index++);
if(c==u_apos) {
// Treat apostrophe as quoting but include it in the style part.
// Find the end of the quoted literal text.
errorCode=U_PATTERN_SYNTAX_ERROR;
return 0;
}
- UChar c=msg.charAt(index);
+ char16_t c=msg.charAt(index);
if(!(c==u_pound || c==u_lessThan || c==u_lessOrEqual)) { // U+2264 is <=
setParseError(parseError, start); // Expected choice separator (#<\u2264) instead of c.
errorCode=U_PATTERN_SYNTAX_ERROR;
int32_t number;
// Defer numeric errors until we know there are only digits.
UBool badNumber;
- UChar c=s.charAt(start++);
+ char16_t c=s.charAt(start++);
if(c==0x30) {
if(start==limit) {
return 0;
int32_t value=0;
int32_t isNegative=0; // not boolean so that we can easily add it to value
int32_t index=start;
- UChar c=msg.charAt(index++);
+ char16_t c=msg.charAt(index++);
if(c==u_minus) {
isNegative=1;
if(index==limit) {
int32_t
MessagePattern::skipWhiteSpace(int32_t index) {
- const UChar *s=msg.getBuffer();
+ const char16_t *s=msg.getBuffer();
int32_t msgLength=msg.length();
- const UChar *t=PatternProps::skipWhiteSpace(s+index, msgLength-index);
+ const char16_t *t=PatternProps::skipWhiteSpace(s+index, msgLength-index);
return (int32_t)(t-s);
}
int32_t
MessagePattern::skipIdentifier(int32_t index) {
- const UChar *s=msg.getBuffer();
+ const char16_t *s=msg.getBuffer();
int32_t msgLength=msg.length();
- const UChar *t=PatternProps::skipIdentifier(s+index, msgLength-index);
+ const char16_t *t=PatternProps::skipIdentifier(s+index, msgLength-index);
return (int32_t)(t-s);
}
MessagePattern::skipDouble(int32_t index) {
int32_t msgLength=msg.length();
while(index<msgLength) {
- UChar c=msg.charAt(index);
+ char16_t c=msg.charAt(index);
// U+221E: Allow the infinity symbol, for ChoiceFormat patterns.
if((c<0x30 && c!=u_plus && c!=u_minus && c!=u_dot) || (c>0x39 && c!=u_e && c!=u_E && c!=0x221e)) {
break;
UBool
MessagePattern::isChoice(int32_t index) {
- UChar c;
+ char16_t c;
return
((c=msg.charAt(index++))==u_c || c==u_C) &&
((c=msg.charAt(index++))==u_h || c==u_H) &&
UBool
MessagePattern::isPlural(int32_t index) {
- UChar c;
+ char16_t c;
return
((c=msg.charAt(index++))==u_p || c==u_P) &&
((c=msg.charAt(index++))==u_l || c==u_L) &&
UBool
MessagePattern::isSelect(int32_t index) {
- UChar c;
+ char16_t c;
return
((c=msg.charAt(index++))==u_s || c==u_S) &&
((c=msg.charAt(index++))==u_e || c==u_E) &&
UBool
MessagePattern::isOrdinal(int32_t index) {
- UChar c;
+ char16_t c;
return
((c=msg.charAt(index++))==u_o || c==u_O) &&
((c=msg.charAt(index++))==u_r || c==u_R) &&
dest.setToBogus();
return dest;
}
- const UChar *sArray=src.getBuffer();
+ const char16_t *sArray=src.getBuffer();
if(&dest==&src || sArray==nullptr) {
errorCode=U_ILLEGAL_ARGUMENT_ERROR;
dest.setToBogus();
return dest;
}
virtual void
- normalize(const UChar *src, const UChar *limit,
+ normalize(const char16_t *src, const char16_t *limit,
ReorderingBuffer &buffer, UErrorCode &errorCode) const = 0;
// normalize and append
if(U_FAILURE(errorCode)) {
return first;
}
- const UChar *secondArray=second.getBuffer();
+ const char16_t *secondArray=second.getBuffer();
if(&first==&second || secondArray==nullptr) {
errorCode=U_ILLEGAL_ARGUMENT_ERROR;
return first;
return first;
}
virtual void
- normalizeAndAppend(const UChar *src, const UChar *limit, UBool doNormalize,
+ normalizeAndAppend(const char16_t *src, const char16_t *limit, UBool doNormalize,
UnicodeString &safeMiddle,
ReorderingBuffer &buffer, UErrorCode &errorCode) const = 0;
virtual UBool
getDecomposition(UChar32 c, UnicodeString &decomposition) const U_OVERRIDE {
- UChar buffer[4];
+ char16_t buffer[4];
int32_t length;
- const UChar *d=impl.getDecomposition(c, buffer, length);
+ const char16_t *d=impl.getDecomposition(c, buffer, length);
if(d==nullptr) {
return false;
}
}
virtual UBool
getRawDecomposition(UChar32 c, UnicodeString &decomposition) const U_OVERRIDE {
- UChar buffer[30];
+ char16_t buffer[30];
int32_t length;
- const UChar *d=impl.getRawDecomposition(c, buffer, length);
+ const char16_t *d=impl.getRawDecomposition(c, buffer, length);
if(d==nullptr) {
return false;
}
if(U_FAILURE(errorCode)) {
return false;
}
- const UChar *sArray=s.getBuffer();
+ const char16_t *sArray=s.getBuffer();
if(sArray==nullptr) {
errorCode=U_ILLEGAL_ARGUMENT_ERROR;
return false;
}
- const UChar *sLimit=sArray+s.length();
+ const char16_t *sLimit=sArray+s.length();
return sLimit==spanQuickCheckYes(sArray, sLimit, errorCode);
}
virtual UNormalizationCheckResult
if(U_FAILURE(errorCode)) {
return 0;
}
- const UChar *sArray=s.getBuffer();
+ const char16_t *sArray=s.getBuffer();
if(sArray==nullptr) {
errorCode=U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
return (int32_t)(spanQuickCheckYes(sArray, sArray+s.length(), errorCode)-sArray);
}
- virtual const UChar *
- spanQuickCheckYes(const UChar *src, const UChar *limit, UErrorCode &errorCode) const = 0;
+ virtual const char16_t *
+ spanQuickCheckYes(const char16_t *src, const char16_t *limit, UErrorCode &errorCode) const = 0;
virtual UNormalizationCheckResult getQuickCheck(UChar32) const {
return UNORM_YES;
private:
virtual void
- normalize(const UChar *src, const UChar *limit,
+ normalize(const char16_t *src, const char16_t *limit,
ReorderingBuffer &buffer, UErrorCode &errorCode) const U_OVERRIDE {
impl.decompose(src, limit, &buffer, errorCode);
}
using Normalizer2WithImpl::normalize; // Avoid warning about hiding base class function.
virtual void
- normalizeAndAppend(const UChar *src, const UChar *limit, UBool doNormalize,
+ normalizeAndAppend(const char16_t *src, const char16_t *limit, UBool doNormalize,
UnicodeString &safeMiddle,
ReorderingBuffer &buffer, UErrorCode &errorCode) const U_OVERRIDE {
impl.decomposeAndAppend(src, limit, doNormalize, safeMiddle, buffer, errorCode);
return sLimit == impl.decomposeUTF8(0, s, sLimit, nullptr, nullptr, errorCode);
}
- virtual const UChar *
- spanQuickCheckYes(const UChar *src, const UChar *limit, UErrorCode &errorCode) const U_OVERRIDE {
+ virtual const char16_t *
+ spanQuickCheckYes(const char16_t *src, const char16_t *limit, UErrorCode &errorCode) const U_OVERRIDE {
return impl.decompose(src, limit, nullptr, errorCode);
}
using Normalizer2WithImpl::spanQuickCheckYes; // Avoid warning about hiding base class function.
private:
virtual void
- normalize(const UChar *src, const UChar *limit,
+ normalize(const char16_t *src, const char16_t *limit,
ReorderingBuffer &buffer, UErrorCode &errorCode) const U_OVERRIDE {
impl.compose(src, limit, onlyContiguous, true, buffer, errorCode);
}
}
virtual void
- normalizeAndAppend(const UChar *src, const UChar *limit, UBool doNormalize,
+ normalizeAndAppend(const char16_t *src, const char16_t *limit, UBool doNormalize,
UnicodeString &safeMiddle,
ReorderingBuffer &buffer, UErrorCode &errorCode) const U_OVERRIDE {
impl.composeAndAppend(src, limit, doNormalize, onlyContiguous, safeMiddle, buffer, errorCode);
if(U_FAILURE(errorCode)) {
return false;
}
- const UChar *sArray=s.getBuffer();
+ const char16_t *sArray=s.getBuffer();
if(sArray==nullptr) {
errorCode=U_ILLEGAL_ARGUMENT_ERROR;
return false;
if(U_FAILURE(errorCode)) {
return UNORM_MAYBE;
}
- const UChar *sArray=s.getBuffer();
+ const char16_t *sArray=s.getBuffer();
if(sArray==nullptr) {
errorCode=U_ILLEGAL_ARGUMENT_ERROR;
return UNORM_MAYBE;
impl.composeQuickCheck(sArray, sArray+s.length(), onlyContiguous, &qcResult);
return qcResult;
}
- virtual const UChar *
- spanQuickCheckYes(const UChar *src, const UChar *limit, UErrorCode &) const U_OVERRIDE {
+ virtual const char16_t *
+ spanQuickCheckYes(const char16_t *src, const char16_t *limit, UErrorCode &) const U_OVERRIDE {
return impl.composeQuickCheck(src, limit, onlyContiguous, nullptr);
}
using Normalizer2WithImpl::spanQuickCheckYes; // Avoid warning about hiding base class function.
private:
virtual void
- normalize(const UChar *src, const UChar *limit,
+ normalize(const char16_t *src, const char16_t *limit,
ReorderingBuffer &buffer, UErrorCode &errorCode) const U_OVERRIDE {
impl.makeFCD(src, limit, &buffer, errorCode);
}
using Normalizer2WithImpl::normalize; // Avoid warning about hiding base class function.
virtual void
- normalizeAndAppend(const UChar *src, const UChar *limit, UBool doNormalize,
+ normalizeAndAppend(const char16_t *src, const char16_t *limit, UBool doNormalize,
UnicodeString &safeMiddle,
ReorderingBuffer &buffer, UErrorCode &errorCode) const U_OVERRIDE {
impl.makeFCDAndAppend(src, limit, doNormalize, safeMiddle, buffer, errorCode);
}
- virtual const UChar *
- spanQuickCheckYes(const UChar *src, const UChar *limit, UErrorCode &errorCode) const U_OVERRIDE {
+ virtual const char16_t *
+ spanQuickCheckYes(const char16_t *src, const char16_t *limit, UErrorCode &errorCode) const U_OVERRIDE {
return impl.makeFCD(src, limit, nullptr, errorCode);
}
using Normalizer2WithImpl::spanQuickCheckYes; // Avoid warning about hiding base class function.
U_CAPI int32_t U_EXPORT2
unorm2_normalize(const UNormalizer2 *norm2,
- const UChar *src, int32_t length,
- UChar *dest, int32_t capacity,
+ const char16_t *src, int32_t length,
+ char16_t *dest, int32_t capacity,
UErrorCode *pErrorCode) {
if(U_FAILURE(*pErrorCode)) {
return 0;
static int32_t
normalizeSecondAndAppend(const UNormalizer2 *norm2,
- UChar *first, int32_t firstLength, int32_t firstCapacity,
- const UChar *second, int32_t secondLength,
+ char16_t *first, int32_t firstLength, int32_t firstCapacity,
+ const char16_t *second, int32_t secondLength,
UBool doNormalize,
UErrorCode *pErrorCode) {
if(U_FAILURE(*pErrorCode)) {
U_CAPI int32_t U_EXPORT2
unorm2_normalizeSecondAndAppend(const UNormalizer2 *norm2,
- UChar *first, int32_t firstLength, int32_t firstCapacity,
- const UChar *second, int32_t secondLength,
+ char16_t *first, int32_t firstLength, int32_t firstCapacity,
+ const char16_t *second, int32_t secondLength,
UErrorCode *pErrorCode) {
return normalizeSecondAndAppend(norm2,
first, firstLength, firstCapacity,
U_CAPI int32_t U_EXPORT2
unorm2_append(const UNormalizer2 *norm2,
- UChar *first, int32_t firstLength, int32_t firstCapacity,
- const UChar *second, int32_t secondLength,
+ char16_t *first, int32_t firstLength, int32_t firstCapacity,
+ const char16_t *second, int32_t secondLength,
UErrorCode *pErrorCode) {
return normalizeSecondAndAppend(norm2,
first, firstLength, firstCapacity,
U_CAPI int32_t U_EXPORT2
unorm2_getDecomposition(const UNormalizer2 *norm2,
- UChar32 c, UChar *decomposition, int32_t capacity,
+ UChar32 c, char16_t *decomposition, int32_t capacity,
UErrorCode *pErrorCode) {
if(U_FAILURE(*pErrorCode)) {
return 0;
U_CAPI int32_t U_EXPORT2
unorm2_getRawDecomposition(const UNormalizer2 *norm2,
- UChar32 c, UChar *decomposition, int32_t capacity,
+ UChar32 c, char16_t *decomposition, int32_t capacity,
UErrorCode *pErrorCode) {
if(U_FAILURE(*pErrorCode)) {
return 0;
U_CAPI UBool U_EXPORT2
unorm2_isNormalized(const UNormalizer2 *norm2,
- const UChar *s, int32_t length,
+ const char16_t *s, int32_t length,
UErrorCode *pErrorCode) {
if(U_FAILURE(*pErrorCode)) {
return 0;
U_CAPI UNormalizationCheckResult U_EXPORT2
unorm2_quickCheck(const UNormalizer2 *norm2,
- const UChar *s, int32_t length,
+ const char16_t *s, int32_t length,
UErrorCode *pErrorCode) {
if(U_FAILURE(*pErrorCode)) {
return UNORM_NO;
U_CAPI int32_t U_EXPORT2
unorm2_spanQuickCheckYes(const UNormalizer2 *norm2,
- const UChar *s, int32_t length,
+ const char16_t *s, int32_t length,
UErrorCode *pErrorCode) {
if(U_FAILURE(*pErrorCode)) {
return 0;
case 2:
return ((c&0x1f)<<6) | (cpStart[1]&0x3f);
case 3:
- // no need for (c&0xf) because the upper bits are truncated after <<12 in the cast to (UChar)
- return (UChar)((c<<12) | ((cpStart[1]&0x3f)<<6) | (cpStart[2]&0x3f));
+ // no need for (c&0xf) because the upper bits are truncated after <<12 in the cast to (char16_t)
+ return (char16_t)((c<<12) | ((cpStart[1]&0x3f)<<6) | (cpStart[2]&0x3f));
case 4:
return ((c&7)<<18) | ((cpStart[1]&0x3f)<<12) | ((cpStart[2]&0x3f)<<6) | (cpStart[3]&0x3f);
default:
return true;
}
-UBool ReorderingBuffer::equals(const UChar *otherStart, const UChar *otherLimit) const {
+UBool ReorderingBuffer::equals(const char16_t *otherStart, const char16_t *otherLimit) const {
int32_t length=(int32_t)(limit-start);
return
length==(int32_t)(otherLimit-otherStart) &&
return true;
}
-UBool ReorderingBuffer::append(const UChar *s, int32_t length, UBool isNFD,
+UBool ReorderingBuffer::append(const char16_t *s, int32_t length, UBool isNFD,
uint8_t leadCC, uint8_t trailCC,
UErrorCode &errorCode) {
if(length==0) {
} else if(leadCC<=1) {
reorderStart=limit+1; // Ok if not a code point boundary.
}
- const UChar *sLimit=s+length;
+ const char16_t *sLimit=s+length;
do { *limit++=*s++; } while(s!=sLimit);
lastCC=trailCC;
} else {
}
remainingCapacity-=cpLength;
if(cpLength==1) {
- *limit++=(UChar)c;
+ *limit++=(char16_t)c;
} else {
limit[0]=U16_LEAD(c);
limit[1]=U16_TRAIL(c);
return true;
}
-UBool ReorderingBuffer::appendZeroCC(const UChar *s, const UChar *sLimit, UErrorCode &errorCode) {
+UBool ReorderingBuffer::appendZeroCC(const char16_t *s, const char16_t *sLimit, UErrorCode &errorCode) {
if(s==sLimit) {
return true;
}
void ReorderingBuffer::skipPrevious() {
codePointLimit=codePointStart;
- UChar c=*--codePointStart;
+ char16_t c=*--codePointStart;
if(U16_IS_TRAIL(c) && start<codePointStart && U16_IS_LEAD(*(codePointStart-1))) {
--codePointStart;
}
return 0;
}
UChar32 c=*--codePointStart;
- UChar c2;
+ char16_t c2;
if(U16_IS_TRAIL(c) && start<codePointStart && U16_IS_LEAD(c2=*(codePointStart-1))) {
--codePointStart;
c=U16_GET_SUPPLEMENTARY(c2, c);
void ReorderingBuffer::insert(UChar32 c, uint8_t cc) {
for(setIterator(), skipPrevious(); previousCC()>cc;) {}
// insert c at codePointLimit, after the character with prevCC<=cc
- UChar *q=limit;
- UChar *r=limit+=U16_LENGTH(c);
+ char16_t *q=limit;
+ char16_t *r=limit+=U16_LENGTH(c);
do {
*--r=*--q;
} while(codePointLimit!=q);
void
Normalizer2Impl::init(const int32_t *inIndexes, const UCPTrie *inTrie,
const uint16_t *inExtraData, const uint8_t *inSmallFCD) {
- minDecompNoCP = static_cast<UChar>(inIndexes[IX_MIN_DECOMP_NO_CP]);
- minCompNoMaybeCP = static_cast<UChar>(inIndexes[IX_MIN_COMP_NO_MAYBE_CP]);
- minLcccCP = static_cast<UChar>(inIndexes[IX_MIN_LCCC_CP]);
+ minDecompNoCP = static_cast<char16_t>(inIndexes[IX_MIN_DECOMP_NO_CP]);
+ minCompNoMaybeCP = static_cast<char16_t>(inIndexes[IX_MIN_COMP_NO_MAYBE_CP]);
+ minLcccCP = static_cast<char16_t>(inIndexes[IX_MIN_LCCC_CP]);
minYesNo = static_cast<uint16_t>(inIndexes[IX_MIN_YES_NO]);
minYesNoMappingsOnly = static_cast<uint16_t>(inIndexes[IX_MIN_YES_NO_MAPPINGS_ONLY]);
}
/* add Hangul LV syllables and LV+1 because of skippables */
- for(UChar c=Hangul::HANGUL_BASE; c<Hangul::HANGUL_LIMIT; c+=Hangul::JAMO_T_COUNT) {
+ for(char16_t c=Hangul::HANGUL_BASE; c<Hangul::HANGUL_LIMIT; c+=Hangul::JAMO_T_COUNT) {
sa->add(sa->set, c);
sa->add(sa->set, c+1);
}
}
}
-const UChar *
-Normalizer2Impl::copyLowPrefixFromNulTerminated(const UChar *src,
+const char16_t *
+Normalizer2Impl::copyLowPrefixFromNulTerminated(const char16_t *src,
UChar32 minNeedDataCP,
ReorderingBuffer *buffer,
UErrorCode &errorCode) const {
// data and check the first part of the string.
// After this prefix, determine the string length to simplify the rest
// of the code.
- const UChar *prevSrc=src;
- UChar c;
+ const char16_t *prevSrc=src;
+ char16_t c;
while((c=*src++)<minNeedDataCP && c!=0) {}
// Back out the last character for full processing.
// Copy this prefix.
dest.setToBogus();
return dest;
}
- const UChar *sArray=src.getBuffer();
+ const char16_t *sArray=src.getBuffer();
if(&dest==&src || sArray==nullptr) {
errorCode=U_ILLEGAL_ARGUMENT_ERROR;
dest.setToBogus();
}
void
-Normalizer2Impl::decompose(const UChar *src, const UChar *limit,
+Normalizer2Impl::decompose(const char16_t *src, const char16_t *limit,
UnicodeString &dest,
int32_t destLengthEstimate,
UErrorCode &errorCode) const {
// Dual functionality:
// buffer!=nullptr: normalize
// buffer==nullptr: isNormalized/spanQuickCheckYes
-const UChar *
-Normalizer2Impl::decompose(const UChar *src, const UChar *limit,
+const char16_t *
+Normalizer2Impl::decompose(const char16_t *src, const char16_t *limit,
ReorderingBuffer *buffer,
UErrorCode &errorCode) const {
UChar32 minNoCP=minDecompNoCP;
limit=u_strchr(src, 0);
}
- const UChar *prevSrc;
+ const char16_t *prevSrc;
UChar32 c=0;
uint16_t norm16=0;
// only for quick check
- const UChar *prevBoundary=src;
+ const char16_t *prevBoundary=src;
uint8_t prevCC=0;
for(;;) {
} else if(!U16_IS_LEAD(c)) {
break;
} else {
- UChar c2;
+ char16_t c2;
if((src+1)!=limit && U16_IS_TRAIL(c2=src[1])) {
c=U16_GET_SUPPLEMENTARY(c, c2);
norm16=UCPTRIE_FAST_SUPP_GET(normTrie, UCPTRIE_16, c);
// fail the quick check loop and/or where the quick check loop's overhead
// is unlikely to be amortized.
// Called by the compose() and makeFCD() implementations.
-const UChar *
-Normalizer2Impl::decomposeShort(const UChar *src, const UChar *limit,
+const char16_t *
+Normalizer2Impl::decomposeShort(const char16_t *src, const char16_t *limit,
UBool stopAtCompBoundary, UBool onlyContiguous,
ReorderingBuffer &buffer, UErrorCode &errorCode) const {
if (U_FAILURE(errorCode)) {
if (stopAtCompBoundary && *src < minCompNoMaybeCP) {
return src;
}
- const UChar *prevSrc = src;
+ const char16_t *prevSrc = src;
UChar32 c;
uint16_t norm16;
UCPTRIE_FAST_U16_NEXT(normTrie, UCPTRIE_16, src, limit, c, norm16);
return buffer.append(c, 0, errorCode);
} else if(isHangulLV(norm16) || isHangulLVT(norm16)) {
// Hangul syllable: decompose algorithmically
- UChar jamos[3];
+ char16_t jamos[3];
return buffer.appendZeroCC(jamos, jamos+Hangul::decompose(c, jamos), errorCode);
}
// c decomposes, get everything from the variable-length extra data
} else {
leadCC=0;
}
- return buffer.append((const UChar *)mapping+1, length, true, leadCC, trailCC, errorCode);
+ return buffer.append((const char16_t *)mapping+1, length, true, leadCC, trailCC, errorCode);
}
// Dual functionality:
return src;
}
-const UChar *
-Normalizer2Impl::getDecomposition(UChar32 c, UChar buffer[4], int32_t &length) const {
+const char16_t *
+Normalizer2Impl::getDecomposition(UChar32 c, char16_t buffer[4], int32_t &length) const {
uint16_t norm16;
if(c<minDecompNoCP || isMaybeOrNonZeroCC(norm16=getNorm16(c))) {
// c does not decompose
return nullptr;
}
- const UChar *decomp = nullptr;
+ const char16_t *decomp = nullptr;
if(isDecompNoAlgorithmic(norm16)) {
// Maps to an isCompYesAndZeroCC.
c=mapAlgorithmic(c, norm16);
// c decomposes, get everything from the variable-length extra data
const uint16_t *mapping=getMapping(norm16);
length=*mapping&MAPPING_LENGTH_MASK;
- return (const UChar *)mapping+1;
+ return (const char16_t *)mapping+1;
}
// The capacity of the buffer must be 30=MAPPING_LENGTH_MASK-1
// so that a raw mapping fits that consists of one unit ("rm0")
// plus all but the first two code units of the normal mapping.
// The maximum length of a normal mapping is 31=MAPPING_LENGTH_MASK.
-const UChar *
-Normalizer2Impl::getRawDecomposition(UChar32 c, UChar buffer[30], int32_t &length) const {
+const char16_t *
+Normalizer2Impl::getRawDecomposition(UChar32 c, char16_t buffer[30], int32_t &length) const {
uint16_t norm16;
if(c<minDecompNoCP || isDecompYes(norm16=getNorm16(c))) {
// c does not decompose
uint16_t rm0=*rawMapping;
if(rm0<=MAPPING_LENGTH_MASK) {
length=rm0;
- return (const UChar *)rawMapping-rm0;
+ return (const char16_t *)rawMapping-rm0;
} else {
// Copy the normal mapping and replace its first two code units with rm0.
- buffer[0]=(UChar)rm0;
- u_memcpy(buffer+1, (const UChar *)mapping+1+2, mLength-2);
+ buffer[0]=(char16_t)rm0;
+ u_memcpy(buffer+1, (const char16_t *)mapping+1+2, mLength-2);
length=mLength-1;
return buffer;
}
} else {
length=mLength;
- return (const UChar *)mapping+1;
+ return (const char16_t *)mapping+1;
}
}
-void Normalizer2Impl::decomposeAndAppend(const UChar *src, const UChar *limit,
+void Normalizer2Impl::decomposeAndAppend(const char16_t *src, const char16_t *limit,
UBool doDecompose,
UnicodeString &safeMiddle,
ReorderingBuffer &buffer,
// Just merge the strings at the boundary.
bool isFirst = true;
uint8_t firstCC = 0, prevCC = 0, cc;
- const UChar *p = src;
+ const char16_t *p = src;
while (p != limit) {
- const UChar *codePointStart = p;
+ const char16_t *codePointStart = p;
UChar32 c;
uint16_t norm16;
UCPTRIE_FAST_U16_NEXT(normTrie, UCPTRIE_16, p, limit, c, norm16);
*/
void Normalizer2Impl::recompose(ReorderingBuffer &buffer, int32_t recomposeStartIndex,
UBool onlyContiguous) const {
- UChar *p=buffer.getStart()+recomposeStartIndex;
- UChar *limit=buffer.getLimit();
+ char16_t *p=buffer.getStart()+recomposeStartIndex;
+ char16_t *limit=buffer.getLimit();
if(p==limit) {
return;
}
- UChar *starter, *pRemove, *q, *r;
+ char16_t *starter, *pRemove, *q, *r;
const uint16_t *compositionsList;
UChar32 c, compositeAndFwd;
uint16_t norm16;
// c is a Jamo V/T, see if we can compose it with the previous character.
if(c<Hangul::JAMO_T_BASE) {
// c is a Jamo Vowel, compose with previous Jamo L and following Jamo T.
- UChar prev=(UChar)(*starter-Hangul::JAMO_L_BASE);
+ char16_t prev=(char16_t)(*starter-Hangul::JAMO_L_BASE);
if(prev<Hangul::JAMO_L_COUNT) {
pRemove=p-1;
- UChar syllable=(UChar)
+ char16_t syllable=(char16_t)
(Hangul::HANGUL_BASE+
(prev*Hangul::JAMO_V_COUNT+(c-Hangul::JAMO_V_BASE))*
Hangul::JAMO_T_COUNT);
- UChar t;
- if(p!=limit && (t=(UChar)(*p-Hangul::JAMO_T_BASE))<Hangul::JAMO_T_COUNT) {
+ char16_t t;
+ if(p!=limit && (t=(char16_t)(*p-Hangul::JAMO_T_BASE))<Hangul::JAMO_T_COUNT) {
++p;
syllable+=t; // The next character was a Jamo T.
}
starter[0]=U16_LEAD(composite);
starter[1]=U16_TRAIL(composite);
} else {
- *starter=(UChar)composite;
+ *starter=(char16_t)composite;
// The composite is shorter than the starter,
// move the intermediate characters forward one.
starterIsSupplementary=false;
*--starter=U16_LEAD(composite); // undo the temporary increment
} else {
// both are on the BMP
- *starter=(UChar)composite;
+ *starter=(char16_t)composite;
}
/* remove the combining mark by moving the following text over it */
// doCompose: normalize
// !doCompose: isNormalized (buffer must be empty and initialized)
UBool
-Normalizer2Impl::compose(const UChar *src, const UChar *limit,
+Normalizer2Impl::compose(const char16_t *src, const char16_t *limit,
UBool onlyContiguous,
UBool doCompose,
ReorderingBuffer &buffer,
UErrorCode &errorCode) const {
- const UChar *prevBoundary=src;
+ const char16_t *prevBoundary=src;
UChar32 minNoMaybeCP=minCompNoMaybeCP;
if(limit==nullptr) {
src=copyLowPrefixFromNulTerminated(src, minNoMaybeCP,
for (;;) {
// Fast path: Scan over a sequence of characters below the minimum "no or maybe" code point,
// or with (compYes && ccc==0) properties.
- const UChar *prevSrc;
+ const char16_t *prevSrc;
UChar32 c = 0;
uint16_t norm16 = 0;
for (;;) {
if(!U16_IS_LEAD(c)) {
break;
} else {
- UChar c2;
+ char16_t c2;
if(src!=limit && U16_IS_TRAIL(c2=*src)) {
++src;
c=U16_GET_SUPPLEMENTARY(c, c2);
if (prevBoundary != prevSrc && !buffer.appendZeroCC(prevBoundary, prevSrc, errorCode)) {
break;
}
- const UChar *mapping = reinterpret_cast<const UChar *>(getMapping(norm16));
+ const char16_t *mapping = reinterpret_cast<const char16_t *>(getMapping(norm16));
int32_t length = *mapping++ & MAPPING_LENGTH_MASK;
if(!buffer.appendZeroCC(mapping, mapping + length, errorCode)) {
break;
// Other "noNo" type, or need to examine more text around this character:
// Fall through to the slow path.
} else if (isJamoVT(norm16) && prevBoundary != prevSrc) {
- UChar prev=*(prevSrc-1);
+ char16_t prev=*(prevSrc-1);
if(c<Hangul::JAMO_T_BASE) {
// The current character is a Jamo Vowel,
// compose with previous Jamo L and following Jamo T.
- UChar l = (UChar)(prev-Hangul::JAMO_L_BASE);
+ char16_t l = (char16_t)(prev-Hangul::JAMO_L_BASE);
if(l<Hangul::JAMO_L_COUNT) {
if (!doCompose) {
return false;
if (prevBoundary != prevSrc && !buffer.appendZeroCC(prevBoundary, prevSrc, errorCode)) {
break;
}
- if(!buffer.appendBMP((UChar)syllable, 0, errorCode)) {
+ if(!buffer.appendBMP((char16_t)syllable, 0, errorCode)) {
break;
}
prevBoundary = src;
if (prevBoundary != prevSrc && !buffer.appendZeroCC(prevBoundary, prevSrc, errorCode)) {
break;
}
- if(!buffer.appendBMP((UChar)syllable, 0, errorCode)) {
+ if(!buffer.appendBMP((char16_t)syllable, 0, errorCode)) {
break;
}
prevBoundary = src;
} else {
// If !onlyContiguous (not FCC), then we ignore the tccc of
// the previous character which passed the quick check "yes && ccc==0" test.
- const UChar *nextSrc;
+ const char16_t *nextSrc;
uint16_t n16;
for (;;) {
if (src == limit) {
// Slow path: Find the nearest boundaries around the current character,
// decompose and recompose.
if (prevBoundary != prevSrc && !norm16HasCompBoundaryBefore(norm16)) {
- const UChar *p = prevSrc;
+ const char16_t *p = prevSrc;
UCPTRIE_FAST_U16_PREV(normTrie, UCPTRIE_16, prevBoundary, p, c, norm16);
if (!norm16HasCompBoundaryAfter(norm16, onlyContiguous)) {
prevSrc = p;
// Very similar to compose(): Make the same changes in both places if relevant.
// pQCResult==nullptr: spanQuickCheckYes
// pQCResult!=nullptr: quickCheck (*pQCResult must be UNORM_YES)
-const UChar *
-Normalizer2Impl::composeQuickCheck(const UChar *src, const UChar *limit,
+const char16_t *
+Normalizer2Impl::composeQuickCheck(const char16_t *src, const char16_t *limit,
UBool onlyContiguous,
UNormalizationCheckResult *pQCResult) const {
- const UChar *prevBoundary=src;
+ const char16_t *prevBoundary=src;
UChar32 minNoMaybeCP=minCompNoMaybeCP;
if(limit==nullptr) {
UErrorCode errorCode=U_ZERO_ERROR;
for(;;) {
// Fast path: Scan over a sequence of characters below the minimum "no or maybe" code point,
// or with (compYes && ccc==0) properties.
- const UChar *prevSrc;
+ const char16_t *prevSrc;
UChar32 c = 0;
uint16_t norm16 = 0;
for (;;) {
if(!U16_IS_LEAD(c)) {
break;
} else {
- UChar c2;
+ char16_t c2;
if(src!=limit && U16_IS_TRAIL(c2=*src)) {
++src;
c=U16_GET_SUPPLEMENTARY(c, c2);
if (norm16HasCompBoundaryBefore(norm16)) {
prevBoundary = prevSrc;
} else {
- const UChar *p = prevSrc;
+ const char16_t *p = prevSrc;
uint16_t n16;
UCPTRIE_FAST_U16_PREV(normTrie, UCPTRIE_16, prevBoundary, p, c, n16);
if (norm16HasCompBoundaryAfter(n16, onlyContiguous)) {
} else {
// If !onlyContiguous (not FCC), then we ignore the tccc of
// the previous character which passed the quick check "yes && ccc==0" test.
- const UChar *nextSrc;
+ const char16_t *nextSrc;
for (;;) {
if (norm16 < MIN_YES_YES_WITH_CC) {
if (pQCResult != nullptr) {
}
}
-void Normalizer2Impl::composeAndAppend(const UChar *src, const UChar *limit,
+void Normalizer2Impl::composeAndAppend(const char16_t *src, const char16_t *limit,
UBool doCompose,
UBool onlyContiguous,
UnicodeString &safeMiddle,
ReorderingBuffer &buffer,
UErrorCode &errorCode) const {
if(!buffer.isEmpty()) {
- const UChar *firstStarterInSrc=findNextCompBoundary(src, limit, onlyContiguous);
+ const char16_t *firstStarterInSrc=findNextCompBoundary(src, limit, onlyContiguous);
if(src!=firstStarterInSrc) {
- const UChar *lastStarterInDest=findPreviousCompBoundary(buffer.getStart(),
+ const char16_t *lastStarterInDest=findPreviousCompBoundary(buffer.getStart(),
buffer.getLimit(), onlyContiguous);
int32_t destSuffixLength=(int32_t)(buffer.getLimit()-lastStarterInDest);
UnicodeString middle(lastStarterInDest, destSuffixLength);
buffer.removeSuffix(destSuffixLength);
safeMiddle=middle;
middle.append(src, (int32_t)(firstStarterInSrc-src));
- const UChar *middleStart=middle.getBuffer();
+ const char16_t *middleStart=middle.getBuffer();
compose(middleStart, middleStart+middle.length(), onlyContiguous,
true, buffer, errorCode);
if(U_FAILURE(errorCode)) {
}
const uint16_t *mapping = getMapping(norm16);
int32_t length = *mapping++ & MAPPING_LENGTH_MASK;
- if (!ByteSinkUtil::appendChange(prevSrc, src, (const UChar *)mapping, length,
+ if (!ByteSinkUtil::appendChange(prevSrc, src, (const char16_t *)mapping, length,
*sink, edits, errorCode)) {
break;
}
return true;
}
-UBool Normalizer2Impl::hasCompBoundaryBefore(const UChar *src, const UChar *limit) const {
+UBool Normalizer2Impl::hasCompBoundaryBefore(const char16_t *src, const char16_t *limit) const {
if (src == limit || *src < minCompNoMaybeCP) {
return true;
}
return norm16HasCompBoundaryBefore(norm16);
}
-UBool Normalizer2Impl::hasCompBoundaryAfter(const UChar *start, const UChar *p,
+UBool Normalizer2Impl::hasCompBoundaryAfter(const char16_t *start, const char16_t *p,
UBool onlyContiguous) const {
if (start == p) {
return true;
return norm16HasCompBoundaryAfter(norm16, onlyContiguous);
}
-const UChar *Normalizer2Impl::findPreviousCompBoundary(const UChar *start, const UChar *p,
+const char16_t *Normalizer2Impl::findPreviousCompBoundary(const char16_t *start, const char16_t *p,
UBool onlyContiguous) const {
while (p != start) {
- const UChar *codePointLimit = p;
+ const char16_t *codePointLimit = p;
UChar32 c;
uint16_t norm16;
UCPTRIE_FAST_U16_PREV(normTrie, UCPTRIE_16, start, p, c, norm16);
return p;
}
-const UChar *Normalizer2Impl::findNextCompBoundary(const UChar *p, const UChar *limit,
+const char16_t *Normalizer2Impl::findNextCompBoundary(const char16_t *p, const char16_t *limit,
UBool onlyContiguous) const {
while (p != limit) {
- const UChar *codePointStart = p;
+ const char16_t *codePointStart = p;
UChar32 c;
uint16_t norm16;
UCPTRIE_FAST_U16_NEXT(normTrie, UCPTRIE_16, p, limit, c, norm16);
return p;
}
-uint8_t Normalizer2Impl::getPreviousTrailCC(const UChar *start, const UChar *p) const {
+uint8_t Normalizer2Impl::getPreviousTrailCC(const char16_t *start, const char16_t *p) const {
if (start == p) {
return 0;
}
// Dual functionality:
// buffer!=nullptr: normalize
// buffer==nullptr: isNormalized/quickCheck/spanQuickCheckYes
-const UChar *
-Normalizer2Impl::makeFCD(const UChar *src, const UChar *limit,
+const char16_t *
+Normalizer2Impl::makeFCD(const char16_t *src, const char16_t *limit,
ReorderingBuffer *buffer,
UErrorCode &errorCode) const {
// Tracks the last FCD-safe boundary, before lccc=0 or after properly-ordered tccc<=1.
// Similar to the prevBoundary in the compose() implementation.
- const UChar *prevBoundary=src;
+ const char16_t *prevBoundary=src;
int32_t prevFCD16=0;
if(limit==nullptr) {
src=copyLowPrefixFromNulTerminated(src, minLcccCP, buffer, errorCode);
// The exception is the call to decomposeShort() which uses the buffer
// in the normal way.
- const UChar *prevSrc;
+ const char16_t *prevSrc;
UChar32 c=0;
uint16_t fcd16=0;
++src;
} else {
if(U16_IS_LEAD(c)) {
- UChar c2;
+ char16_t c2;
if((src+1)!=limit && U16_IS_TRAIL(c2=src[1])) {
c=U16_GET_SUPPLEMENTARY(c, c2);
}
}
}
} else {
- const UChar *p=src-1;
+ const char16_t *p=src-1;
if(U16_IS_TRAIL(*p) && prevSrc<p && U16_IS_LEAD(*(p-1))) {
--p;
// Need to fetch the previous character's FCD value because
return src;
}
-void Normalizer2Impl::makeFCDAndAppend(const UChar *src, const UChar *limit,
+void Normalizer2Impl::makeFCDAndAppend(const char16_t *src, const char16_t *limit,
UBool doMakeFCD,
UnicodeString &safeMiddle,
ReorderingBuffer &buffer,
UErrorCode &errorCode) const {
if(!buffer.isEmpty()) {
- const UChar *firstBoundaryInSrc=findNextFCDBoundary(src, limit);
+ const char16_t *firstBoundaryInSrc=findNextFCDBoundary(src, limit);
if(src!=firstBoundaryInSrc) {
- const UChar *lastBoundaryInDest=findPreviousFCDBoundary(buffer.getStart(),
+ const char16_t *lastBoundaryInDest=findPreviousFCDBoundary(buffer.getStart(),
buffer.getLimit());
int32_t destSuffixLength=(int32_t)(buffer.getLimit()-lastBoundaryInDest);
UnicodeString middle(lastBoundaryInDest, destSuffixLength);
buffer.removeSuffix(destSuffixLength);
safeMiddle=middle;
middle.append(src, (int32_t)(firstBoundaryInSrc-src));
- const UChar *middleStart=middle.getBuffer();
+ const char16_t *middleStart=middle.getBuffer();
makeFCD(middleStart, middleStart+middle.length(), &buffer, errorCode);
if(U_FAILURE(errorCode)) {
return;
}
}
-const UChar *Normalizer2Impl::findPreviousFCDBoundary(const UChar *start, const UChar *p) const {
+const char16_t *Normalizer2Impl::findPreviousFCDBoundary(const char16_t *start, const char16_t *p) const {
while(start<p) {
- const UChar *codePointLimit = p;
+ const char16_t *codePointLimit = p;
UChar32 c;
uint16_t norm16;
UCPTRIE_FAST_U16_PREV(normTrie, UCPTRIE_16, start, p, c, norm16);
return p;
}
-const UChar *Normalizer2Impl::findNextFCDBoundary(const UChar *p, const UChar *limit) const {
+const char16_t *Normalizer2Impl::findNextFCDBoundary(const char16_t *p, const char16_t *limit) const {
while(p<limit) {
- const UChar *codePointStart=p;
+ const char16_t *codePointStart=p;
UChar32 c;
uint16_t norm16;
UCPTRIE_FAST_U16_NEXT(normTrie, UCPTRIE_16, p, limit, c, norm16);
}
}
-const UChar *
-PatternProps::skipWhiteSpace(const UChar *s, int32_t length) {
+const char16_t *
+PatternProps::skipWhiteSpace(const char16_t *s, int32_t length) {
while(length>0 && isWhiteSpace(*s)) {
++s;
--length;
return i;
}
-const UChar *
-PatternProps::trimWhiteSpace(const UChar *s, int32_t &length) {
+const char16_t *
+PatternProps::trimWhiteSpace(const char16_t *s, int32_t &length) {
if(length<=0 || (!isWhiteSpace(s[0]) && !isWhiteSpace(s[length-1]))) {
return s;
}
}
UBool
-PatternProps::isIdentifier(const UChar *s, int32_t length) {
+PatternProps::isIdentifier(const char16_t *s, int32_t length) {
if(length<=0) {
return false;
}
- const UChar *limit=s+length;
+ const char16_t *limit=s+length;
do {
if(isSyntaxOrWhiteSpace(*s++)) {
return false;
return true;
}
-const UChar *
-PatternProps::skipIdentifier(const UChar *s, int32_t length) {
+const char16_t *
+PatternProps::skipIdentifier(const char16_t *s, int32_t length) {
while(length>0 && !isSyntaxOrWhiteSpace(*s)) {
++s;
--length;
* Skips over Pattern_White_Space starting at s.
* @return The smallest pointer at or after s with a non-white space character.
*/
- static const UChar *skipWhiteSpace(const UChar *s, int32_t length);
+ static const char16_t *skipWhiteSpace(const char16_t *s, int32_t length);
/**
* Skips over Pattern_White_Space starting at index start in s.
/**
* @return s except with leading and trailing Pattern_White_Space removed and length adjusted.
*/
- static const UChar *trimWhiteSpace(const UChar *s, int32_t &length);
+ static const char16_t *trimWhiteSpace(const char16_t *s, int32_t &length);
/**
* Tests whether the string contains a "pattern identifier", that is,
* whether it contains only non-Pattern_White_Space, non-Pattern_Syntax characters.
* @return true if there are no Pattern_White_Space or Pattern_Syntax characters in s.
*/
- static UBool isIdentifier(const UChar *s, int32_t length);
+ static UBool isIdentifier(const char16_t *s, int32_t length);
/**
* Skips over a "pattern identifier" starting at index s.
* @return The smallest pointer at or after s with
* a Pattern_White_Space or Pattern_Syntax character.
*/
- static const UChar *skipIdentifier(const UChar *s, int32_t length);
+ static const char16_t *skipIdentifier(const char16_t *s, int32_t length);
private:
PatternProps() = delete; // no constructor: all static methods
// encode
U_CAPI int32_t
-u_strToPunycode(const UChar *src, int32_t srcLength,
- UChar *dest, int32_t destCapacity,
+u_strToPunycode(const char16_t *src, int32_t srcLength,
+ char16_t *dest, int32_t destCapacity,
const UBool *caseFlags,
UErrorCode *pErrorCode) {
int32_t cpBuffer[ENCODE_MAX_CODE_UNITS];
int32_t n, delta, handledCPCount, basicLength, destLength, bias, j, m, q, k, t, srcCPCount;
- UChar c, c2;
+ char16_t c, c2;
/* argument checking */
if(pErrorCode==nullptr || U_FAILURE(*pErrorCode)) {
// decode
U_CAPI int32_t
-u_strFromPunycode(const UChar *src, int32_t srcLength,
- UChar *dest, int32_t destCapacity,
+u_strFromPunycode(const char16_t *src, int32_t srcLength,
+ char16_t *dest, int32_t destCapacity,
UBool *caseFlags,
UErrorCode *pErrorCode) {
int32_t n, destLength, i, bias, basicLength, j, in, oldi, w, k, digit, t,
destCPCount, firstSupplementaryIndex, cpLength;
- UChar b;
+ char16_t b;
/* argument checking */
if(pErrorCode==nullptr || U_FAILURE(*pErrorCode)) {
}
if(j<destCapacity) {
- dest[j]=(UChar)b;
+ dest[j]=(char16_t)b;
if(caseFlags!=nullptr) {
caseFlags[j]=IS_BASIC_UPPERCASE(b);
U16_FWD_N(dest, codeUnitIndex, destLength, i-codeUnitIndex);
}
- /* use the UChar index codeUnitIndex instead of the code point index i */
+ /* use the char16_t index codeUnitIndex instead of the code point index i */
if(codeUnitIndex<destLength) {
uprv_memmove(dest+codeUnitIndex+cpLength,
dest+codeUnitIndex,
}
if(cpLength==1) {
/* BMP, insert one code unit */
- dest[codeUnitIndex]=(UChar)n;
+ dest[codeUnitIndex]=(char16_t)n;
} else {
/* supplementary character, insert two code units */
dest[codeUnitIndex]=U16_LEAD(n);
UErrorCode status = U_ZERO_ERROR;
int32_t windowsPathUtf8Len = 0;
u_strToUTF8(windowsPathUtf8, static_cast<int32_t>(UPRV_LENGTHOF(windowsPathUtf8)),
- &windowsPathUtf8Len, reinterpret_cast<const UChar*>(windowsPath), -1, &status);
+ &windowsPathUtf8Len, reinterpret_cast<const char16_t*>(windowsPath), -1, &status);
if (U_SUCCESS(status) && (status != U_STRING_NOT_TERMINATED_WARNING) &&
(windowsPathUtf8Len < (UPRV_LENGTHOF(windowsPathUtf8) - 1))) {
}
U_CAPI void U_EXPORT2
-u_versionFromUString(UVersionInfo versionArray, const UChar *versionString) {
+u_versionFromUString(UVersionInfo versionArray, const char16_t *versionString) {
if(versionArray!=nullptr && versionString!=nullptr) {
char versionChars[U_MAX_VERSION_STRING_LENGTH+1];
int32_t len = u_strlen(versionString);
uint32_t fTrie; /* Offset to Trie data for character categories */
uint32_t fTrieLen;
uint32_t fRuleSource; /* Offset to the source for for the break */
- uint32_t fRuleSourceLen; /* rules. Stored UChar *. */
+ uint32_t fRuleSourceLen; /* rules. Stored char16_t *. */
uint32_t fStatusTable; /* Offset to the table of rule status values */
uint32_t fStatusTableLen;
// source form of the state transition table for the RBBI rule parser.
//
//------------------------------------------------------------------------------
-static const UChar gRuleSet_rule_char_pattern[] = {
+static const char16_t gRuleSet_rule_char_pattern[] = {
// Characters that may appear as literals in patterns without escaping or quoting.
// [ ^ [ \ p { Z } \ u 0 0 2 0
0x5b, 0x5e, 0x5b, 0x5c, 0x70, 0x7b, 0x5a, 0x7d, 0x5c, 0x75, 0x30, 0x30, 0x32, 0x30,
// { L } ] - [ \ p { N } ] ]
0x7b, 0x4c, 0x7d, 0x5d, 0x2d, 0x5b, 0x5c, 0x70, 0x7b, 0x4e, 0x7d, 0x5d, 0x5d, 0};
-static const UChar gRuleSet_name_char_pattern[] = {
+static const char16_t gRuleSet_name_char_pattern[] = {
// [ _ \ p { L } \ p { N } ]
0x5b, 0x5f, 0x5c, 0x70, 0x7b, 0x4c, 0x7d, 0x5c, 0x70, 0x7b, 0x4e, 0x7d, 0x5d, 0};
-static const UChar gRuleSet_digit_char_pattern[] = {
+static const char16_t gRuleSet_digit_char_pattern[] = {
// [ 0 - 9 ]
0x5b, 0x30, 0x2d, 0x39, 0x5d, 0};
-static const UChar gRuleSet_name_start_char_pattern[] = {
+static const char16_t gRuleSet_name_start_char_pattern[] = {
// [ _ \ p { L } ]
0x5b, 0x5f, 0x5c, 0x70, 0x7b, 0x4c, 0x7d, 0x5d, 0 };
-static const UChar kAny[] = {0x61, 0x6e, 0x79, 0x00}; // "any"
+static const char16_t kAny[] = {0x61, 0x6e, 0x79, 0x00}; // "any"
U_CDECL_BEGIN
// Numeric because there is no portable way to enter them as literals.
// (Think EBCDIC).
//
-static const UChar chCR = 0x0d; // New lines, for terminating comments.
-static const UChar chLF = 0x0a;
-static const UChar chNEL = 0x85; // NEL newline variant
-static const UChar chLS = 0x2028; // Unicode Line Separator
-static const UChar chApos = 0x27; // single quote, for quoted chars.
-static const UChar chPound = 0x23; // '#', introduces a comment.
-static const UChar chBackSlash = 0x5c; // '\' introduces a char escape
-static const UChar chLParen = 0x28;
-static const UChar chRParen = 0x29;
+static const char16_t chCR = 0x0d; // New lines, for terminating comments.
+static const char16_t chLF = 0x0a;
+static const char16_t chNEL = 0x85; // NEL newline variant
+static const char16_t chLS = 0x2028; // Unicode Line Separator
+static const char16_t chApos = 0x27; // single quote, for quoted chars.
+static const char16_t chPound = 0x23; // '#', introduces a comment.
+static const char16_t chBackSlash = 0x5c; // '\' introduces a char escape
+static const char16_t chLParen = 0x28;
+static const char16_t chRParen = 0x29;
//------------------------------------------------------------------------------
U_NAMESPACE_BEGIN
RBBISymbolTable::RBBISymbolTable(RBBIRuleScanner *rs, const UnicodeString &rules, UErrorCode &status)
- :fRules(rules), fRuleScanner(rs), ffffString(UChar(0xffff))
+ :fRules(rules), fRuleScanner(rs), ffffString(char16_t(0xffff))
{
fHashTable = nullptr;
fCachedSetLookup = nullptr;
int32_t i = start;
UnicodeString result;
while (i < limit) {
- UChar c = text.charAt(i);
+ char16_t c = text.charAt(i);
if ((i==start && !u_isIDStart(c)) || !u_isIDPart(c)) {
break;
}
UnicodeString ResourceBundle::getString(UErrorCode& status) const {
int32_t len = 0;
- const UChar *r = ures_getString(fResource, &len, &status);
+ const char16_t *r = ures_getString(fResource, &len, &status);
return UnicodeString(true, r, len);
}
UnicodeString ResourceBundle::getNextString(UErrorCode& status) {
int32_t len = 0;
- const UChar* r = ures_getNextString(fResource, &len, 0, &status);
+ const char16_t* r = ures_getNextString(fResource, &len, 0, &status);
return UnicodeString(true, r, len);
}
UnicodeString ResourceBundle::getNextString(const char ** key, UErrorCode& status) {
int32_t len = 0;
- const UChar* r = ures_getNextString(fResource, &len, key, &status);
+ const char16_t* r = ures_getNextString(fResource, &len, key, &status);
return UnicodeString(true, r, len);
}
UnicodeString ResourceBundle::getStringEx(int32_t indexS, UErrorCode& status) const {
int32_t len = 0;
- const UChar* r = ures_getStringByIndex(fResource, indexS, &len, &status);
+ const char16_t* r = ures_getStringByIndex(fResource, indexS, &len, &status);
return UnicodeString(true, r, len);
}
}
UnicodeString ResourceBundle::getStringEx(const char* key, UErrorCode& status) const {
int32_t len = 0;
- const UChar* r = ures_getStringByKey(fResource, key, &len, &status);
+ const char16_t* r = ures_getStringByKey(fResource, key, &len, &status);
return UnicodeString(true, r, len);
}
}
else {
UnicodeString nullTerminatedPath(path);
- nullTerminatedPath.append((UChar)0);
+ nullTerminatedPath.append((char16_t)0);
fResource = ures_openU(nullTerminatedPath.getBuffer(), locale.getName(), &error);
}
}
*
* @see ures_getString()
*/
- virtual const UChar *getString(int32_t &length, UErrorCode &errorCode) const = 0;
+ virtual const char16_t *getString(int32_t &length, UErrorCode &errorCode) const = 0;
inline UnicodeString getUnicodeString(UErrorCode &errorCode) const {
int32_t len = 0;
- const UChar *r = getString(len, errorCode);
+ const char16_t *r = getString(len, errorCode);
return UnicodeString(true, r, len);
}
/**
* Sets U_RESOURCE_TYPE_MISMATCH if this is not an alias resource.
*/
- virtual const UChar *getAliasString(int32_t &length, UErrorCode &errorCode) const = 0;
+ virtual const char16_t *getAliasString(int32_t &length, UErrorCode &errorCode) const = 0;
inline UnicodeString getAliasUnicodeString(UErrorCode &errorCode) const {
int32_t len = 0;
- const UChar *r = getAliasString(len, errorCode);
+ const char16_t *r = getAliasString(len, errorCode);
return UnicodeString(true, r, len);
}
UnicodeString& RuleCharacterIterator::toString(UnicodeString& result) const {
int32_t b = pos.getIndex();
text.extract(0, b, result);
- return result.append((UChar) 0x7C).append(text, b, 0x7FFFFFFF); // Insert '|' at index
+ return result.append((char16_t) 0x7C).append(text, b, 0x7FFFFFFF); // Insert '|' at index
}
*/
******************************************************************
*/
-const UChar ICUServiceKey::PREFIX_DELIMITER = 0x002F; /* '/' */
+const char16_t ICUServiceKey::PREFIX_DELIMITER = 0x002F; /* '/' */
ICUServiceKey::ICUServiceKey(const UnicodeString& id)
: _id(id) {
if (actualReturn != nullptr) {
// strip null prefix
- if (result->actualDescriptor.indexOf((UChar)0x2f) == 0) { // U+002f=slash (/)
+ if (result->actualDescriptor.indexOf((char16_t)0x2f) == 0) { // U+002f=slash (/)
actualReturn->remove();
actualReturn->append(result->actualDescriptor,
1,
const UnicodeString _id;
protected:
- static const UChar PREFIX_DELIMITER;
+ static const char16_t PREFIX_DELIMITER;
public:
#include "charstr.h"
#include "uassert.h"
-#define UNDERSCORE_CHAR ((UChar)0x005f)
-#define AT_SIGN_CHAR ((UChar)64)
-#define PERIOD_CHAR ((UChar)46)
+#define UNDERSCORE_CHAR ((char16_t)0x005f)
+#define AT_SIGN_CHAR ((char16_t)64)
+#define PERIOD_CHAR ((char16_t)46)
U_NAMESPACE_BEGIN
UnicodeString&
LocaleKey::prefix(UnicodeString& result) const {
if (_kind != KIND_ANY) {
- UChar buffer[64];
+ char16_t buffer[64];
uprv_itou(buffer, 64, _kind, 10, 0);
UnicodeString temp(buffer);
result.append(temp);
#include "ucln_cmn.h"
#include "uassert.h"
-#define UNDERSCORE_CHAR ((UChar)0x005f)
-#define AT_SIGN_CHAR ((UChar)64)
-#define PERIOD_CHAR ((UChar)46)
+#define UNDERSCORE_CHAR ((char16_t)0x005f)
+#define AT_SIGN_CHAR ((char16_t)64)
+#define PERIOD_CHAR ((char16_t)46)
U_NAMESPACE_BEGIN
#include "charstr.h"
#include "uassert.h"
-#define UNDERSCORE_CHAR ((UChar)0x005f)
-#define AT_SIGN_CHAR ((UChar)64)
-#define PERIOD_CHAR ((UChar)46)
+#define UNDERSCORE_CHAR ((char16_t)0x005f)
+#define AT_SIGN_CHAR ((char16_t)64)
+#define PERIOD_CHAR ((char16_t)46)
U_NAMESPACE_BEGIN
#include "ucln_cmn.h"
#include "uassert.h"
-#define UNDERSCORE_CHAR ((UChar)0x005f)
-#define AT_SIGN_CHAR ((UChar)64)
-#define PERIOD_CHAR ((UChar)46)
+#define UNDERSCORE_CHAR ((char16_t)0x005f)
+#define AT_SIGN_CHAR ((char16_t)64)
+#define PERIOD_CHAR ((char16_t)46)
U_NAMESPACE_BEGIN
#include "charstr.h"
#include "uassert.h"
-#define UNDERSCORE_CHAR ((UChar)0x005f)
-#define AT_SIGN_CHAR ((UChar)64)
-#define PERIOD_CHAR ((UChar)46)
+#define UNDERSCORE_CHAR ((char16_t)0x005f)
+#define AT_SIGN_CHAR ((char16_t)64)
+#define PERIOD_CHAR ((char16_t)46)
U_NAMESPACE_BEGIN
*/
const int32_t ARG_NUM_LIMIT = 0x100;
/**
- * Initial and maximum char/UChar value set for a text segment.
+ * Initial and maximum char/char16_t value set for a text segment.
* Segment length char values are from ARG_NUM_LIMIT+1 to this value here.
* Normally 0xffff, but can be as small as ARG_NUM_LIMIT+1 for testing.
*/
-const UChar SEGMENT_LENGTH_PLACEHOLDER_CHAR = 0xffff;
+const char16_t SEGMENT_LENGTH_PLACEHOLDER_CHAR = 0xffff;
/**
* Maximum length of a text segment. Longer segments are split into shorter ones.
*/
// Parse consistent with MessagePattern, but
// - support only simple numbered arguments
// - build a simple binary structure into the result string
- const UChar *patternBuffer = pattern.getBuffer();
+ const char16_t *patternBuffer = pattern.getBuffer();
int32_t patternLength = pattern.length();
// Reserve the first char for the number of arguments.
- compiledPattern.setTo((UChar)0);
+ compiledPattern.setTo((char16_t)0);
int32_t textLength = 0;
int32_t maxArg = -1;
UBool inQuote = false;
for (int32_t i = 0; i < patternLength;) {
- UChar c = patternBuffer[i++];
+ char16_t c = patternBuffer[i++];
if (c == APOS) {
if (i < patternLength && (c = patternBuffer[i]) == APOS) {
// double apostrophe, skip the second one
} else if (!inQuote && c == OPEN_BRACE) {
if (textLength > 0) {
compiledPattern.setCharAt(compiledPattern.length() - textLength - 1,
- (UChar)(ARG_NUM_LIMIT + textLength));
+ (char16_t)(ARG_NUM_LIMIT + textLength));
textLength = 0;
}
int32_t argNumber;
if (argNumber > maxArg) {
maxArg = argNumber;
}
- compiledPattern.append((UChar)argNumber);
+ compiledPattern.append((char16_t)argNumber);
continue;
} // else: c is part of literal text
// Append c and track the literal-text segment length.
}
if (textLength > 0) {
compiledPattern.setCharAt(compiledPattern.length() - textLength - 1,
- (UChar)(ARG_NUM_LIMIT + textLength));
+ (char16_t)(ARG_NUM_LIMIT + textLength));
}
int32_t argCount = maxArg + 1;
if (argCount < min || max < argCount) {
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
return false;
}
- compiledPattern.setCharAt(0, (UChar)argCount);
+ compiledPattern.setCharAt(0, (char16_t)argCount);
return true;
}
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
return result;
}
- const UChar *cp = compiledPattern.getBuffer();
+ const char16_t *cp = compiledPattern.getBuffer();
int32_t cpLength = compiledPattern.length();
if (valuesLength < getArgumentLimit(cp, cpLength)) {
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
}
UnicodeString SimpleFormatter::getTextWithNoArguments(
- const UChar *compiledPattern,
+ const char16_t *compiledPattern,
int32_t compiledPatternLength,
int32_t* offsets,
int32_t offsetsLength) {
}
UnicodeString &SimpleFormatter::format(
- const UChar *compiledPattern, int32_t compiledPatternLength,
+ const char16_t *compiledPattern, int32_t compiledPatternLength,
const UnicodeString *const *values,
UnicodeString &result, const UnicodeString *resultCopy, UBool forbidResultAsValue,
int32_t *offsets, int32_t offsetsLength,
// length different units at unitIndex
int32_t
StringTrieBuilder::writeBranchSubNode(int32_t start, int32_t limit, int32_t unitIndex, int32_t length) {
- UChar middleUnits[kMaxSplitBranchLevels];
+ char16_t middleUnits[kMaxSplitBranchLevels];
int32_t lessThan[kMaxSplitBranchLevels];
int32_t ltLength=0;
while(length>getMaxBranchLinearSubNodeLength()) {
int32_t unitNumber=0;
do {
int32_t i=starts[unitNumber]=start;
- UChar unit=getElementUnit(i++, unitIndex);
+ char16_t unit=getElementUnit(i++, unitIndex);
i=indexOfElementWithNextUnit(i, unitIndex, unit);
isFinal[unitNumber]= start==i-1 && unitIndex+1==getElementStringLength(start);
start=i;
if(U_FAILURE(errorCode)) {
return nullptr;
}
- UChar middleUnits[kMaxSplitBranchLevels];
+ char16_t middleUnits[kMaxSplitBranchLevels];
Node *lessThan[kMaxSplitBranchLevels];
int32_t ltLength=0;
while(length>getMaxBranchLinearSubNodeLength()) {
int32_t unitNumber=0;
do {
int32_t i=start;
- UChar unit=getElementUnit(i++, unitIndex);
+ char16_t unit=getElementUnit(i++, unitIndex);
i=indexOfElementWithNextUnit(i, unitIndex, unit);
if(start==i-1 && unitIndex+1==getElementStringLength(start)) {
listNode->add(unit, getElementValue(start));
start=i;
} while(++unitNumber<length-1);
// unitNumber==length-1, and the maxUnit elements range is [start..limit[
- UChar unit=getElementUnit(start, unitIndex);
+ char16_t unit=getElementUnit(start, unitIndex);
if(start==limit-1 && unitIndex+1==getElementStringLength(start)) {
listNode->add(unit, getElementValue(start));
} else {
* rules of the BiDi algorithm, in this example to the second rule of the
* resolution of weak types.
*
- * For handling surrogate pairs, where two UChar's form one "abstract" (or UTF-32)
- * character according to UTF-16, the second UChar gets the directional property of
+ * For handling surrogate pairs, where two char16_t's form one "abstract" (or UTF-32)
+ * character according to UTF-16, the second char16_t gets the directional property of
* the entire character assigned, while the first one gets a BN, a boundary
* neutral, type, which is ignored by most of the algorithm according to
* rule (X9) and the implementation suggestions of the BiDi algorithm.
*
* Later, adjustWSLevels() will set the level for each BN to that of the
- * following character (UChar), which results in surrogate pairs getting the
+ * following character (char16_t), which results in surrogate pairs getting the
* same level on each of their surrogates.
*
* In a UTF-8 implementation, the same thing could be done: the last byte of
}
U_CAPI UBiDiDirection U_EXPORT2
-ubidi_getBaseDirection(const UChar *text,
+ubidi_getBaseDirection(const char16_t *text,
int32_t length){
int32_t i;
*/
static DirProp
firstL_R_AL(UBiDi *pBiDi) {
- const UChar *text=pBiDi->prologue;
+ const char16_t *text=pBiDi->prologue;
int32_t length=pBiDi->proLength;
int32_t i;
UChar32 uchar;
*/
static UBool
getDirProps(UBiDi *pBiDi) {
- const UChar *text=pBiDi->text;
+ const char16_t *text=pBiDi->text;
DirProp *dirProps=pBiDi->dirPropsMemory; /* pBiDi->dirProps is const */
int32_t i=0, originalLength=pBiDi->originalLength;
/* newly found opening bracket: create an openings entry */
static UBool /* return true if success */
-bracketAddOpening(BracketData *bd, UChar match, int32_t position) {
+bracketAddOpening(BracketData *bd, char16_t match, int32_t position) {
IsoRun *pLastIsoRun=&bd->isoRuns[bd->isoRunLast];
Opening *pOpening;
if(pLastIsoRun->limit>=bd->openingsCount) { /* no available new entry */
dirProps=bd->pBiDi->dirProps;
dirProp=dirProps[position];
if(dirProp==ON) {
- UChar c, match;
+ char16_t c, match;
int32_t idx;
/* First see if it is a matching closing bracket. Hopefully, this is
more efficient than checking if it is a closing bracket at all */
bracket or it is a case of N0d */
/* Now see if it is an opening bracket */
if(c)
- match= static_cast<UChar>(u_getBidiPairedBracket(c)); /* get the matching char */
+ match= static_cast<char16_t>(u_getBidiPairedBracket(c)); /* get the matching char */
else
match=0;
if(match!=c && /* has a matching char */
resolveExplicitLevels(UBiDi *pBiDi, UErrorCode *pErrorCode) {
DirProp *dirProps=pBiDi->dirProps;
UBiDiLevel *levels=pBiDi->levels;
- const UChar *text=pBiDi->text;
+ const char16_t *text=pBiDi->text;
int32_t i=0, length=pBiDi->length;
Flags flags=pBiDi->flags; /* collect all directionalities in the text */
*/
static DirProp
lastL_R_AL(UBiDi *pBiDi) {
- const UChar *text=pBiDi->prologue;
+ const char16_t *text=pBiDi->prologue;
int32_t length=pBiDi->proLength;
int32_t i;
UChar32 uchar;
*/
static DirProp
firstL_R_AL_EN_AN(UBiDi *pBiDi) {
- const UChar *text=pBiDi->epilogue;
+ const char16_t *text=pBiDi->epilogue;
int32_t length=pBiDi->epiLength;
int32_t i;
UChar32 uchar;
U_CAPI void U_EXPORT2
ubidi_setContext(UBiDi *pBiDi,
- const UChar *prologue, int32_t proLength,
- const UChar *epilogue, int32_t epiLength,
+ const char16_t *prologue, int32_t proLength,
+ const char16_t *epilogue, int32_t epiLength,
UErrorCode *pErrorCode) {
/* check the argument values */
RETURN_VOID_IF_NULL_OR_FAILING_ERRCODE(pErrorCode);
#define BIDI_ABS(x) ((x)>=0 ? (x) : (-(x)))
static void
-setParaRunsOnly(UBiDi *pBiDi, const UChar *text, int32_t length,
+setParaRunsOnly(UBiDi *pBiDi, const char16_t *text, int32_t length,
UBiDiLevel paraLevel, UErrorCode *pErrorCode) {
int32_t *runsOnlyMemory = nullptr;
int32_t *visualMap;
- UChar *visualText;
+ char16_t *visualText;
int32_t saveLength, saveTrailingWSStart;
const UBiDiLevel *levels;
UBiDiLevel *saveLevels;
goto cleanup3;
}
/* obtain memory for mapping table and visual text */
- runsOnlyMemory=static_cast<int32_t *>(uprv_malloc(length*(sizeof(int32_t)+sizeof(UChar)+sizeof(UBiDiLevel))));
+ runsOnlyMemory=static_cast<int32_t *>(uprv_malloc(length*(sizeof(int32_t)+sizeof(char16_t)+sizeof(UBiDiLevel))));
if(runsOnlyMemory==nullptr) {
*pErrorCode=U_MEMORY_ALLOCATION_ERROR;
goto cleanup3;
}
visualMap=runsOnlyMemory;
- visualText=(UChar *)&visualMap[length];
+ visualText=(char16_t *)&visualMap[length];
saveLevels=(UBiDiLevel *)&visualText[length];
saveOptions=pBiDi->reorderingOptions;
if(saveOptions & UBIDI_OPTION_INSERT_MARKS) {
/* ubidi_setPara ------------------------------------------------------------ */
U_CAPI void U_EXPORT2
-ubidi_setPara(UBiDi *pBiDi, const UChar *text, int32_t length,
+ubidi_setPara(UBiDi *pBiDi, const char16_t *text, int32_t length,
UBiDiLevel paraLevel, UBiDiLevel *embeddingLevels,
UErrorCode *pErrorCode) {
UBiDiDirection direction;
}
}
-U_CAPI const UChar * U_EXPORT2
+U_CAPI const char16_t * U_EXPORT2
ubidi_getText(const UBiDi *pBiDi) {
if(IS_VALID_PARA_OR_LINE(pBiDi)) {
return pBiDi->text;
/* handle remove BiDi control characters */
if(pBiDi->controlCount>0) {
int32_t runIndex;
- const UChar *start=pBiDi->text, *limit=start+pBiDi->length, *pu;
+ const char16_t *start=pBiDi->text, *limit=start+pBiDi->length, *pu;
for(pu=start; pu<limit; pu++) {
if(IS_BIDI_CONTROL_CHAR(*pu)) {
runIndex=getRunFromLogicalIndex(pBiDi, (int32_t)(pu-start));
Run *runs=pBiDi->runs;
int32_t i, j, start, limit, length, insertRemove;
int32_t visualStart=0, controlFound=0;
- UChar uchar=pBiDi->text[logicalIndex];
+ char16_t uchar=pBiDi->text[logicalIndex];
/* is the logical index pointing to a control ? */
if(IS_BIDI_CONTROL_CHAR(uchar)) {
return UBIDI_MAP_NOWHERE;
/* handle removed BiDi control characters */
int32_t controlFound=0, insertRemove, length;
int32_t logicalStart, logicalEnd, visualStart=0, j, k;
- UChar uchar;
+ char16_t uchar;
UBool evenRun;
/* add number of controls until visual index */
for(i=0; ; i++, visualStart+=length) {
int32_t controlFound=0, runCount=pBiDi->runCount;
int32_t length, insertRemove;
UBool evenRun;
- UChar uchar;
+ char16_t uchar;
visualStart=0;
/* subtract number of controls found until each index */
for(i=0; i<runCount; i++, visualStart+=length) {
else if(pBiDi->controlCount>0) {
int32_t runCount=pBiDi->runCount, logicalEnd;
int32_t insertRemove, length, i, j, k, m;
- UChar uchar;
+ char16_t uchar;
UBool evenRun;
runs=pBiDi->runs;
visualStart=0;
struct UBiDiTransform {
UBiDi *pBidi; /* pointer to a UBiDi object */
const ReorderingScheme *pActiveScheme; /* effective reordering scheme */
- UChar *src; /* input text */
- UChar *dest; /* output text */
+ char16_t *src; /* input text */
+ char16_t *dest; /* output text */
uint32_t srcLength; /* input text length - not really needed as we are zero-terminated and can u_strlen */
uint32_t srcSize; /* input text capacity excluding the trailing zero */
uint32_t destSize; /* output text capacity */
*
* @param pTransform A pointer to the <code>UBiDiTransform</code> structure.
* @param newSrc A pointer whose value is to be used as input text.
- * @param newLength A length of the new text in <code>UChar</code>s.
- * @param newSize A new source capacity in <code>UChar</code>s.
+ * @param newLength A length of the new text in <code>char16_t</code>s.
+ * @param newSize A new source capacity in <code>char16_t</code>s.
* @param pErrorCode Pointer to the error code value.
*/
static void
-updateSrc(UBiDiTransform *pTransform, const UChar *newSrc, uint32_t newLength,
+updateSrc(UBiDiTransform *pTransform, const char16_t *newSrc, uint32_t newLength,
uint32_t newSize, UErrorCode *pErrorCode)
{
if (newSize < newLength) {
uprv_free(pTransform->src);
pTransform->src = nullptr;
}
- pTransform->src = (UChar *)uprv_malloc(newSize * sizeof(UChar));
+ pTransform->src = (char16_t *)uprv_malloc(newSize * sizeof(char16_t));
if (pTransform->src == nullptr) {
*pErrorCode = U_MEMORY_ALLOCATION_ERROR;
//pTransform->srcLength = pTransform->srcSize = 0;
* of the first strong bidi character.
*/
static void
-resolveBaseDirection(const UChar *text, uint32_t length,
+resolveBaseDirection(const char16_t *text, uint32_t length,
UBiDiLevel *pInLevel, UBiDiLevel *pOutLevel)
{
switch (*pInLevel) {
U_CAPI uint32_t U_EXPORT2
ubiditransform_transform(UBiDiTransform *pBiDiTransform,
- const UChar *src, int32_t srcLength,
- UChar *dest, int32_t destSize,
+ const char16_t *src, int32_t srcLength,
+ char16_t *dest, int32_t destSize,
UBiDiLevel inParaLevel, UBiDiOrder inOrder,
UBiDiLevel outParaLevel, UBiDiOrder outOrder,
UBiDiMirroring doMirroring, uint32_t shapingOptions,
* we are writing RTL output in reverse.
*/
static int32_t
-doWriteForward(const UChar *src, int32_t srcLength,
- UChar *dest, int32_t destSize,
+doWriteForward(const char16_t *src, int32_t srcLength,
+ char16_t *dest, int32_t destSize,
uint16_t options,
UErrorCode *pErrorCode) {
/* optimize for several combinations of options */
case UBIDI_REMOVE_BIDI_CONTROLS: {
/* copy the LTR run and remove any BiDi control characters */
int32_t remaining=destSize;
- UChar c;
+ char16_t c;
do {
c=*src++;
if(!IS_BIDI_CONTROL_CHAR(c)) {
}
static int32_t
-doWriteReverse(const UChar *src, int32_t srcLength,
- UChar *dest, int32_t destSize,
+doWriteReverse(const char16_t *src, int32_t srcLength,
+ char16_t *dest, int32_t destSize,
uint16_t options,
UErrorCode *pErrorCode) {
/*
/* we need to find out the destination length of the run,
which will not include the BiDi control characters */
int32_t length=srcLength;
- UChar ch;
+ char16_t ch;
i=0;
do {
}
U_CAPI int32_t U_EXPORT2
-ubidi_writeReverse(const UChar *src, int32_t srcLength,
- UChar *dest, int32_t destSize,
+ubidi_writeReverse(const char16_t *src, int32_t srcLength,
+ char16_t *dest, int32_t destSize,
uint16_t options,
UErrorCode *pErrorCode) {
int32_t destLength;
#endif
U_CAPI int32_t U_EXPORT2
ubidi_writeReordered(UBiDi *pBiDi,
- UChar *dest, int32_t destSize,
+ char16_t *dest, int32_t destSize,
uint16_t options,
UErrorCode *pErrorCode) {
- const UChar *text;
- UChar *saveDest;
+ const char16_t *text;
+ char16_t *saveDest;
int32_t length, destCapacity;
int32_t run, runCount, logicalStart, runLength;
} else {
/* insert BiDi controls for "inverse BiDi" */
const DirProp *dirProps=pBiDi->dirProps;
- const UChar *src;
- UChar uc;
+ const char16_t *src;
+ char16_t uc;
UBiDiDirection dir;
int32_t markFlag;
} else {
/* insert BiDi controls for "inverse BiDi" */
const DirProp *dirProps=pBiDi->dirProps;
- const UChar *src;
+ const char16_t *src;
UBiDiDirection dir;
for(run=runCount; --run>=0;) {
U_CAPI UBreakIterator* U_EXPORT2
ubrk_open(UBreakIteratorType type,
const char *locale,
- const UChar *text,
+ const char16_t *text,
int32_t textLength,
UErrorCode *status)
{
//
//------------------------------------------------------------------------------
U_CAPI UBreakIterator* U_EXPORT2
-ubrk_openRules( const UChar *rules,
+ubrk_openRules( const char16_t *rules,
int32_t rulesLength,
- const UChar *text,
+ const char16_t *text,
int32_t textLength,
UParseError *parseErr,
UErrorCode *status) {
U_CAPI UBreakIterator* U_EXPORT2
ubrk_openBinaryRules(const uint8_t *binaryRules, int32_t rulesLength,
- const UChar * text, int32_t textLength,
+ const char16_t * text, int32_t textLength,
UErrorCode * status)
{
if (U_FAILURE(*status)) {
U_CAPI void U_EXPORT2
ubrk_setText(UBreakIterator* bi,
- const UChar* text,
+ const char16_t* text,
int32_t textLength,
UErrorCode* status)
{
UText ut = UTEXT_INITIALIZER;
utext_openUChars(&ut, text, textLength, status);
((BreakIterator*)bi)->setText(&ut, *status);
- // A stack allocated UText wrapping a UChar * string
+ // A stack allocated UText wrapping a char16_t * string
// can be dumped without explicitly closing it.
}
return c;
}
-static const UChar iDot[2] = { 0x69, 0x307 };
-static const UChar jDot[2] = { 0x6a, 0x307 };
-static const UChar iOgonekDot[3] = { 0x12f, 0x307 };
-static const UChar iDotGrave[3] = { 0x69, 0x307, 0x300 };
-static const UChar iDotAcute[3] = { 0x69, 0x307, 0x301 };
-static const UChar iDotTilde[3] = { 0x69, 0x307, 0x303 };
+static const char16_t iDot[2] = { 0x69, 0x307 };
+static const char16_t jDot[2] = { 0x6a, 0x307 };
+static const char16_t iOgonekDot[3] = { 0x12f, 0x307 };
+static const char16_t iDotGrave[3] = { 0x69, 0x307, 0x300 };
+static const char16_t iDotAcute[3] = { 0x69, 0x307, 0x301 };
+static const char16_t iDotTilde[3] = { 0x69, 0x307, 0x303 };
U_CFUNC void U_EXPORT2
* full case mappings. Add them all.
*/
const uint16_t *pe0, *pe=GET_EXCEPTIONS(&ucase_props_singleton, props);
- const UChar *closure;
+ const char16_t *closure;
uint16_t excWord=*pe++;
int32_t idx, closureLength, fullLength, length;
pe=pe0;
GET_SLOT_VALUE(excWord, UCASE_EXC_CLOSURE, pe, closureLength);
closureLength&=UCASE_CLOSURE_MAX_LENGTH; /* higher bits are reserved */
- closure=(const UChar *)pe+1; /* behind this slot, unless there are full case mappings */
+ closure=(const char16_t *)pe+1; /* behind this slot, unless there are full case mappings */
} else {
closureLength=0;
closure=nullptr;
/* add the full case folding string */
length=fullLength&0xf;
if(length!=0) {
- sa->addString(sa->set, (const UChar *)pe, length);
+ sa->addString(sa->set, (const char16_t *)pe, length);
pe+=length;
}
fullLength>>=4;
pe+=fullLength;
- closure=(const UChar *)pe; /* behind full case mappings */
+ closure=(const char16_t *)pe; /* behind full case mappings */
}
/* add each code point in the closure string */
* must be length>0 and max>0 and length<=max
*/
static inline int32_t
-strcmpMax(const UChar *s, int32_t length, const UChar *t, int32_t max) {
+strcmpMax(const char16_t *s, int32_t length, const char16_t *t, int32_t max) {
int32_t c1, c2;
max-=length; /* we require length<=max, so no need to decrement max in the loop */
}
U_CFUNC UBool U_EXPORT2
-ucase_addStringCaseClosure(const UChar *s, int32_t length, const USetAdder *sa) {
+ucase_addStringCaseClosure(const char16_t *s, int32_t length, const USetAdder *sa) {
int32_t i, start, limit, result, unfoldRows, unfoldRowWidth, unfoldStringWidth;
if(ucase_props_singleton.unfold==nullptr || s==nullptr) {
limit=unfoldRows;
while(start<limit) {
i=(start+limit)/2;
- const UChar *p=reinterpret_cast<const UChar *>(unfold+(i*unfoldRowWidth));
+ const char16_t *p=reinterpret_cast<const char16_t *>(unfold+(i*unfoldRowWidth));
result=strcmpMax(s, length, p, unfoldStringWidth);
if(result==0) {
U_NAMESPACE_BEGIN
FullCaseFoldingIterator::FullCaseFoldingIterator()
- : unfold(reinterpret_cast<const UChar *>(ucase_props_singleton.unfold)),
+ : unfold(reinterpret_cast<const char16_t *>(ucase_props_singleton.unfold)),
unfoldRows(unfold[UCASE_UNFOLD_ROWS]),
unfoldRowWidth(unfold[UCASE_UNFOLD_ROW_WIDTH]),
unfoldStringWidth(unfold[UCASE_UNFOLD_STRING_WIDTH]),
UChar32
FullCaseFoldingIterator::next(UnicodeString &full) {
// Advance past the last-delivered code point.
- const UChar *p=unfold+(currentRow*unfoldRowWidth);
+ const char16_t *p=unfold+(currentRow*unfoldRowWidth);
if(rowCpIndex>=unfoldRowWidth || p[rowCpIndex]==0) {
++currentRow;
p+=unfoldRowWidth;
U_CAPI int32_t U_EXPORT2
ucase_toFullLower(UChar32 c,
UCaseContextIterator *iter, void *context,
- const UChar **pString,
+ const char16_t **pString,
int32_t loc) {
// The sign of the result has meaning, input must be non-negative so that it can be returned as is.
U_ASSERT(c >= 0);
full&=UCASE_FULL_LOWER;
if(full!=0) {
/* set the output pointer to the lowercase mapping */
- *pString=reinterpret_cast<const UChar *>(pe+1);
+ *pString=reinterpret_cast<const char16_t *>(pe+1);
/* return the string length */
return full;
static int32_t
toUpperOrTitle(UChar32 c,
UCaseContextIterator *iter, void *context,
- const UChar **pString,
+ const char16_t **pString,
int32_t loc,
UBool upperNotTitle) {
// The sign of the result has meaning, input must be non-negative so that it can be returned as is.
if(full!=0) {
/* set the output pointer to the result string */
- *pString=reinterpret_cast<const UChar *>(pe);
+ *pString=reinterpret_cast<const char16_t *>(pe);
/* return the string length */
return full;
U_CAPI int32_t U_EXPORT2
ucase_toFullUpper(UChar32 c,
UCaseContextIterator *iter, void *context,
- const UChar **pString,
+ const char16_t **pString,
int32_t caseLocale) {
return toUpperOrTitle(c, iter, context, pString, caseLocale, true);
}
U_CAPI int32_t U_EXPORT2
ucase_toFullTitle(UChar32 c,
UCaseContextIterator *iter, void *context,
- const UChar **pString,
+ const char16_t **pString,
int32_t caseLocale) {
return toUpperOrTitle(c, iter, context, pString, caseLocale, false);
}
U_CAPI int32_t U_EXPORT2
ucase_toFullFolding(UChar32 c,
- const UChar **pString,
+ const char16_t **pString,
uint32_t options) {
// The sign of the result has meaning, input must be non-negative so that it can be returned as is.
U_ASSERT(c >= 0);
if(full!=0) {
/* set the output pointer to the result string */
- *pString=reinterpret_cast<const UChar *>(pe);
+ *pString=reinterpret_cast<const char16_t *>(pe);
/* return the string length */
return full;
U_CFUNC int32_t U_EXPORT2
ucase_hasBinaryProperty(UChar32 c, UProperty which) {
/* case mapping properties */
- const UChar *resultString;
+ const char16_t *resultString;
switch(which) {
case UCHAR_LOWERCASE:
return (UBool)(UCASE_LOWER==ucase_getType(c));
FullCaseFoldingIterator(const FullCaseFoldingIterator &) = delete; // no copy
FullCaseFoldingIterator &operator=(const FullCaseFoldingIterator &) = delete; // no assignment
- const UChar *unfold;
+ const char16_t *unfold;
int32_t unfoldRows;
int32_t unfoldRowWidth;
int32_t unfoldStringWidth;
namespace LatinCase {
/** Case mapping/folding data for code points up to U+017F. */
-constexpr UChar LIMIT = 0x180;
+constexpr char16_t LIMIT = 0x180;
/** U+017F case-folds and uppercases crossing the ASCII boundary. */
-constexpr UChar LONG_S = 0x17f;
+constexpr char16_t LONG_S = 0x17f;
/** Exception: Complex mapping, or too-large delta. */
constexpr int8_t EXC = -0x80;
/* append a full case mapping result, see UCASE_MAX_STRING_LENGTH */
inline UBool
-appendResult(int32_t cpLength, int32_t result, const UChar *s,
+appendResult(int32_t cpLength, int32_t result, const char16_t *s,
ByteSink &sink, uint32_t options, icu::Edits *edits, UErrorCode &errorCode) {
U_ASSERT(U_SUCCESS(errorCode));
break;
}
// slow path
- const UChar *s;
+ const char16_t *s;
if (caseLocale >= 0) {
csc->cpStart = cpStart;
csc->cpLimit = srcIndex;
// slow path
csc->cpStart = cpStart;
csc->cpLimit = srcIndex;
- const UChar *s;
+ const char16_t *s;
c = ucase_toFullUpper(c, utf8_caseContextIterator, csc, &s, caseLocale);
if (c >= 0) {
ByteSinkUtil::appendUnchanged(src + prev, cpStart - prev,
if(c>=0) {
csc.cpStart=titleStart;
csc.cpLimit=titleLimit;
- const UChar *s;
+ const char16_t *s;
c=ucase_toFullTitle(c, utf8_caseContextIterator, &csc, &s, caseLocale);
if (!appendResult(titleLimit-titleStart, c, s, sink, options, edits, errorCode)) {
return;
}
}
} else if(c>=0) {
- const UChar *s;
+ const char16_t *s;
c=ucase_toFullUpper(c, nullptr, nullptr, &s, UCASE_LOC_GREEK);
if (!appendResult(nextIndex - i, c, s, sink, options, edits, errorCode)) {
return;
/** Implements UStringCaseMapper. */
U_CFUNC int32_t U_CALLCONV
ustrcase_internalToLower(int32_t caseLocale, uint32_t options, UCASEMAP_BREAK_ITERATOR_PARAM
- UChar *dest, int32_t destCapacity,
- const UChar *src, int32_t srcLength,
+ char16_t *dest, int32_t destCapacity,
+ const char16_t *src, int32_t srcLength,
icu::Edits *edits,
UErrorCode &errorCode);
/** Implements UStringCaseMapper. */
U_CFUNC int32_t U_CALLCONV
ustrcase_internalToUpper(int32_t caseLocale, uint32_t options, UCASEMAP_BREAK_ITERATOR_PARAM
- UChar *dest, int32_t destCapacity,
- const UChar *src, int32_t srcLength,
+ char16_t *dest, int32_t destCapacity,
+ const char16_t *src, int32_t srcLength,
icu::Edits *edits,
UErrorCode &errorCode);
U_CFUNC int32_t U_CALLCONV
ustrcase_internalToTitle(int32_t caseLocale, uint32_t options,
icu::BreakIterator *iter,
- UChar *dest, int32_t destCapacity,
- const UChar *src, int32_t srcLength,
+ char16_t *dest, int32_t destCapacity,
+ const char16_t *src, int32_t srcLength,
icu::Edits *edits,
UErrorCode &errorCode);
/** Implements UStringCaseMapper. */
U_CFUNC int32_t U_CALLCONV
ustrcase_internalFold(int32_t caseLocale, uint32_t options, UCASEMAP_BREAK_ITERATOR_PARAM
- UChar *dest, int32_t destCapacity,
- const UChar *src, int32_t srcLength,
+ char16_t *dest, int32_t destCapacity,
+ const char16_t *src, int32_t srcLength,
icu::Edits *edits,
UErrorCode &errorCode);
*/
U_CFUNC int32_t
ustrcase_map(int32_t caseLocale, uint32_t options, UCASEMAP_BREAK_ITERATOR_PARAM
- UChar *dest, int32_t destCapacity,
- const UChar *src, int32_t srcLength,
+ char16_t *dest, int32_t destCapacity,
+ const char16_t *src, int32_t srcLength,
UStringCaseMapper *stringCaseMapper,
icu::Edits *edits,
UErrorCode &errorCode);
*/
U_CFUNC int32_t
ustrcase_mapWithOverlap(int32_t caseLocale, uint32_t options, UCASEMAP_BREAK_ITERATOR_PARAM
- UChar *dest, int32_t destCapacity,
- const UChar *src, int32_t srcLength,
+ char16_t *dest, int32_t destCapacity,
+ const char16_t *src, int32_t srcLength,
UStringCaseMapper *stringCaseMapper,
UErrorCode &errorCode);
ures_close((UResourceBundle*) catd); /* may be nullptr */
}
-U_CAPI const UChar* U_EXPORT2
+U_CAPI const char16_t* U_EXPORT2
u_catgets(u_nl_catd catd, int32_t set_num, int32_t msg_num,
- const UChar* s,
+ const char16_t* s,
int32_t* len, UErrorCode* ec) {
char key[MAX_KEY_LEN];
- const UChar* result;
+ const char16_t* result;
if (ec == nullptr || U_FAILURE(*ec)) {
goto ERROR;
UStringTrieResult
UCharsTrie::current() const {
- const UChar *pos=pos_;
+ const char16_t *pos=pos_;
if(pos==nullptr) {
return USTRINGTRIE_NO_MATCH;
} else {
}
UStringTrieResult
-UCharsTrie::branchNext(const UChar *pos, int32_t length, int32_t uchar) {
+UCharsTrie::branchNext(const char16_t *pos, int32_t length, int32_t uchar) {
// Branch according to the current unit.
if(length==0) {
length=*pos++;
}
UStringTrieResult
-UCharsTrie::nextImpl(const UChar *pos, int32_t uchar) {
+UCharsTrie::nextImpl(const char16_t *pos, int32_t uchar) {
int32_t node=*pos++;
for(;;) {
if(node<kMinLinearMatch) {
UStringTrieResult
UCharsTrie::next(int32_t uchar) {
- const UChar *pos=pos_;
+ const char16_t *pos=pos_;
if(pos==nullptr) {
return USTRINGTRIE_NO_MATCH;
}
UStringTrieResult
UCharsTrie::next(ConstChar16Ptr ptr, int32_t sLength) {
- const UChar *s=ptr;
+ const char16_t *s=ptr;
if(sLength<0 ? *s==0 : sLength==0) {
// Empty input.
return current();
}
- const UChar *pos=pos_;
+ const char16_t *pos=pos_;
if(pos==nullptr) {
return USTRINGTRIE_NO_MATCH;
}
}
}
-const UChar *
-UCharsTrie::findUniqueValueFromBranch(const UChar *pos, int32_t length,
+const char16_t *
+UCharsTrie::findUniqueValueFromBranch(const char16_t *pos, int32_t length,
UBool haveUniqueValue, int32_t &uniqueValue) {
while(length>kMaxBranchLinearSubNodeLength) {
++pos; // ignore the comparison unit
}
UBool
-UCharsTrie::findUniqueValue(const UChar *pos, UBool haveUniqueValue, int32_t &uniqueValue) {
+UCharsTrie::findUniqueValue(const char16_t *pos, UBool haveUniqueValue, int32_t &uniqueValue) {
int32_t node=*pos++;
for(;;) {
if(node<kMinLinearMatch) {
int32_t
UCharsTrie::getNextUChars(Appendable &out) const {
- const UChar *pos=pos_;
+ const char16_t *pos=pos_;
if(pos==nullptr) {
return 0;
}
}
void
-UCharsTrie::getNextBranchUChars(const UChar *pos, int32_t length, Appendable &out) {
+UCharsTrie::getNextBranchUChars(const char16_t *pos, int32_t length, Appendable &out) {
while(length>kMaxBranchLinearSubNodeLength) {
++pos; // ignore the comparison unit
getNextBranchUChars(jumpByDelta(pos), length>>1, out);
return strings[stringOffset];
}
- UChar charAt(int32_t index, const UnicodeString &strings) const {
+ char16_t charAt(int32_t index, const UnicodeString &strings) const {
return strings[stringOffset+1+index];
}
return;
}
stringOffset=strings.length();
- strings.append((UChar)length);
+ strings.append((char16_t)length);
value=val;
strings.append(s);
}
prev.fastCopyFrom(current);
}
}
- // Create and UChar-serialize the trie for the elements.
+ // Create and char16_t-serialize the trie for the elements.
ucharsLength=0;
int32_t capacity=strings.length();
if(capacity<1024) {
}
if(ucharsCapacity<capacity) {
uprv_free(uchars);
- uchars=static_cast<UChar *>(uprv_malloc(capacity*2));
+ uchars=static_cast<char16_t *>(uprv_malloc(capacity*2));
if(uchars==nullptr) {
errorCode=U_MEMORY_ALLOCATION_ERROR;
ucharsCapacity=0;
return elements[i].getStringLength(strings);
}
-UChar
+char16_t
UCharsTrieBuilder::getElementUnit(int32_t i, int32_t unitIndex) const {
return elements[i].charAt(unitIndex, strings);
}
int32_t length=0; // Number of different units at unitIndex.
int32_t i=start;
do {
- UChar unit=elements[i++].charAt(unitIndex, strings);
+ char16_t unit=elements[i++].charAt(unitIndex, strings);
while(i<limit && unit==elements[i].charAt(unitIndex, strings)) {
++i;
}
int32_t
UCharsTrieBuilder::skipElementsBySomeUnits(int32_t i, int32_t unitIndex, int32_t count) const {
do {
- UChar unit=elements[i++].charAt(unitIndex, strings);
+ char16_t unit=elements[i++].charAt(unitIndex, strings);
while(unit==elements[i].charAt(unitIndex, strings)) {
++i;
}
}
int32_t
-UCharsTrieBuilder::indexOfElementWithNextUnit(int32_t i, int32_t unitIndex, UChar unit) const {
+UCharsTrieBuilder::indexOfElementWithNextUnit(int32_t i, int32_t unitIndex, char16_t unit) const {
while(unit==elements[i].charAt(unitIndex, strings)) {
++i;
}
return i;
}
-UCharsTrieBuilder::UCTLinearMatchNode::UCTLinearMatchNode(const UChar *units, int32_t len, Node *nextNode)
+UCharsTrieBuilder::UCTLinearMatchNode::UCTLinearMatchNode(const char16_t *units, int32_t len, Node *nextNode)
: LinearMatchNode(len, nextNode), s(units) {
hash=hash*37u+ustr_hashUCharsN(units, len);
}
do {
newCapacity*=2;
} while(newCapacity<=length);
- UChar *newUChars=static_cast<UChar *>(uprv_malloc(newCapacity*2));
+ char16_t *newUChars=static_cast<char16_t *>(uprv_malloc(newCapacity*2));
if(newUChars==nullptr) {
// unable to allocate memory
uprv_free(uchars);
int32_t newLength=ucharsLength+1;
if(ensureCapacity(newLength)) {
ucharsLength=newLength;
- uchars[ucharsCapacity-ucharsLength]=(UChar)unit;
+ uchars[ucharsCapacity-ucharsLength]=(char16_t)unit;
}
return ucharsLength;
}
int32_t
-UCharsTrieBuilder::write(const UChar *s, int32_t length) {
+UCharsTrieBuilder::write(const char16_t *s, int32_t length) {
int32_t newLength=ucharsLength+length;
if(ensureCapacity(newLength)) {
ucharsLength=newLength;
if(0<=i && i<=UCharsTrie::kMaxOneUnitValue) {
return write(i|(isFinal<<15));
}
- UChar intUnits[3];
+ char16_t intUnits[3];
int32_t length;
if(i<0 || i>UCharsTrie::kMaxTwoUnitValue) {
- intUnits[0]=(UChar)(UCharsTrie::kThreeUnitValueLead);
- intUnits[1]=(UChar)((uint32_t)i>>16);
- intUnits[2]=(UChar)i;
+ intUnits[0]=(char16_t)(UCharsTrie::kThreeUnitValueLead);
+ intUnits[1]=(char16_t)((uint32_t)i>>16);
+ intUnits[2]=(char16_t)i;
length=3;
// } else if(i<=UCharsTrie::kMaxOneUnitValue) {
- // intUnits[0]=(UChar)(i);
+ // intUnits[0]=(char16_t)(i);
// length=1;
} else {
- intUnits[0]=(UChar)(UCharsTrie::kMinTwoUnitValueLead+(i>>16));
- intUnits[1]=(UChar)i;
+ intUnits[0]=(char16_t)(UCharsTrie::kMinTwoUnitValueLead+(i>>16));
+ intUnits[1]=(char16_t)i;
length=2;
}
- intUnits[0]=(UChar)(intUnits[0]|(isFinal<<15));
+ intUnits[0]=(char16_t)(intUnits[0]|(isFinal<<15));
return write(intUnits, length);
}
if(!hasValue) {
return write(node);
}
- UChar intUnits[3];
+ char16_t intUnits[3];
int32_t length;
if(value<0 || value>UCharsTrie::kMaxTwoUnitNodeValue) {
- intUnits[0]=(UChar)(UCharsTrie::kThreeUnitNodeValueLead);
- intUnits[1]=(UChar)((uint32_t)value>>16);
- intUnits[2]=(UChar)value;
+ intUnits[0]=(char16_t)(UCharsTrie::kThreeUnitNodeValueLead);
+ intUnits[1]=(char16_t)((uint32_t)value>>16);
+ intUnits[2]=(char16_t)value;
length=3;
} else if(value<=UCharsTrie::kMaxOneUnitNodeValue) {
- intUnits[0]=(UChar)((value+1)<<6);
+ intUnits[0]=(char16_t)((value+1)<<6);
length=1;
} else {
- intUnits[0]=(UChar)(UCharsTrie::kMinTwoUnitNodeValueLead+((value>>10)&0x7fc0));
- intUnits[1]=(UChar)value;
+ intUnits[0]=(char16_t)(UCharsTrie::kMinTwoUnitNodeValueLead+((value>>10)&0x7fc0));
+ intUnits[1]=(char16_t)value;
length=2;
}
- intUnits[0]|=(UChar)node;
+ intUnits[0]|=(char16_t)node;
return write(intUnits, length);
}
if(i<=UCharsTrie::kMaxOneUnitDelta) {
return write(i);
}
- UChar intUnits[3];
+ char16_t intUnits[3];
int32_t length;
if(i<=UCharsTrie::kMaxTwoUnitDelta) {
- intUnits[0]=(UChar)(UCharsTrie::kMinTwoUnitDeltaLead+(i>>16));
+ intUnits[0]=(char16_t)(UCharsTrie::kMinTwoUnitDeltaLead+(i>>16));
length=1;
} else {
- intUnits[0]=(UChar)(UCharsTrie::kThreeUnitDeltaLead);
- intUnits[1]=(UChar)(i>>16);
+ intUnits[0]=(char16_t)(UCharsTrie::kThreeUnitDeltaLead);
+ intUnits[1]=(char16_t)(i>>16);
length=2;
}
- intUnits[length++]=(UChar)i;
+ intUnits[length++]=(char16_t)i;
return write(intUnits, length);
}
if(U_FAILURE(errorCode)) {
return false;
}
- const UChar *pos=pos_;
+ const char16_t *pos=pos_;
if(pos==nullptr) {
if(stack_->isEmpty()) {
return false;
}
// Branch node, needs to take the first outbound edge and push state for the rest.
-const UChar *
-UCharsTrie::Iterator::branchNext(const UChar *pos, int32_t length, UErrorCode &errorCode) {
+const char16_t *
+UCharsTrie::Iterator::branchNext(const char16_t *pos, int32_t length, UErrorCode &errorCode) {
while(length>kMaxBranchLinearSubNodeLength) {
++pos; // ignore the comparison unit
// Push state for the greater-or-equal edge.
}
// List of key-value pairs where values are either final values or jump deltas.
// Read the first (key, value) pair.
- UChar trieUnit=*pos++;
+ char16_t trieUnit=*pos++;
int32_t node=*pos++;
UBool isFinal=(UBool)(node>>15);
int32_t value=readValue(pos, node&=0x7fff);
return new UCharCharacterIterator(*this);
}
-UChar
+char16_t
UCharCharacterIterator::first() {
pos = begin;
if(pos < end) {
}
}
-UChar
+char16_t
UCharCharacterIterator::firstPostInc() {
pos = begin;
if(pos < end) {
}
}
-UChar
+char16_t
UCharCharacterIterator::last() {
pos = end;
if(pos > begin) {
}
}
-UChar
+char16_t
UCharCharacterIterator::setIndex(int32_t position) {
if(position < begin) {
pos = begin;
}
}
-UChar
+char16_t
UCharCharacterIterator::current() const {
if (pos >= begin && pos < end) {
return text[pos];
}
}
-UChar
+char16_t
UCharCharacterIterator::next() {
if (pos + 1 < end) {
return text[++pos];
}
}
-UChar
+char16_t
UCharCharacterIterator::nextPostInc() {
if (pos < end) {
return text[pos++];
return (UBool)(pos < end ? true : false);
}
-UChar
+char16_t
UCharCharacterIterator::previous() {
if (pos > begin) {
return text[--pos];
typedef struct UAmbiguousConverter {
const char *name;
- const UChar variant5c;
+ const char16_t variant5c;
} UAmbiguousConverter;
static const UAmbiguousConverter ambiguousConverters[]={
return ucnv_createConverterFromPackage(packageName, converterName, err);
}
-/*Extracts the UChar* to a char* and calls through createConverter */
+/*Extracts the char16_t* to a char* and calls through createConverter */
U_CAPI UConverter* U_EXPORT2
-ucnv_openU (const UChar * name,
+ucnv_openU (const char16_t * name,
UErrorCode * err)
{
char asciiName[UCNV_MAX_CONVERTER_NAME_LENGTH];
U_CAPI void U_EXPORT2
ucnv_setSubstString(UConverter *cnv,
- const UChar *s,
+ const char16_t *s,
int32_t length,
UErrorCode *err) {
alignas(UConverter) char cloneBuffer[U_CNV_SAFECLONE_BUFFERSIZE];
if (length > UCNV_ERROR_BUFFER_LENGTH) {
/*
* Should not occur. The converter should output at least one byte
- * per UChar, which means that ucnv_fromUChars() should catch all
+ * per char16_t, which means that ucnv_fromUChars() should catch all
* overflows.
*/
*err = U_BUFFER_OVERFLOW_ERROR;
_fromUnicodeWithCallback(UConverterFromUnicodeArgs *pArgs, UErrorCode *err) {
UConverterFromUnicode fromUnicode;
UConverter *cnv;
- const UChar *s;
+ const char16_t *s;
char *t;
int32_t *offsets;
int32_t sourceIndex;
UBool converterSawEndOfInput, calledCallback;
/* variables for m:n conversion */
- UChar replay[UCNV_EXT_MAX_UCHARS];
- const UChar *realSource, *realSourceLimit;
+ char16_t replay[UCNV_EXT_MAX_UCHARS];
+ const char16_t *realSource, *realSourceLimit;
int32_t realSourceIndex;
UBool realFlush;
U_CAPI void U_EXPORT2
ucnv_fromUnicode(UConverter *cnv,
char **target, const char *targetLimit,
- const UChar **source, const UChar *sourceLimit,
+ const char16_t **source, const char16_t *sourceLimit,
int32_t *offsets,
UBool flush,
UErrorCode *err) {
UConverterFromUnicodeArgs args;
- const UChar *s;
+ const char16_t *s;
char *t;
/* check parameters */
if ((const void *)U_MAX_PTR(sourceLimit) == (const void *)sourceLimit) {
/*
Prevent code from going into an infinite loop in case we do hit this
- limit. The limit pointer is expected to be on a UChar * boundary.
+ limit. The limit pointer is expected to be on a char16_t * boundary.
This also prevents the next argument check from failing.
*/
- sourceLimit = (const UChar *)(((const char *)sourceLimit) - 1);
+ sourceLimit = (const char16_t *)(((const char *)sourceLimit) - 1);
}
/*
* consumed or the target filled (unless an error occurs).
* An adjustment would be targetLimit=t+0x7fffffff; for example.
*
- * 3) Make sure that the user didn't incorrectly cast a UChar * pointer
- * to a char * pointer and provide an incomplete UChar code unit.
+ * 3) Make sure that the user didn't incorrectly cast a char16_t * pointer
+ * to a char * pointer and provide an incomplete char16_t code unit.
*/
if (sourceLimit<s || targetLimit<t ||
((size_t)(sourceLimit-s)>(size_t)0x3fffffff && sourceLimit>s) ||
UConverterToUnicode toUnicode;
UConverter *cnv;
const char *s;
- UChar *t;
+ char16_t *t;
int32_t *offsets;
int32_t sourceIndex;
int32_t errorInputLength;
*/
static UBool
ucnv_outputOverflowToUnicode(UConverter *cnv,
- UChar **target, const UChar *targetLimit,
+ char16_t **target, const char16_t *targetLimit,
int32_t **pOffsets,
UErrorCode *err) {
int32_t *offsets;
- UChar *overflow, *t;
+ char16_t *overflow, *t;
int32_t i, length;
t=*target;
U_CAPI void U_EXPORT2
ucnv_toUnicode(UConverter *cnv,
- UChar **target, const UChar *targetLimit,
+ char16_t **target, const char16_t *targetLimit,
const char **source, const char *sourceLimit,
int32_t *offsets,
UBool flush,
UErrorCode *err) {
UConverterToUnicodeArgs args;
const char *s;
- UChar *t;
+ char16_t *t;
/* check parameters */
if(err==nullptr || U_FAILURE(*err)) {
if ((const void *)U_MAX_PTR(targetLimit) == (const void *)targetLimit) {
/*
Prevent code from going into an infinite loop in case we do hit this
- limit. The limit pointer is expected to be on a UChar * boundary.
+ limit. The limit pointer is expected to be on a char16_t * boundary.
This also prevents the next argument check from failing.
*/
- targetLimit = (const UChar *)(((const char *)targetLimit) - 1);
+ targetLimit = (const char16_t *)(((const char *)targetLimit) - 1);
}
/*
* consumed or the target filled (unless an error occurs).
* An adjustment would be sourceLimit=t+0x7fffffff; for example.
*
- * 3) Make sure that the user didn't incorrectly cast a UChar * pointer
- * to a char * pointer and provide an incomplete UChar code unit.
+ * 3) Make sure that the user didn't incorrectly cast a char16_t * pointer
+ * to a char * pointer and provide an incomplete char16_t code unit.
*/
if (sourceLimit<s || targetLimit<t ||
((size_t)(sourceLimit-s)>(size_t)0x7fffffff && sourceLimit>s) ||
U_CAPI int32_t U_EXPORT2
ucnv_fromUChars(UConverter *cnv,
char *dest, int32_t destCapacity,
- const UChar *src, int32_t srcLength,
+ const char16_t *src, int32_t srcLength,
UErrorCode *pErrorCode) {
- const UChar *srcLimit;
+ const char16_t *srcLimit;
char *originalDest, *destLimit;
int32_t destLength;
U_CAPI int32_t U_EXPORT2
ucnv_toUChars(UConverter *cnv,
- UChar *dest, int32_t destCapacity,
+ char16_t *dest, int32_t destCapacity,
const char *src, int32_t srcLength,
UErrorCode *pErrorCode) {
const char *srcLimit;
- UChar *originalDest, *destLimit;
+ char16_t *originalDest, *destLimit;
int32_t destLength;
/* check arguments */
/* if an overflow occurs, then get the preflighting length */
if(*pErrorCode==U_BUFFER_OVERFLOW_ERROR)
{
- UChar buffer[1024];
+ char16_t buffer[1024];
destLimit=buffer+UPRV_LENGTHOF(buffer);
do {
const char **source, const char *sourceLimit,
UErrorCode *err) {
UConverterToUnicodeArgs args;
- UChar buffer[U16_MAX_LENGTH];
+ char16_t buffer[U16_MAX_LENGTH];
const char *s;
UChar32 c;
int32_t i, length;
/* flush the target overflow buffer */
if(cnv->UCharErrorBufferLength>0) {
- UChar *overflow;
+ char16_t *overflow;
overflow=cnv->UCharErrorBuffer;
i=0;
}
}
- /* convert to one UChar in buffer[0], or handle getNextUChar() errors */
+ /* convert to one char16_t in buffer[0], or handle getNextUChar() errors */
_toUnicodeWithCallback(&args, err);
if(*err==U_BUFFER_OVERFLOW_ERROR) {
length=(int32_t)(args.target-buffer);
} else {
/* write the lead surrogate from the overflow buffer */
- buffer[0]=(UChar)c;
+ buffer[0]=(char16_t)c;
args.target=buffer+1;
i=0;
length=1;
/* consume c=buffer[0], done */
} else {
/* got a lead surrogate, see if a trail surrogate follows */
- UChar c2;
+ char16_t c2;
if(cnv->UCharErrorBufferLength>0) {
/* got overflow output from the conversion */
ucnv_convertEx(UConverter *targetCnv, UConverter *sourceCnv,
char **target, const char *targetLimit,
const char **source, const char *sourceLimit,
- UChar *pivotStart, UChar **pivotSource,
- UChar **pivotTarget, const UChar *pivotLimit,
+ char16_t *pivotStart, char16_t **pivotSource,
+ char16_t **pivotTarget, const char16_t *pivotLimit,
UBool reset, UBool flush,
UErrorCode *pErrorCode) {
- UChar pivotBuffer[CHUNK_SIZE];
- const UChar *myPivotSource;
- UChar *myPivotTarget;
+ char16_t pivotBuffer[CHUNK_SIZE];
+ const char16_t *myPivotSource;
+ char16_t *myPivotTarget;
const char *s;
char *t;
/* use the stack pivot buffer */
myPivotSource=myPivotTarget=pivotStart=pivotBuffer;
- pivotSource=(UChar **)&myPivotSource;
+ pivotSource=(char16_t **)&myPivotSource;
pivotTarget=&myPivotTarget;
pivotLimit=pivotBuffer+CHUNK_SIZE;
} else if( pivotStart>=pivotLimit ||
_fromUnicodeWithCallback(&fromUArgs, pErrorCode);
if(U_FAILURE(*pErrorCode)) {
/* target overflow, or conversion error */
- *pivotSource=(UChar *)fromUArgs.source;
+ *pivotSource=(char16_t *)fromUArgs.source;
break;
}
char *target, int32_t targetCapacity,
const char *source, int32_t sourceLength,
UErrorCode *pErrorCode) {
- UChar pivotBuffer[CHUNK_SIZE];
- UChar *pivot, *pivot2;
+ char16_t pivotBuffer[CHUNK_SIZE];
+ char16_t *pivot, *pivot2;
char *myTarget;
const char *sourceLimit;
U_CAPI void U_EXPORT2
ucnv_fixFileSeparator(const UConverter *cnv,
- UChar* source,
+ char16_t* source,
int32_t sourceLength) {
const UAmbiguousConverter *a;
int32_t i;
- UChar variant5c;
+ char16_t variant5c;
if(cnv==nullptr || source==nullptr || sourceLength<=0 || (a=ucnv_getAmbiguous(cnv))==nullptr)
{
U_CAPI void U_EXPORT2
ucnv_getInvalidUChars (const UConverter * converter,
- UChar *errChars,
+ char16_t *errChars,
int8_t * len,
UErrorCode * err)
{
UErrorCode* err){
const char* mySourceLimit, *realSourceLimit;
const char* sourceStart;
- const UChar* myTargetStart;
+ const char16_t* myTargetStart;
UConverter* saveThis;
UConverterDataISO2022* myData;
int8_t length;
ISO2022State *pFromU2022State;
uint8_t *target = (uint8_t *) args->target;
const uint8_t *targetLimit = (const uint8_t *) args->targetLimit;
- const UChar* source = args->source;
- const UChar* sourceLimit = args->sourceLimit;
+ const char16_t* source = args->source;
+ const char16_t* sourceLimit = args->sourceLimit;
int32_t* offsets = args->offsets;
UChar32 sourceChar;
char buffer[8];
/*look ahead to find the trail surrogate*/
if(source < sourceLimit) {
/* test the following code unit */
- UChar trail=(UChar) *source;
+ char16_t trail=(char16_t) *source;
if(U16_IS_TRAIL(trail)) {
source++;
sourceChar=U16_GET_SUPPLEMENTARY(sourceChar, trail);
UErrorCode* err){
char tempBuf[2];
const char *mySource = (char *) args->source;
- UChar *myTarget = args->target;
+ char16_t *myTarget = args->target;
const char *mySourceLimit = args->sourceLimit;
uint32_t targetUniChar = 0x0000;
uint32_t mySourceChar = 0x0000;
if(args->offsets){
args->offsets[myTarget - args->target] = (int32_t)(mySource - args->source - (mySourceChar <= 0xff ? 1 : 2));
}
- *(myTarget++)=(UChar)targetUniChar;
+ *(myTarget++)=(char16_t)targetUniChar;
}
else if(targetUniChar > missingCharMarker){
/* disassemble the surrogate pair and write to output*/
targetUniChar-=0x0010000;
- *myTarget = (UChar)(0xd800+(UChar)(targetUniChar>>10));
+ *myTarget = (char16_t)(0xd800+(char16_t)(targetUniChar>>10));
if(args->offsets){
args->offsets[myTarget - args->target] = (int32_t)(mySource - args->source - (mySourceChar <= 0xff ? 1 : 2));
}
++myTarget;
if(myTarget< args->targetLimit){
- *myTarget = (UChar)(0xdc00+(UChar)(targetUniChar&0x3ff));
+ *myTarget = (char16_t)(0xdc00+(char16_t)(targetUniChar&0x3ff));
if(args->offsets){
args->offsets[myTarget - args->target] = (int32_t)(mySource - args->source - (mySourceChar <= 0xff ? 1 : 2));
}
++myTarget;
}else{
args->converter->UCharErrorBuffer[args->converter->UCharErrorBufferLength++]=
- (UChar)(0xdc00+(UChar)(targetUniChar&0x3ff));
+ (char16_t)(0xdc00+(char16_t)(targetUniChar&0x3ff));
}
}
static void U_CALLCONV
UConverter_fromUnicode_ISO_2022_KR_OFFSETS_LOGIC(UConverterFromUnicodeArgs* args, UErrorCode* err){
- const UChar *source = args->source;
- const UChar *sourceLimit = args->sourceLimit;
+ const char16_t *source = args->source;
+ const char16_t *sourceLimit = args->sourceLimit;
unsigned char *target = (unsigned char *) args->target;
unsigned char *targetLimit = (unsigned char *) args->targetLimit;
int32_t* offsets = args->offsets;
/*look ahead to find the trail surrogate*/
if(source < sourceLimit) {
/* test the following code unit */
- UChar trail=(UChar) *source;
+ char16_t trail=(char16_t) *source;
if(U16_IS_TRAIL(trail)) {
source++;
sourceChar=U16_GET_SUPPLEMENTARY(sourceChar, trail);
if(args->offsets != nullptr && sourceStart != args->source) {
/* update offsets to base them on the actual start of the input */
int32_t *offsets = args->offsets;
- UChar *target = args->target;
+ char16_t *target = args->target;
int32_t delta = (int32_t)(args->source - sourceStart);
while(target < subArgs.target) {
if(*offsets >= 0) {
UErrorCode* err){
char tempBuf[2];
const char *mySource = ( char *) args->source;
- UChar *myTarget = args->target;
+ char16_t *myTarget = args->target;
const char *mySourceLimit = args->sourceLimit;
UChar32 targetUniChar = 0x0000;
- UChar mySourceChar = 0x0000;
+ char16_t mySourceChar = 0x0000;
UConverterDataISO2022* myData;
UConverterSharedData* sharedData ;
UBool useFallback;
/* report a pair of illegal bytes if the second byte is not a DBCS starter */
++mySource;
/* add another bit so that the code below writes 2 bytes in case of error */
- mySourceChar = static_cast<UChar>(0x10000 | (mySourceChar << 8) | trailByte);
+ mySourceChar = static_cast<char16_t>(0x10000 | (mySourceChar << 8) | trailByte);
}
} else {
args->converter->toUBytes[0] = (uint8_t)mySourceChar;
if(args->offsets) {
args->offsets[myTarget - args->target] = (int32_t)(mySource - args->source - (mySourceChar <= 0xff ? 1 : 2));
}
- *(myTarget++)=(UChar)targetUniChar;
+ *(myTarget++)=(char16_t)targetUniChar;
}
else {
/* Call the callback function*/
ISO2022State *pFromU2022State;
uint8_t *target = (uint8_t *) args->target;
const uint8_t *targetLimit = (const uint8_t *) args->targetLimit;
- const UChar* source = args->source;
- const UChar* sourceLimit = args->sourceLimit;
+ const char16_t* source = args->source;
+ const char16_t* sourceLimit = args->sourceLimit;
int32_t* offsets = args->offsets;
UChar32 sourceChar;
char buffer[8];
/*look ahead to find the trail surrogate*/
if(source < sourceLimit) {
/* test the following code unit */
- UChar trail=(UChar) *source;
+ char16_t trail=(char16_t) *source;
if(U16_IS_TRAIL(trail)) {
source++;
sourceChar=U16_GET_SUPPLEMENTARY(sourceChar, trail);
UErrorCode* err){
char tempBuf[3];
const char *mySource = (char *) args->source;
- UChar *myTarget = args->target;
+ char16_t *myTarget = args->target;
const char *mySourceLimit = args->sourceLimit;
uint32_t targetUniChar = 0x0000;
uint32_t mySourceChar = 0x0000;
}
else{
if(mySourceChar <= 0x7f) {
- targetUniChar = (UChar) mySourceChar;
+ targetUniChar = (char16_t) mySourceChar;
}
}
break;
if(args->offsets){
args->offsets[myTarget - args->target] = (int32_t)(mySource - args->source - (mySourceChar <= 0xff ? 1 : 2));
}
- *(myTarget++)=(UChar)targetUniChar;
+ *(myTarget++)=(char16_t)targetUniChar;
}
else if(targetUniChar > missingCharMarker){
/* disassemble the surrogate pair and write to output*/
targetUniChar-=0x0010000;
- *myTarget = (UChar)(0xd800+(UChar)(targetUniChar>>10));
+ *myTarget = (char16_t)(0xd800+(char16_t)(targetUniChar>>10));
if(args->offsets){
args->offsets[myTarget - args->target] = (int32_t)(mySource - args->source - (mySourceChar <= 0xff ? 1 : 2));
}
++myTarget;
if(myTarget< args->targetLimit){
- *myTarget = (UChar)(0xdc00+(UChar)(targetUniChar&0x3ff));
+ *myTarget = (char16_t)(0xdc00+(char16_t)(targetUniChar&0x3ff));
if(args->offsets){
args->offsets[myTarget - args->target] = (int32_t)(mySource - args->source - (mySourceChar <= 0xff ? 1 : 2));
}
++myTarget;
}else{
args->converter->UCharErrorBuffer[args->converter->UCharErrorBufferLength++]=
- (UChar)(0xdc00+(UChar)(targetUniChar&0x3ff));
+ (char16_t)(0xdc00+(char16_t)(targetUniChar&0x3ff));
}
}
UCNV_IBM,
UCNV_ISO_2022,
1,
- 3, /* max 3 bytes per UChar from UTF-8 (4 bytes from surrogate _pair_) */
+ 3, /* max 3 bytes per char16_t from UTF-8 (4 bytes from surrogate _pair_) */
{ 0x1a, 0, 0, 0 },
1,
false,
UCNV_IBM,
UCNV_ISO_2022,
1,
- 6, /* max 6 bytes per UChar: 4-byte escape sequence + DBCS */
+ 6, /* max 6 bytes per char16_t: 4-byte escape sequence + DBCS */
{ 0x1a, 0, 0, 0 },
1,
false,
UCNV_IBM,
UCNV_ISO_2022,
1,
- 8, /* max 8 bytes per UChar */
+ 8, /* max 8 bytes per char16_t */
{ 0x1a, 0, 0, 0 },
1,
false,
UCNV_IBM,
UCNV_ISO_2022,
1,
- 8, /* max 8 bytes per UChar: 4-byte CNS designator + 2 bytes for SS2/SS3 + DBCS */
+ 8, /* max 8 bytes per char16_t: 4-byte CNS designator + 2 bytes for SS2/SS3 + DBCS */
{ 0x1a, 0, 0, 0 },
1,
false,
U_CAPI void U_EXPORT2
ucnv_cbFromUWriteUChars(UConverterFromUnicodeArgs *args,
- const UChar** source,
- const UChar* sourceLimit,
+ const char16_t** source,
+ const char16_t* sourceLimit,
int32_t offsetIndex,
UErrorCode * err)
{
* and will not recurse.
* At worst we should get a U_BUFFER_OVERFLOW_ERROR.
*/
- const UChar *source = (const UChar *)converter->subChars;
+ const char16_t *source = (const char16_t *)converter->subChars;
ucnv_cbFromUWriteUChars(args, &source, source - length, offsetIndex, err);
return;
}
U_CAPI void U_EXPORT2
ucnv_cbToUWriteUChars (UConverterToUnicodeArgs *args,
- const UChar* source,
+ const char16_t* source,
int32_t length,
int32_t offsetIndex,
UErrorCode * err)
int32_t offsetIndex,
UErrorCode * err)
{
- static const UChar kSubstituteChar1 = 0x1A, kSubstituteChar = 0xFFFD;
+ static const char16_t kSubstituteChar1 = 0x1A, kSubstituteChar = 0xFFFD;
/* could optimize this case, just one uchar */
if(args->converter->invalidCharLength == 1 && args->converter->subChar1 != 0) {
U_CFUNC void
ucnv_toUWriteUChars(UConverter *cnv,
- const UChar *uchars, int32_t length,
- UChar **target, const UChar *targetLimit,
+ const char16_t *uchars, int32_t length,
+ char16_t **target, const char16_t *targetLimit,
int32_t **offsets,
int32_t sourceIndex,
UErrorCode *pErrorCode) {
- UChar *t=*target;
+ char16_t *t=*target;
int32_t *o;
/* write UChars */
U_CFUNC void
ucnv_toUWriteCodePoint(UConverter *cnv,
UChar32 c,
- UChar **target, const UChar *targetLimit,
+ char16_t **target, const char16_t *targetLimit,
int32_t **offsets,
int32_t sourceIndex,
UErrorCode *pErrorCode) {
- UChar *t;
+ char16_t *t;
int32_t *o;
t=*target;
if(t<targetLimit) {
if(c<=0xffff) {
- *t++=(UChar)c;
+ *t++=(char16_t)c;
c=U_SENTINEL;
} else /* c is a supplementary code point */ {
*t++=U16_LEAD(c);
c=U16_TRAIL(c);
if(t<targetLimit) {
- *t++=(UChar)c;
+ *t++=(char16_t)c;
c=U_SENTINEL;
}
}
UConverter *cnv = args->converter;
uint8_t *target = (uint8_t *) args->target;
const uint8_t *targetLimit = (const uint8_t *) args->targetLimit;
- const UChar* source = args->source;
- const UChar* sourceLimit = args->sourceLimit;
+ const char16_t* source = args->source;
+ const char16_t* sourceLimit = args->sourceLimit;
/* int32_t* offsets = args->offsets; */
UChar32 sourceChar;
UBool useFallback = cnv->useFallback;
/*look ahead to find the trail surrogate*/
if(source < sourceLimit) {
/* test the following code unit */
- UChar trail=(UChar) *source;
+ char16_t trail=(char16_t) *source;
if(U16_IS_TRAIL(trail)) {
source++;
sourceChar=U16_GET_SUPPLEMENTARY(sourceChar, trail);
UConverter_toUnicode_CompoundText_OFFSETS(UConverterToUnicodeArgs *args,
UErrorCode* err){
const char *mySource = (char *) args->source;
- UChar *myTarget = args->target;
+ char16_t *myTarget = args->target;
const char *mySourceLimit = args->sourceLimit;
const char *tmpSourceLimit = mySourceLimit;
uint32_t mySourceChar = 0x0000;
UCNV_FROM_U_CALLBACK_STOP (
const void *context,
UConverterFromUnicodeArgs *fromUArgs,
- const UChar* codeUnits,
+ const char16_t* codeUnits,
int32_t length,
UChar32 codePoint,
UConverterCallbackReason reason,
UCNV_FROM_U_CALLBACK_SKIP (
const void *context,
UConverterFromUnicodeArgs *fromUArgs,
- const UChar* codeUnits,
+ const char16_t* codeUnits,
int32_t length,
UChar32 codePoint,
UConverterCallbackReason reason,
UCNV_FROM_U_CALLBACK_SUBSTITUTE (
const void *context,
UConverterFromUnicodeArgs *fromArgs,
- const UChar* codeUnits,
+ const char16_t* codeUnits,
int32_t length,
UChar32 codePoint,
UConverterCallbackReason reason,
UCNV_FROM_U_CALLBACK_ESCAPE (
const void *context,
UConverterFromUnicodeArgs *fromArgs,
- const UChar *codeUnits,
+ const char16_t *codeUnits,
int32_t length,
UChar32 codePoint,
UConverterCallbackReason reason,
UErrorCode * err)
{
- UChar valueString[VALUE_STRING_LENGTH];
+ char16_t valueString[VALUE_STRING_LENGTH];
int32_t valueStringLength = 0;
int32_t i = 0;
- const UChar *myValueSource = nullptr;
+ const char16_t *myValueSource = nullptr;
UErrorCode err2 = U_ZERO_ERROR;
UConverterFromUCallback original = nullptr;
const void *originalContext;
{
while (i < length)
{
- valueString[valueStringLength++] = (UChar) UNICODE_PERCENT_SIGN_CODEPOINT; /* adding % */
- valueString[valueStringLength++] = (UChar) UNICODE_U_CODEPOINT; /* adding U */
+ valueString[valueStringLength++] = (char16_t) UNICODE_PERCENT_SIGN_CODEPOINT; /* adding % */
+ valueString[valueStringLength++] = (char16_t) UNICODE_U_CODEPOINT; /* adding U */
valueStringLength += uprv_itou (valueString + valueStringLength, VALUE_STRING_LENGTH - valueStringLength, (uint16_t)codeUnits[i++], 16, 4);
}
}
case UCNV_PRV_ESCAPE_JAVA:
while (i < length)
{
- valueString[valueStringLength++] = (UChar) UNICODE_RS_CODEPOINT; /* adding \ */
- valueString[valueStringLength++] = (UChar) UNICODE_U_LOW_CODEPOINT; /* adding u */
+ valueString[valueStringLength++] = (char16_t) UNICODE_RS_CODEPOINT; /* adding \ */
+ valueString[valueStringLength++] = (char16_t) UNICODE_U_LOW_CODEPOINT; /* adding u */
valueStringLength += uprv_itou (valueString + valueStringLength, VALUE_STRING_LENGTH - valueStringLength, (uint16_t)codeUnits[i++], 16, 4);
}
break;
case UCNV_PRV_ESCAPE_C:
- valueString[valueStringLength++] = (UChar) UNICODE_RS_CODEPOINT; /* adding \ */
+ valueString[valueStringLength++] = (char16_t) UNICODE_RS_CODEPOINT; /* adding \ */
if(length==2){
- valueString[valueStringLength++] = (UChar) UNICODE_U_CODEPOINT; /* adding U */
+ valueString[valueStringLength++] = (char16_t) UNICODE_U_CODEPOINT; /* adding U */
valueStringLength += uprv_itou (valueString + valueStringLength, VALUE_STRING_LENGTH - valueStringLength, codePoint, 16, 8);
}
else{
- valueString[valueStringLength++] = (UChar) UNICODE_U_LOW_CODEPOINT; /* adding u */
+ valueString[valueStringLength++] = (char16_t) UNICODE_U_LOW_CODEPOINT; /* adding u */
valueStringLength += uprv_itou (valueString + valueStringLength, VALUE_STRING_LENGTH - valueStringLength, (uint16_t)codeUnits[0], 16, 4);
}
break;
case UCNV_PRV_ESCAPE_XML_DEC:
- valueString[valueStringLength++] = (UChar) UNICODE_AMP_CODEPOINT; /* adding & */
- valueString[valueStringLength++] = (UChar) UNICODE_HASH_CODEPOINT; /* adding # */
+ valueString[valueStringLength++] = (char16_t) UNICODE_AMP_CODEPOINT; /* adding & */
+ valueString[valueStringLength++] = (char16_t) UNICODE_HASH_CODEPOINT; /* adding # */
if(length==2){
valueStringLength += uprv_itou (valueString + valueStringLength, VALUE_STRING_LENGTH - valueStringLength, codePoint, 10, 0);
}
else{
valueStringLength += uprv_itou (valueString + valueStringLength, VALUE_STRING_LENGTH - valueStringLength, (uint16_t)codeUnits[0], 10, 0);
}
- valueString[valueStringLength++] = (UChar) UNICODE_SEMICOLON_CODEPOINT; /* adding ; */
+ valueString[valueStringLength++] = (char16_t) UNICODE_SEMICOLON_CODEPOINT; /* adding ; */
break;
case UCNV_PRV_ESCAPE_XML_HEX:
- valueString[valueStringLength++] = (UChar) UNICODE_AMP_CODEPOINT; /* adding & */
- valueString[valueStringLength++] = (UChar) UNICODE_HASH_CODEPOINT; /* adding # */
- valueString[valueStringLength++] = (UChar) UNICODE_X_LOW_CODEPOINT; /* adding x */
+ valueString[valueStringLength++] = (char16_t) UNICODE_AMP_CODEPOINT; /* adding & */
+ valueString[valueStringLength++] = (char16_t) UNICODE_HASH_CODEPOINT; /* adding # */
+ valueString[valueStringLength++] = (char16_t) UNICODE_X_LOW_CODEPOINT; /* adding x */
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);
}
- valueString[valueStringLength++] = (UChar) UNICODE_SEMICOLON_CODEPOINT; /* adding ; */
+ valueString[valueStringLength++] = (char16_t) UNICODE_SEMICOLON_CODEPOINT; /* adding ; */
break;
case UCNV_PRV_ESCAPE_UNICODE:
- valueString[valueStringLength++] = (UChar) UNICODE_LEFT_CURLY_CODEPOINT; /* adding { */
- valueString[valueStringLength++] = (UChar) UNICODE_U_CODEPOINT; /* adding U */
- valueString[valueStringLength++] = (UChar) UNICODE_PLUS_CODEPOINT; /* adding + */
+ valueString[valueStringLength++] = (char16_t) UNICODE_LEFT_CURLY_CODEPOINT; /* adding { */
+ valueString[valueStringLength++] = (char16_t) UNICODE_U_CODEPOINT; /* adding U */
+ valueString[valueStringLength++] = (char16_t) UNICODE_PLUS_CODEPOINT; /* adding + */
if (length == 2) {
valueStringLength += uprv_itou (valueString + valueStringLength, VALUE_STRING_LENGTH - valueStringLength, codePoint, 16, 4);
} else {
valueStringLength += uprv_itou (valueString + valueStringLength, VALUE_STRING_LENGTH - valueStringLength, (uint16_t)codeUnits[0], 16, 4);
}
- valueString[valueStringLength++] = (UChar) UNICODE_RIGHT_CURLY_CODEPOINT; /* adding } */
+ valueString[valueStringLength++] = (char16_t) UNICODE_RIGHT_CURLY_CODEPOINT; /* adding } */
break;
case UCNV_PRV_ESCAPE_CSS2:
- valueString[valueStringLength++] = (UChar) UNICODE_RS_CODEPOINT; /* adding \ */
+ valueString[valueStringLength++] = (char16_t) UNICODE_RS_CODEPOINT; /* adding \ */
valueStringLength += uprv_itou (valueString + valueStringLength, VALUE_STRING_LENGTH - valueStringLength, codePoint, 16, 0);
/* Always add space character, because the next character might be whitespace,
which would erroneously be considered the termination of the escape sequence. */
- valueString[valueStringLength++] = (UChar) UNICODE_SPACE_CODEPOINT;
+ valueString[valueStringLength++] = (char16_t) UNICODE_SPACE_CODEPOINT;
break;
default:
while (i < length)
{
- valueString[valueStringLength++] = (UChar) UNICODE_PERCENT_SIGN_CODEPOINT; /* adding % */
- valueString[valueStringLength++] = (UChar) UNICODE_U_CODEPOINT; /* adding U */
+ valueString[valueStringLength++] = (char16_t) UNICODE_PERCENT_SIGN_CODEPOINT; /* adding % */
+ valueString[valueStringLength++] = (char16_t) UNICODE_U_CODEPOINT; /* adding U */
valueStringLength += uprv_itou (valueString + valueStringLength, VALUE_STRING_LENGTH - valueStringLength, (uint16_t)codeUnits[i++], 16, 4);
}
}
UConverterCallbackReason reason,
UErrorCode * err)
{
- UChar uniValueString[VALUE_STRING_LENGTH];
+ char16_t uniValueString[VALUE_STRING_LENGTH];
int32_t valueStringLength = 0;
int32_t i = 0;
{
while (i < length)
{
- uniValueString[valueStringLength++] = (UChar) UNICODE_PERCENT_SIGN_CODEPOINT; /* adding % */
- uniValueString[valueStringLength++] = (UChar) UNICODE_X_CODEPOINT; /* adding X */
+ uniValueString[valueStringLength++] = (char16_t) UNICODE_PERCENT_SIGN_CODEPOINT; /* adding % */
+ uniValueString[valueStringLength++] = (char16_t) UNICODE_X_CODEPOINT; /* adding X */
valueStringLength += uprv_itou (uniValueString + valueStringLength, VALUE_STRING_LENGTH - valueStringLength, (uint8_t) codeUnits[i++], 16, 2);
}
}
case UCNV_PRV_ESCAPE_XML_DEC:
while (i < length)
{
- uniValueString[valueStringLength++] = (UChar) UNICODE_AMP_CODEPOINT; /* adding & */
- uniValueString[valueStringLength++] = (UChar) UNICODE_HASH_CODEPOINT; /* adding # */
+ uniValueString[valueStringLength++] = (char16_t) UNICODE_AMP_CODEPOINT; /* adding & */
+ uniValueString[valueStringLength++] = (char16_t) UNICODE_HASH_CODEPOINT; /* adding # */
valueStringLength += uprv_itou (uniValueString + valueStringLength, VALUE_STRING_LENGTH - valueStringLength, (uint8_t)codeUnits[i++], 10, 0);
- uniValueString[valueStringLength++] = (UChar) UNICODE_SEMICOLON_CODEPOINT; /* adding ; */
+ uniValueString[valueStringLength++] = (char16_t) UNICODE_SEMICOLON_CODEPOINT; /* adding ; */
}
break;
case UCNV_PRV_ESCAPE_XML_HEX:
while (i < length)
{
- uniValueString[valueStringLength++] = (UChar) UNICODE_AMP_CODEPOINT; /* adding & */
- uniValueString[valueStringLength++] = (UChar) UNICODE_HASH_CODEPOINT; /* adding # */
- uniValueString[valueStringLength++] = (UChar) UNICODE_X_LOW_CODEPOINT; /* adding x */
+ uniValueString[valueStringLength++] = (char16_t) UNICODE_AMP_CODEPOINT; /* adding & */
+ uniValueString[valueStringLength++] = (char16_t) UNICODE_HASH_CODEPOINT; /* adding # */
+ uniValueString[valueStringLength++] = (char16_t) UNICODE_X_LOW_CODEPOINT; /* adding x */
valueStringLength += uprv_itou (uniValueString + valueStringLength, VALUE_STRING_LENGTH - valueStringLength, (uint8_t)codeUnits[i++], 16, 0);
- uniValueString[valueStringLength++] = (UChar) UNICODE_SEMICOLON_CODEPOINT; /* adding ; */
+ uniValueString[valueStringLength++] = (char16_t) UNICODE_SEMICOLON_CODEPOINT; /* adding ; */
}
break;
case UCNV_PRV_ESCAPE_C:
while (i < length)
{
- uniValueString[valueStringLength++] = (UChar) UNICODE_RS_CODEPOINT; /* adding \ */
- uniValueString[valueStringLength++] = (UChar) UNICODE_X_LOW_CODEPOINT; /* adding x */
+ uniValueString[valueStringLength++] = (char16_t) UNICODE_RS_CODEPOINT; /* adding \ */
+ uniValueString[valueStringLength++] = (char16_t) UNICODE_X_LOW_CODEPOINT; /* adding x */
valueStringLength += uprv_itou (uniValueString + valueStringLength, VALUE_STRING_LENGTH - valueStringLength, (uint8_t)codeUnits[i++], 16, 2);
}
break;
default:
while (i < length)
{
- uniValueString[valueStringLength++] = (UChar) UNICODE_PERCENT_SIGN_CODEPOINT; /* adding % */
- uniValueString[valueStringLength++] = (UChar) UNICODE_X_CODEPOINT; /* adding X */
+ uniValueString[valueStringLength++] = (char16_t) UNICODE_PERCENT_SIGN_CODEPOINT; /* adding % */
+ uniValueString[valueStringLength++] = (char16_t) UNICODE_X_CODEPOINT; /* adding X */
uprv_itou (uniValueString + valueStringLength, VALUE_STRING_LENGTH - valueStringLength, (uint8_t) codeUnits[i++], 16, 2);
valueStringLength += 2;
}
}
}
- /* search for the current UChar */
+ /* search for the current char16_t */
value=ucnv_extFindToU(toUSection, length, b);
if(value==0) {
/* no match here, stop with the longest match so far */
static inline void
ucnv_extWriteToU(UConverter *cnv, const int32_t *cx,
uint32_t value,
- UChar **target, const UChar *targetLimit,
+ char16_t **target, const char16_t *targetLimit,
int32_t **offsets, int32_t srcIndex,
UErrorCode *pErrorCode) {
/* output the result */
/* output a string - with correct data we have resultLength>0 */
ucnv_toUWriteUChars(
cnv,
- UCNV_EXT_ARRAY(cx, UCNV_EXT_TO_U_UCHARS_INDEX, UChar)+
+ UCNV_EXT_ARRAY(cx, UCNV_EXT_TO_U_UCHARS_INDEX, char16_t)+
UCNV_EXT_TO_U_GET_INDEX(value),
UCNV_EXT_TO_U_GET_LENGTH(value),
target, targetLimit,
ucnv_extInitialMatchToU(UConverter *cnv, const int32_t *cx,
int32_t firstLength,
const char **src, const char *srcLimit,
- UChar **target, const UChar *targetLimit,
+ char16_t **target, const char16_t *targetLimit,
int32_t **offsets, int32_t srcIndex,
UBool flush,
UErrorCode *pErrorCode) {
}
/*
- * @return index of the UChar, if found; else <0
+ * @return index of the char16_t, if found; else <0
*/
static inline int32_t
-ucnv_extFindFromU(const UChar *fromUSection, int32_t length, UChar u) {
+ucnv_extFindFromU(const char16_t *fromUSection, int32_t length, char16_t u) {
int32_t i, start, limit;
/* binary search */
static int32_t
ucnv_extMatchFromU(const int32_t *cx,
UChar32 firstCP,
- const UChar *pre, int32_t preLength,
- const UChar *src, int32_t srcLength,
+ const char16_t *pre, int32_t preLength,
+ const char16_t *src, int32_t srcLength,
uint32_t *pMatchValue,
UBool useFallback, UBool flush) {
const uint16_t *stage12, *stage3;
const uint32_t *stage3b;
- const UChar *fromUTableUChars, *fromUSectionUChars;
+ const char16_t *fromUTableUChars, *fromUSectionUChars;
const uint32_t *fromUTableValues, *fromUSectionValues;
uint32_t value, matchValue;
int32_t i, j, idx, length, matchLength;
- UChar c;
+ char16_t c;
if(cx==nullptr) {
return 0; /* no extension data, no match */
idx=(int32_t)UCNV_EXT_FROM_U_GET_PARTIAL_INDEX(value);
/* initialize */
- fromUTableUChars=UCNV_EXT_ARRAY(cx, UCNV_EXT_FROM_U_UCHARS_INDEX, UChar);
+ fromUTableUChars=UCNV_EXT_ARRAY(cx, UCNV_EXT_FROM_U_UCHARS_INDEX, char16_t);
fromUTableValues=UCNV_EXT_ARRAY(cx, UCNV_EXT_FROM_U_VALUES_INDEX, uint32_t);
matchValue=0;
}
}
- /* search for the current UChar */
+ /* search for the current char16_t */
idx=ucnv_extFindFromU(fromUSectionUChars, length, c);
if(idx<0) {
/* no match here, stop with the longest match so far */
U_CFUNC UBool
ucnv_extInitialMatchFromU(UConverter *cnv, const int32_t *cx,
UChar32 cp,
- const UChar **src, const UChar *srcLimit,
+ const char16_t **src, const char16_t *srcLimit,
char **target, const char *targetLimit,
int32_t **offsets, int32_t srcIndex,
UBool flush,
return true;
} else if(match<0) {
/* save state for partial match */
- const UChar *s;
+ const char16_t *s;
int32_t j;
/* copy the first code point */
pErrorCode);
} else if(match<0) {
/* save state for partial match */
- const UChar *s;
+ const char16_t *s;
int32_t j;
/* just _append_ the newly consumed input to preFromU[] */
UConverterUnicodeSet which,
int32_t minLength,
UChar32 firstCP,
- UChar s[UCNV_EXT_MAX_UCHARS], int32_t length,
+ char16_t s[UCNV_EXT_MAX_UCHARS], int32_t length,
int32_t sectionIndex,
UErrorCode *pErrorCode) {
- const UChar *fromUSectionUChars;
+ const char16_t *fromUSectionUChars;
const uint32_t *fromUSectionValues;
uint32_t value;
int32_t i, count;
- fromUSectionUChars=UCNV_EXT_ARRAY(cx, UCNV_EXT_FROM_U_UCHARS_INDEX, UChar)+sectionIndex;
+ fromUSectionUChars=UCNV_EXT_ARRAY(cx, UCNV_EXT_FROM_U_UCHARS_INDEX, char16_t)+sectionIndex;
fromUSectionValues=UCNV_EXT_ARRAY(cx, UCNV_EXT_FROM_U_VALUES_INDEX, uint32_t)+sectionIndex;
/* read first pair of the section */
uint32_t value;
int32_t st1, stage1Length, st2, st3, minLength;
- UChar s[UCNV_EXT_MAX_UCHARS];
+ char16_t s[UCNV_EXT_MAX_UCHARS];
UChar32 c;
int32_t length;
static const struct _UniLMBCSGrpMap
{
- const UChar uniStartRange;
- const UChar uniEndRange;
+ const char16_t uniStartRange;
+ const char16_t uniEndRange;
const ulmbcs_byte_t GrpType;
} UniLMBCSGrpMap[]
=
};
static ulmbcs_byte_t
-FindLMBCSUniRange(UChar uniChar)
+FindLMBCSUniRange(char16_t uniChar)
{
const struct _UniLMBCSGrpMap * pTable = UniLMBCSGrpMap;
UConverterDataLMBCS * extraInfo, /* subconverters, opt & locale groups */
ulmbcs_byte_t group, /* The group to try */
ulmbcs_byte_t * pStartLMBCS, /* where to put the results */
- UChar * pUniChar, /* The input unicode character */
+ char16_t * pUniChar, /* The input unicode character */
ulmbcs_byte_t * lastConverterIndex, /* output: track last successful group used */
UBool * groups_tried /* output: track any unsuccessful groups */
)
know we are writing LMBCS using the Unicode group
*/
static size_t
-LMBCSConvertUni(ulmbcs_byte_t * pLMBCS, UChar uniChar)
+LMBCSConvertUni(ulmbcs_byte_t * pLMBCS, char16_t uniChar)
{
/* encode into LMBCS Unicode range */
uint8_t LowCh = (uint8_t)(uniChar & 0x00FF);
UErrorCode* err)
{
ulmbcs_byte_t lastConverterIndex = 0;
- UChar uniChar;
+ char16_t uniChar;
ulmbcs_byte_t LMBCS[ULMBCS_CHARSIZE_MAX];
ulmbcs_byte_t * pLMBCS;
int32_t bytes_written;
/* A function to call when we are looking at the Unicode group byte in LMBCS */
-static UChar
+static char16_t
GetUniFromLMBCSUni(char const ** ppLMBCSin) /* Called with LMBCS-style Unicode byte stream */
{
uint8_t HighCh = *(*ppLMBCSin)++; /* Big-endian Unicode in LMBCS compatibility group*/
HighCh = LowCh;
LowCh = 0; /* zero-byte in LSB special character */
}
- return (UChar)((HighCh << 8) | LowCh);
+ return (char16_t)((HighCh << 8) | LowCh);
}
UErrorCode* err)
{
char LMBCS [ULMBCS_CHARSIZE_MAX];
- UChar uniChar; /* one output UNICODE char */
+ char16_t uniChar; /* one output UNICODE char */
const char * saveSource; /* beginning of current code point */
const char * pStartLMBCS = args->source; /* beginning of whole string */
const char * errSource = nullptr; /* pointer to actual input in case an error occurs */
args->source = errSource = LMBCS;
args->sourceLimit = LMBCS+size_old+size_new;
savebytes = (int8_t)(size_old+size_new);
- uniChar = (UChar) _LMBCSGetNextUCharWorker(args, err);
+ uniChar = (char16_t) _LMBCSGetNextUCharWorker(args, err);
args->source = saveSource + ((args->source - LMBCS) - size_old);
args->sourceLimit = saveSourceLimit;
else
{
errSource = saveSource;
- uniChar = (UChar) _LMBCSGetNextUCharWorker(args, err);
+ uniChar = (char16_t) _LMBCSGetNextUCharWorker(args, err);
savebytes = (int8_t)(args->source - saveSource);
}
if (U_SUCCESS(*err))
_UTF16BEFromUnicodeWithOffsets(UConverterFromUnicodeArgs *pArgs,
UErrorCode *pErrorCode) {
UConverter *cnv;
- const UChar *source;
+ const char16_t *source;
char *target;
int32_t *offsets;
uint32_t targetCapacity, length, sourceIndex;
- UChar c, trail;
+ char16_t c, trail;
char overflow[4];
source=pArgs->source;
/* c!=0 indicates in several places outside the main loops that a surrogate was found */
- if((c=(UChar)cnv->fromUChar32)!=0 && U16_IS_TRAIL(trail=*source) && targetCapacity>=4) {
+ if((c=(char16_t)cnv->fromUChar32)!=0 && U16_IS_TRAIL(trail=*source) && targetCapacity>=4) {
/* the last buffer ended with a lead surrogate, output the surrogate pair */
++source;
--length;
UErrorCode *pErrorCode) {
UConverter *cnv;
const uint8_t *source;
- UChar *target;
+ char16_t *target;
int32_t *offsets;
uint32_t targetCapacity, length, count, sourceIndex;
- UChar c, trail;
+ char16_t c, trail;
if(pArgs->converter->mode<8) {
_UTF16ToUnicodeWithOffsets(pArgs, pErrorCode);
sourceIndex=0;
c=0;
- /* complete a partial UChar or pair from the last call */
+ /* complete a partial char16_t or pair from the last call */
if(cnv->toUnicodeStatus!=0) {
/*
* special case: single byte from a previous buffer,
++sourceIndex;
--length;
if(count==2) {
- c=((UChar)p[0]<<8)|p[1];
+ c=((char16_t)p[0]<<8)|p[1];
if(U16_IS_SINGLE(c)) {
/* output the BMP code point */
*target++=c;
break;
}
} else if(count==4) {
- c=((UChar)p[0]<<8)|p[1];
- trail=((UChar)p[2]<<8)|p[3];
+ c=((char16_t)p[0]<<8)|p[1];
+ trail=((char16_t)p[2]<<8)|p[3];
if(U16_IS_TRAIL(trail)) {
/* output the surrogate pair */
*target++=c;
targetCapacity-=count;
if(offsets==nullptr) {
do {
- c=((UChar)source[0]<<8)|source[1];
+ c=((char16_t)source[0]<<8)|source[1];
source+=2;
if(U16_IS_SINGLE(c)) {
*target++=c;
} else if(U16_IS_SURROGATE_LEAD(c) && count>=2 &&
- U16_IS_TRAIL(trail=((UChar)source[0]<<8)|source[1])
+ U16_IS_TRAIL(trail=((char16_t)source[0]<<8)|source[1])
) {
source+=2;
--count;
} while(--count>0);
} else {
do {
- c=((UChar)source[0]<<8)|source[1];
+ c=((char16_t)source[0]<<8)|source[1];
source+=2;
if(U16_IS_SINGLE(c)) {
*target++=c;
*offsets++=sourceIndex;
sourceIndex+=2;
} else if(U16_IS_SURROGATE_LEAD(c) && count>=2 &&
- U16_IS_TRAIL(trail=((UChar)source[0]<<8)|source[1])
+ U16_IS_TRAIL(trail=((char16_t)source[0]<<8)|source[1])
) {
source+=2;
--count;
if(U16_IS_SURROGATE_LEAD(c)) {
if(length>=2) {
- if(U16_IS_TRAIL(trail=((UChar)source[0]<<8)|source[1])) {
+ if(U16_IS_TRAIL(trail=((char16_t)source[0]<<8)|source[1])) {
/* output the surrogate pair, will overflow (see conditions comment above) */
source+=2;
length-=2;
}
if(s+2>sourceLimit) {
- /* only one byte: truncated UChar */
+ /* only one byte: truncated char16_t */
pArgs->converter->toUBytes[0]=*s++;
pArgs->converter->toULength=1;
pArgs->source=(const char *)s;
return 0xffff;
}
- /* get one UChar */
+ /* get one char16_t */
c=((UChar32)*s<<8)|s[1];
s+=2;
if(U_IS_SURROGATE(c)) {
if(U16_IS_SURROGATE_LEAD(c)) {
if(s+2<=sourceLimit) {
- UChar trail;
+ char16_t trail;
- /* get a second UChar and see if it is a trail surrogate */
- trail=((UChar)*s<<8)|s[1];
+ /* get a second char16_t and see if it is a trail surrogate */
+ trail=((char16_t)*s<<8)|s[1];
if(U16_IS_TRAIL(trail)) {
c=U16_GET_SUPPLEMENTARY(c, trail);
s+=2;
_UTF16LEFromUnicodeWithOffsets(UConverterFromUnicodeArgs *pArgs,
UErrorCode *pErrorCode) {
UConverter *cnv;
- const UChar *source;
+ const char16_t *source;
char *target;
int32_t *offsets;
uint32_t targetCapacity, length, sourceIndex;
- UChar c, trail;
+ char16_t c, trail;
char overflow[4];
source=pArgs->source;
/* c!=0 indicates in several places outside the main loops that a surrogate was found */
- if((c=(UChar)cnv->fromUChar32)!=0 && U16_IS_TRAIL(trail=*source) && targetCapacity>=4) {
+ if((c=(char16_t)cnv->fromUChar32)!=0 && U16_IS_TRAIL(trail=*source) && targetCapacity>=4) {
/* the last buffer ended with a lead surrogate, output the surrogate pair */
++source;
--length;
UErrorCode *pErrorCode) {
UConverter *cnv;
const uint8_t *source;
- UChar *target;
+ char16_t *target;
int32_t *offsets;
uint32_t targetCapacity, length, count, sourceIndex;
- UChar c, trail;
+ char16_t c, trail;
if(pArgs->converter->mode<8) {
_UTF16ToUnicodeWithOffsets(pArgs, pErrorCode);
sourceIndex=0;
c=0;
- /* complete a partial UChar or pair from the last call */
+ /* complete a partial char16_t or pair from the last call */
if(cnv->toUnicodeStatus!=0) {
/*
* special case: single byte from a previous buffer,
++sourceIndex;
--length;
if(count==2) {
- c=((UChar)p[1]<<8)|p[0];
+ c=((char16_t)p[1]<<8)|p[0];
if(U16_IS_SINGLE(c)) {
/* output the BMP code point */
*target++=c;
break;
}
} else if(count==4) {
- c=((UChar)p[1]<<8)|p[0];
- trail=((UChar)p[3]<<8)|p[2];
+ c=((char16_t)p[1]<<8)|p[0];
+ trail=((char16_t)p[3]<<8)|p[2];
if(U16_IS_TRAIL(trail)) {
/* output the surrogate pair */
*target++=c;
targetCapacity-=count;
if(offsets==nullptr) {
do {
- c=((UChar)source[1]<<8)|source[0];
+ c=((char16_t)source[1]<<8)|source[0];
source+=2;
if(U16_IS_SINGLE(c)) {
*target++=c;
} else if(U16_IS_SURROGATE_LEAD(c) && count>=2 &&
- U16_IS_TRAIL(trail=((UChar)source[1]<<8)|source[0])
+ U16_IS_TRAIL(trail=((char16_t)source[1]<<8)|source[0])
) {
source+=2;
--count;
} while(--count>0);
} else {
do {
- c=((UChar)source[1]<<8)|source[0];
+ c=((char16_t)source[1]<<8)|source[0];
source+=2;
if(U16_IS_SINGLE(c)) {
*target++=c;
*offsets++=sourceIndex;
sourceIndex+=2;
} else if(U16_IS_SURROGATE_LEAD(c) && count>=2 &&
- U16_IS_TRAIL(trail=((UChar)source[1]<<8)|source[0])
+ U16_IS_TRAIL(trail=((char16_t)source[1]<<8)|source[0])
) {
source+=2;
--count;
if(U16_IS_SURROGATE_LEAD(c)) {
if(length>=2) {
- if(U16_IS_TRAIL(trail=((UChar)source[1]<<8)|source[0])) {
+ if(U16_IS_TRAIL(trail=((char16_t)source[1]<<8)|source[0])) {
/* output the surrogate pair, will overflow (see conditions comment above) */
source+=2;
length-=2;
}
if(s+2>sourceLimit) {
- /* only one byte: truncated UChar */
+ /* only one byte: truncated char16_t */
pArgs->converter->toUBytes[0]=*s++;
pArgs->converter->toULength=1;
pArgs->source=(const char *)s;
return 0xffff;
}
- /* get one UChar */
+ /* get one char16_t */
c=((UChar32)s[1]<<8)|*s;
s+=2;
if(U_IS_SURROGATE(c)) {
if(U16_IS_SURROGATE_LEAD(c)) {
if(s+2<=sourceLimit) {
- UChar trail;
+ char16_t trail;
- /* get a second UChar and see if it is a trail surrogate */
- trail=((UChar)s[1]<<8)|*s;
+ /* get a second char16_t and see if it is a trail surrogate */
+ trail=((char16_t)s[1]<<8)|*s;
if(U16_IS_TRAIL(trail)) {
c=U16_GET_SUPPLEMENTARY(c, trail);
s+=2;
UErrorCode * err)
{
const unsigned char *mySource = (unsigned char *) args->source;
- UChar *myTarget = args->target;
+ char16_t *myTarget = args->target;
const unsigned char *sourceLimit = (unsigned char *) args->sourceLimit;
- const UChar *targetLimit = args->targetLimit;
+ const char16_t *targetLimit = args->targetLimit;
unsigned char *toUBytes = args->converter->toUBytes;
uint32_t ch, i;
if (ch <= MAXIMUM_UCS2)
{
/* fits in 16 bits */
- *(myTarget++) = (UChar) ch;
+ *(myTarget++) = (char16_t) ch;
}
else {
/* write out the surrogates */
*(myTarget++) = U16_LEAD(ch);
ch = U16_TRAIL(ch);
if (myTarget < targetLimit) {
- *(myTarget++) = (UChar)ch;
+ *(myTarget++) = (char16_t)ch;
}
else {
/* Put in overflow buffer (not handled here) */
- args->converter->UCharErrorBuffer[0] = (UChar) ch;
+ args->converter->UCharErrorBuffer[0] = (char16_t) ch;
args->converter->UCharErrorBufferLength = 1;
*err = U_BUFFER_OVERFLOW_ERROR;
break;
UErrorCode * err)
{
const unsigned char *mySource = (unsigned char *) args->source;
- UChar *myTarget = args->target;
+ char16_t *myTarget = args->target;
int32_t *myOffsets = args->offsets;
const unsigned char *sourceLimit = (unsigned char *) args->sourceLimit;
- const UChar *targetLimit = args->targetLimit;
+ const char16_t *targetLimit = args->targetLimit;
unsigned char *toUBytes = args->converter->toUBytes;
uint32_t ch, i;
int32_t offsetNum = 0;
/* Normal valid byte when the loop has not prematurely terminated (i < inBytes) */
if (ch <= MAXIMUM_UCS2) {
/* fits in 16 bits */
- *(myTarget++) = (UChar) ch;
+ *(myTarget++) = (char16_t) ch;
*(myOffsets++) = offsetNum;
}
else {
ch = U16_TRAIL(ch);
if (myTarget < targetLimit)
{
- *(myTarget++) = (UChar)ch;
+ *(myTarget++) = (char16_t)ch;
*(myOffsets++) = offsetNum;
}
else {
/* Put in overflow buffer (not handled here) */
- args->converter->UCharErrorBuffer[0] = (UChar) ch;
+ args->converter->UCharErrorBuffer[0] = (char16_t) ch;
args->converter->UCharErrorBufferLength = 1;
*err = U_BUFFER_OVERFLOW_ERROR;
break;
T_UConverter_fromUnicode_UTF32_BE(UConverterFromUnicodeArgs * args,
UErrorCode * err)
{
- const UChar *mySource = args->source;
+ const char16_t *mySource = args->source;
unsigned char *myTarget;
- const UChar *sourceLimit = args->sourceLimit;
+ const char16_t *sourceLimit = args->sourceLimit;
const unsigned char *targetLimit = (unsigned char *) args->targetLimit;
UChar32 ch, ch2;
unsigned int indexToWrite;
T_UConverter_fromUnicode_UTF32_BE_OFFSET_LOGIC(UConverterFromUnicodeArgs * args,
UErrorCode * err)
{
- const UChar *mySource = args->source;
+ const char16_t *mySource = args->source;
unsigned char *myTarget;
int32_t *myOffsets;
- const UChar *sourceLimit = args->sourceLimit;
+ const char16_t *sourceLimit = args->sourceLimit;
const unsigned char *targetLimit = (unsigned char *) args->targetLimit;
UChar32 ch, ch2;
int32_t offsetNum = 0;
UErrorCode * err)
{
const unsigned char *mySource = (unsigned char *) args->source;
- UChar *myTarget = args->target;
+ char16_t *myTarget = args->target;
const unsigned char *sourceLimit = (unsigned char *) args->sourceLimit;
- const UChar *targetLimit = args->targetLimit;
+ const char16_t *targetLimit = args->targetLimit;
unsigned char *toUBytes = args->converter->toUBytes;
uint32_t ch, i;
/* Normal valid byte when the loop has not prematurely terminated (i < inBytes) */
if (ch <= MAXIMUM_UCS2) {
/* fits in 16 bits */
- *(myTarget++) = (UChar) ch;
+ *(myTarget++) = (char16_t) ch;
}
else {
/* write out the surrogates */
*(myTarget++) = U16_LEAD(ch);
ch = U16_TRAIL(ch);
if (myTarget < targetLimit) {
- *(myTarget++) = (UChar)ch;
+ *(myTarget++) = (char16_t)ch;
}
else {
/* Put in overflow buffer (not handled here) */
- args->converter->UCharErrorBuffer[0] = (UChar) ch;
+ args->converter->UCharErrorBuffer[0] = (char16_t) ch;
args->converter->UCharErrorBufferLength = 1;
*err = U_BUFFER_OVERFLOW_ERROR;
break;
UErrorCode * err)
{
const unsigned char *mySource = (unsigned char *) args->source;
- UChar *myTarget = args->target;
+ char16_t *myTarget = args->target;
int32_t *myOffsets = args->offsets;
const unsigned char *sourceLimit = (unsigned char *) args->sourceLimit;
- const UChar *targetLimit = args->targetLimit;
+ const char16_t *targetLimit = args->targetLimit;
unsigned char *toUBytes = args->converter->toUBytes;
uint32_t ch, i;
int32_t offsetNum = 0;
if (ch <= MAXIMUM_UCS2)
{
/* fits in 16 bits */
- *(myTarget++) = (UChar) ch;
+ *(myTarget++) = (char16_t) ch;
*(myOffsets++) = offsetNum;
}
else {
ch = U16_TRAIL(ch);
if (myTarget < targetLimit)
{
- *(myTarget++) = (UChar)ch;
+ *(myTarget++) = (char16_t)ch;
*(myOffsets++) = offsetNum;
}
else
{
/* Put in overflow buffer (not handled here) */
- args->converter->UCharErrorBuffer[0] = (UChar) ch;
+ args->converter->UCharErrorBuffer[0] = (char16_t) ch;
args->converter->UCharErrorBufferLength = 1;
*err = U_BUFFER_OVERFLOW_ERROR;
break;
T_UConverter_fromUnicode_UTF32_LE(UConverterFromUnicodeArgs * args,
UErrorCode * err)
{
- const UChar *mySource = args->source;
+ const char16_t *mySource = args->source;
unsigned char *myTarget;
- const UChar *sourceLimit = args->sourceLimit;
+ const char16_t *sourceLimit = args->sourceLimit;
const unsigned char *targetLimit = (unsigned char *) args->targetLimit;
UChar32 ch, ch2;
unsigned int indexToWrite;
T_UConverter_fromUnicode_UTF32_LE_OFFSET_LOGIC(UConverterFromUnicodeArgs * args,
UErrorCode * err)
{
- const UChar *mySource = args->source;
+ const char16_t *mySource = args->source;
unsigned char *myTarget;
int32_t *myOffsets;
- const UChar *sourceLimit = args->sourceLimit;
+ const char16_t *sourceLimit = args->sourceLimit;
const unsigned char *targetLimit = (unsigned char *) args->targetLimit;
UChar32 ch, ch2;
unsigned int indexToWrite;
UErrorCode *pErrorCode) {
UConverter *cnv;
const uint8_t *source, *sourceLimit;
- UChar *target;
- const UChar *targetLimit;
+ char16_t *target;
+ const char16_t *targetLimit;
int32_t *offsets;
uint8_t *bytes;
* base64Value==-1 for any legal character except base64 and minus sign, or
* base64Value==-3 for illegal characters:
* 1. In either case, leave Unicode mode.
- * 2.1. If we ended with an incomplete UChar or none after the +, then
+ * 2.1. If we ended with an incomplete char16_t or none after the +, then
* generate an error for the preceding erroneous sequence and deal with
* the current (possibly illegal) character next time through.
- * 2.2. Else the current char comes after a complete UChar, which was already
+ * 2.2. Else the current char comes after a complete char16_t, which was already
* pushed to the output buf, so:
* 2.2.1. If the current char is legal, just save it for processing next time.
* It may be for example, a plus which we need to deal with in direct mode.
*pErrorCode=U_ILLEGAL_CHAR_FOUND;
break;
} else if(bits!=0) {
- /* bits are illegally left over, a UChar is incomplete */
+ /* bits are illegally left over, a char16_t is incomplete */
/* don't include current char (legal or illegal) in error seq */
--source;
--byteIndex;
*pErrorCode=U_ILLEGAL_CHAR_FOUND;
break;
} else {
- /* previous UChar was complete */
+ /* previous char16_t was complete */
if(base64Value==-3) {
/* current character is illegal, deal with it here */
*pErrorCode=U_ILLEGAL_CHAR_FOUND;
++base64Counter;
break;
case 2:
- *target++=(UChar)((bits<<4)|(base64Value>>2));
+ *target++=(char16_t)((bits<<4)|(base64Value>>2));
if(offsets!=nullptr) {
*offsets++=sourceIndex;
sourceIndex=nextSourceIndex-1;
base64Counter=3;
break;
case 5:
- *target++=(UChar)((bits<<2)|(base64Value>>4));
+ *target++=(char16_t)((bits<<2)|(base64Value>>4));
if(offsets!=nullptr) {
*offsets++=sourceIndex;
sourceIndex=nextSourceIndex-1;
base64Counter=6;
break;
case 7:
- *target++=(UChar)((bits<<6)|base64Value);
+ *target++=(char16_t)((bits<<6)|base64Value);
if(offsets!=nullptr) {
*offsets++=sourceIndex;
sourceIndex=nextSourceIndex;
} else {
/* absorb the minus and leave the Unicode Mode */
if(bits!=0) {
- /* bits are illegally left over, a UChar is incomplete */
+ /* bits are illegally left over, a char16_t is incomplete */
*pErrorCode=U_ILLEGAL_CHAR_FOUND;
break;
}
_UTF7FromUnicodeWithOffsets(UConverterFromUnicodeArgs *pArgs,
UErrorCode *pErrorCode) {
UConverter *cnv;
- const UChar *source, *sourceLimit;
+ const char16_t *source, *sourceLimit;
uint8_t *target, *targetLimit;
int32_t *offsets;
int32_t length, targetCapacity, sourceIndex;
- UChar c;
+ char16_t c;
/* UTF-7 state */
const UBool *encodeDirectly;
UErrorCode *pErrorCode) {
UConverter *cnv;
const uint8_t *source, *sourceLimit;
- UChar *target;
- const UChar *targetLimit;
+ char16_t *target;
+ const char16_t *targetLimit;
int32_t *offsets;
uint8_t *bytes;
int32_t sourceIndex, nextSourceIndex;
- UChar c;
+ char16_t c;
uint8_t b;
/* set up the local pointers */
++base64Counter;
break;
case 2:
- c=(UChar)((bits<<4)|(base64Value>>2));
+ c=(char16_t)((bits<<4)|(base64Value>>2));
if(isLegalIMAP(c)) {
/* illegal */
inDirectMode=true;
base64Counter=3;
break;
case 5:
- c=(UChar)((bits<<2)|(base64Value>>4));
+ c=(char16_t)((bits<<2)|(base64Value>>4));
if(isLegalIMAP(c)) {
/* illegal */
inDirectMode=true;
base64Counter=6;
break;
case 7:
- c=(UChar)((bits<<6)|base64Value);
+ c=(char16_t)((bits<<6)|base64Value);
if(isLegalIMAP(c)) {
/* illegal */
inDirectMode=true;
} else {
/* absorb the minus and leave the Unicode Mode */
if(bits!=0 || (base64Counter!=0 && base64Counter!=3 && base64Counter!=6)) {
- /* bits are illegally left over, a UChar is incomplete */
+ /* bits are illegally left over, a char16_t is incomplete */
/* base64Counter other than 0, 3, 6 means non-minimal zero-padding, also illegal */
*pErrorCode=U_ILLEGAL_CHAR_FOUND;
break;
_IMAPFromUnicodeWithOffsets(UConverterFromUnicodeArgs *pArgs,
UErrorCode *pErrorCode) {
UConverter *cnv;
- const UChar *source, *sourceLimit;
+ const char16_t *source, *sourceLimit;
uint8_t *target, *targetLimit;
int32_t *offsets;
int32_t length, targetCapacity, sourceIndex;
- UChar c;
+ char16_t c;
uint8_t b;
/* UTF-7 state */
{
UConverter *cnv = args->converter;
const unsigned char *mySource = (unsigned char *) args->source;
- UChar *myTarget = args->target;
+ char16_t *myTarget = args->target;
const unsigned char *sourceLimit = (unsigned char *) args->sourceLimit;
- const UChar *targetLimit = args->targetLimit;
+ const char16_t *targetLimit = args->targetLimit;
unsigned char *toUBytes = cnv->toUBytes;
UBool isCESU8 = hasCESU8Data(cnv);
uint32_t ch, ch2 = 0;
ch = *(mySource++);
if (U8_IS_SINGLE(ch)) /* Simple case */
{
- *(myTarget++) = (UChar) ch;
+ *(myTarget++) = (char16_t) ch;
}
else
{
if (ch <= MAXIMUM_UCS2)
{
/* fits in 16 bits */
- *(myTarget++) = (UChar) ch;
+ *(myTarget++) = (char16_t) ch;
}
else
{
ch = U16_TRAIL(ch);
if (myTarget < targetLimit)
{
- *(myTarget++) = (UChar)ch;
+ *(myTarget++) = (char16_t)ch;
}
else
{
/* Put in overflow buffer (not handled here) */
- cnv->UCharErrorBuffer[0] = (UChar) ch;
+ cnv->UCharErrorBuffer[0] = (char16_t) ch;
cnv->UCharErrorBufferLength = 1;
*err = U_BUFFER_OVERFLOW_ERROR;
break;
{
UConverter *cnv = args->converter;
const unsigned char *mySource = (unsigned char *) args->source;
- UChar *myTarget = args->target;
+ char16_t *myTarget = args->target;
int32_t *myOffsets = args->offsets;
int32_t offsetNum = 0;
const unsigned char *sourceLimit = (unsigned char *) args->sourceLimit;
- const UChar *targetLimit = args->targetLimit;
+ const char16_t *targetLimit = args->targetLimit;
unsigned char *toUBytes = cnv->toUBytes;
UBool isCESU8 = hasCESU8Data(cnv);
uint32_t ch, ch2 = 0;
ch = *(mySource++);
if (U8_IS_SINGLE(ch)) /* Simple case */
{
- *(myTarget++) = (UChar) ch;
+ *(myTarget++) = (char16_t) ch;
*(myOffsets++) = offsetNum++;
}
else
if (ch <= MAXIMUM_UCS2)
{
/* fits in 16 bits */
- *(myTarget++) = (UChar) ch;
+ *(myTarget++) = (char16_t) ch;
*(myOffsets++) = offsetNum;
}
else
ch = U16_TRAIL(ch);
if (myTarget < targetLimit)
{
- *(myTarget++) = (UChar)ch;
+ *(myTarget++) = (char16_t)ch;
*(myOffsets++) = offsetNum;
}
else
{
- cnv->UCharErrorBuffer[0] = (UChar) ch;
+ cnv->UCharErrorBuffer[0] = (char16_t) ch;
cnv->UCharErrorBufferLength = 1;
*err = U_BUFFER_OVERFLOW_ERROR;
}
UErrorCode * err)
{
UConverter *cnv = args->converter;
- const UChar *mySource = args->source;
- const UChar *sourceLimit = args->sourceLimit;
+ const char16_t *mySource = args->source;
+ const char16_t *sourceLimit = args->sourceLimit;
uint8_t *myTarget = (uint8_t *) args->target;
const uint8_t *targetLimit = (uint8_t *) args->targetLimit;
uint8_t *tempPtr;
UErrorCode * err)
{
UConverter *cnv = args->converter;
- const UChar *mySource = args->source;
+ const char16_t *mySource = args->source;
int32_t *myOffsets = args->offsets;
- const UChar *sourceLimit = args->sourceLimit;
+ const char16_t *sourceLimit = args->sourceLimit;
uint8_t *myTarget = (uint8_t *) args->target;
const uint8_t *targetLimit = (uint8_t *) args->targetLimit;
uint8_t *tempPtr;
sizeof(UConverterStaticData),
"UTF-8",
1208, UCNV_IBM, UCNV_UTF8,
- 1, 3, /* max 3 bytes per UChar from UTF-8 (4 bytes from surrogate _pair_) */
+ 1, 3, /* max 3 bytes per char16_t from UTF-8 (4 bytes from surrogate _pair_) */
{ 0xef, 0xbf, 0xbd, 0 },3,false,false,
0,
0,
_Bocu1FromUnicodeWithOffsets(UConverterFromUnicodeArgs *pArgs,
UErrorCode *pErrorCode) {
UConverter *cnv;
- const UChar *source, *sourceLimit;
+ const char16_t *source, *sourceLimit;
uint8_t *target;
int32_t targetCapacity;
int32_t *offsets;
getTrail:
if(source<sourceLimit) {
/* test the following code unit */
- UChar trail=*source;
+ char16_t trail=*source;
if(U16_IS_TRAIL(trail)) {
++source;
++nextSourceIndex;
_Bocu1FromUnicode(UConverterFromUnicodeArgs *pArgs,
UErrorCode *pErrorCode) {
UConverter *cnv;
- const UChar *source, *sourceLimit;
+ const char16_t *source, *sourceLimit;
uint8_t *target;
int32_t targetCapacity;
getTrail:
if(source<sourceLimit) {
/* test the following code unit */
- UChar trail=*source;
+ char16_t trail=*source;
if(U16_IS_TRAIL(trail)) {
++source;
c=U16_GET_SUPPLEMENTARY(c, trail);
UErrorCode *pErrorCode) {
UConverter *cnv;
const uint8_t *source, *sourceLimit;
- UChar *target;
- const UChar *targetLimit;
+ char16_t *target;
+ const char16_t *targetLimit;
int32_t *offsets;
int32_t prev, count, diff, c;
if(BOCU1_START_NEG_2<=(c=*source) && c<BOCU1_START_POS_2) {
c=prev+(c-BOCU1_MIDDLE);
if(c<0x3000) {
- *target++=(UChar)c;
+ *target++=(char16_t)c;
*offsets++=nextSourceIndex++;
prev=BOCU1_SIMPLE_PREV(c);
} else {
if(c!=0x20) {
prev=BOCU1_ASCII_PREV;
}
- *target++=(UChar)c;
+ *target++=(char16_t)c;
*offsets++=nextSourceIndex++;
} else {
break;
/* Write a code point directly from a single-byte difference. */
c=prev+(c-BOCU1_MIDDLE);
if(c<0x3000) {
- *target++=(UChar)c;
+ *target++=(char16_t)c;
*offsets++=sourceIndex;
prev=BOCU1_SIMPLE_PREV(c);
sourceIndex=nextSourceIndex;
if(c!=0x20) {
prev=BOCU1_ASCII_PREV;
}
- *target++=(UChar)c;
+ *target++=(char16_t)c;
*offsets++=sourceIndex;
sourceIndex=nextSourceIndex;
continue;
/* calculate the next prev and output c */
prev=BOCU1_PREV(c);
if(c<=0xffff) {
- *target++=(UChar)c;
+ *target++=(char16_t)c;
*offsets++=sourceIndex;
} else {
/* output surrogate pair */
UErrorCode *pErrorCode) {
UConverter *cnv;
const uint8_t *source, *sourceLimit;
- UChar *target;
- const UChar *targetLimit;
+ char16_t *target;
+ const char16_t *targetLimit;
int32_t prev, count, diff, c;
if(BOCU1_START_NEG_2<=(c=*source) && c<BOCU1_START_POS_2) {
c=prev+(c-BOCU1_MIDDLE);
if(c<0x3000) {
- *target++=(UChar)c;
+ *target++=(char16_t)c;
prev=BOCU1_SIMPLE_PREV(c);
} else {
break;
if(c!=0x20) {
prev=BOCU1_ASCII_PREV;
}
- *target++=(UChar)c;
+ *target++=(char16_t)c;
} else {
break;
}
/* Write a code point directly from a single-byte difference. */
c=prev+(c-BOCU1_MIDDLE);
if(c<0x3000) {
- *target++=(UChar)c;
+ *target++=(char16_t)c;
prev=BOCU1_SIMPLE_PREV(c);
goto fastSingle;
}
if(c!=0x20) {
prev=BOCU1_ASCII_PREV;
}
- *target++=(UChar)c;
+ *target++=(char16_t)c;
continue;
} else if(BOCU1_START_NEG_3<=c && c<BOCU1_START_POS_3 && source<sourceLimit) {
/* Optimize two-byte case. */
/* calculate the next prev and output c */
prev=BOCU1_PREV(c);
if(c<=0xffff) {
- *target++=(UChar)c;
+ *target++=(char16_t)c;
} else {
/* output surrogate pair */
*target++=U16_LEAD(c);
"BOCU-1",
1214, /* CCSID for BOCU-1 */
UCNV_IBM, UCNV_BOCU1,
- 1, 4, /* one UChar generates at least 1 byte and at most 4 bytes */
+ 1, 4, /* one char16_t generates at least 1 byte and at most 4 bytes */
{ 0x1a, 0, 0, 0 }, 1, /* BOCU-1 never needs to write a subchar */
false, false,
0,
U_CAPI int32_t U_EXPORT2
ucnv_getDisplayName(const UConverter *cnv,
const char *displayLocale,
- UChar *displayName, int32_t displayNameCapacity,
+ char16_t *displayName, int32_t displayNameCapacity,
UErrorCode *pErrorCode) {
UResourceBundle *rb;
- const UChar *name;
+ const char16_t *name;
int32_t length;
UErrorCode localStatus = U_ZERO_ERROR;
UErrorCode* err){
char tempBuf[2];
const char *mySource = ( char *) args->source;
- UChar *myTarget = args->target;
+ char16_t *myTarget = args->target;
const char *mySourceLimit = args->sourceLimit;
UChar32 targetUniChar = 0x0000;
int32_t mySourceChar = 0x0000;
if(args->offsets) {
args->offsets[myTarget - args->target]=(int32_t)(mySource - args->source - 2);
}
- *(myTarget++)=(UChar)mySourceChar;
+ *(myTarget++)=(char16_t)mySourceChar;
myData->isEmptySegment = false;
continue;
case UCNV_OPEN_BRACE:
args->converter->mode = UCNV_TILDE;
continue;
} else if(mySourceChar <= 0x7f) {
- targetUniChar = (UChar)mySourceChar; /* ASCII */
+ targetUniChar = (char16_t)mySourceChar; /* ASCII */
myData->isEmptySegment = false; /* the segment has something valid */
} else {
targetUniChar = 0xffff;
args->offsets[myTarget - args->target]=(int32_t)(mySource - args->source - 1-(myData->isStateDBCS));
}
- *(myTarget++)=(UChar)targetUniChar;
+ *(myTarget++)=(char16_t)targetUniChar;
}
else /* targetUniChar>=0xfffe */ {
if(targetUniChar == 0xfffe){
static void U_CALLCONV
UConverter_fromUnicode_HZ_OFFSETS_LOGIC (UConverterFromUnicodeArgs * args,
UErrorCode * err){
- const UChar *mySource = args->source;
+ const char16_t *mySource = args->source;
char *myTarget = args->target;
int32_t* offsets = args->offsets;
int32_t mySourceIndex = 0;
targetUniChar = missingCharMarker;
if (myTargetIndex < targetLength){
- mySourceChar = (UChar) mySource[mySourceIndex++];
+ mySourceChar = (char16_t) mySource[mySourceIndex++];
oldIsTargetUCharDBCS = isTargetUCharDBCS;
/*look ahead to find the trail surrogate*/
if(mySourceIndex < mySourceLength) {
/* test the following code unit */
- UChar trail=(UChar) args->source[mySourceIndex];
+ char16_t trail=(char16_t) args->source[mySourceIndex];
if(U16_IS_TRAIL(trail)) {
++mySourceIndex;
mySourceChar=U16_GET_SUPPLEMENTARY(args->converter->fromUChar32, trail);
#define ISCII_CNV_PREFIX "ISCII,version="
typedef struct {
- UChar contextCharToUnicode; /* previous Unicode codepoint for contextual analysis */
- UChar contextCharFromUnicode; /* previous Unicode codepoint for contextual analysis */
+ char16_t contextCharToUnicode; /* previous Unicode codepoint for contextual analysis */
+ char16_t contextCharFromUnicode; /* previous Unicode codepoint for contextual analysis */
uint16_t defDeltaToUnicode; /* delta for switching to default state when DEF is encountered */
uint16_t currentDeltaFromUnicode; /* current delta in Indic block */
uint16_t currentDeltaToUnicode; /* current delta in Indic block */
static void U_CALLCONV
UConverter_fromUnicode_ISCII_OFFSETS_LOGIC(
UConverterFromUnicodeArgs * args, UErrorCode * err) {
- const UChar *source = args->source;
- const UChar *sourceLimit = args->sourceLimit;
+ const char16_t *source = args->source;
+ const char16_t *sourceLimit = args->sourceLimit;
unsigned char *target = (unsigned char *) args->target;
unsigned char *targetLimit = (unsigned char *) args->targetLimit;
int32_t* offsets = args->offsets;
}
} else if (targetByteUnit != missingCharMarker) {
if (targetByteUnit==ISCII_HALANT) {
- converterData->contextCharFromUnicode = (UChar)targetByteUnit;
+ converterData->contextCharFromUnicode = (char16_t)targetByteUnit;
}
/* write targetByteUnit to target*/
WRITE_TO_TARGET_FROM_U(args,offsets,source,target,targetLimit,targetByteUnit,err);
/*look ahead to find the trail surrogate*/
if (source < sourceLimit) {
/* test the following code unit */
- UChar trail= (*source);
+ char16_t trail= (*source);
if (U16_IS_TRAIL(trail)) {
source++;
sourceChar=U16_GET_SUPPLEMENTARY(sourceChar, trail);
} \
/* now write the targetUniChar */ \
if(target<args->targetLimit){ \
- *(target)++ = (UChar)targetUniChar; \
+ *(target)++ = (char16_t)targetUniChar; \
if(offsets){ \
*(offsets)++ = (int32_t)(offset); \
} \
}else{ \
args->converter->UCharErrorBuffer[args->converter->UCharErrorBufferLength++] = \
- (UChar)targetUniChar; \
+ (char16_t)targetUniChar; \
*err = U_BUFFER_OVERFLOW_ERROR; \
} \
} UPRV_BLOCK_MACRO_END
static void U_CALLCONV
UConverter_toUnicode_ISCII_OFFSETS_LOGIC(UConverterToUnicodeArgs *args, UErrorCode* err) {
const char *source = ( char *) args->source;
- UChar *target = args->target;
+ char16_t *target = args->target;
const char *sourceLimit = args->sourceLimit;
- const UChar* targetLimit = args->targetLimit;
+ const char16_t* targetLimit = args->targetLimit;
uint32_t targetUniChar = 0x0000;
uint8_t sourceChar = 0x0000;
UConverterDataISCII* data;
UChar32* toUnicodeStatus=nullptr;
UChar32 tempTargetUniChar = 0x0000;
- UChar* contextCharToUnicode= nullptr;
+ char16_t* contextCharToUnicode= nullptr;
UBool found;
int i;
int offset = 0;
case ISCII_INV:
case EXT:
case ATR:
- *contextCharToUnicode = (UChar)sourceChar;
+ *contextCharToUnicode = (char16_t)sourceChar;
if (*toUnicodeStatus != missingCharMarker) {
/* Write the previous toUnicodeStatus, this was delayed to handle consonant clustering for Gurmukhi script. */
if (targetUniChar != missingCharMarker) {
/* now save the targetUniChar for delayed write */
- *toUnicodeStatus = (UChar) targetUniChar;
+ *toUnicodeStatus = (char16_t) targetUniChar;
if (data->resetToDefaultToUnicode) {
data->currentDeltaToUnicode = data->defDeltaToUnicode;
data->currentMaskToUnicode = data->defMaskToUnicode;
_Latin1ToUnicodeWithOffsets(UConverterToUnicodeArgs *pArgs,
UErrorCode *pErrorCode) {
const uint8_t *source;
- UChar *target;
+ char16_t *target;
int32_t targetCapacity, length;
int32_t *offsets;
sourceIndex=0;
/*
- * since the conversion here is 1:1 UChar:uint8_t, we need only one counter
+ * since the conversion here is 1:1 char16_t:uint8_t, we need only one counter
* for the minimum of the sourceLength and targetCapacity
*/
length=(int32_t)((const uint8_t *)pArgs->sourceLimit-source);
_Latin1FromUnicodeWithOffsets(UConverterFromUnicodeArgs *pArgs,
UErrorCode *pErrorCode) {
UConverter *cnv;
- const UChar *source, *sourceLimit;
+ const char16_t *source, *sourceLimit;
uint8_t *target, *oldTarget;
int32_t targetCapacity, length;
int32_t *offsets;
UChar32 cp;
- UChar c, max;
+ char16_t c, max;
int32_t sourceIndex;
sourceIndex= cp==0 ? 0 : -1;
/*
- * since the conversion here is 1:1 UChar:uint8_t, we need only one counter
+ * since the conversion here is 1:1 char16_t:uint8_t, we need only one counter
* for the minimum of the sourceLength and targetCapacity
*/
length=(int32_t)(sourceLimit-source);
/* unroll the loop with the most common case */
if(targetCapacity>=16) {
int32_t count, loops;
- UChar u, oredChars;
+ char16_t u, oredChars;
loops=count=targetCapacity>>4;
do {
getTrail:
if(source<sourceLimit) {
/* test the following code unit */
- UChar trail=*source;
+ char16_t trail=*source;
if(U16_IS_TRAIL(trail)) {
++source;
cp=U16_GET_SUPPLEMENTARY(cp, trail);
_ASCIIToUnicodeWithOffsets(UConverterToUnicodeArgs *pArgs,
UErrorCode *pErrorCode) {
const uint8_t *source, *sourceLimit;
- UChar *target, *oldTarget;
+ char16_t *target, *oldTarget;
int32_t targetCapacity, length;
int32_t *offsets;
sourceIndex=0;
/*
- * since the conversion here is 1:1 UChar:uint8_t, we need only one counter
+ * since the conversion here is 1:1 char16_t:uint8_t, we need only one counter
* for the minimum of the sourceLength and targetCapacity
*/
length=(int32_t)(sourceLimit-source);
if(targetCapacity>=8) {
/* This loop is unrolled for speed and improved pipelining. */
int32_t count, loops;
- UChar oredChars;
+ char16_t oredChars;
loops=count=targetCapacity>>3;
do {
action=MBCS_ENTRY_FINAL_ACTION(entry);
if(action==MBCS_STATE_VALID_DIRECT_16) {
/* output BMP code point */
- c=(UChar)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ c=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
} else if(action==MBCS_STATE_VALID_16) {
int32_t finalOffset=offset+MBCS_ENTRY_FINAL_VALUE_16(entry);
c=unicodeCodeUnits[finalOffset];
static UChar32
_extFromU(UConverter *cnv, const UConverterSharedData *sharedData,
UChar32 cp,
- const UChar **source, const UChar *sourceLimit,
+ const char16_t **source, const char16_t *sourceLimit,
uint8_t **target, const uint8_t *targetLimit,
int32_t **offsets, int32_t sourceIndex,
UBool flush,
_extToU(UConverter *cnv, const UConverterSharedData *sharedData,
int8_t length,
const uint8_t **source, const uint8_t *sourceLimit,
- UChar **target, const UChar *targetLimit,
+ char16_t **target, const char16_t *targetLimit,
int32_t **offsets, int32_t sourceIndex,
UBool flush,
UErrorCode *pErrorCode) {
mbcsTable->mbcsIndex=(const uint16_t *)
(mbcsTable->fromUnicodeBytes+
(noFromU ? 0 : mbcsTable->fromUBytesLength));
- mbcsTable->maxFastUChar=(((UChar)header->version[2])<<8)|0xff;
+ mbcsTable->maxFastUChar=(((char16_t)header->version[2])<<8)|0xff;
}
}
UErrorCode *pErrorCode) {
UConverter *cnv;
const uint8_t *source, *sourceLimit;
- UChar *target;
- const UChar *targetLimit;
+ char16_t *target;
+ const char16_t *targetLimit;
int32_t *offsets;
const int32_t (*stateTable)[256];
int32_t sourceIndex;
int32_t entry;
- UChar c;
+ char16_t c;
uint8_t action;
/* set up the local pointers */
/* test the most common case first */
if(MBCS_ENTRY_FINAL_IS_VALID_DIRECT_16(entry)) {
/* output BMP code point */
- *target++=(UChar)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
if(offsets!=nullptr) {
*offsets++=sourceIndex;
}
) {
entry=MBCS_ENTRY_FINAL_VALUE(entry);
/* output surrogate pair */
- *target++=(UChar)(0xd800|(UChar)(entry>>10));
+ *target++=(char16_t)(0xd800|(char16_t)(entry>>10));
if(offsets!=nullptr) {
*offsets++=sourceIndex;
}
- c=(UChar)(0xdc00|(UChar)(entry&0x3ff));
+ c=(char16_t)(0xdc00|(char16_t)(entry&0x3ff));
if(target<targetLimit) {
*target++=c;
if(offsets!=nullptr) {
} else if(action==MBCS_STATE_FALLBACK_DIRECT_16) {
if(UCNV_TO_U_USE_FALLBACK(cnv)) {
/* output BMP code point */
- *target++=(UChar)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
if(offsets!=nullptr) {
*offsets++=sourceIndex;
}
UErrorCode *pErrorCode) {
UConverter *cnv;
const uint8_t *source, *sourceLimit, *lastSource;
- UChar *target;
+ char16_t *target;
int32_t targetCapacity, length;
int32_t *offsets;
lastSource=source;
/*
- * since the conversion here is 1:1 UChar:uint8_t, we need only one counter
+ * since the conversion here is 1:1 char16_t:uint8_t, we need only one counter
* for the minimum of the sourceLength and targetCapacity
*/
length=(int32_t)(sourceLimit-source);
loops=count=targetCapacity>>4;
do {
oredEntries=entry=stateTable[0][*source++];
- *target++=(UChar)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
oredEntries|=entry=stateTable[0][*source++];
- *target++=(UChar)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
oredEntries|=entry=stateTable[0][*source++];
- *target++=(UChar)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
oredEntries|=entry=stateTable[0][*source++];
- *target++=(UChar)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
oredEntries|=entry=stateTable[0][*source++];
- *target++=(UChar)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
oredEntries|=entry=stateTable[0][*source++];
- *target++=(UChar)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
oredEntries|=entry=stateTable[0][*source++];
- *target++=(UChar)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
oredEntries|=entry=stateTable[0][*source++];
- *target++=(UChar)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
oredEntries|=entry=stateTable[0][*source++];
- *target++=(UChar)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
oredEntries|=entry=stateTable[0][*source++];
- *target++=(UChar)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
oredEntries|=entry=stateTable[0][*source++];
- *target++=(UChar)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
oredEntries|=entry=stateTable[0][*source++];
- *target++=(UChar)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
oredEntries|=entry=stateTable[0][*source++];
- *target++=(UChar)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
oredEntries|=entry=stateTable[0][*source++];
- *target++=(UChar)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
oredEntries|=entry=stateTable[0][*source++];
- *target++=(UChar)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
oredEntries|=entry=stateTable[0][*source++];
- *target++=(UChar)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
/* were all 16 entries really valid? */
if(!MBCS_ENTRY_FINAL_IS_VALID_DIRECT_16(oredEntries)) {
/* test the most common case first */
if(MBCS_ENTRY_FINAL_IS_VALID_DIRECT_16(entry)) {
/* output BMP code point */
- *target++=(UChar)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
--targetCapacity;
continue;
}
if(action==MBCS_STATE_FALLBACK_DIRECT_16) {
if(UCNV_TO_U_USE_FALLBACK(cnv)) {
/* output BMP code point */
- *target++=(UChar)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
--targetCapacity;
continue;
}
UErrorCode *pErrorCode) {
UConverter *cnv;
const uint8_t *source, *sourceLimit;
- UChar *target;
- const UChar *targetLimit;
+ char16_t *target;
+ const char16_t *targetLimit;
int32_t *offsets;
const int32_t (*stateTable)[256];
int32_t sourceIndex, nextSourceIndex;
int32_t entry;
- UChar c;
+ char16_t c;
uint8_t action;
/* use optimized function if possible */
if(MBCS_ENTRY_FINAL_IS_VALID_DIRECT_16(entry)) {
/* output BMP code point */
++source;
- *target++=(UChar)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
state=(uint8_t)MBCS_ENTRY_FINAL_STATE(entry); /* typically 0 */
} else {
/* leave the optimized loop */
if(MBCS_ENTRY_FINAL_IS_VALID_DIRECT_16(entry)) {
/* output BMP code point */
++source;
- *target++=(UChar)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
if(offsets!=nullptr) {
*offsets++=sourceIndex;
sourceIndex=++nextSourceIndex;
} else if(c==0xfffe) {
if(UCNV_TO_U_USE_FALLBACK(cnv) && (entry=(int32_t)ucnv_MBCSGetFallback(&cnv->sharedData->mbcs, offset))!=0xfffe) {
/* output fallback BMP code point */
- *target++=(UChar)entry;
+ *target++=(char16_t)entry;
if(offsets!=nullptr) {
*offsets++=sourceIndex;
}
}
} else if(action==MBCS_STATE_VALID_DIRECT_16) {
/* output BMP code point */
- *target++=(UChar)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
if(offsets!=nullptr) {
*offsets++=sourceIndex;
}
byteIndex=0;
} else if(UCNV_TO_U_USE_FALLBACK(cnv) ? c<=0xdfff : c<=0xdbff) {
/* output roundtrip or fallback surrogate pair */
- *target++=(UChar)(c&0xdbff);
+ *target++=(char16_t)(c&0xdbff);
if(offsets!=nullptr) {
*offsets++=sourceIndex;
}
) {
entry=MBCS_ENTRY_FINAL_VALUE(entry);
/* output surrogate pair */
- *target++=(UChar)(0xd800|(UChar)(entry>>10));
+ *target++=(char16_t)(0xd800|(char16_t)(entry>>10));
if(offsets!=nullptr) {
*offsets++=sourceIndex;
}
byteIndex=0;
- c=(UChar)(0xdc00|(UChar)(entry&0x3ff));
+ c=(char16_t)(0xdc00|(char16_t)(entry&0x3ff));
if(target<targetLimit) {
*target++=c;
if(offsets!=nullptr) {
} else if(action==MBCS_STATE_FALLBACK_DIRECT_16) {
if(UCNV_TO_U_USE_FALLBACK(cnv)) {
/* output BMP code point */
- *target++=(UChar)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ *target++=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
if(offsets!=nullptr) {
*offsets++=sourceIndex;
}
if(MBCS_ENTRY_FINAL_IS_VALID_DIRECT_16(entry)) {
/* output BMP code point */
- return (UChar)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ return (char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
}
/*
} else if(action==MBCS_STATE_FALLBACK_DIRECT_16) {
if(UCNV_TO_U_USE_FALLBACK(cnv)) {
/* output BMP code point */
- return (UChar)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ return (char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
}
} else if(action==MBCS_STATE_UNASSIGNED) {
/* just fall through */
action=(uint8_t)(MBCS_ENTRY_FINAL_ACTION(entry));
if(action==MBCS_STATE_VALID_DIRECT_16) {
/* output BMP code point */
- c=(UChar)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ c=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
break;
} else if(action==MBCS_STATE_VALID_16) {
offset+=MBCS_ENTRY_FINAL_VALUE_16(entry);
} else if(action==MBCS_STATE_FALLBACK_DIRECT_16) {
if(UCNV_TO_U_USE_FALLBACK(cnv)) {
/* output BMP code point */
- c=(UChar)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ c=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
break;
}
} else if(action==MBCS_STATE_UNASSIGNED) {
if(MBCS_ENTRY_FINAL_IS_VALID_DIRECT_16(entry)) {
/* output BMP code point */
- return (UChar)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ return (char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
}
/*
return 0xfffe;
}
/* output BMP code point */
- return (UChar)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ return (char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
} else if(action==MBCS_STATE_FALLBACK_DIRECT_20) {
if(!TO_U_USE_FALLBACK(useFallback)) {
return 0xfffe;
break;
} else if(action==MBCS_STATE_VALID_DIRECT_16) {
/* output BMP code point */
- c=(UChar)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ c=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
break;
} else if(action==MBCS_STATE_VALID_16_PAIR) {
offset+=MBCS_ENTRY_FINAL_VALUE_16(entry);
break;
}
/* output BMP code point */
- c=(UChar)MBCS_ENTRY_FINAL_VALUE_16(entry);
+ c=(char16_t)MBCS_ENTRY_FINAL_VALUE_16(entry);
break;
} else if(action==MBCS_STATE_FALLBACK_DIRECT_20) {
if(!TO_U_USE_FALLBACK(useFallback)) {
ucnv_MBCSDoubleFromUnicodeWithOffsets(UConverterFromUnicodeArgs *pArgs,
UErrorCode *pErrorCode) {
UConverter *cnv;
- const UChar *source, *sourceLimit;
+ const char16_t *source, *sourceLimit;
uint8_t *target;
int32_t targetCapacity;
int32_t *offsets;
if(targetCapacity>0) {
/*
* Get a correct Unicode code point:
- * a single UChar for a BMP code point or
+ * a single char16_t for a BMP code point or
* a matched surrogate pair for a "supplementary code point".
*/
c=*source++;
getTrail:
if(source<sourceLimit) {
/* test the following code unit */
- UChar trail=*source;
+ char16_t trail=*source;
if(U16_IS_TRAIL(trail)) {
++source;
++nextSourceIndex;
ucnv_MBCSSingleFromUnicodeWithOffsets(UConverterFromUnicodeArgs *pArgs,
UErrorCode *pErrorCode) {
UConverter *cnv;
- const UChar *source, *sourceLimit;
+ const char16_t *source, *sourceLimit;
uint8_t *target;
int32_t targetCapacity;
int32_t *offsets;
if(targetCapacity>0) {
/*
* Get a correct Unicode code point:
- * a single UChar for a BMP code point or
+ * a single char16_t for a BMP code point or
* a matched surrogate pair for a "supplementary code point".
*/
c=*source++;
getTrail:
if(source<sourceLimit) {
/* test the following code unit */
- UChar trail=*source;
+ char16_t trail=*source;
if(U16_IS_TRAIL(trail)) {
++source;
++nextSourceIndex;
ucnv_MBCSSingleFromBMPWithOffsets(UConverterFromUnicodeArgs *pArgs,
UErrorCode *pErrorCode) {
UConverter *cnv;
- const UChar *source, *sourceLimit, *lastSource;
+ const char16_t *source, *sourceLimit, *lastSource;
uint8_t *target;
int32_t targetCapacity, length;
int32_t *offsets;
lastSource=source;
/*
- * since the conversion here is 1:1 UChar:uint8_t, we need only one counter
+ * since the conversion here is 1:1 char16_t:uint8_t, we need only one counter
* for the minimum of the sourceLength and targetCapacity
*/
length=(int32_t)(sourceLimit-source);
while(targetCapacity>0) {
/*
* Get a correct Unicode code point:
- * a single UChar for a BMP code point or
+ * a single char16_t for a BMP code point or
* a matched surrogate pair for a "supplementary code point".
*/
c=*source++;
getTrail:
if(source<sourceLimit) {
/* test the following code unit */
- UChar trail=*source;
+ char16_t trail=*source;
if(U16_IS_TRAIL(trail)) {
++source;
c=U16_GET_SUPPLEMENTARY(c, trail);
ucnv_MBCSFromUnicodeWithOffsets(UConverterFromUnicodeArgs *pArgs,
UErrorCode *pErrorCode) {
UConverter *cnv;
- const UChar *source, *sourceLimit;
+ const char16_t *source, *sourceLimit;
uint8_t *target;
int32_t targetCapacity;
int32_t *offsets;
if(targetCapacity>0) {
/*
* Get a correct Unicode code point:
- * a single UChar for a BMP code point or
+ * a single char16_t for a BMP code point or
* a matched surrogate pair for a "supplementary code point".
*/
c=*source++;
getTrail:
if(source<sourceLimit) {
/* test the following code unit */
- UChar trail=*source;
+ char16_t trail=*source;
if(U16_IS_TRAIL(trail)) {
++source;
++nextSourceIndex;
* If we have a partial match on c, we will return and revert
* to UTF-8->UTF-16->charset conversion.
*/
- static const UChar nul=0;
- const UChar *noSource=&nul;
+ static const char16_t nul=0;
+ const char16_t *noSource=&nul;
c=_extFromU(cnv, cnv->sharedData,
c, &noSource, noSource,
&target, target+targetCapacity,
* If we have a partial match on c, we will return and revert
* to UTF-8->UTF-16->charset conversion.
*/
- static const UChar nul=0;
- const UChar *noSource=&nul;
+ static const char16_t nul=0;
+ const char16_t *noSource=&nul;
c=_extFromU(cnv, cnv->sharedData,
c, &noSource, noSource,
&target, target+targetCapacity,
UConverter *cnv;
SCSUData *scsu;
const uint8_t *source, *sourceLimit;
- UChar *target;
- const UChar *targetLimit;
+ char16_t *target;
+ const char16_t *targetLimit;
int32_t *offsets;
UBool isSingleByteMode;
uint8_t state, byteOne;
++nextSourceIndex;
if(b<=0x7f) {
/* write US-ASCII graphic character or DEL */
- *target++=(UChar)b;
+ *target++=(char16_t)b;
if(offsets!=nullptr) {
*offsets++=sourceIndex;
}
/* write from dynamic window */
uint32_t c=scsu->toUDynamicOffsets[dynamicWindow]+(b&0x7f);
if(c<=0xffff) {
- *target++=(UChar)c;
+ *target++=(char16_t)c;
if(offsets!=nullptr) {
*offsets++=sourceIndex;
}
} else {
/* output surrogate pair */
- *target++=(UChar)(0xd7c0+(c>>10));
+ *target++=(char16_t)(0xd7c0+(c>>10));
if(target<targetLimit) {
- *target++=(UChar)(0xdc00|(c&0x3ff));
+ *target++=(char16_t)(0xdc00|(c&0x3ff));
if(offsets!=nullptr) {
*offsets++=sourceIndex;
*offsets++=sourceIndex;
if(offsets!=nullptr) {
*offsets++=sourceIndex;
}
- cnv->UCharErrorBuffer[0]=(UChar)(0xdc00|(c&0x3ff));
+ cnv->UCharErrorBuffer[0]=(char16_t)(0xdc00|(c&0x3ff));
cnv->UCharErrorBufferLength=1;
*pErrorCode=U_BUFFER_OVERFLOW_ERROR;
goto endloop;
/* here: b<0x20 because otherwise we would be in fastSingle */
if((1UL<<b)&0x2601 /* binary 0010 0110 0000 0001, check for b==0xd || b==0xa || b==9 || b==0 */) {
/* CR/LF/TAB/NUL */
- *target++=(UChar)b;
+ *target++=(char16_t)b;
if(offsets!=nullptr) {
*offsets++=sourceIndex;
}
state=quotePairTwo;
break;
case quotePairTwo:
- *target++=(UChar)((byteOne<<8)|b);
+ *target++=(char16_t)((byteOne<<8)|b);
if(offsets!=nullptr) {
*offsets++=sourceIndex;
}
case quoteOne:
if(b<0x80) {
/* all static offsets are in the BMP */
- *target++=(UChar)(staticOffsets[quoteWindow]+b);
+ *target++=(char16_t)(staticOffsets[quoteWindow]+b);
if(offsets!=nullptr) {
*offsets++=sourceIndex;
}
/* write from dynamic window */
uint32_t c=scsu->toUDynamicOffsets[quoteWindow]+(b&0x7f);
if(c<=0xffff) {
- *target++=(UChar)c;
+ *target++=(char16_t)c;
if(offsets!=nullptr) {
*offsets++=sourceIndex;
}
} else {
/* output surrogate pair */
- *target++=(UChar)(0xd7c0+(c>>10));
+ *target++=(char16_t)(0xd7c0+(c>>10));
if(target<targetLimit) {
- *target++=(UChar)(0xdc00|(c&0x3ff));
+ *target++=(char16_t)(0xdc00|(c&0x3ff));
if(offsets!=nullptr) {
*offsets++=sourceIndex;
*offsets++=sourceIndex;
if(offsets!=nullptr) {
*offsets++=sourceIndex;
}
- cnv->UCharErrorBuffer[0]=(UChar)(0xdc00|(c&0x3ff));
+ cnv->UCharErrorBuffer[0]=(char16_t)(0xdc00|(c&0x3ff));
cnv->UCharErrorBufferLength=1;
*pErrorCode=U_BUFFER_OVERFLOW_ERROR;
goto endloop;
if(state==readCommand) {
fastUnicode:
while(source+1<sourceLimit && target<targetLimit && (uint8_t)((b=*source)-UC0)>(Urs-UC0)) {
- *target++=(UChar)((b<<8)|source[1]);
+ *target++=(char16_t)((b<<8)|source[1]);
if(offsets!=nullptr) {
*offsets++=sourceIndex;
}
state=quotePairTwo;
break;
case quotePairTwo:
- *target++=(UChar)((byteOne<<8)|b);
+ *target++=(char16_t)((byteOne<<8)|b);
if(offsets!=nullptr) {
*offsets++=sourceIndex;
}
UConverter *cnv;
SCSUData *scsu;
const uint8_t *source, *sourceLimit;
- UChar *target;
- const UChar *targetLimit;
+ char16_t *target;
+ const char16_t *targetLimit;
UBool isSingleByteMode;
uint8_t state, byteOne;
int8_t quoteWindow, dynamicWindow;
++source;
if(b<=0x7f) {
/* write US-ASCII graphic character or DEL */
- *target++=(UChar)b;
+ *target++=(char16_t)b;
} else {
/* write from dynamic window */
uint32_t c=scsu->toUDynamicOffsets[dynamicWindow]+(b&0x7f);
if(c<=0xffff) {
- *target++=(UChar)c;
+ *target++=(char16_t)c;
} else {
/* output surrogate pair */
- *target++=(UChar)(0xd7c0+(c>>10));
+ *target++=(char16_t)(0xd7c0+(c>>10));
if(target<targetLimit) {
- *target++=(UChar)(0xdc00|(c&0x3ff));
+ *target++=(char16_t)(0xdc00|(c&0x3ff));
} else {
/* target overflow */
- cnv->UCharErrorBuffer[0]=(UChar)(0xdc00|(c&0x3ff));
+ cnv->UCharErrorBuffer[0]=(char16_t)(0xdc00|(c&0x3ff));
cnv->UCharErrorBufferLength=1;
*pErrorCode=U_BUFFER_OVERFLOW_ERROR;
goto endloop;
/* here: b<0x20 because otherwise we would be in fastSingle */
if((1UL<<b)&0x2601 /* binary 0010 0110 0000 0001, check for b==0xd || b==0xa || b==9 || b==0 */) {
/* CR/LF/TAB/NUL */
- *target++=(UChar)b;
+ *target++=(char16_t)b;
goto fastSingle;
} else if(SC0<=b) {
if(b<=SC7) {
state=quotePairTwo;
break;
case quotePairTwo:
- *target++=(UChar)((byteOne<<8)|b);
+ *target++=(char16_t)((byteOne<<8)|b);
state=readCommand;
goto fastSingle;
case quoteOne:
if(b<0x80) {
/* all static offsets are in the BMP */
- *target++=(UChar)(staticOffsets[quoteWindow]+b);
+ *target++=(char16_t)(staticOffsets[quoteWindow]+b);
} else {
/* write from dynamic window */
uint32_t c=scsu->toUDynamicOffsets[quoteWindow]+(b&0x7f);
if(c<=0xffff) {
- *target++=(UChar)c;
+ *target++=(char16_t)c;
} else {
/* output surrogate pair */
- *target++=(UChar)(0xd7c0+(c>>10));
+ *target++=(char16_t)(0xd7c0+(c>>10));
if(target<targetLimit) {
- *target++=(UChar)(0xdc00|(c&0x3ff));
+ *target++=(char16_t)(0xdc00|(c&0x3ff));
} else {
/* target overflow */
- cnv->UCharErrorBuffer[0]=(UChar)(0xdc00|(c&0x3ff));
+ cnv->UCharErrorBuffer[0]=(char16_t)(0xdc00|(c&0x3ff));
cnv->UCharErrorBufferLength=1;
*pErrorCode=U_BUFFER_OVERFLOW_ERROR;
goto endloop;
if(state==readCommand) {
fastUnicode:
while(source+1<sourceLimit && target<targetLimit && (uint8_t)((b=*source)-UC0)>(Urs-UC0)) {
- *target++=(UChar)((b<<8)|source[1]);
+ *target++=(char16_t)((b<<8)|source[1]);
source+=2;
}
}
state=quotePairTwo;
break;
case quotePairTwo:
- *target++=(UChar)((byteOne<<8)|b);
+ *target++=(char16_t)((byteOne<<8)|b);
state=readCommand;
goto fastUnicode;
}
UErrorCode *pErrorCode) {
UConverter *cnv;
SCSUData *scsu;
- const UChar *source, *sourceLimit;
+ const char16_t *source, *sourceLimit;
uint8_t *target;
int32_t targetCapacity;
int32_t *offsets;
/* variables for compression heuristics */
uint32_t offset;
- UChar lead, trail;
+ char16_t lead, trail;
int code;
int8_t window;
} else if(U16_IS_SURROGATE(c)) {
if(U16_IS_SURROGATE_LEAD(c)) {
getTrailSingle:
- lead=(UChar)c;
+ lead=(char16_t)c;
if(source<sourceLimit) {
/* test the following code unit */
trail=*source;
/* c is a surrogate */
if(U16_IS_SURROGATE_LEAD(c)) {
getTrailUnicode:
- lead=(UChar)c;
+ lead=(char16_t)c;
if(source<sourceLimit) {
/* test the following code unit */
trail=*source;
UErrorCode *pErrorCode) {
UConverter *cnv;
SCSUData *scsu;
- const UChar *source, *sourceLimit;
+ const char16_t *source, *sourceLimit;
uint8_t *target;
int32_t targetCapacity;
/* variables for compression heuristics */
uint32_t offset;
- UChar lead, trail;
+ char16_t lead, trail;
int code;
int8_t window;
} else if(U16_IS_SURROGATE(c)) {
if(U16_IS_SURROGATE_LEAD(c)) {
getTrailSingle:
- lead=(UChar)c;
+ lead=(char16_t)c;
if(source<sourceLimit) {
/* test the following code unit */
trail=*source;
/* c is a surrogate */
if(U16_IS_SURROGATE_LEAD(c)) {
getTrailUnicode:
- lead=(UChar)c;
+ lead=(char16_t)c;
if(source<sourceLimit) {
/* test the following code unit */
trail=*source;
"SCSU",
1212, /* CCSID for SCSU */
UCNV_IBM, UCNV_SCSU,
- 1, 3, /* one UChar generates at least 1 byte and at most 3 bytes */
+ 1, 3, /* one char16_t generates at least 1 byte and at most 3 bytes */
/*
* The subchar here is ignored because _SCSUOpen() sets U+fffd as a Unicode
* substitution string.
/* check a string against the selector - UTF16 version */
U_CAPI UEnumeration * U_EXPORT2
ucnvsel_selectForString(const UConverterSelector* sel,
- const UChar *s, int32_t length, UErrorCode *status) {
+ const char16_t *s, int32_t length, UErrorCode *status) {
// check if already failed
if (U_FAILURE(*status)) {
return nullptr;
uprv_memset(mask, ~0, columns *4);
if(s!=nullptr) {
- const UChar *limit;
+ const char16_t *limit;
if (length >= 0) {
limit = s + length;
} else {
uint32_t magic; /* magic number - lets us know whether reserved data is reset or junked */
uint32_t mappingPosition; /* const uint8_t *mappingPosition; */
uint32_t expansion; /* uint32_t *expansion; */
- uint32_t contractionIndex; /* UChar *contractionIndex; */
+ uint32_t contractionIndex; /* char16_t *contractionIndex; */
uint32_t contractionCEs; /* uint32_t *contractionCEs; */
uint32_t contractionSize; /* needed for various closures */
/*int32_t latinOneMapping;*/ /* this is now handled in the trie itself *//* fast track to latin1 chars */
/* in contractions. */
int32_t contractionUCACombosSize; /* number of UCA contraction items. */
- /*Length is contractionUCACombosSize*contractionUCACombosWidth*sizeof(UChar) */
+ /*Length is contractionUCACombosSize*contractionUCACombosWidth*sizeof(char16_t) */
UBool jamoSpecial; /* is jamoSpecial */
UBool isBigEndian; /* is this data big endian? from the UDataInfo header*/
uint8_t charSetFamily; /* what is the charset family of this data from the UDataInfo header*/
/* swap the contractions */
if(header.contractionSize!=0) {
- /* contractionIndex: UChar[] */
+ /* contractionIndex: char16_t[] */
ds->swapArray16(ds, inBytes+header.contractionIndex, header.contractionSize*2,
outBytes+header.contractionIndex, pErrorCode);
#endif
typedef struct IsoCodeEntry {
- const UChar *isoCode; /* const because it's a reference to a resource bundle string. */
+ const char16_t *isoCode; /* const because it's a reference to a resource bundle string. */
UDate from;
UDate to;
} IsoCodeEntry;
}
/**
- * Unfortunately, we have to convert the UChar* currency code to char*
+ * Unfortunately, we have to convert the char16_t* currency code to char*
* to use it as a resource key.
*/
static inline char*
-myUCharsToChars(char* resultOfLen4, const UChar* currency) {
+myUCharsToChars(char* resultOfLen4, const char16_t* currency) {
u_UCharsToChars(currency, resultOfLen4, ISO_CURRENCY_CODE_LENGTH);
resultOfLen4[ISO_CURRENCY_CODE_LENGTH] = 0;
return resultOfLen4;
* and cashRounding ).
*/
static const int32_t*
-_findMetaData(const UChar* currency, UErrorCode& ec) {
+_findMetaData(const char16_t* currency, UErrorCode& ec) {
if (currency == 0 || *currency == 0) {
if (U_SUCCESS(ec)) {
struct CReg : public icu::UMemory {
CReg *next;
- UChar iso[ISO_CURRENCY_CODE_LENGTH+1];
+ char16_t iso[ISO_CURRENCY_CODE_LENGTH+1];
char id[ULOC_FULLNAME_CAPACITY];
- CReg(const UChar* _iso, const char* _id)
+ CReg(const char16_t* _iso, const char* _id)
: next(0)
{
int32_t len = (int32_t)uprv_strlen(_id);
iso[ISO_CURRENCY_CODE_LENGTH] = 0;
}
- static UCurrRegistryKey reg(const UChar* _iso, const char* _id, UErrorCode* status)
+ static UCurrRegistryKey reg(const char16_t* _iso, const char* _id, UErrorCode* status)
{
if (status && U_SUCCESS(*status) && _iso && _id) {
CReg* n = new CReg(_iso, _id);
return found;
}
- static const UChar* get(const char* id) {
- const UChar* result = nullptr;
+ static const char16_t* get(const char* id) {
+ const char16_t* result = nullptr;
umtx_lock(&gCRegLock);
CReg* p = gCRegHead;
// -------------------------------------
U_CAPI UCurrRegistryKey U_EXPORT2
-ucurr_register(const UChar* isoCode, const char* locale, UErrorCode *status)
+ucurr_register(const char16_t* isoCode, const char* locale, UErrorCode *status)
{
if (status && U_SUCCESS(*status)) {
char id[ULOC_FULLNAME_CAPACITY];
U_CAPI int32_t U_EXPORT2
ucurr_forLocale(const char* locale,
- UChar* buff,
+ char16_t* buff,
int32_t buffCapacity,
UErrorCode* ec) {
if (U_FAILURE(*ec)) { return 0; }
}
#if !UCONFIG_NO_SERVICE
- const UChar* result = CReg::get(id);
+ const char16_t* result = CReg::get(id);
if (result) {
if(buffCapacity > u_strlen(result)) {
u_strcpy(buff, result);
idDelim[0] = 0;
}
- const UChar* s = nullptr; // Currency code from data file.
+ const char16_t* s = nullptr; // Currency code from data file.
if (id[0] == 0) {
// No point looking in the data for an empty string.
// This is what we would get.
ures_getByIndex(countryArray, i, nullptr, &localStatus));
// The currency is legal tender if it is *not* marked with tender{"false"}.
UErrorCode tenderStatus = localStatus;
- const UChar *tender =
+ const char16_t *tender =
ures_getStringByKey(currencyReq.getAlias(), "tender", nullptr, &tenderStatus);
bool isTender = U_FAILURE(tenderStatus) || u_strcmp(tender, u"false") != 0;
if (!isTender && s != nullptr) {
}
-U_CAPI const UChar* U_EXPORT2
-ucurr_getName(const UChar* currency,
+U_CAPI const char16_t* U_EXPORT2
+ucurr_getName(const char16_t* currency,
const char* locale,
UCurrNameStyle nameStyle,
UBool* isChoiceFormat, // fillin
/* Normalize the keyword value to uppercase */
T_CString_toUpperCase(buf);
- const UChar* s = nullptr;
+ const char16_t* s = nullptr;
ec2 = U_ZERO_ERROR;
LocalUResourceBundlePointer rb(ures_open(U_ICUDATA_CURR, loc, &ec2));
return currency;
}
-U_CAPI const UChar* U_EXPORT2
-ucurr_getPluralName(const UChar* currency,
+U_CAPI const char16_t* U_EXPORT2
+ucurr_getPluralName(const char16_t* currency,
const char* locale,
UBool* isChoiceFormat,
const char* pluralCount,
char buf[ISO_CURRENCY_CODE_LENGTH+1];
myUCharsToChars(buf, currency);
- const UChar* s = nullptr;
+ const char16_t* s = nullptr;
ec2 = U_ZERO_ERROR;
UResourceBundle* rb = ures_open(U_ICUDATA_CURR, loc, &ec2);
typedef struct {
const char* IsoCode; // key
- UChar* currencyName; // value
+ char16_t* currencyName; // value
int32_t currencyNameLen; // value length
int32_t flag; // flags
} CurrencyNameStruct;
U_NAMESPACE_USE
*total_currency_name_count = 0;
*total_currency_symbol_count = 0;
- const UChar* s = nullptr;
+ const char16_t* s = nullptr;
char locale[ULOC_FULLNAME_CAPACITY] = "";
uprv_strcpy(locale, loc);
const icu::Hashtable *currencySymbolsEquiv = getCurrSymbolsEquiv();
}
}
-static UChar*
-toUpperCase(const UChar* source, int32_t len, const char* locale) {
- UChar* dest = nullptr;
+static char16_t*
+toUpperCase(const char16_t* source, int32_t len, const char* locale) {
+ char16_t* dest = nullptr;
UErrorCode ec = U_ZERO_ERROR;
int32_t destLen = u_strToUpper(dest, 0, source, len, locale, &ec);
ec = U_ZERO_ERROR;
- dest = (UChar*)uprv_malloc(sizeof(UChar) * MAX(destLen, len));
+ dest = (char16_t*)uprv_malloc(sizeof(char16_t) * MAX(destLen, len));
u_strToUpper(dest, destLen, source, len, locale, &ec);
if (U_FAILURE(ec)) {
u_memcpy(dest, source, len);
if (U_FAILURE(ec)) return;
- const UChar* s = nullptr; // currency name
+ const char16_t* s = nullptr; // currency name
char* iso = nullptr; // currency ISO code
*total_currency_name_count = 0;
}
// Add currency symbol.
(*currencySymbols)[*total_currency_symbol_count].IsoCode = iso;
- (*currencySymbols)[*total_currency_symbol_count].currencyName = (UChar*)s;
+ (*currencySymbols)[*total_currency_symbol_count].currencyName = (char16_t*)s;
(*currencySymbols)[*total_currency_symbol_count].flag = 0;
(*currencySymbols)[(*total_currency_symbol_count)++].currencyNameLen = len;
// Add equivalent symbols
while ((symbol = iter.next()) != nullptr) {
(*currencySymbols)[*total_currency_symbol_count].IsoCode = iso;
(*currencySymbols)[*total_currency_symbol_count].currencyName =
- const_cast<UChar*>(symbol->getBuffer());
+ const_cast<char16_t*>(symbol->getBuffer());
(*currencySymbols)[*total_currency_symbol_count].flag = 0;
(*currencySymbols)[(*total_currency_symbol_count)++].currencyNameLen = symbol->length();
}
// Add currency long name.
s = ures_getStringByIndex(names, UCURR_LONG_NAME, &len, &ec2);
(*currencyNames)[*total_currency_name_count].IsoCode = iso;
- UChar* upperName = toUpperCase(s, len, locale);
+ char16_t* upperName = toUpperCase(s, len, locale);
(*currencyNames)[*total_currency_name_count].currencyName = upperName;
(*currencyNames)[*total_currency_name_count].flag = NEED_TO_BE_DELETED;
(*currencyNames)[(*total_currency_name_count)++].currencyNameLen = len;
// put (iso, 3, and iso) in to array
// Add currency ISO code.
(*currencySymbols)[*total_currency_symbol_count].IsoCode = iso;
- (*currencySymbols)[*total_currency_symbol_count].currencyName = (UChar*)uprv_malloc(sizeof(UChar)*3);
+ (*currencySymbols)[*total_currency_symbol_count].currencyName = (char16_t*)uprv_malloc(sizeof(char16_t)*3);
// Must convert iso[] into Unicode
u_charsToUChars(iso, (*currencySymbols)[*total_currency_symbol_count].currencyName, 3);
(*currencySymbols)[*total_currency_symbol_count].flag = NEED_TO_BE_DELETED;
// currency long name?
s = ures_getStringByIndex(names, j, &len, &ec5);
(*currencyNames)[*total_currency_name_count].IsoCode = iso;
- UChar* upperName = toUpperCase(s, len, locale);
+ char16_t* upperName = toUpperCase(s, len, locale);
(*currencyNames)[*total_currency_name_count].currencyName = upperName;
(*currencyNames)[*total_currency_name_count].flag = NEED_TO_BE_DELETED;
(*currencyNames)[(*total_currency_name_count)++].currencyNameLen = len;
static int32_t
binarySearch(const CurrencyNameStruct* currencyNames,
int32_t indexInCurrencyNames,
- const UChar key,
+ const char16_t key,
int32_t* begin, int32_t* end) {
#ifdef UCURR_DEBUG
printf("key = %x\n", key);
static void
linearSearch(const CurrencyNameStruct* currencyNames,
int32_t begin, int32_t end,
- const UChar* text, int32_t textLen,
+ const char16_t* text, int32_t textLen,
int32_t *partialMatchLen,
int32_t *maxMatchLen, int32_t* maxMatchIndex) {
int32_t initialPartialMatchLen = *partialMatchLen;
for (int32_t index = begin; index <= end; ++index) {
int32_t len = currencyNames[index].currencyNameLen;
if (len > *maxMatchLen && len <= textLen &&
- uprv_memcmp(currencyNames[index].currencyName, text, len * sizeof(UChar)) == 0) {
+ uprv_memcmp(currencyNames[index].currencyName, text, len * sizeof(char16_t)) == 0) {
*partialMatchLen = MAX(*partialMatchLen, len);
*maxMatchIndex = index;
*maxMatchLen = len;
static void
searchCurrencyName(const CurrencyNameStruct* currencyNames,
int32_t total_currency_count,
- const UChar* text, int32_t textLen,
+ const char16_t* text, int32_t textLen,
int32_t *partialMatchLen,
int32_t* maxMatchLen, int32_t* maxMatchIndex) {
*maxMatchIndex = -1;
icu::ParsePosition& pos,
int8_t type,
int32_t* partialMatchLen,
- UChar* result,
+ char16_t* result,
UErrorCode& ec) {
U_NAMESPACE_USE
if (U_FAILURE(ec)) {
int32_t start = pos.getIndex();
- UChar inputText[MAX_CURRENCY_NAME_LEN];
- UChar upperText[MAX_CURRENCY_NAME_LEN];
+ char16_t inputText[MAX_CURRENCY_NAME_LEN];
+ char16_t upperText[MAX_CURRENCY_NAME_LEN];
int32_t textLen = MIN(MAX_CURRENCY_NAME_LEN, text.length() - start);
text.extract(start, textLen, inputText);
UErrorCode ec1 = U_ZERO_ERROR;
* DecimalFormat and DecimalFormatSymbols.
*/
U_CAPI void
-uprv_getStaticCurrencyName(const UChar* iso, const char* loc,
+uprv_getStaticCurrencyName(const char16_t* iso, const char* loc,
icu::UnicodeString& result, UErrorCode& ec)
{
U_NAMESPACE_USE
int32_t len;
- const UChar* currname = ucurr_getName(iso, loc, UCURR_SYMBOL_NAME,
+ const char16_t* currname = ucurr_getName(iso, loc, UCURR_SYMBOL_NAME,
nullptr /* isChoiceFormat */, &len, &ec);
if (U_SUCCESS(ec)) {
result.setTo(currname, len);
}
U_CAPI int32_t U_EXPORT2
-ucurr_getDefaultFractionDigits(const UChar* currency, UErrorCode* ec) {
+ucurr_getDefaultFractionDigits(const char16_t* currency, UErrorCode* ec) {
return ucurr_getDefaultFractionDigitsForUsage(currency,UCURR_USAGE_STANDARD,ec);
}
U_CAPI int32_t U_EXPORT2
-ucurr_getDefaultFractionDigitsForUsage(const UChar* currency, const UCurrencyUsage usage, UErrorCode* ec) {
+ucurr_getDefaultFractionDigitsForUsage(const char16_t* currency, const UCurrencyUsage usage, UErrorCode* ec) {
int32_t fracDigits = 0;
if (U_SUCCESS(*ec)) {
switch (usage) {
}
U_CAPI double U_EXPORT2
-ucurr_getRoundingIncrement(const UChar* currency, UErrorCode* ec) {
+ucurr_getRoundingIncrement(const char16_t* currency, UErrorCode* ec) {
return ucurr_getRoundingIncrementForUsage(currency, UCURR_USAGE_STANDARD, ec);
}
U_CAPI double U_EXPORT2
-ucurr_getRoundingIncrementForUsage(const UChar* currency, const UCurrencyUsage usage, UErrorCode* ec) {
+ucurr_getRoundingIncrementForUsage(const char16_t* currency, const UCurrencyUsage usage, UErrorCode* ec) {
double result = 0.0;
const int32_t *data = _findMetaData(currency, *ec);
if (idRes == nullptr) {
continue;
}
- const UChar *isoCode = ures_getString(idRes, &isoLength, &localStatus);
+ const char16_t *isoCode = ures_getString(idRes, &isoLength, &localStatus);
// get from date
UDate fromDate = U_DATE_MIN;
entry->to = toDate;
localStatus = U_ZERO_ERROR;
- uhash_put(isoCodes, (UChar *)isoCode, entry, &localStatus);
+ uhash_put(isoCodes, (char16_t *)isoCode, entry, &localStatus);
}
} else {
*status = localStatus;
}
U_CAPI UBool U_EXPORT2
-ucurr_isAvailable(const UChar* isoCode, UDate from, UDate to, UErrorCode* eErrorCode) {
+ucurr_isAvailable(const char16_t* isoCode, UDate from, UDate to, UErrorCode* eErrorCode) {
umtx_initOnce(gIsoCodesInitOnce, &initIsoCodes, *eErrorCode);
if (U_FAILURE(*eErrorCode)) {
return false;
ucurr_forLocaleAndDate(const char* locale,
UDate date,
int32_t index,
- UChar* buff,
+ char16_t* buff,
int32_t buffCapacity,
UErrorCode* ec)
{
int32_t resLen = 0;
int32_t currIndex = 0;
- const UChar* s = nullptr;
+ const char16_t* s = nullptr;
if (ec != nullptr && U_SUCCESS(*ec))
{
/* optimize - use the utf-8 string */
#else
{
- const UChar* defString = ures_getStringByKey(&curbndl, "id", &curIDLength, status);
+ const char16_t* defString = ures_getStringByKey(&curbndl, "id", &curIDLength, status);
if(U_SUCCESS(*status)) {
if(curIDLength+1 > ULOC_KEYWORDS_CAPACITY) {
*status = U_BUFFER_OVERFLOW_ERROR;
U_CAPI int32_t U_EXPORT2
-ucurr_getNumericCode(const UChar* currency) {
+ucurr_getNumericCode(const char16_t* currency) {
int32_t code = 0;
if (currency && u_strlen(currency) == ISO_CURRENCY_CODE_LENGTH) {
UErrorCode status = U_ZERO_ERROR;
}
/* Don't call this directly. Only uenum_unext should be calling this. */
-U_CAPI const UChar* U_EXPORT2
+U_CAPI const char16_t* U_EXPORT2
uenum_unextDefault(UEnumeration* en,
int32_t* resultLength,
UErrorCode* status)
{
- UChar *ustr = nullptr;
+ char16_t *ustr = nullptr;
int32_t len = 0;
if (en->next != nullptr) {
const char *cstr = en->next(en, &len, status);
if (cstr != nullptr) {
- ustr = (UChar*) _getBuffer(en, (len+1) * sizeof(UChar));
+ ustr = (char16_t*) _getBuffer(en, (len+1) * sizeof(char16_t));
if (ustr == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
} else {
{
if (en->uNext != nullptr) {
char *tempCharVal;
- const UChar *tempUCharVal = en->uNext(en, resultLength, status);
+ const char16_t *tempUCharVal = en->uNext(en, resultLength, status);
if (tempUCharVal == nullptr) {
return nullptr;
}
}
}
-U_CAPI const UChar* U_EXPORT2
+U_CAPI const char16_t* U_EXPORT2
uenum_unext(UEnumeration* en,
int32_t* resultLength,
UErrorCode* status)
U_CAPI int32_t U_EXPORT2
uhash_hashUChars(const UHashTok key) {
- const UChar *s = (const UChar *)key.pointer;
+ const char16_t *s = (const char16_t *)key.pointer;
return s == nullptr ? 0 : ustr_hashUCharsN(s, u_strlen(s));
}
U_CAPI UBool U_EXPORT2
uhash_compareUChars(const UHashTok key1, const UHashTok key2) {
- const UChar *p1 = (const UChar*) key1.pointer;
- const UChar *p2 = (const UChar*) key2.pointer;
+ const char16_t *p1 = (const char16_t*) key1.pointer;
+ const char16_t *p2 = (const char16_t*) key2.pointer;
if (p1 == p2) {
return true;
}
#include "sprpimpl.h"
/* it is official IDNA ACE Prefix is "xn--" */
-static const UChar ACE_PREFIX[] ={ 0x0078,0x006E,0x002d,0x002d } ;
+static const char16_t ACE_PREFIX[] ={ 0x0078,0x006E,0x002d,0x002d } ;
#define ACE_PREFIX_LENGTH 4
#define MAX_LABEL_LENGTH 63
#define CAPITAL_A 0x0041
#define CAPITAL_Z 0x005A
-inline static UChar
-toASCIILower(UChar ch){
+inline static char16_t
+toASCIILower(char16_t ch){
if(CAPITAL_A <= ch && ch <= CAPITAL_Z){
return ch + LOWER_CASE_DELTA;
}
}
inline static UBool
-startsWithPrefix(const UChar* src , int32_t srcLength){
+startsWithPrefix(const char16_t* src , int32_t srcLength){
if(srcLength < ACE_PREFIX_LENGTH){
return false;
}
inline static int32_t
-compareCaseInsensitiveASCII(const UChar* s1, int32_t s1Len,
- const UChar* s2, int32_t s2Len){
+compareCaseInsensitiveASCII(const char16_t* s1, int32_t s1Len,
+ const char16_t* s2, int32_t s2Len){
int32_t minLength;
int32_t lengthResult;
lengthResult = 0;
}
- UChar c1,c2;
+ char16_t c1,c2;
int32_t rc;
for(int32_t i =0;/* no condition */;i++) {
* @return true if the char is a label separator
* @stable ICU 2.8
*/
-static inline UBool isLabelSeparator(UChar ch){
+static inline UBool isLabelSeparator(char16_t ch){
switch(ch){
case 0x002e:
case 0x3002:
// if *limit == separator then the length returned does not include
// the separtor.
static inline int32_t
-getNextSeparator(UChar *src, int32_t srcLength,
- UChar **limit, UBool *done){
+getNextSeparator(char16_t *src, int32_t srcLength,
+ char16_t **limit, UBool *done){
if(srcLength == -1){
int32_t i;
for(i=0 ; ;i++){
return i;
}
}
-static inline UBool isLDHChar(UChar ch){
+static inline UBool isLDHChar(char16_t ch){
// high runner case
if(ch>0x007A){
return false;
}
static int32_t
-_internal_toASCII(const UChar* src, int32_t srcLength,
- UChar* dest, int32_t destCapacity,
+_internal_toASCII(const char16_t* src, int32_t srcLength,
+ char16_t* dest, int32_t destCapacity,
int32_t options,
UStringPrepProfile* nameprep,
UParseError* parseError,
{
// TODO Revisit buffer handling. The label should not be over 63 ASCII characters. ICU4J may need to be updated too.
- UChar b1Stack[MAX_LABEL_BUFFER_SIZE], b2Stack[MAX_LABEL_BUFFER_SIZE];
+ char16_t b1Stack[MAX_LABEL_BUFFER_SIZE], b2Stack[MAX_LABEL_BUFFER_SIZE];
//initialize pointers to stack buffers
- UChar *b1 = b1Stack, *b2 = b2Stack;
+ char16_t *b1 = b1Stack, *b2 = b2Stack;
int32_t b1Len=0, b2Len,
b1Capacity = MAX_LABEL_BUFFER_SIZE,
b2Capacity = MAX_LABEL_BUFFER_SIZE ,
}
if(srcLength > b1Capacity){
- b1 = (UChar*) uprv_malloc(srcLength * U_SIZEOF_UCHAR);
+ b1 = (char16_t*) uprv_malloc(srcLength * U_SIZEOF_UCHAR);
if(b1==nullptr){
*status = U_MEMORY_ALLOCATION_ERROR;
goto CLEANUP;
if(b1 != b1Stack){
uprv_free(b1);
}
- b1 = (UChar*) uprv_malloc(b1Len * U_SIZEOF_UCHAR);
+ b1 = (char16_t*) uprv_malloc(b1Len * U_SIZEOF_UCHAR);
if(b1==nullptr){
*status = U_MEMORY_ALLOCATION_ERROR;
goto CLEANUP;
if(*status == U_BUFFER_OVERFLOW_ERROR){
// redo processing of string
/* we do not have enough room so grow the buffer*/
- b2 = (UChar*) uprv_malloc(b2Len * U_SIZEOF_UCHAR);
+ b2 = (char16_t*) uprv_malloc(b2Len * U_SIZEOF_UCHAR);
if(b2 == nullptr){
*status = U_MEMORY_ALLOCATION_ERROR;
goto CLEANUP;
}
static int32_t
-_internal_toUnicode(const UChar* src, int32_t srcLength,
- UChar* dest, int32_t destCapacity,
+_internal_toUnicode(const char16_t* src, int32_t srcLength,
+ char16_t* dest, int32_t destCapacity,
int32_t options,
UStringPrepProfile* nameprep,
UParseError* parseError,
int32_t namePrepOptions = ((options & UIDNA_ALLOW_UNASSIGNED) != 0) ? USPREP_ALLOW_UNASSIGNED: 0;
// TODO Revisit buffer handling. The label should not be over 63 ASCII characters. ICU4J may need to be updated too.
- UChar b1Stack[MAX_LABEL_BUFFER_SIZE], b2Stack[MAX_LABEL_BUFFER_SIZE], b3Stack[MAX_LABEL_BUFFER_SIZE];
+ char16_t b1Stack[MAX_LABEL_BUFFER_SIZE], b2Stack[MAX_LABEL_BUFFER_SIZE], b3Stack[MAX_LABEL_BUFFER_SIZE];
//initialize pointers to stack buffers
- UChar *b1 = b1Stack, *b2 = b2Stack, *b1Prime=nullptr, *b3=b3Stack;
+ char16_t *b1 = b1Stack, *b2 = b2Stack, *b1Prime=nullptr, *b3=b3Stack;
int32_t b1Len = 0, b2Len, b1PrimeLen, b3Len,
b1Capacity = MAX_LABEL_BUFFER_SIZE,
b2Capacity = MAX_LABEL_BUFFER_SIZE,
if(*status == U_BUFFER_OVERFLOW_ERROR){
// redo processing of string
/* we do not have enough room so grow the buffer*/
- b1 = (UChar*) uprv_malloc(b1Len * U_SIZEOF_UCHAR);
+ b1 = (char16_t*) uprv_malloc(b1Len * U_SIZEOF_UCHAR);
if(b1==nullptr){
*status = U_MEMORY_ALLOCATION_ERROR;
goto CLEANUP;
}else{
//just point src to b1
- b1 = (UChar*) src;
+ b1 = (char16_t*) src;
b1Len = srcLength;
}
if(*status == U_BUFFER_OVERFLOW_ERROR){
// redo processing of string
/* we do not have enough room so grow the buffer*/
- b2 = (UChar*) uprv_malloc(b2Len * U_SIZEOF_UCHAR);
+ b2 = (char16_t*) uprv_malloc(b2Len * U_SIZEOF_UCHAR);
if(b2==nullptr){
*status = U_MEMORY_ALLOCATION_ERROR;
goto CLEANUP;
if(*status == U_BUFFER_OVERFLOW_ERROR){
// redo processing of string
/* we do not have enough room so grow the buffer*/
- b3 = (UChar*) uprv_malloc(b3Len * U_SIZEOF_UCHAR);
+ b3 = (char16_t*) uprv_malloc(b3Len * U_SIZEOF_UCHAR);
if(b3==nullptr){
*status = U_MEMORY_ALLOCATION_ERROR;
goto CLEANUP;
}
U_CAPI int32_t U_EXPORT2
-uidna_toASCII(const UChar* src, int32_t srcLength,
- UChar* dest, int32_t destCapacity,
+uidna_toASCII(const char16_t* src, int32_t srcLength,
+ char16_t* dest, int32_t destCapacity,
int32_t options,
UParseError* parseError,
UErrorCode* status){
}
U_CAPI int32_t U_EXPORT2
-uidna_toUnicode(const UChar* src, int32_t srcLength,
- UChar* dest, int32_t destCapacity,
+uidna_toUnicode(const char16_t* src, int32_t srcLength,
+ char16_t* dest, int32_t destCapacity,
int32_t options,
UParseError* parseError,
UErrorCode* status){
U_CAPI int32_t U_EXPORT2
-uidna_IDNToASCII( const UChar *src, int32_t srcLength,
- UChar* dest, int32_t destCapacity,
+uidna_IDNToASCII( const char16_t *src, int32_t srcLength,
+ char16_t* dest, int32_t destCapacity,
int32_t options,
UParseError *parseError,
UErrorCode *status){
}
//initialize pointers
- UChar *delimiter = (UChar*)src;
- UChar *labelStart = (UChar*)src;
- UChar *currentDest = (UChar*) dest;
+ char16_t *delimiter = (char16_t*)src;
+ char16_t *labelStart = (char16_t*)src;
+ char16_t *currentDest = (char16_t*) dest;
int32_t remainingLen = srcLength;
int32_t remainingDestCapacity = destCapacity;
int32_t labelLen = 0, labelReqLength = 0;
}
U_CAPI int32_t U_EXPORT2
-uidna_IDNToUnicode( const UChar* src, int32_t srcLength,
- UChar* dest, int32_t destCapacity,
+uidna_IDNToUnicode( const char16_t* src, int32_t srcLength,
+ char16_t* dest, int32_t destCapacity,
int32_t options,
UParseError* parseError,
UErrorCode* status){
}
//initialize pointers
- UChar *delimiter = (UChar*)src;
- UChar *labelStart = (UChar*)src;
- UChar *currentDest = (UChar*) dest;
+ char16_t *delimiter = (char16_t*)src;
+ char16_t *labelStart = (char16_t*)src;
+ char16_t *currentDest = (char16_t*) dest;
int32_t remainingLen = srcLength;
int32_t remainingDestCapacity = destCapacity;
int32_t labelLen = 0, labelReqLength = 0;
}
U_CAPI int32_t U_EXPORT2
-uidna_compare( const UChar *s1, int32_t length1,
- const UChar *s2, int32_t length2,
+uidna_compare( const char16_t *s1, int32_t length1,
+ const char16_t *s2, int32_t length2,
int32_t options,
UErrorCode* status){
return -1;
}
- UChar b1Stack[MAX_IDN_BUFFER_SIZE], b2Stack[MAX_IDN_BUFFER_SIZE];
- UChar *b1 = b1Stack, *b2 = b2Stack;
+ char16_t b1Stack[MAX_IDN_BUFFER_SIZE], b2Stack[MAX_IDN_BUFFER_SIZE];
+ char16_t *b1 = b1Stack, *b2 = b2Stack;
int32_t b1Len, b2Len, b1Capacity = MAX_IDN_BUFFER_SIZE, b2Capacity = MAX_IDN_BUFFER_SIZE;
int32_t result=-1;
b1Len = uidna_IDNToASCII(s1, length1, b1, b1Capacity, options, &parseError, status);
if(*status == U_BUFFER_OVERFLOW_ERROR){
// redo processing of string
- b1 = (UChar*) uprv_malloc(b1Len * U_SIZEOF_UCHAR);
+ b1 = (char16_t*) uprv_malloc(b1Len * U_SIZEOF_UCHAR);
if(b1==nullptr){
*status = U_MEMORY_ALLOCATION_ERROR;
goto CLEANUP;
b2Len = uidna_IDNToASCII(s2,length2, b2,b2Capacity, options, &parseError, status);
if(*status == U_BUFFER_OVERFLOW_ERROR){
// redo processing of string
- b2 = (UChar*) uprv_malloc(b2Len * U_SIZEOF_UCHAR);
+ b2 = (char16_t*) uprv_malloc(b2Len * U_SIZEOF_UCHAR);
if(b2==nullptr){
*status = U_MEMORY_ALLOCATION_ERROR;
goto CLEANUP;
U_CAPI void U_EXPORT2
-u_charsToUChars(const char *cs, UChar *us, int32_t length) {
- UChar u;
+u_charsToUChars(const char *cs, char16_t *us, int32_t length) {
+ char16_t u;
uint8_t c;
/*
*/
while(length>0) {
c=(uint8_t)(*cs++);
- u=(UChar)CHAR_TO_UCHAR(c);
+ u=(char16_t)CHAR_TO_UCHAR(c);
U_ASSERT((u!=0 || c==0)); /* only invariant chars converted? */
*us++=u;
--length;
}
U_CAPI void U_EXPORT2
-u_UCharsToChars(const UChar *us, char *cs, int32_t length) {
- UChar u;
+u_UCharsToChars(const char16_t *us, char *cs, int32_t length) {
+ char16_t u;
while(length>0) {
u=*us++;
}
U_CAPI UBool U_EXPORT2
-uprv_isInvariantUString(const UChar *s, int32_t length) {
- UChar c;
+uprv_isInvariantUString(const char16_t *s, int32_t length) {
+ char16_t c;
for(;;) {
if(length<0) {
U_CFUNC int32_t
uprv_compareInvAscii(const UDataSwapper *ds,
const char *outString, int32_t outLength,
- const UChar *localString, int32_t localLength) {
+ const char16_t *localString, int32_t localLength) {
(void)ds;
int32_t minLength;
UChar32 c1, c2;
U_CFUNC int32_t
uprv_compareInvEbcdic(const UDataSwapper *ds,
const char *outString, int32_t outLength,
- const UChar *localString, int32_t localLength) {
+ const char16_t *localString, int32_t localLength) {
(void)ds;
int32_t minLength;
UChar32 c1, c2;
/* UCharIterator implementation for simple strings -------------------------- */
/*
- * This is an implementation of a code unit (UChar) iterator
- * for UChar * strings.
+ * This is an implementation of a code unit (char16_t) iterator
+ * for char16_t * strings.
*
* The UCharIterator.context field holds a pointer to the string.
*/
static UChar32 U_CALLCONV
stringIteratorCurrent(UCharIterator *iter) {
if(iter->index<iter->limit) {
- return ((const UChar *)(iter->context))[iter->index];
+ return ((const char16_t *)(iter->context))[iter->index];
} else {
return U_SENTINEL;
}
static UChar32 U_CALLCONV
stringIteratorNext(UCharIterator *iter) {
if(iter->index<iter->limit) {
- return ((const UChar *)(iter->context))[iter->index++];
+ return ((const char16_t *)(iter->context))[iter->index++];
} else {
return U_SENTINEL;
}
static UChar32 U_CALLCONV
stringIteratorPrevious(UCharIterator *iter) {
if(iter->index>iter->start) {
- return ((const UChar *)(iter->context))[--iter->index];
+ return ((const char16_t *)(iter->context))[--iter->index];
} else {
return U_SENTINEL;
}
};
U_CAPI void U_EXPORT2
-uiter_setString(UCharIterator *iter, const UChar *s, int32_t length) {
+uiter_setString(UCharIterator *iter, const char16_t *s, int32_t length) {
if(iter!=0) {
if(s!=0 && length>=-1) {
*iter=stringIterator;
/* UCharIterator implementation for UTF-16BE strings ------------------------ */
/*
- * This is an implementation of a code unit (UChar) iterator
+ * This is an implementation of a code unit (char16_t) iterator
* for UTF-16BE strings, i.e., strings in byte-vectors where
- * each UChar is stored as a big-endian pair of bytes.
+ * each char16_t is stored as a big-endian pair of bytes.
*
* The UCharIterator.context field holds a pointer to the string.
- * Everything works just like with a normal UChar iterator (uiter_setString),
+ * Everything works just like with a normal char16_t iterator (uiter_setString),
* except that UChars are assembled from byte pairs.
*/
static inline UChar32
utf16BEIteratorGet(UCharIterator *iter, int32_t index) {
const uint8_t *p=(const uint8_t *)iter->context;
- return ((UChar)p[2*index]<<8)|(UChar)p[2*index+1];
+ return ((char16_t)p[2*index]<<8)|(char16_t)p[2*index+1];
}
static UChar32 U_CALLCONV
};
/*
- * Count the number of UChars in a UTF-16BE string before a terminating UChar NUL,
+ * Count the number of UChars in a UTF-16BE string before a terminating char16_t NUL,
* i.e., before a pair of 0 bytes where the first 0 byte is at an even
* offset from s.
*/
if(IS_POINTER_EVEN(s)) {
/*
* even-aligned, call u_strlen(s)
- * we are probably on a little-endian machine, but searching for UChar NUL
+ * we are probably on a little-endian machine, but searching for char16_t NUL
* does not care about endianness
*/
- return u_strlen((const UChar *)s);
+ return u_strlen((const char16_t *)s);
} else {
/* odd-aligned, search for pair of 0 bytes */
const char *p=s;
length>>=1;
if(U_IS_BIG_ENDIAN && IS_POINTER_EVEN(s)) {
- /* big-endian machine and 2-aligned UTF-16BE string: use normal UChar iterator */
- uiter_setString(iter, (const UChar *)s, length);
+ /* big-endian machine and 2-aligned UTF-16BE string: use normal char16_t iterator */
+ uiter_setString(iter, (const char16_t *)s, length);
return;
}
/* UCharIterator wrapper around Replaceable --------------------------------- */
/*
- * This is an implementation of a code unit (UChar) iterator
+ * This is an implementation of a code unit (char16_t) iterator
* based on a Replaceable object.
*
* The UCharIterator.context field holds a pointer to the Replaceable.
/*
* Minimal implementation:
- * Maintain a single-UChar buffer for an additional surrogate.
+ * Maintain a single-char16_t buffer for an additional surrogate.
* The caller must not modify start and limit because they are used internally.
*
* Use UCharIterator fields as follows:
int32_t index;
if(iter->reservedField!=0) {
- UChar trail=U16_TRAIL(iter->reservedField);
+ char16_t trail=U16_TRAIL(iter->reservedField);
iter->reservedField=0;
if((index=iter->index)>=0) {
iter->index=index+1;
int32_t index;
if(iter->reservedField!=0) {
- UChar lead=U16_LEAD(iter->reservedField);
+ char16_t lead=U16_LEAD(iter->reservedField);
iter->reservedField=0;
iter->start-=4; /* we stayed behind the supplementary code point; go before it now */
if((index=iter->index)>0) {
while (ures_hasNext(typeAliasResByKey.getAlias()) && U_SUCCESS(sts)) {
int32_t toLen;
typeAliasDataEntry.adoptInstead(ures_getNextResource(typeAliasResByKey.getAlias(), typeAliasDataEntry.orphan(), &sts));
- const UChar* to = ures_getString(typeAliasDataEntry.getAlias(), &toLen, &sts);
+ const char16_t* to = ures_getString(typeAliasDataEntry.getAlias(), &toLen, &sts);
if (U_FAILURE(sts)) {
break;
}
while (ures_hasNext(bcpTypeAliasResByKey.getAlias()) && U_SUCCESS(sts)) {
int32_t toLen;
bcpTypeAliasDataEntry.adoptInstead(ures_getNextResource(bcpTypeAliasResByKey.getAlias(), bcpTypeAliasDataEntry.orphan(), &sts));
- const UChar* to = ures_getString(bcpTypeAliasDataEntry.getAlias(), &toLen, &sts);
+ const char16_t* to = ures_getString(bcpTypeAliasDataEntry.getAlias(), &toLen, &sts);
if (U_FAILURE(sts)) {
break;
}
// Convert from UTF-8 string to UTF-16 string.
wchar_t utf16Path[MAX_PATH];
int32_t pathUtf16Len = 0;
- u_strFromUTF8(reinterpret_cast<UChar*>(utf16Path), static_cast<int32_t>(UPRV_LENGTHOF(utf16Path)), &pathUtf16Len, path, -1, status);
+ u_strFromUTF8(reinterpret_cast<char16_t*>(utf16Path), static_cast<int32_t>(UPRV_LENGTHOF(utf16Path)), &pathUtf16Len, path, -1, status);
if (U_FAILURE(*status)) {
return false;
*/
static void
charSetToUSet(uint32_t cset[8], const USetAdder *sa) {
- UChar us[256];
+ char16_t us[256];
char cs[256];
int32_t i, length;
}
}
- /* convert the char string to a UChar string */
+ /* convert the char string to a char16_t string */
u_charsToUChars(cs, us, length);
- /* add each UChar to the USet */
+ /* add each char16_t to the USet */
for(i=0; i<length; ++i) {
- if(us[i]!=0 || cs[i]==0) { /* non-invariant chars become (UChar)0 */
+ if(us[i]!=0 || cs[i]==0) { /* non-invariant chars become (char16_t)0 */
sa->add(sa->set, us[i]);
}
}
ures_getUnicodeString(const UResourceBundle *resB, UErrorCode* status) {
UnicodeString result;
int32_t len = 0;
- const UChar *r = ures_getString(resB, &len, status);
+ const char16_t *r = ures_getString(resB, &len, status);
if(U_SUCCESS(*status)) {
result.setTo(true, r, len);
} else {
ures_getNextUnicodeString(UResourceBundle *resB, const char ** key, UErrorCode* status) {
UnicodeString result;
int32_t len = 0;
- const UChar* r = ures_getNextString(resB, &len, key, status);
+ const char16_t* r = ures_getNextString(resB, &len, key, status);
if(U_SUCCESS(*status)) {
result.setTo(true, r, len);
} else {
ures_getUnicodeStringByIndex(const UResourceBundle *resB, int32_t indexS, UErrorCode* status) {
UnicodeString result;
int32_t len = 0;
- const UChar* r = ures_getStringByIndex(resB, indexS, &len, status);
+ const char16_t* r = ures_getStringByIndex(resB, indexS, &len, status);
if(U_SUCCESS(*status)) {
result.setTo(true, r, len);
} else {
ures_getUnicodeStringByKey(const UResourceBundle *resB, const char* key, UErrorCode* status) {
UnicodeString result;
int32_t len = 0;
- const UChar* r = ures_getStringByKey(resB, key, &len, status);
+ const char16_t* r = ures_getStringByKey(resB, key, &len, status);
if(U_SUCCESS(*status)) {
result.setTo(true, r, len);
} else {
// firstChar is the leftmost char to match in the
// forward direction or the rightmost char to match in
// the reverse direction.
- UChar firstChar = text.charAt(offset);
+ char16_t firstChar = text.charAt(offset);
// If there are multiple strings that can match we
// return the longest match.
continue; // skip the empty string
}
- UChar c = trial.charAt(forward ? 0 : trial.length() - 1);
+ char16_t c = trial.charAt(forward ? 0 : trial.length() - 1);
// Strings are sorted, so we can optimize in the
// forward direction.
*/
void UnicodeSet::setPattern(const char16_t *newPat, int32_t newPatLen) {
releasePattern();
- pat = (UChar *)uprv_malloc((newPatLen + 1) * sizeof(UChar));
+ pat = (char16_t *)uprv_malloc((newPatLen + 1) * sizeof(char16_t));
if (pat) {
patLen = newPatLen;
u_memcpy(pat, newPat, patLen);
return this;
}
-int32_t UnicodeSet::span(const UChar *s, int32_t length, USetSpanCondition spanCondition) const {
+int32_t UnicodeSet::span(const char16_t *s, int32_t length, USetSpanCondition spanCondition) const {
if(length>0 && bmpSet!=nullptr) {
return (int32_t)(bmpSet->span(s, s+length, spanCondition)-s);
}
return prev;
}
-int32_t UnicodeSet::spanBack(const UChar *s, int32_t length, USetSpanCondition spanCondition) const {
+int32_t UnicodeSet::spanBack(const char16_t *s, int32_t length, USetSpanCondition spanCondition) const {
if(length>0 && bmpSet!=nullptr) {
return (int32_t)(bmpSet->spanBack(s, s+length, spanCondition)-s);
}
}
static void U_CALLCONV
-_set_addString(USet *set, const UChar *str, int32_t length) {
+_set_addString(USet *set, const char16_t *str, int32_t length) {
((UnicodeSet *)set)->add(UnicodeString((UBool)(length<0), str, length));
}
// add the result of a full case mapping to the set
// use str as a temporary string to avoid constructing one
static inline void
-addCaseMapping(UnicodeSet &set, int32_t result, const UChar *full, UnicodeString &str) {
+addCaseMapping(UnicodeSet &set, int32_t result, const char16_t *full, UnicodeString &str) {
if(result >= 0) {
if(result > UCASE_MAX_STRING_LENGTH) {
// add a single-code point case mapping
int32_t n = getRangeCount();
UChar32 result;
- const UChar *full;
+ const char16_t *full;
for (int32_t i=0; i<n; ++i) {
UChar32 start = getRangeStart(i);
static inline UBool
isPerlOpen(const UnicodeString &pattern, int32_t pos) {
- UChar c;
+ char16_t c;
return pattern.charAt(pos)==u'\\' && ((c=pattern.charAt(pos+1))==u'p' || c==u'P');
}
*/
UBool UnicodeSet::resemblesPattern(const UnicodeString& pattern, int32_t pos) {
return ((pos+1) < pattern.length() &&
- pattern.charAt(pos) == (UChar)91/*[*/) ||
+ pattern.charAt(pos) == (char16_t)91/*[*/) ||
resemblesPropertyPattern(pattern, pos);
}
// lastItem: 0=none, 1=char, 2=set
int8_t lastItem = 0, mode = 0;
UChar32 lastChar = 0;
- UChar op = 0;
+ char16_t op = 0;
UBool invert = false;
case u'-':
if (op == 0) {
if (lastItem != 0) {
- op = (UChar) c;
+ op = (char16_t) c;
continue;
} else {
// Treat final trailing '-' as a literal
return;
case u'&':
if (lastItem == 2 && op == 0) {
- op = (UChar) c;
+ op = (char16_t) c;
continue;
}
// syntaxError(chars, "'&' not after set");
}
add(U_ETHER);
usePat = true;
- patLocal.append((UChar) SymbolTable::SYMBOL_REF);
+ patLocal.append((char16_t) SymbolTable::SYMBOL_REF);
patLocal.append(u']');
mode = 2;
continue;
invert = true;
}
} else if (isPerlOpen(pattern, pos) || isNameOpen(pattern, pos)) {
- UChar c = pattern.charAt(pos+1);
+ char16_t c = pattern.charAt(pos+1);
invert = (c == u'P');
isName = (c == u'N');
pos += 2;
// Get the number of UTF-8 bytes for a UTF-16 (sub)string.
static int32_t
-getUTF8Length(const UChar *s, int32_t length) {
+getUTF8Length(const char16_t *s, int32_t length) {
UErrorCode errorCode=U_ZERO_ERROR;
int32_t length8=0;
u_strToUTF8(nullptr, 0, &length8, s, length, &errorCode);
// Append the UTF-8 version of the string to t and return the appended UTF-8 length.
static int32_t
-appendUTF8(const UChar *s, int32_t length, uint8_t *t, int32_t capacity) {
+appendUTF8(const char16_t *s, int32_t length, uint8_t *t, int32_t capacity) {
UErrorCode errorCode=U_ZERO_ERROR;
int32_t length8=0;
u_strToUTF8((char *)t, capacity, &length8, s, length, &errorCode);
UBool someRelevant=false;
for(i=0; i<stringsLength; ++i) {
const UnicodeString &string=*(const UnicodeString *)strings.elementAt(i);
- const UChar *s16=string.getBuffer();
+ const char16_t *s16=string.getBuffer();
int32_t length16=string.length();
if (length16==0) {
continue; // skip the empty string
for(i=0; i<stringsLength; ++i) {
const UnicodeString &string=*(const UnicodeString *)strings.elementAt(i);
- const UChar *s16=string.getBuffer();
+ const char16_t *s16=string.getBuffer();
int32_t length16=string.length();
spanLength=spanSet.span(s16, length16, USET_SPAN_CONTAINED);
if(spanLength<length16 && length16>0) { // Relevant string.
// Compare strings without any argument checks. Requires length>0.
static inline UBool
-matches16(const UChar *s, const UChar *t, int32_t length) {
+matches16(const char16_t *s, const char16_t *t, int32_t length) {
do {
if(*s++!=*t++) {
return false;
// at code point boundaries.
// That is, each edge of a match must not be in the middle of a surrogate pair.
static inline UBool
-matches16CPB(const UChar *s, int32_t start, int32_t limit, const UChar *t, int32_t length) {
+matches16CPB(const char16_t *s, int32_t start, int32_t limit, const char16_t *t, int32_t length) {
s+=start;
limit-=start;
return matches16(s, t, length) &&
// Does the set contain the next code point?
// If so, return its length; otherwise return its negative length.
static inline int32_t
-spanOne(const UnicodeSet &set, const UChar *s, int32_t length) {
- UChar c=*s, c2;
+spanOne(const UnicodeSet &set, const char16_t *s, int32_t length) {
+ char16_t c=*s, c2;
if(c>=0xd800 && c<=0xdbff && length>=2 && U16_IS_TRAIL(c2=s[1])) {
return set.contains(U16_GET_SUPPLEMENTARY(c, c2)) ? 2 : -2;
}
}
static inline int32_t
-spanOneBack(const UnicodeSet &set, const UChar *s, int32_t length) {
- UChar c=s[length-1], c2;
+spanOneBack(const UnicodeSet &set, const char16_t *s, int32_t length) {
+ char16_t c=s[length-1], c2;
if(c>=0xdc00 && c<=0xdfff && length>=2 && U16_IS_LEAD(c2=s[length-2])) {
return set.contains(U16_GET_SUPPLEMENTARY(c2, c)) ? 2 : -2;
}
* Stop if spanLength==0, otherwise continue the loop.
*/
-int32_t UnicodeSetStringSpan::span(const UChar *s, int32_t length, USetSpanCondition spanCondition) const {
+int32_t UnicodeSetStringSpan::span(const char16_t *s, int32_t length, USetSpanCondition spanCondition) const {
if(spanCondition==USET_SPAN_NOT_CONTAINED) {
return spanNot(s, length);
}
continue; // Irrelevant string. (Also the empty string.)
}
const UnicodeString &string=*(const UnicodeString *)strings.elementAt(i);
- const UChar *s16=string.getBuffer();
+ const char16_t *s16=string.getBuffer();
int32_t length16=string.length();
U_ASSERT(length>0);
// to find the match from the earliest start.
const UnicodeString &string=*(const UnicodeString *)strings.elementAt(i);
- const UChar *s16=string.getBuffer();
+ const char16_t *s16=string.getBuffer();
int32_t length16=string.length();
if (length16==0) {
continue; // skip the empty string
}
}
-int32_t UnicodeSetStringSpan::spanBack(const UChar *s, int32_t length, USetSpanCondition spanCondition) const {
+int32_t UnicodeSetStringSpan::spanBack(const char16_t *s, int32_t length, USetSpanCondition spanCondition) const {
if(spanCondition==USET_SPAN_NOT_CONTAINED) {
return spanNotBack(s, length);
}
continue; // Irrelevant string. (Also the empty string.)
}
const UnicodeString &string=*(const UnicodeString *)strings.elementAt(i);
- const UChar *s16=string.getBuffer();
+ const char16_t *s16=string.getBuffer();
int32_t length16=string.length();
U_ASSERT(length>0);
// to find the match from the latest end.
const UnicodeString &string=*(const UnicodeString *)strings.elementAt(i);
- const UChar *s16=string.getBuffer();
+ const char16_t *s16=string.getBuffer();
int32_t length16=string.length();
if (length16==0) {
continue; // skip the empty string
* when there is not actually a match for such a set string.
*/
-int32_t UnicodeSetStringSpan::spanNot(const UChar *s, int32_t length) const {
+int32_t UnicodeSetStringSpan::spanNot(const char16_t *s, int32_t length) const {
int32_t pos=0, rest=length;
int32_t i, stringsLength=strings.size();
do {
continue; // Irrelevant string. (Also the empty string.)
}
const UnicodeString &string=*(const UnicodeString *)strings.elementAt(i);
- const UChar *s16=string.getBuffer();
+ const char16_t *s16=string.getBuffer();
int32_t length16=string.length();
U_ASSERT(length>0);
if(length16<=rest && matches16CPB(s, pos, length, s16, length16)) {
return length; // Reached the end of the string.
}
-int32_t UnicodeSetStringSpan::spanNotBack(const UChar *s, int32_t length) const {
+int32_t UnicodeSetStringSpan::spanNotBack(const char16_t *s, int32_t length) const {
int32_t pos=length;
int32_t i, stringsLength=strings.size();
do {
continue; // Irrelevant string. (Also the empty string.)
}
const UnicodeString &string=*(const UnicodeString *)strings.elementAt(i);
- const UChar *s16=string.getBuffer();
+ const char16_t *s16=string.getBuffer();
int32_t length16=string.length();
U_ASSERT(length>0);
if(length16<=pos && matches16CPB(s, pos-length16, length, s16, length16)) {
// For fast UnicodeSet::contains(c).
inline UBool contains(UChar32 c) const;
- int32_t span(const UChar *s, int32_t length, USetSpanCondition spanCondition) const;
+ int32_t span(const char16_t *s, int32_t length, USetSpanCondition spanCondition) const;
- int32_t spanBack(const UChar *s, int32_t length, USetSpanCondition spanCondition) const;
+ int32_t spanBack(const char16_t *s, int32_t length, USetSpanCondition spanCondition) const;
int32_t spanUTF8(const uint8_t *s, int32_t length, USetSpanCondition spanCondition) const;
// so that a character span ends before any string.
void addToSpanNotSet(UChar32 c);
- int32_t spanNot(const UChar *s, int32_t length) const;
- int32_t spanNotBack(const UChar *s, int32_t length) const;
+ int32_t spanNot(const char16_t *s, int32_t length) const;
+ int32_t spanNotBack(const char16_t *s, int32_t length) const;
int32_t spanNotUTF8(const uint8_t *s, int32_t length) const;
int32_t spanNotBackUTF8(const uint8_t *s, int32_t length) const;
print(const UnicodeString& s,
const char *name)
{
- UChar c;
+ char16_t c;
cout << name << ":|";
for(int i = 0; i < s.length(); ++i) {
c = s[i];
}
void
-print(const UChar *s,
+print(const char16_t *s,
int32_t len,
const char *name)
{
- UChar c;
+ char16_t c;
cout << name << ":|";
for(int i = 0; i < len; ++i) {
c = s[i];
// need to copy areas that may overlap
static
inline void
-us_arrayCopy(const UChar *src, int32_t srcStart,
- UChar *dst, int32_t dstStart, int32_t count)
+us_arrayCopy(const char16_t *src, int32_t srcStart,
+ char16_t *dst, int32_t dstStart, int32_t count)
{
if(count>0) {
uprv_memmove(dst+dstStart, src+srcStart, (size_t)count*sizeof(*src));
}
}
-// u_unescapeAt() callback to get a UChar from a UnicodeString
+// u_unescapeAt() callback to get a char16_t from a UnicodeString
U_CDECL_BEGIN
-static UChar U_CALLCONV
+static char16_t U_CALLCONV
UnicodeString_charAt(int32_t offset, void *context) {
return ((icu::UnicodeString*) context)->charAt(offset);
}
capacity = length;
}
if(allocate(capacity)) {
- UChar *array = getArrayStart();
- UChar unit = (UChar)c;
+ char16_t *array = getArrayStart();
+ char16_t unit = (char16_t)c;
for(int32_t i = 0; i < length; ++i) {
array[i] = unit;
}
capacity = length;
}
if(allocate(capacity)) {
- UChar *array = getArrayStart();
- UChar lead = U16_LEAD(c);
- UChar trail = U16_TRAIL(c);
+ char16_t *array = getArrayStart();
+ char16_t lead = U16_LEAD(c);
+ char16_t trail = U16_TRAIL(c);
for(int32_t i = 0; i < length; i += 2) {
array[i] = lead;
array[i + 1] = trail;
}
}
-UnicodeString::UnicodeString(UChar ch) {
+UnicodeString::UnicodeString(char16_t ch) {
fUnion.fFields.fLengthAndFlags = kLength1 | kShortString;
fUnion.fStackFields.fBuffer[0] = ch;
}
}
}
-UnicodeString::UnicodeString(const UChar *text) {
+UnicodeString::UnicodeString(const char16_t *text) {
fUnion.fFields.fLengthAndFlags = kShortString;
doAppend(text, 0, -1);
}
-UnicodeString::UnicodeString(const UChar *text,
+UnicodeString::UnicodeString(const char16_t *text,
int32_t textLength) {
fUnion.fFields.fLengthAndFlags = kShortString;
doAppend(text, 0, textLength);
ConstChar16Ptr textPtr,
int32_t textLength) {
fUnion.fFields.fLengthAndFlags = kReadonlyAlias;
- const UChar *text = textPtr;
+ const char16_t *text = textPtr;
if(text == nullptr) {
// treat as an empty string, do not alias
setToEmpty();
// text is terminated, or else it would have failed the above test
textLength = u_strlen(text);
}
- setArray(const_cast<UChar *>(text), textLength,
+ setArray(const_cast<char16_t *>(text), textLength,
isTerminated ? textLength + 1 : textLength);
}
}
-UnicodeString::UnicodeString(UChar *buff,
+UnicodeString::UnicodeString(char16_t *buff,
int32_t buffLength,
int32_t buffCapacity) {
fUnion.fFields.fLengthAndFlags = kWritableAlias;
} else {
if(buffLength == -1) {
// fLength = u_strlen(buff); but do not look beyond buffCapacity
- const UChar *p = buff, *limit = buff + buffCapacity;
+ const char16_t *p = buff, *limit = buff + buffCapacity;
while(p != limit && *p != 0) {
++p;
}
*array++ = 1;
numBytes -= sizeof(int32_t);
- // have fArray point to the first UChar
- fUnion.fFields.fArray = (UChar *)array;
+ // have fArray point to the first char16_t
+ fUnion.fFields.fArray = (char16_t *)array;
fUnion.fFields.fCapacity = (int32_t)(numBytes / U_SIZEOF_UCHAR);
fUnion.fFields.fLengthAndFlags = kLongString;
return true;
capacity = length + (length >> 4) + 4;
}
do {
- UChar *utf16 = result.getBuffer(capacity);
+ char16_t *utf16 = result.getBuffer(capacity);
int32_t length16;
UErrorCode errorCode = U_ZERO_ERROR;
u_strFromUTF32WithSub(utf16, result.getCapacity(), &length16,
if (result.isBogus()) {
return result;
}
- const UChar *array = getBuffer();
+ const char16_t *array = getBuffer();
int32_t len = length();
int32_t prev = 0;
for (int32_t i=0;;) {
int8_t
UnicodeString::doCompare( int32_t start,
int32_t length,
- const UChar *srcChars,
+ const char16_t *srcChars,
int32_t srcStart,
int32_t srcLength) const
{
pinIndices(start, length);
if(srcChars == nullptr) {
- // treat const UChar *srcChars==nullptr as an empty string
+ // treat const char16_t *srcChars==nullptr as an empty string
return length == 0 ? 0 : 1;
}
// get the correct pointer
- const UChar *chars = getArrayStart();
+ const char16_t *chars = getArrayStart();
chars += start;
srcChars += srcStart;
# if U_IS_BIG_ENDIAN
// big-endian: byte comparison works
- result = uprv_memcmp(chars, srcChars, minLength * sizeof(UChar));
+ result = uprv_memcmp(chars, srcChars, minLength * sizeof(char16_t));
if(result != 0) {
return (int8_t)(result >> 15 | 1);
}
# else
- // little-endian: compare UChar units
+ // little-endian: compare char16_t units
do {
result = ((int32_t)*(chars++) - (int32_t)*(srcChars++));
if(result != 0) {
int8_t
UnicodeString::doCompareCodePointOrder(int32_t start,
int32_t length,
- const UChar *srcChars,
+ const char16_t *srcChars,
int32_t srcStart,
int32_t srcLength) const
{
// compare illegal string values
- // treat const UChar *srcChars==nullptr as an empty string
+ // treat const char16_t *srcChars==nullptr as an empty string
if(isBogus()) {
return -1;
}
return length();
}
-UChar
+char16_t
UnicodeString::getCharAt(int32_t offset) const {
return charAt(offset);
}
{
int32_t len = length();
if((uint32_t)offset < (uint32_t)len) {
- const UChar *array = getArrayStart();
+ const char16_t *array = getArrayStart();
UChar32 c;
U16_GET(array, 0, offset, len, c);
return c;
int32_t
UnicodeString::getChar32Start(int32_t offset) const {
if((uint32_t)offset < (uint32_t)length()) {
- const UChar *array = getArrayStart();
+ const char16_t *array = getArrayStart();
U16_SET_CP_START(array, 0, offset);
return offset;
} else {
UnicodeString::getChar32Limit(int32_t offset) const {
int32_t len = length();
if((uint32_t)offset < (uint32_t)len) {
- const UChar *array = getArrayStart();
+ const char16_t *array = getArrayStart();
U16_SET_CP_LIMIT(array, 0, offset, len);
return offset;
} else {
index=len;
}
- const UChar *array = getArrayStart();
+ const char16_t *array = getArrayStart();
if(delta>0) {
U16_FWD_N(array, index, len, delta);
} else {
void
UnicodeString::doExtract(int32_t start,
int32_t length,
- UChar *dst,
+ char16_t *dst,
int32_t dstStart) const
{
// pin indices to legal values
pinIndices(start, length);
// do not copy anything if we alias dst itself
- const UChar *array = getArrayStart();
+ const char16_t *array = getArrayStart();
if(array + start != dst + dstStart) {
us_arrayCopy(array, start, dst, dstStart, length);
}
if(isBogus() || destCapacity<0 || (destCapacity>0 && dest==0)) {
errorCode=U_ILLEGAL_ARGUMENT_ERROR;
} else {
- const UChar *array = getArrayStart();
+ const char16_t *array = getArrayStart();
if(len>0 && len<=destCapacity && array!=dest) {
u_memcpy(dest, array, len);
}
UnicodeString
UnicodeString::tempSubString(int32_t start, int32_t len) const {
pinIndices(start, len);
- const UChar *array = getBuffer(); // not getArrayStart() to check kIsBogus & kOpenGetBuffer
+ const char16_t *array = getBuffer(); // not getArrayStart() to check kIsBogus & kOpenGetBuffer
if(array==nullptr) {
array=fUnion.fStackFields.fBuffer; // anything not nullptr because that would make an empty string
len=-2; // bogus result string
}
int32_t
-UnicodeString::indexOf(const UChar *srcChars,
+UnicodeString::indexOf(const char16_t *srcChars,
int32_t srcStart,
int32_t srcLength,
int32_t start,
pinIndices(start, length);
// find the first occurrence of the substring
- const UChar *array = getArrayStart();
- const UChar *match = u_strFindFirst(array + start, length, srcChars + srcStart, srcLength);
+ const char16_t *array = getArrayStart();
+ const char16_t *match = u_strFindFirst(array + start, length, srcChars + srcStart, srcLength);
if(match == nullptr) {
return -1;
} else {
}
int32_t
-UnicodeString::doIndexOf(UChar c,
+UnicodeString::doIndexOf(char16_t c,
int32_t start,
int32_t length) const
{
pinIndices(start, length);
// find the first occurrence of c
- const UChar *array = getArrayStart();
- const UChar *match = u_memchr(array + start, c, length);
+ const char16_t *array = getArrayStart();
+ const char16_t *match = u_memchr(array + start, c, length);
if(match == nullptr) {
return -1;
} else {
pinIndices(start, length);
// find the first occurrence of c
- const UChar *array = getArrayStart();
- const UChar *match = u_memchr32(array + start, c, length);
+ const char16_t *array = getArrayStart();
+ const char16_t *match = u_memchr32(array + start, c, length);
if(match == nullptr) {
return -1;
} else {
}
int32_t
-UnicodeString::lastIndexOf(const UChar *srcChars,
+UnicodeString::lastIndexOf(const char16_t *srcChars,
int32_t srcStart,
int32_t srcLength,
int32_t start,
pinIndices(start, length);
// find the last occurrence of the substring
- const UChar *array = getArrayStart();
- const UChar *match = u_strFindLast(array + start, length, srcChars + srcStart, srcLength);
+ const char16_t *array = getArrayStart();
+ const char16_t *match = u_strFindLast(array + start, length, srcChars + srcStart, srcLength);
if(match == nullptr) {
return -1;
} else {
}
int32_t
-UnicodeString::doLastIndexOf(UChar c,
+UnicodeString::doLastIndexOf(char16_t c,
int32_t start,
int32_t length) const
{
pinIndices(start, length);
// find the last occurrence of c
- const UChar *array = getArrayStart();
- const UChar *match = u_memrchr(array + start, c, length);
+ const char16_t *array = getArrayStart();
+ const char16_t *match = u_memrchr(array + start, c, length);
if(match == nullptr) {
return -1;
} else {
pinIndices(start, length);
// find the last occurrence of c
- const UChar *array = getArrayStart();
- const UChar *match = u_memrchr32(array + start, c, length);
+ const char16_t *array = getArrayStart();
+ const char16_t *match = u_memrchr32(array + start, c, length);
if(match == nullptr) {
return -1;
} else {
if(!isWritable()) {
return nullptr;
}
- UChar *array = getArrayStart();
+ char16_t *array = getArrayStart();
int32_t len = length();
if(len < getCapacity()) {
if(fUnion.fFields.fLengthAndFlags & kBufferIsReadonly) {
return *this;
}
- const UChar *text = textPtr;
+ const char16_t *text = textPtr;
if(text == nullptr) {
// treat as an empty string, do not alias
releaseArray();
textLength = u_strlen(text);
}
fUnion.fFields.fLengthAndFlags = kReadonlyAlias;
- setArray((UChar *)text, textLength, isTerminated ? textLength + 1 : textLength);
+ setArray((char16_t *)text, textLength, isTerminated ? textLength + 1 : textLength);
return *this;
}
// setTo() analogous to the writable-aliasing constructor with the same signature
UnicodeString &
-UnicodeString::setTo(UChar *buffer,
+UnicodeString::setTo(char16_t *buffer,
int32_t buffLength,
int32_t buffCapacity) {
if(fUnion.fFields.fLengthAndFlags & kOpenGetBuffer) {
return *this;
} else if(buffLength == -1) {
// buffLength = u_strlen(buff); but do not look beyond buffCapacity
- const UChar *p = buffer, *limit = buffer + buffCapacity;
+ const char16_t *p = buffer, *limit = buffer + buffCapacity;
while(p != limit && *p != 0) {
++p;
}
} else {
capacity = length + 1; // +1 for the terminating NUL.
}
- UChar *utf16 = getBuffer(capacity);
+ char16_t *utf16 = getBuffer(capacity);
int32_t length16;
UErrorCode errorCode = U_ZERO_ERROR;
u_strFromUTF8WithSub(utf16, getCapacity(), &length16,
UnicodeString&
UnicodeString::setCharAt(int32_t offset,
- UChar c)
+ char16_t c)
{
int32_t len = length();
if(cloneArrayIfNeeded() && len > 0) {
UnicodeString::replace(int32_t start,
int32_t _length,
UChar32 srcChar) {
- UChar buffer[U16_MAX_LENGTH];
+ char16_t buffer[U16_MAX_LENGTH];
int32_t count = 0;
UBool isError = false;
U16_APPEND(buffer, count, U16_MAX_LENGTH, srcChar, isError);
UnicodeString&
UnicodeString::append(UChar32 srcChar) {
- UChar buffer[U16_MAX_LENGTH];
+ char16_t buffer[U16_MAX_LENGTH];
int32_t _length = 0;
UBool isError = false;
U16_APPEND(buffer, _length, U16_MAX_LENGTH, srcChar, isError);
UnicodeString&
UnicodeString::doReplace(int32_t start,
int32_t length,
- const UChar *srcChars,
+ const char16_t *srcChars,
int32_t srcStart,
int32_t srcLength)
{
newLength += srcLength;
// Check for insertion into ourself
- const UChar *oldArray = getArrayStart();
+ const char16_t *oldArray = getArrayStart();
if (isBufferWritable() &&
oldArray < srcChars + srcLength &&
srcChars < oldArray + oldLength) {
// cloneArrayIfNeeded(doCopyArray=false) may change fArray but will not copy the current contents;
// therefore we need to keep the current fArray
- UChar oldStackBuffer[US_STACKBUF_SIZE];
+ char16_t oldStackBuffer[US_STACKBUF_SIZE];
if((fUnion.fFields.fLengthAndFlags&kUsingStackBuffer) && (newLength > US_STACKBUF_SIZE)) {
// copy the stack buffer contents because it will be overwritten with
// fUnion.fFields values
// now do the replace
- UChar *newArray = getArrayStart();
+ char16_t *newArray = getArrayStart();
if(newArray != oldArray) {
// if fArray changed, then we need to copy everything except what will change
us_arrayCopy(oldArray, 0, newArray, 0, start);
}
UnicodeString&
-UnicodeString::doAppend(const UChar *srcChars, int32_t srcStart, int32_t srcLength) {
+UnicodeString::doAppend(const char16_t *srcChars, int32_t srcStart, int32_t srcLength) {
if(!isWritable() || srcLength == 0 || srcChars == nullptr) {
return *this;
}
}
// Check for append onto ourself
- const UChar* oldArray = getArrayStart();
+ const char16_t* oldArray = getArrayStart();
if (isBufferWritable() &&
oldArray < srcChars + srcLength &&
srcChars < oldArray + oldLength) {
// optimize append() onto a large-enough, owned string
if((newLength <= getCapacity() && isBufferWritable()) ||
cloneArrayIfNeeded(newLength, getGrowCapacity(newLength))) {
- UChar *newArray = getArrayStart();
+ char16_t *newArray = getArrayStart();
// Do not copy characters when
- // UChar *buffer=str.getAppendBuffer(...);
+ // char16_t *buffer=str.getAppendBuffer(...);
// is followed by
// str.append(buffer, length);
// or
if (limit <= start) {
return; // Nothing to do; avoid bogus malloc call
}
- UChar* text = (UChar*) uprv_malloc( sizeof(UChar) * (limit - start) );
+ char16_t* text = (char16_t*) uprv_malloc( sizeof(char16_t) * (limit - start) );
// Check to make sure text is not null.
if (text != nullptr) {
extractBetween(start, limit, text, 0);
return *this;
}
- UChar *left = getArrayStart() + start;
- UChar *right = left + length - 1; // -1 for inclusive boundary (length>=2)
- UChar swap;
+ char16_t *left = getArrayStart() + start;
+ char16_t *right = left + length - 1; // -1 for inclusive boundary (length>=2)
+ char16_t swap;
UBool hasSupplementary = false;
// Before the loop we know left<right because length>=2.
/* if there are supplementary code points in the reversed range, then re-swap their surrogates */
if(hasSupplementary) {
- UChar swap2;
+ char16_t swap2;
left = getArrayStart() + start;
right = left + length - 1; // -1 so that we can look at *(left+1) if left<right
UBool
UnicodeString::padLeading(int32_t targetLength,
- UChar padChar)
+ char16_t padChar)
{
int32_t oldLength = length();
if(oldLength >= targetLength || !cloneArrayIfNeeded(targetLength)) {
return false;
} else {
// move contents up by padding width
- UChar *array = getArrayStart();
+ char16_t *array = getArrayStart();
int32_t start = targetLength - oldLength;
us_arrayCopy(array, 0, array, start, oldLength);
UBool
UnicodeString::padTrailing(int32_t targetLength,
- UChar padChar)
+ char16_t padChar)
{
int32_t oldLength = length();
if(oldLength >= targetLength || !cloneArrayIfNeeded(targetLength)) {
return false;
} else {
// fill in padding character
- UChar *array = getArrayStart();
+ char16_t *array = getArrayStart();
int32_t length = targetLength;
while(--length >= oldLength) {
array[length] = padChar;
UnicodeString::doHashCode() const
{
/* Delegate hash computation to uhash. This makes UnicodeString
- * hashing consistent with UChar* hashing. */
+ * hashing consistent with char16_t* hashing. */
int32_t hashCode = ustr_hashUCharsN(getArrayStart(), length());
if (hashCode == kInvalidHashCode) {
hashCode = kEmptyHashCode;
int32_t capacity=getCapacity();
if(newLength==-1) {
// the new length is the string length, capped by fCapacity
- const UChar *array=getArrayStart(), *p=array, *limit=array+capacity;
+ const char16_t *array=getArrayStart(), *p=array, *limit=array+capacity;
while(p<limit && *p!=0) {
++p;
}
}
// save old values
- UChar oldStackBuffer[US_STACKBUF_SIZE];
- UChar *oldArray;
+ char16_t oldStackBuffer[US_STACKBUF_SIZE];
+ char16_t *oldArray;
int32_t oldLength = length();
int16_t flags = fUnion.fFields.fLengthAndFlags;
UnicodeStringAppendable::~UnicodeStringAppendable() {}
UBool
-UnicodeStringAppendable::appendCodeUnit(UChar c) {
+UnicodeStringAppendable::appendCodeUnit(char16_t c) {
return str.doAppend(&c, 0, 1).isWritable();
}
UBool
UnicodeStringAppendable::appendCodePoint(UChar32 c) {
- UChar buffer[U16_MAX_LENGTH];
+ char16_t buffer[U16_MAX_LENGTH];
int32_t cLength = 0;
UBool isError = false;
U16_APPEND(buffer, cLength, U16_MAX_LENGTH, c, isError);
}
UBool
-UnicodeStringAppendable::appendString(const UChar *s, int32_t length) {
+UnicodeStringAppendable::appendString(const char16_t *s, int32_t length) {
return str.doAppend(s, 0, length).isWritable();
}
return str.cloneArrayIfNeeded(str.length() + appendCapacity);
}
-UChar *
+char16_t *
UnicodeStringAppendable::getAppendBuffer(int32_t minCapacity,
int32_t desiredCapacityHint,
- UChar *scratch, int32_t scratchCapacity,
+ char16_t *scratch, int32_t scratchCapacity,
int32_t *resultCapacity) {
if(minCapacity < 1 || scratchCapacity < minCapacity) {
*resultCapacity = 0;
int8_t
UnicodeString::doCaseCompare(int32_t start,
int32_t length,
- const UChar *srcChars,
+ const char16_t *srcChars,
int32_t srcStart,
int32_t srcLength,
uint32_t options) const
{
// compare illegal string values
- // treat const UChar *srcChars==nullptr as an empty string
+ // treat const char16_t *srcChars==nullptr as an empty string
if(isBogus()) {
return -1;
}
}
// get the correct pointer
- const UChar *chars = getArrayStart();
+ const char16_t *chars = getArrayStart();
chars += start;
if(srcStart!=0) {
return *this;
}
- UChar oldBuffer[2 * US_STACKBUF_SIZE];
- UChar *oldArray;
+ char16_t oldBuffer[2 * US_STACKBUF_SIZE];
+ char16_t *oldArray;
int32_t oldLength = length();
int32_t newLength;
UBool writable = isBufferWritable();
if (writable ? oldLength <= UPRV_LENGTHOF(oldBuffer) : oldLength < US_STACKBUF_SIZE) {
// Short string: Copy the contents into a temporary buffer and
// case-map back into the current array, or into the stack buffer.
- UChar *buffer = getArrayStart();
+ char16_t *buffer = getArrayStart();
int32_t capacity;
oldArray = oldBuffer;
u_memcpy(oldBuffer, buffer, oldLength);
// and often does not change its length.
oldArray = getArrayStart();
Edits edits;
- UChar replacementChars[200];
+ char16_t replacementChars[200];
#if !UCONFIG_NO_BREAK_ITERATION
if (iter != nullptr) {
oldString.setTo(false, oldArray, oldLength);
return 0;
}
- const UChar *src=getArrayStart()+start, *srcLimit=src+length;
+ const char16_t *src=getArrayStart()+start, *srcLimit=src+length;
char *originalDest=dest;
const char *destLimit;
// set up the conversion parameters
const char *mySource = codepageData;
const char *mySourceEnd = mySource + dataLength;
- UChar *array, *myTarget;
+ char16_t *array, *myTarget;
// estimate the size needed:
int32_t arraySize;
// try to use the stack buffer
arraySize = US_STACKBUF_SIZE;
} else {
- // 1.25 UChar's per source byte should cover most cases
+ // 1.25 char16_t's per source byte should cover most cases
arraySize = dataLength + (dataLength >> 2);
}
doCopyArray = true;
// estimate the new size needed, larger than before
- // try 2 UChar's per remaining source byte
+ // try 2 char16_t's per remaining source byte
arraySize = (int32_t)(length() + 2 * (mySourceEnd - mySource));
} else {
break;
return *this;
}
- UChar *array = getArrayStart();
+ char16_t *array = getArrayStart();
UChar32 c;
int32_t oldLength = this->length();
int32_t i = oldLength, length;
* {
* UnicodeStringAppender appender(astring);
* for (int32_t i = 0; i < 100; ++i) {
- * appender.append((UChar) i);
+ * appender.append((char16_t) i);
* }
* // appender flushed automatically when it goes out of scope.
* }
*/
UnicodeStringAppender(UnicodeString &dest) : fDest(&dest), fIdx(0) { }
- inline void append(UChar x) {
+ inline void append(char16_t x) {
if (fIdx == UPRV_LENGTHOF(fBuffer)) {
fDest->append(fBuffer, 0, fIdx);
fIdx = 0;
private:
UnicodeString *fDest;
int32_t fIdx;
- UChar fBuffer[32];
+ char16_t fBuffer[32];
UnicodeStringAppender(const UnicodeStringAppender &other);
UnicodeStringAppender &operator=(const UnicodeStringAppender &other);
};
/* quick check functions ---------------------------------------------------- */
U_CAPI UNormalizationCheckResult U_EXPORT2
-unorm_quickCheck(const UChar *src,
+unorm_quickCheck(const char16_t *src,
int32_t srcLength,
UNormalizationMode mode,
UErrorCode *pErrorCode) {
}
U_CAPI UNormalizationCheckResult U_EXPORT2
-unorm_quickCheckWithOptions(const UChar *src, int32_t srcLength,
+unorm_quickCheckWithOptions(const char16_t *src, int32_t srcLength,
UNormalizationMode mode, int32_t options,
UErrorCode *pErrorCode) {
const Normalizer2 *n2=Normalizer2Factory::getInstance(mode, *pErrorCode);
}
U_CAPI UBool U_EXPORT2
-unorm_isNormalized(const UChar *src, int32_t srcLength,
+unorm_isNormalized(const char16_t *src, int32_t srcLength,
UNormalizationMode mode,
UErrorCode *pErrorCode) {
const Normalizer2 *n2=Normalizer2Factory::getInstance(mode, *pErrorCode);
}
U_CAPI UBool U_EXPORT2
-unorm_isNormalizedWithOptions(const UChar *src, int32_t srcLength,
+unorm_isNormalizedWithOptions(const char16_t *src, int32_t srcLength,
UNormalizationMode mode, int32_t options,
UErrorCode *pErrorCode) {
const Normalizer2 *n2=Normalizer2Factory::getInstance(mode, *pErrorCode);
/** Public API for normalizing. */
U_CAPI int32_t U_EXPORT2
-unorm_normalize(const UChar *src, int32_t srcLength,
+unorm_normalize(const char16_t *src, int32_t srcLength,
UNormalizationMode mode, int32_t options,
- UChar *dest, int32_t destCapacity,
+ char16_t *dest, int32_t destCapacity,
UErrorCode *pErrorCode) {
const Normalizer2 *n2=Normalizer2Factory::getInstance(mode, *pErrorCode);
if(options&UNORM_UNICODE_3_2) {
static int32_t
_iterate(UCharIterator *src, UBool forward,
- UChar *dest, int32_t destCapacity,
+ char16_t *dest, int32_t destCapacity,
const Normalizer2 *n2,
UBool doNormalize, UBool *pNeededToNormalize,
UErrorCode *pErrorCode) {
static int32_t
unorm_iterate(UCharIterator *src, UBool forward,
- UChar *dest, int32_t destCapacity,
+ char16_t *dest, int32_t destCapacity,
UNormalizationMode mode, int32_t options,
UBool doNormalize, UBool *pNeededToNormalize,
UErrorCode *pErrorCode) {
U_CAPI int32_t U_EXPORT2
unorm_previous(UCharIterator *src,
- UChar *dest, int32_t destCapacity,
+ char16_t *dest, int32_t destCapacity,
UNormalizationMode mode, int32_t options,
UBool doNormalize, UBool *pNeededToNormalize,
UErrorCode *pErrorCode) {
U_CAPI int32_t U_EXPORT2
unorm_next(UCharIterator *src,
- UChar *dest, int32_t destCapacity,
+ char16_t *dest, int32_t destCapacity,
UNormalizationMode mode, int32_t options,
UBool doNormalize, UBool *pNeededToNormalize,
UErrorCode *pErrorCode) {
/* Concatenation of normalized strings -------------------------------------- */
static int32_t
-_concatenate(const UChar *left, int32_t leftLength,
- const UChar *right, int32_t rightLength,
- UChar *dest, int32_t destCapacity,
+_concatenate(const char16_t *left, int32_t leftLength,
+ const char16_t *right, int32_t rightLength,
+ char16_t *dest, int32_t destCapacity,
const Normalizer2 *n2,
UErrorCode *pErrorCode) {
if(U_FAILURE(*pErrorCode)) {
}
U_CAPI int32_t U_EXPORT2
-unorm_concatenate(const UChar *left, int32_t leftLength,
- const UChar *right, int32_t rightLength,
- UChar *dest, int32_t destCapacity,
+unorm_concatenate(const char16_t *left, int32_t leftLength,
+ const char16_t *right, int32_t rightLength,
+ char16_t *dest, int32_t destCapacity,
UNormalizationMode mode, int32_t options,
UErrorCode *pErrorCode) {
const Normalizer2 *n2=Normalizer2Factory::getInstance(mode, *pErrorCode);
/* stack element for previous-level source/decomposition pointers */
struct CmpEquivLevel {
- const UChar *start, *s, *limit;
+ const char16_t *start, *s, *limit;
};
typedef struct CmpEquivLevel CmpEquivLevel;
/* internal function */
static int32_t
-unorm_cmpEquivFold(const UChar *s1, int32_t length1,
- const UChar *s2, int32_t length2,
+unorm_cmpEquivFold(const char16_t *s1, int32_t length1,
+ const char16_t *s2, int32_t length2,
uint32_t options,
UErrorCode *pErrorCode) {
const Normalizer2Impl *nfcImpl;
/* current-level start/limit - s1/s2 as current */
- const UChar *start1, *start2, *limit1, *limit2;
+ const char16_t *start1, *start2, *limit1, *limit2;
/* decomposition and case folding variables */
- const UChar *p;
+ const char16_t *p;
int32_t length;
/* stacks of previous-level start/current/limit */
CmpEquivLevel stack1[2], stack2[2];
/* buffers for algorithmic decompositions */
- UChar decomp1[4], decomp2[4];
+ char16_t decomp1[4], decomp2[4];
/* case folding buffers, only use current-level start/limit */
- UChar fold1[UCASE_MAX_STRING_LENGTH+1], fold2[UCASE_MAX_STRING_LENGTH+1];
+ char16_t fold1[UCASE_MAX_STRING_LENGTH+1], fold2[UCASE_MAX_STRING_LENGTH+1];
/* track which is the current level per string */
int32_t level1, level2;
/* get complete code points for c1, c2 for lookups if either is a surrogate */
cp1=c1;
if(U_IS_SURROGATE(c1)) {
- UChar c;
+ char16_t c;
if(U_IS_SURROGATE_LEAD(c1)) {
if(s1!=limit1 && U16_IS_TRAIL(c=*s1)) {
cp2=c2;
if(U_IS_SURROGATE(c2)) {
- UChar c;
+ char16_t c;
if(U_IS_SURROGATE_LEAD(c2)) {
if(s2!=limit2 && U16_IS_TRAIL(c=*s2)) {
}
static
-UBool _normalize(const Normalizer2 *n2, const UChar *s, int32_t length,
+UBool _normalize(const Normalizer2 *n2, const char16_t *s, int32_t length,
UnicodeString &normalized, UErrorCode *pErrorCode) {
UnicodeString str(length<0, s, length);
}
U_CAPI int32_t U_EXPORT2
-unorm_compare(const UChar *s1, int32_t length1,
- const UChar *s2, int32_t length2,
+unorm_compare(const char16_t *s1, int32_t length1,
+ const char16_t *s2, int32_t length2,
uint32_t options,
UErrorCode *pErrorCode) {
/* argument checking */
*
* Strings are either stored as a single code unit or as the length
* followed by that many units.
- * const UChar *s=extraData+(index from auxTrie data bits 9..0);
+ * const char16_t *s=extraData+(index from auxTrie data bits 9..0);
* int32_t length;
* if(*s<0xff00) {
* // s points to the single-unit string
}
if(c>=0) {
/* single code point */
- const UChar *resultString;
+ const char16_t *resultString;
return (UBool)(ucase_toFullFolding(c, &resultString, U_FOLD_CASE_DEFAULT)>=0);
} else {
/* guess some large but stack-friendly capacity */
- UChar dest[2*UCASE_MAX_STRING_LENGTH];
+ char16_t dest[2*UCASE_MAX_STRING_LENGTH];
int32_t destLength;
destLength=u_strFoldCase(dest, UPRV_LENGTHOF(dest),
nfd.getBuffer(), nfd.length(),
ReorderingBuffer buffer(*kcf, dest);
// Small destCapacity for NFKC_CF(c).
if(buffer.init(5, errorCode)) {
- const UChar *srcArray=src.getBuffer();
+ const char16_t *srcArray=src.getBuffer();
kcf->compose(srcArray, srcArray+src.length(), false,
true, buffer, errorCode);
}
}
U_CAPI UBool U_EXPORT2
-u_stringHasBinaryProperty(const UChar *s, int32_t length, UProperty which) {
+u_stringHasBinaryProperty(const char16_t *s, int32_t length, UProperty which) {
if (s == nullptr && length != 0) { return false; }
if (length == 1) {
return u_hasBinaryProperty(s[0], which); // single code point
#if !UCONFIG_NO_NORMALIZATION
U_CAPI int32_t U_EXPORT2
-u_getFC_NFKC_Closure(UChar32 c, UChar *dest, int32_t destCapacity, UErrorCode *pErrorCode) {
+u_getFC_NFKC_Closure(UChar32 c, char16_t *dest, int32_t destCapacity, UErrorCode *pErrorCode) {
if(pErrorCode==nullptr || U_FAILURE(*pErrorCode)) {
return 0;
}
}
// first: b = NFKC(Fold(a))
UnicodeString folded1String;
- const UChar *folded1;
+ const char16_t *folded1;
int32_t folded1Length=ucase_toFullFolding(c, &folded1, U_FOLD_CASE_DEFAULT);
if(folded1Length<0) {
const Normalizer2Impl *nfkcImpl=Normalizer2Factory::getImpl(nfkc);
#include "ustr_cnv.h"
U_CAPI UResourceBundle * U_EXPORT2
-ures_openU(const UChar *myPath,
+ures_openU(const char16_t *myPath,
const char *localeID,
UErrorCode *status)
{
aliasres = res_getResource(&(r->fData), "%%ALIAS");
if (aliasres != RES_BOGUS) {
// No tracing: called during initial data loading
- const UChar *alias = res_getStringNoTrace(&(r->fData), aliasres, &aliasLen);
+ const char16_t *alias = res_getStringNoTrace(&(r->fData), aliasres, &aliasLen);
if(alias != nullptr && aliasLen > 0) { /* if there is actual alias - unload and load new data */
u_UCharsToChars(alias, aliasName, aliasLen+1);
r->fAlias = init_entry(aliasName, path, status);
if (parentRes != RES_BOGUS) { // An explicit parent was found.
int32_t parentLocaleLen = 0;
// No tracing: called during initial data loading
- const UChar *parentLocaleName = res_getStringNoTrace(&(t1->fData), parentRes, &parentLocaleLen);
+ const char16_t *parentLocaleName = res_getStringNoTrace(&(t1->fData), parentRes, &parentLocaleLen);
if(parentLocaleName != nullptr && 0 < parentLocaleLen && parentLocaleLen < nameCapacity) {
u_UCharsToChars(parentLocaleName, name, parentLocaleLen + 1);
if (uprv_strcmp(name, kRootLocaleName) == 0) {
if (U_FAILURE(*status)) { return resB; }
U_ASSERT(RES_GET_TYPE(r) == URES_ALIAS);
int32_t len = 0;
- const UChar *alias = res_getAlias(&resData, r, &len);
+ const char16_t *alias = res_getAlias(&resData, r, &len);
if(len <= 0) {
// bad alias
*status = U_ILLEGAL_ARGUMENT_ERROR;
* Functions to retrieve data from resource bundles.
*/
-U_CAPI const UChar* U_EXPORT2 ures_getString(const UResourceBundle* resB, int32_t* len, UErrorCode* status) {
- const UChar *s;
+U_CAPI const char16_t* U_EXPORT2 ures_getString(const UResourceBundle* resB, int32_t* len, UErrorCode* status) {
+ const char16_t *s;
if (status==nullptr || U_FAILURE(*status)) {
return nullptr;
}
}
static const char *
-ures_toUTF8String(const UChar *s16, int32_t length16,
+ures_toUTF8String(const char16_t *s16, int32_t length16,
char *dest, int32_t *pLength,
UBool forceCopy,
UErrorCode *status) {
}
if (!forceCopy && (length16 <= 0x2aaaaaaa)) {
/*
- * We know the string will fit into dest because each UChar turns
+ * We know the string will fit into dest because each char16_t turns
* into at most three UTF-8 bytes. Fill the latter part of dest
* so that callers do not expect to use dest as a string pointer,
* hopefully leading to more robust code for when resource bundles
UBool forceCopy,
UErrorCode *status) {
int32_t length16;
- const UChar *s16 = ures_getString(resB, &length16, status);
+ const char16_t *s16 = ures_getString(resB, &length16, status);
return ures_toUTF8String(s16, length16, dest, pLength, forceCopy, status);
}
return resB->fSize;
}
-static const UChar* ures_getStringWithAlias(const UResourceBundle *resB, Resource r, int32_t sIndex, int32_t *len, UErrorCode *status) {
+static const char16_t* ures_getStringWithAlias(const UResourceBundle *resB, Resource r, int32_t sIndex, int32_t *len, UErrorCode *status) {
if(RES_GET_TYPE(r) == URES_ALIAS) {
- const UChar* result = 0;
+ const char16_t* result = 0;
UResourceBundle *tempRes = ures_getByIndex(resB, sIndex, nullptr, status);
result = ures_getString(tempRes, len, status);
ures_close(tempRes);
return (UBool)(resB->fIndex < resB->fSize-1);
}
-U_CAPI const UChar* U_EXPORT2 ures_getNextString(UResourceBundle *resB, int32_t* len, const char ** key, UErrorCode *status) {
+U_CAPI const char16_t* U_EXPORT2 ures_getNextString(UResourceBundle *resB, int32_t* len, const char ** key, UErrorCode *status) {
Resource r = RES_BOGUS;
if (status==nullptr || U_FAILURE(*status)) {
return fillIn;
}
-U_CAPI const UChar* U_EXPORT2 ures_getStringByIndex(const UResourceBundle *resB, int32_t indexS, int32_t* len, UErrorCode *status) {
+U_CAPI const char16_t* U_EXPORT2 ures_getStringByIndex(const UResourceBundle *resB, int32_t indexS, int32_t* len, UErrorCode *status) {
const char* key = nullptr;
Resource r = RES_BOGUS;
UBool forceCopy,
UErrorCode *status) {
int32_t length16;
- const UChar *s16 = ures_getStringByIndex(resB, idx, &length16, status);
+ const char16_t *s16 = ures_getStringByIndex(resB, idx, &length16, status);
return ures_toUTF8String(s16, length16, dest, pLength, forceCopy, status);
}
return result;
}
-U_CAPI const UChar* U_EXPORT2
+U_CAPI const char16_t* U_EXPORT2
ures_getStringByKeyWithFallback(const UResourceBundle *resB,
const char* inKey,
int32_t* len,
UErrorCode *status) {
UResourceBundle stack;
- const UChar* retVal = nullptr;
+ const char16_t* retVal = nullptr;
ures_initStackObject(&stack);
ures_getByKeyWithFallback(resB, inKey, &stack, status);
int32_t length;
return fillIn;
}
-U_CAPI const UChar* U_EXPORT2 ures_getStringByKey(const UResourceBundle *resB, const char* inKey, int32_t* len, UErrorCode *status) {
+U_CAPI const char16_t* U_EXPORT2 ures_getStringByKey(const UResourceBundle *resB, const char* inKey, int32_t* len, UErrorCode *status) {
Resource res = RES_BOGUS;
UResourceDataEntry *dataEntry = nullptr;
const char* key = inKey;
return res_getString({resB, key}, &dataEntry->fData, res, len);
case URES_ALIAS:
{
- const UChar* result = 0;
+ const char16_t* result = 0;
UResourceBundle *tempRes = ures_getByKey(resB, inKey, nullptr, status);
result = ures_getString(tempRes, len, status);
ures_close(tempRes);
return res_getString({resB, key}, &resB->getResData(), res, len);
case URES_ALIAS:
{
- const UChar* result = 0;
+ const char16_t* result = 0;
UResourceBundle *tempRes = ures_getByKey(resB, inKey, nullptr, status);
result = ures_getString(tempRes, len, status);
ures_close(tempRes);
UBool forceCopy,
UErrorCode *status) {
int32_t length16;
- const UChar *s16 = ures_getStringByKey(resB, key, &length16, status);
+ const char16_t *s16 = ures_getStringByKey(resB, key, &length16, status);
return ures_toUTF8String(s16, length16, dest, pLength, forceCopy, status);
}
int32_t minor_len = 0;
int32_t len;
- const UChar* minor_version = ures_getStringByKey(resourceBundle, kVersionTag, &minor_len, &status);
+ const char16_t* minor_version = ures_getStringByKey(resourceBundle, kVersionTag, &minor_len, &status);
/* Determine the length of of the final version string. This is */
/* the length of the major part + the length of the separator */
} else if(subStatus == U_ZERO_ERROR) {
ures_getByKey(res,resName,&bund1, &subStatus);
if(subStatus == U_ZERO_ERROR) {
- const UChar *defUstr;
+ const char16_t *defUstr;
int32_t defLen;
/* look for default item */
#if defined(URES_TREE_DEBUG)
}
/* now, recalculate default kw if need be */
if(uprv_strlen(defLoc) > uprv_strlen(full)) {
- const UChar *defUstr;
+ const char16_t *defUstr;
int32_t defLen;
/* look for default item */
#if defined(URES_TREE_DEBUG)
/* now, recalculate default kw if need be */
if(uprv_strlen(defLoc) > uprv_strlen(full)) {
- const UChar *defUstr;
+ const char16_t *defUstr;
int32_t defLen;
/* look for default item */
#if defined(URES_TREE_DEBUG)
U_CAPI void U_EXPORT2
ures_getVersionByKey(const UResourceBundle* res, const char *key, UVersionInfo ver, UErrorCode *status) {
- const UChar *str;
+ const char16_t *str;
int32_t len;
str = ures_getStringByKey(res, key, &len, status);
if(U_SUCCESS(*status)) {
static const struct {
int32_t length;
- UChar nul;
- UChar pad;
+ char16_t nul;
+ char16_t pad;
} gEmptyString={ 0, 0, 0 };
/*
return (UResType)gPublicTypes[RES_GET_TYPE(res)];
}
-U_CAPI const UChar * U_EXPORT2
+U_CAPI const char16_t * U_EXPORT2
res_getStringNoTrace(const ResourceData *pResData, Resource res, int32_t *pLength) {
- const UChar *p;
+ const char16_t *p;
uint32_t offset=RES_GET_OFFSET(res);
int32_t length;
if(RES_GET_TYPE(res)==URES_STRING_V2) {
int32_t first;
if((int32_t)offset<pResData->poolStringIndexLimit) {
- p=(const UChar *)pResData->poolBundleStrings+offset;
+ p=(const char16_t *)pResData->poolBundleStrings+offset;
} else {
- p=(const UChar *)pResData->p16BitUnits+(offset-pResData->poolStringIndexLimit);
+ p=(const char16_t *)pResData->p16BitUnits+(offset-pResData->poolStringIndexLimit);
}
first=*p;
if(!U16_IS_TRAIL(first)) {
} else if(res==offset) /* RES_GET_TYPE(res)==URES_STRING */ {
const int32_t *p32= res==0 ? &gEmptyString.length : pResData->pRoot+res;
length=*p32++;
- p=(const UChar *)p32;
+ p=(const char16_t *)p32;
} else {
p=nullptr;
length=0;
} else if (res == offset) {
const int32_t *p32=pResData->pRoot+res;
int32_t length=*p32;
- const UChar *p=(const UChar *)p32;
+ const char16_t *p=(const char16_t *)p32;
return length == 3 && p[2] == 0x2205 && p[3] == 0x2205 && p[4] == 0x2205;
} else if (RES_GET_TYPE(res) == URES_STRING_V2) {
- const UChar *p;
+ const char16_t *p;
if((int32_t)offset<pResData->poolStringIndexLimit) {
- p=(const UChar *)pResData->poolBundleStrings+offset;
+ p=(const char16_t *)pResData->poolBundleStrings+offset;
} else {
- p=(const UChar *)pResData->p16BitUnits+(offset-pResData->poolStringIndexLimit);
+ p=(const char16_t *)pResData->p16BitUnits+(offset-pResData->poolStringIndexLimit);
}
int32_t first=*p;
if (first == 0x2205) { // implicit length
for(int32_t i = 0; i < length; ++i) {
int32_t sLength;
// No tracing: handled by the caller
- const UChar *s = res_getStringNoTrace(pResData, array.internalGetResource(pResData, i), &sLength);
+ const char16_t *s = res_getStringNoTrace(pResData, array.internalGetResource(pResData, i), &sLength);
if(s == nullptr) {
errorCode = U_RESOURCE_TYPE_MISMATCH;
return 0;
} // namespace
-U_CAPI const UChar * U_EXPORT2
+U_CAPI const char16_t * U_EXPORT2
res_getAlias(const ResourceData *pResData, Resource res, int32_t *pLength) {
- const UChar *p;
+ const char16_t *p;
uint32_t offset=RES_GET_OFFSET(res);
int32_t length;
if(RES_GET_TYPE(res)==URES_ALIAS) {
const int32_t *p32= offset==0 ? &gEmptyString.length : pResData->pRoot+offset;
length=*p32++;
- p=(const UChar *)p32;
+ p=(const char16_t *)p32;
} else {
p=nullptr;
length=0;
return res_getPublicType(res);
}
-const UChar *ResourceDataValue::getString(int32_t &length, UErrorCode &errorCode) const {
+const char16_t *ResourceDataValue::getString(int32_t &length, UErrorCode &errorCode) const {
if(U_FAILURE(errorCode)) {
return nullptr;
}
- const UChar *s = res_getString(fTraceInfo, &getData(), res, &length);
+ const char16_t *s = res_getString(fTraceInfo, &getData(), res, &length);
if(s == nullptr) {
errorCode = U_RESOURCE_TYPE_MISMATCH;
}
return s;
}
-const UChar *ResourceDataValue::getAliasString(int32_t &length, UErrorCode &errorCode) const {
+const char16_t *ResourceDataValue::getAliasString(int32_t &length, UErrorCode &errorCode) const {
if(U_FAILURE(errorCode)) {
return nullptr;
}
- const UChar *s = res_getAlias(&getData(), res, &length);
+ const char16_t *s = res_getAlias(&getData(), res, &length);
if(s == nullptr) {
errorCode = U_RESOURCE_TYPE_MISMATCH;
}
return 1;
}
int32_t sLength;
- const UChar *s = res_getString(fTraceInfo, &getData(), res, &sLength);
+ const char16_t *s = res_getString(fTraceInfo, &getData(), res, &sLength);
if(s != nullptr) {
dest[0].setTo(true, s, sLength);
return 1;
return us;
}
int32_t sLength;
- const UChar *s = res_getString(fTraceInfo, &getData(), res, &sLength);
+ const char16_t *s = res_getString(fTraceInfo, &getData(), res, &sLength);
if(s != nullptr) {
us.setTo(true, s, sLength);
return us;
static const char *const gUnknownKey="";
/* resource table key for collation binaries: "%%CollationBin" */
-static const UChar gCollationBinKey[]={
+static const char16_t gCollationBinKey[]={
0x25, 0x25,
0x43, 0x6f, 0x6c, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e,
0x42, 0x69, 0x6e,
count=udata_readInt32(ds, (int32_t)*p);
/* swap length */
ds->swapArray32(ds, p, 4, q, pErrorCode);
- /* swap each UChar (the terminating NUL would not change) */
+ /* swap each char16_t (the terminating NUL would not change) */
ds->swapArray16(ds, p+1, 2*count, q+1, pErrorCode);
break;
case URES_BINARY:
U_NAMESPACE_BEGIN
-inline const UChar* res_getString(const ResourceTracer& traceInfo,
+inline const char16_t* res_getString(const ResourceTracer& traceInfo,
const ResourceData *pResData, Resource res, int32_t *pLength) {
traceInfo.trace("string");
return res_getStringNoTrace(pResData, res, pLength);
UResourceDataEntry *getValidLocaleDataEntry() const { return validLocaleDataEntry; }
Resource getResource() const { return res; }
virtual UResType getType() const override;
- virtual const UChar *getString(int32_t &length, UErrorCode &errorCode) const override;
- virtual const UChar *getAliasString(int32_t &length, UErrorCode &errorCode) const override;
+ virtual const char16_t *getString(int32_t &length, UErrorCode &errorCode) const override;
+ virtual const char16_t *getAliasString(int32_t &length, UErrorCode &errorCode) const override;
virtual int32_t getInt(UErrorCode &errorCode) const override;
virtual uint32_t getUInt(UErrorCode &errorCode) const override;
virtual const int32_t *getIntVector(int32_t &length, UErrorCode &errorCode) const override;
struct UScriptRun
{
int32_t textLength;
- const UChar *textArray;
+ const char16_t *textArray;
int32_t scriptStart;
int32_t scriptLimit;
}
U_CAPI UScriptRun * U_EXPORT2
-uscript_openRun(const UChar *src, int32_t length, UErrorCode *pErrorCode)
+uscript_openRun(const char16_t *src, int32_t length, UErrorCode *pErrorCode)
{
UScriptRun *result = nullptr;
}
U_CAPI void U_EXPORT2
-uscript_setRunText(UScriptRun *scriptRun, const UChar *src, int32_t length, UErrorCode *pErrorCode)
+uscript_setRunText(UScriptRun *scriptRun, const char16_t *src, int32_t length, UErrorCode *pErrorCode)
{
if (pErrorCode == nullptr || U_FAILURE(*pErrorCode)) {
return;
scriptRun->scriptCode = USCRIPT_COMMON;
for (scriptRun->scriptStart = scriptRun->scriptLimit; scriptRun->scriptLimit < scriptRun->textLength; scriptRun->scriptLimit += 1) {
- UChar high = scriptRun->textArray[scriptRun->scriptLimit];
- UChar32 ch = high;
+ char16_t high = scriptRun->textArray[scriptRun->scriptLimit];
+ UChar32 ch = high;
UScriptCode sc;
int32_t pairIndex;
* in the text, see if it's followed by a low surrogate
*/
if (high >= 0xD800 && high <= 0xDBFF && scriptRun->scriptLimit < scriptRun->textLength - 1) {
- UChar low = scriptRun->textArray[scriptRun->scriptLimit + 1];
+ char16_t low = scriptRun->textArray[scriptRun->scriptLimit + 1];
/*
* if it is followed by a low surrogate,
} // namespace
U_CAPI int32_t U_EXPORT2
-uscript_getSampleString(UScriptCode script, UChar *dest, int32_t capacity, UErrorCode *pErrorCode) {
+uscript_getSampleString(UScriptCode script, char16_t *dest, int32_t capacity, UErrorCode *pErrorCode) {
if(U_FAILURE(*pErrorCode)) { return 0; }
if(capacity < 0 || (capacity > 0 && dest == nullptr)) {
*pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
}
U_CAPI void U_EXPORT2
-uset_addString(USet* set, const UChar* str, int32_t strLen) {
+uset_addString(USet* set, const char16_t* str, int32_t strLen) {
// UnicodeString handles -1 for strLen
UnicodeString s(strLen<0, str, strLen);
((UnicodeSet*) set)->UnicodeSet::add(s);
}
U_CAPI void U_EXPORT2
-uset_addAllCodePoints(USet* set, const UChar *str, int32_t strLen) {
+uset_addAllCodePoints(USet* set, const char16_t *str, int32_t strLen) {
// UnicodeString handles -1 for strLen
UnicodeString s(str, strLen);
((UnicodeSet*) set)->UnicodeSet::addAll(s);
}
U_CAPI void U_EXPORT2
-uset_removeString(USet* set, const UChar* str, int32_t strLen) {
+uset_removeString(USet* set, const char16_t* str, int32_t strLen) {
UnicodeString s(strLen==-1, str, strLen);
((UnicodeSet*) set)->UnicodeSet::remove(s);
}
U_CAPI void U_EXPORT2
-uset_removeAllCodePoints(USet *set, const UChar *str, int32_t length) {
+uset_removeAllCodePoints(USet *set, const char16_t *str, int32_t length) {
UnicodeString s(length==-1, str, length);
((UnicodeSet*) set)->UnicodeSet::removeAll(s);
}
}
U_CAPI void U_EXPORT2
-uset_retainString(USet *set, const UChar *str, int32_t length) {
+uset_retainString(USet *set, const char16_t *str, int32_t length) {
UnicodeString s(length==-1, str, length);
((UnicodeSet*) set)->UnicodeSet::retain(s);
}
U_CAPI void U_EXPORT2
-uset_retainAllCodePoints(USet *set, const UChar *str, int32_t length) {
+uset_retainAllCodePoints(USet *set, const char16_t *str, int32_t length) {
UnicodeString s(length==-1, str, length);
((UnicodeSet*) set)->UnicodeSet::retainAll(s);
}
}
U_CAPI void U_EXPORT2
-uset_complementString(USet *set, const UChar *str, int32_t length) {
+uset_complementString(USet *set, const char16_t *str, int32_t length) {
UnicodeString s(length==-1, str, length);
((UnicodeSet*) set)->UnicodeSet::complement(s);
}
U_CAPI void U_EXPORT2
-uset_complementAllCodePoints(USet *set, const UChar *str, int32_t length) {
+uset_complementAllCodePoints(USet *set, const char16_t *str, int32_t length) {
UnicodeString s(length==-1, str, length);
((UnicodeSet*) set)->UnicodeSet::complementAll(s);
}
}
U_CAPI UBool U_EXPORT2
-uset_containsString(const USet* set, const UChar* str, int32_t strLen) {
+uset_containsString(const USet* set, const char16_t* str, int32_t strLen) {
UnicodeString s(strLen==-1, str, strLen);
return ((const UnicodeSet*) set)->UnicodeSet::contains(s);
}
}
U_CAPI UBool U_EXPORT2
-uset_containsAllCodePoints(const USet* set, const UChar *str, int32_t strLen) {
+uset_containsAllCodePoints(const USet* set, const char16_t *str, int32_t strLen) {
// Create a string alias, since nothing is being added to the set.
UnicodeString s(strLen==-1, str, strLen);
return ((const UnicodeSet*) set)->UnicodeSet::containsAll(s);
}
U_CAPI int32_t U_EXPORT2
-uset_span(const USet *set, const UChar *s, int32_t length, USetSpanCondition spanCondition) {
+uset_span(const USet *set, const char16_t *s, int32_t length, USetSpanCondition spanCondition) {
return ((UnicodeSet*) set)->UnicodeSet::span(s, length, spanCondition);
}
U_CAPI int32_t U_EXPORT2
-uset_spanBack(const USet *set, const UChar *s, int32_t length, USetSpanCondition spanCondition) {
+uset_spanBack(const USet *set, const char16_t *s, int32_t length, USetSpanCondition spanCondition) {
return ((UnicodeSet*) set)->UnicodeSet::spanBack(s, length, spanCondition);
}
U_CAPI int32_t U_EXPORT2
uset_getItem(const USet* uset, int32_t itemIndex,
UChar32* start, UChar32* end,
- UChar* str, int32_t strCapacity,
+ char16_t* str, int32_t strCapacity,
UErrorCode* ec) {
if (U_FAILURE(*ec)) return 0;
const UnicodeSet& set = *(const UnicodeSet*)uset;
U_NAMESPACE_USE
U_CAPI USet* U_EXPORT2
-uset_openPattern(const UChar* pattern, int32_t patternLength,
+uset_openPattern(const char16_t* pattern, int32_t patternLength,
UErrorCode* ec)
{
UnicodeString pat(patternLength==-1, pattern, patternLength);
}
U_CAPI USet* U_EXPORT2
-uset_openPatternOptions(const UChar* pattern, int32_t patternLength,
+uset_openPatternOptions(const char16_t* pattern, int32_t patternLength,
uint32_t options,
UErrorCode* ec)
{
U_CAPI int32_t U_EXPORT2
uset_applyPattern(USet *set,
- const UChar *pattern, int32_t patternLength,
+ const char16_t *pattern, int32_t patternLength,
uint32_t options,
UErrorCode *status){
U_CAPI void U_EXPORT2
uset_applyPropertyAlias(USet* set,
- const UChar *prop, int32_t propLength,
- const UChar *value, int32_t valueLength,
+ const char16_t *prop, int32_t propLength,
+ const char16_t *value, int32_t valueLength,
UErrorCode* ec) {
UnicodeString p(prop, propLength);
}
U_CAPI UBool U_EXPORT2
-uset_resemblesPattern(const UChar *pattern, int32_t patternLength,
+uset_resemblesPattern(const char16_t *pattern, int32_t patternLength,
int32_t pos) {
UnicodeString pat(pattern, patternLength);
return ((pos+1) < pat.length() &&
- pat.charAt(pos) == (UChar)91/*[*/) ||
+ pat.charAt(pos) == (char16_t)91/*[*/) ||
UnicodeSet::resemblesPattern(pat, pos);
}
U_CAPI int32_t U_EXPORT2
uset_toPattern(const USet* set,
- UChar* result, int32_t resultCapacity,
+ char16_t* result, int32_t resultCapacity,
UBool escapeUnprintable,
UErrorCode* ec) {
UnicodeString pat;
/*
* This implementation is designed for 16-bit Unicode strings.
* The main assumption is that the Arabic characters and their
- * presentation forms each fit into a single UChar.
+ * presentation forms each fit into a single char16_t.
* With UTF-8, they occupy 2 or 3 bytes, and more than the ASCII
* characters.
*/
#define DESHAPE_MODE 1
struct uShapeVariables {
- UChar tailChar;
+ char16_t tailChar;
uint32_t uShapeLamalefBegin;
uint32_t uShapeLamalefEnd;
uint32_t uShapeTashkeelBegin;
/* FE7F */ 1
};
-static const UChar yehHamzaToYeh[] =
+static const char16_t yehHamzaToYeh[] =
{
/* isolated*/ 0xFEEF,
/* final */ 0xFEF0
};
-static const UChar convertLamAlef[] =
+static const char16_t convertLamAlef[] =
{
/*FEF5*/ 0x0622,
/*FEF6*/ 0x0622,
/*FEFC*/ 0x0627
};
-static const UChar araLink[178]=
+static const char16_t araLink[178]=
{
1 + 32 + 256 * 0x11,/*0x0622*/
1 + 32 + 256 * 0x13,/*0x0623*/
/*FEF*/ 1, 0, 1, 2,1 + 2, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0
};
-static const UChar convertFBto06[] =
+static const char16_t convertFBto06[] =
{
/***********0******1******2******3******4******5******6******7******8******9******A******B******C******D******E******F***/
/*FB5*/ 0x671, 0x671, 0x67B, 0x67B, 0x67B, 0x67B, 0x67E, 0x67E, 0x67E, 0x67E, 0, 0, 0, 0, 0x67A, 0x67A,
/*FBF*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x6CC, 0x6CC, 0x6CC, 0x6CC
};
-static const UChar convertFEto06[] =
+static const char16_t convertFEto06[] =
{
/***********0******1******2******3******4******5******6******7******8******9******A******B******C******D******E******F***/
/*FE7*/ 0x64B, 0x64B, 0x64C, 0x64C, 0x64D, 0x64D, 0x64E, 0x64E, 0x64F, 0x64F, 0x650, 0x650, 0x651, 0x651, 0x652, 0x652,
* we can safely just work with code units (again, at least UTF-16).
*/
static void
-_shapeToArabicDigitsWithContext(UChar *s, int32_t length,
- UChar digitBase,
+_shapeToArabicDigitsWithContext(char16_t *s, int32_t length,
+ char16_t digitBase,
UBool isLogical, UBool lastStrongWasAL) {
int32_t i;
- UChar c;
+ char16_t c;
digitBase-=0x30;
break;
case U_EUROPEAN_NUMBER: /* EN */
if(lastStrongWasAL && (uint32_t)(c-0x30)<10) {
- s[i]=(UChar)(digitBase+c); /* digitBase+(c-0x30) - digitBase was modified above */
+ s[i]=(char16_t)(digitBase+c); /* digitBase+(c-0x30) - digitBase was modified above */
}
break;
default :
break;
case U_EUROPEAN_NUMBER: /* EN */
if(lastStrongWasAL && (uint32_t)(c-0x30)<10) {
- s[i]=(UChar)(digitBase+c); /* digitBase+(c-0x30) - digitBase was modified above */
+ s[i]=(char16_t)(digitBase+c); /* digitBase+(c-0x30) - digitBase was modified above */
}
break;
default :
* U_SHAPE_TEXT_DIRECTION_LOGICAL
*/
static void
-invertBuffer(UChar *buffer, int32_t size, uint32_t /*options*/, int32_t lowlimit, int32_t highlimit) {
- UChar temp;
+invertBuffer(char16_t *buffer, int32_t size, uint32_t /*options*/, int32_t lowlimit, int32_t highlimit) {
+ char16_t temp;
int32_t i=0,j=0;
for(i=lowlimit,j=size-highlimit-1;i<j;i++,j--) {
temp = buffer[i];
* later it'll be converted into the 0xFExx LamAlefs
* in the shaping function.
*/
-static inline UChar
-changeLamAlef(UChar ch) {
+static inline char16_t
+changeLamAlef(char16_t ch) {
switch(ch) {
case 0x0622 :
return 0x065C;
* Arabic characters have four forms :
* Isolated, Initial, Middle and Final Form
*/
-static UChar
-getLink(UChar ch) {
+static char16_t
+getLink(char16_t ch) {
if(ch >= 0x0622 && ch <= 0x06D3) {
return(araLink[ch-0x0622]);
} else if(ch == 0x200D) {
* at each end of the logical buffer
*/
static void
-countSpaces(UChar *dest, int32_t size, uint32_t /*options*/, int32_t *spacesCountl, int32_t *spacesCountr) {
+countSpaces(char16_t *dest, int32_t size, uint32_t /*options*/, int32_t *spacesCountl, int32_t *spacesCountr) {
int32_t i = 0;
int32_t countl = 0,countr = 0;
while((dest[i] == SPACE_CHAR) && (countl < size)) {
*Function : Returns 1 for Tashkeel characters in 06 range else return 0
*/
static inline int32_t
-isTashkeelChar(UChar ch) {
+isTashkeelChar(char16_t ch) {
return (int32_t)( ch>=0x064B && ch<= 0x0652 );
}
*Function : Returns 1 for Tashkeel characters in FE range else return 0
*/
static inline int32_t
-isTashkeelCharFE(UChar ch) {
+isTashkeelCharFE(char16_t ch) {
return (int32_t)( ch>=0xFE70 && ch<= 0xFE7F );
}
*Function : Returns 1 for Alef characters else return 0
*/
static inline int32_t
-isAlefChar(UChar ch) {
+isAlefChar(char16_t ch) {
return (int32_t)( (ch==0x0622)||(ch==0x0623)||(ch==0x0625)||(ch==0x0627) );
}
*Function : Returns 1 for LamAlef characters else return 0
*/
static inline int32_t
-isLamAlefChar(UChar ch) {
+isLamAlefChar(char16_t ch) {
return (int32_t)((ch>=0xFEF5)&&(ch<=0xFEFC) );
}
*/
static inline int32_t
-isTailChar(UChar ch) {
+isTailChar(char16_t ch) {
if(ch == OLD_TAIL_CHAR || ch == NEW_TAIL_CHAR){
return 1;
}else{
*/
static inline int32_t
-isSeenTailFamilyChar(UChar ch) {
+isSeenTailFamilyChar(char16_t ch) {
if(ch >= 0xfeb1 && ch < 0xfebf){
return tailFamilyIsolatedFinal [ch - 0xFEB1];
}else{
*/
static inline int32_t
-isSeenFamilyChar(UChar ch){
+isSeenFamilyChar(char16_t ch){
if(ch >= 0x633 && ch <= 0x636){
return 1;
}else {
* otherwise returns 0
*/
static inline int32_t
-isAlefMaksouraChar(UChar ch) {
+isAlefMaksouraChar(char16_t ch) {
return (int32_t)( (ch == 0xFEEF) || ( ch == 0xFEF0) || (ch == 0x0649));
}
* final is found otherwise returns 0
*/
static inline int32_t
-isYehHamzaChar(UChar ch) {
+isYehHamzaChar(char16_t ch) {
if((ch==0xFE89)||(ch==0xFE8A)){
return 1;
}else{
* returns 0
*/
static inline int32_t
-isTashkeelOnTatweelChar(UChar ch){
+isTashkeelOnTatweelChar(char16_t ch){
if(ch >= 0xfe70 && ch <= 0xfe7f && ch != NEW_TAIL_CHAR && ch != 0xFE75 && ch != SHADDA_TATWEEL_CHAR)
{
return tashkeelMedial [ch - 0xFE70];
* returns 2 otherwise returns 0
*/
static inline int32_t
-isIsolatedTashkeelChar(UChar ch){
+isIsolatedTashkeelChar(char16_t ch){
if(ch >= 0xfe70 && ch <= 0xfe7f && ch != NEW_TAIL_CHAR && ch != 0xFE75){
return (1 - tashkeelMedial [ch - 0xFE70]);
}else if(ch >= 0xfc5e && ch <= 0xfc63){
*/
static int32_t
-calculateSize(const UChar *source, int32_t sourceLength,
+calculateSize(const char16_t *source, int32_t sourceLength,
int32_t destSize,uint32_t options) {
int32_t i = 0;
*
*/
static int32_t
-handleTashkeelWithTatweel(UChar *dest, int32_t sourceLength,
+handleTashkeelWithTatweel(char16_t *dest, int32_t sourceLength,
int32_t /*destSize*/, uint32_t /*options*/,
UErrorCode * /*pErrorCode*/) {
int i;
*/
static int32_t
-handleGeneratedSpaces(UChar *dest, int32_t sourceLength,
+handleGeneratedSpaces(char16_t *dest, int32_t sourceLength,
int32_t destSize,
uint32_t options,
UErrorCode *pErrorCode,struct uShapeVariables shapeVars ) {
int32_t i = 0, j = 0;
int32_t count = 0;
- UChar *tempbuffer=nullptr;
+ char16_t *tempbuffer=nullptr;
int lamAlefOption = 0;
int tashkeelOption = 0;
}
}
- tempbuffer = (UChar *)uprv_malloc((sourceLength+1)*U_SIZEOF_UCHAR);
+ tempbuffer = (char16_t *)uprv_malloc((sourceLength+1)*U_SIZEOF_UCHAR);
/* Test for nullptr */
if(tempbuffer == nullptr) {
*pErrorCode = U_MEMORY_ALLOCATION_ERROR;
*/
static int32_t
-expandCompositCharAtBegin(UChar *dest, int32_t sourceLength, int32_t destSize,UErrorCode *pErrorCode) {
+expandCompositCharAtBegin(char16_t *dest, int32_t sourceLength, int32_t destSize,UErrorCode *pErrorCode) {
int32_t i = 0,j = 0;
int32_t countl = 0;
- UChar *tempbuffer=nullptr;
+ char16_t *tempbuffer=nullptr;
- tempbuffer = (UChar *)uprv_malloc((sourceLength+1)*U_SIZEOF_UCHAR);
+ tempbuffer = (char16_t *)uprv_malloc((sourceLength+1)*U_SIZEOF_UCHAR);
/* Test for nullptr */
if(tempbuffer == nullptr) {
*/
static int32_t
-expandCompositCharAtEnd(UChar *dest, int32_t sourceLength, int32_t destSize,UErrorCode *pErrorCode) {
+expandCompositCharAtEnd(char16_t *dest, int32_t sourceLength, int32_t destSize,UErrorCode *pErrorCode) {
int32_t i = 0,j = 0;
int32_t countr = 0;
int32_t inpsize = sourceLength;
- UChar *tempbuffer=nullptr;
- tempbuffer = (UChar *)uprv_malloc((sourceLength+1)*U_SIZEOF_UCHAR);
+ char16_t *tempbuffer=nullptr;
+ tempbuffer = (char16_t *)uprv_malloc((sourceLength+1)*U_SIZEOF_UCHAR);
/* Test for nullptr */
if(tempbuffer == nullptr) {
*/
static int32_t
-expandCompositCharAtNear(UChar *dest, int32_t sourceLength, int32_t destSize,UErrorCode *pErrorCode,
+expandCompositCharAtNear(char16_t *dest, int32_t sourceLength, int32_t destSize,UErrorCode *pErrorCode,
int yehHamzaOption, int seenTailOption, int lamAlefOption, struct uShapeVariables shapeVars) {
int32_t i = 0;
- UChar lamalefChar, yehhamzaChar;
+ char16_t lamalefChar, yehhamzaChar;
for(i = 0 ;i<=sourceLength-1;i++) {
if (seenTailOption && isSeenTailFamilyChar(dest[i])) {
*/
static int32_t
-expandCompositChar(UChar *dest, int32_t sourceLength,
+expandCompositChar(char16_t *dest, int32_t sourceLength,
int32_t destSize,uint32_t options,
UErrorCode *pErrorCode, int shapingMode,struct uShapeVariables shapeVars) {
int32_t i = 0,j = 0;
- UChar *tempbuffer=nullptr;
+ char16_t *tempbuffer=nullptr;
int yehHamzaOption = 0;
int seenTailOption = 0;
int lamAlefOption = 0;
if (shapingMode == 1){
if ( (options&U_SHAPE_LAMALEF_MASK) == U_SHAPE_LAMALEF_RESIZE){
destSize = calculateSize(dest,sourceLength,destSize,options);
- tempbuffer = (UChar *)uprv_malloc((destSize+1)*U_SIZEOF_UCHAR);
+ tempbuffer = (char16_t *)uprv_malloc((destSize+1)*U_SIZEOF_UCHAR);
/* Test for nullptr */
if(tempbuffer == nullptr) {
* arabic Unicode buffer in FExx Range
*/
static int32_t
-shapeUnicode(UChar *dest, int32_t sourceLength,
+shapeUnicode(char16_t *dest, int32_t sourceLength,
int32_t destSize,uint32_t options,
UErrorCode *pErrorCode,
int tashkeelFlag, struct uShapeVariables shapeVars) {
unsigned int Shape;
int32_t lamalef_found = 0;
int32_t seenfamFound = 0, yehhamzaFound =0, tashkeelFound = 0;
- UChar prevLink = 0, lastLink = 0, currLink, nextLink = 0;
- UChar wLamalef;
+ char16_t prevLink = 0, lastLink = 0, currLink, nextLink = 0;
+ char16_t wLamalef;
/*
* Converts the input buffer from FExx Range into 06xx Range
*/
if ((options & U_SHAPE_PRESERVE_PRESENTATION_MASK) == U_SHAPE_PRESERVE_PRESENTATION_NOOP) {
for (i = 0; i < sourceLength; i++) {
- UChar inputChar = dest[i];
+ char16_t inputChar = dest[i];
if ( (inputChar >= 0xFB50) && (inputChar <= 0xFBFF)) {
- UChar c = convertFBto06 [ (inputChar - 0xFB50) ];
+ char16_t c = convertFBto06 [ (inputChar - 0xFB50) ];
if (c != 0)
dest[i] = c;
} else if ( (inputChar >= 0xFE70) && (inputChar <= 0xFEFC)) {
/* to ensure the array index is within the range */
U_ASSERT(dest[i] >= 0x064Bu
&& dest[i]-0x064Bu < UPRV_LENGTHOF(IrrelevantPos));
- dest[i] = 0xFE70 + IrrelevantPos[(dest[i] - 0x064B)] + static_cast<UChar>(Shape);
+ dest[i] = 0xFE70 + IrrelevantPos[(dest[i] - 0x064B)] + static_cast<char16_t>(Shape);
}
}else if ((currLink & APRESENT) > 0) {
- dest[i] = (UChar)(0xFB50 + (currLink >> 8) + Shape);
+ dest[i] = (char16_t)(0xFB50 + (currLink >> 8) + Shape);
}else if ((currLink >> 8) > 0 && (currLink & IRRELEVANT) == 0) {
- dest[i] = (UChar)(0xFE70 + (currLink >> 8) + Shape);
+ dest[i] = (char16_t)(0xFE70 + (currLink >> 8) + Shape);
}
}
}
* arabic Unicode buffer in 06xx Range
*/
static int32_t
-deShapeUnicode(UChar *dest, int32_t sourceLength,
+deShapeUnicode(char16_t *dest, int32_t sourceLength,
int32_t destSize,uint32_t options,
UErrorCode *pErrorCode, struct uShapeVariables shapeVars) {
int32_t i = 0;
*/
for(i = 0; i < sourceLength; i++) {
- UChar inputChar = dest[i];
+ char16_t inputChar = dest[i];
if ( (inputChar >= 0xFB50) && (inputChar <= 0xFBFF)) { /* FBxx Arabic range */
- UChar c = convertFBto06 [ (inputChar - 0xFB50) ];
+ char16_t c = convertFBto06 [ (inputChar - 0xFB50) ];
if (c != 0)
dest[i] = c;
} else if( (yehHamzaComposeEnabled == 1) && ((inputChar == HAMZA06_CHAR) || (inputChar == HAMZAFE_CHAR))
*/
U_CAPI int32_t U_EXPORT2
-u_shapeArabic(const UChar *source, int32_t sourceLength,
- UChar *dest, int32_t destCapacity,
+u_shapeArabic(const char16_t *source, int32_t sourceLength,
+ char16_t *dest, int32_t destCapacity,
uint32_t options,
UErrorCode *pErrorCode) {
}
if((options&U_SHAPE_LETTERS_MASK)!=U_SHAPE_LETTERS_NOOP) {
- UChar buffer[300];
- UChar *tempbuffer, *tempsource = nullptr;
+ char16_t buffer[300];
+ char16_t *tempbuffer, *tempsource = nullptr;
int32_t outputSize, spacesCountl=0, spacesCountr=0;
if((options&U_SHAPE_AGGREGATE_TASHKEEL_MASK)>0) {
int i=logical_order?-1:sourceLength;
int end=logical_order?sourceLength:-1;
int aggregation_possible = 1;
- UChar prev = 0;
- UChar prevLink, currLink = 0;
+ char16_t prev = 0;
+ char16_t prevLink, currLink = 0;
int newSourceLength = 0;
- tempsource = (UChar *)uprv_malloc(2*sourceLength*U_SIZEOF_UCHAR);
+ tempsource = (char16_t *)uprv_malloc(2*sourceLength*U_SIZEOF_UCHAR);
if(tempsource == nullptr) {
*pErrorCode = U_MEMORY_ALLOCATION_ERROR;
return 0;
outputSize=UPRV_LENGTHOF(buffer);
tempbuffer=buffer;
} else {
- tempbuffer = (UChar *)uprv_malloc(outputSize*U_SIZEOF_UCHAR);
+ tempbuffer = (char16_t *)uprv_malloc(outputSize*U_SIZEOF_UCHAR);
/*Test for nullptr*/
if(tempbuffer == nullptr) {
* "shape" the digits in-place.
*/
if((options&U_SHAPE_DIGITS_MASK)!=U_SHAPE_DIGITS_NOOP) {
- UChar digitBase;
+ char16_t digitBase;
int32_t i;
/* select the requested digit group */
}
U_CFUNC void
-uprv_syntaxError(const UChar* rules,
+uprv_syntaxError(const char16_t* rules,
int32_t pos,
int32_t rulesLen,
UParseError* parseError){
return type;
}
-// TODO: change to writing to UnicodeString not UChar *
+// TODO: change to writing to UnicodeString not char16_t *
static int32_t
usprep_map( const UStringPrepProfile* profile,
- const UChar* src, int32_t srcLength,
- UChar* dest, int32_t destCapacity,
+ const char16_t* src, int32_t srcLength,
+ char16_t* dest, int32_t destCapacity,
int32_t options,
UParseError* parseError,
UErrorCode* status ){
//copy the code point into destination
if(ch <= 0xFFFF){
if(destIndex < destCapacity ){
- dest[destIndex] = (UChar)ch;
+ dest[destIndex] = (char16_t)ch;
}
destIndex++;
}else{
*/
U_CAPI int32_t U_EXPORT2
usprep_prepare( const UStringPrepProfile* profile,
- const UChar* src, int32_t srcLength,
- UChar* dest, int32_t destCapacity,
+ const char16_t* src, int32_t srcLength,
+ char16_t* dest, int32_t destCapacity,
int32_t options,
UParseError* parseError,
UErrorCode* status ){
}
// map
UnicodeString s1;
- UChar *b1 = s1.getBuffer(srcLength);
+ char16_t *b1 = s1.getBuffer(srcLength);
if(b1==nullptr){
*status = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
// Prohibit and checkBiDi in one pass
- const UChar *b2 = s2.getBuffer();
+ const char16_t *b2 = s2.getBuffer();
int32_t b2Len = s2.length();
UCharDirection direction=U_CHAR_DIRECTION_COUNT, firstCharDir=U_CHAR_DIRECTION_COUNT;
UBool leftToRight=false, rightToLeft=false;
}
-/* conversions between char* and UChar* ------------------------------------- */
+/* conversions between char* and char16_t* ------------------------------------- */
/* maximum string length for u_uastrcpy() and u_austrcpy() implementations */
#define MAX_STRLEN 0x0FFFFFFF
return len;
}
-U_CAPI UChar* U_EXPORT2
-u_uastrncpy(UChar *ucs1,
+U_CAPI char16_t* U_EXPORT2
+u_uastrncpy(char16_t *ucs1,
const char *s2,
int32_t n)
{
- UChar *target = ucs1;
+ char16_t *target = ucs1;
UErrorCode err = U_ZERO_ERROR;
UConverter *cnv = u_getDefaultConverter(&err);
if(U_SUCCESS(err) && cnv != nullptr) {
return ucs1;
}
-U_CAPI UChar* U_EXPORT2
-u_uastrcpy(UChar *ucs1,
+U_CAPI char16_t* U_EXPORT2
+u_uastrcpy(char16_t *ucs1,
const char *s2 )
{
UErrorCode err = U_ZERO_ERROR;
/*
returns the minimum of (the length of the null-terminated string) and n.
*/
-static int32_t u_ustrnlen(const UChar *ucs1, int32_t n)
+static int32_t u_ustrnlen(const char16_t *ucs1, int32_t n)
{
int32_t len = 0;
U_CAPI char* U_EXPORT2
u_austrncpy(char *s1,
- const UChar *ucs2,
+ const char16_t *ucs2,
int32_t n)
{
char *target = s1;
U_CAPI char* U_EXPORT2
u_austrcpy(char *s1,
- const UChar *ucs2 )
+ const char16_t *ucs2 )
{
UErrorCode err = U_ZERO_ERROR;
UConverter *cnv = u_getDefaultConverter(&err);
int32_t CaseMap::toTitle(
const char *locale, uint32_t options, BreakIterator *iter,
- const UChar *src, int32_t srcLength,
- UChar *dest, int32_t destCapacity, Edits *edits,
+ const char16_t *src, int32_t srcLength,
+ char16_t *dest, int32_t destCapacity, Edits *edits,
UErrorCode &errorCode) {
LocalPointer<BreakIterator> ownedIter;
iter = ustrcase_getTitleBreakIterator(nullptr, locale, options, iter, ownedIter, errorCode);
U_NAMESPACE_USE
U_CAPI int32_t U_EXPORT2
-u_strToTitle(UChar *dest, int32_t destCapacity,
- const UChar *src, int32_t srcLength,
+u_strToTitle(char16_t *dest, int32_t destCapacity,
+ const char16_t *src, int32_t srcLength,
UBreakIterator *titleIter,
const char *locale,
UErrorCode *pErrorCode) {
U_CAPI int32_t U_EXPORT2
ucasemap_toTitle(UCaseMap *csm,
- UChar *dest, int32_t destCapacity,
- const UChar *src, int32_t srcLength,
+ char16_t *dest, int32_t destCapacity,
+ const char16_t *src, int32_t srcLength,
UErrorCode *pErrorCode) {
if (U_FAILURE(*pErrorCode)) {
return 0;
#define _BUFFER_CAPACITY_MULTIPLIER 2
#if !defined(U_WCHAR_IS_UTF16) && !defined(U_WCHAR_IS_UTF32)
-// TODO: We should use CharString for char buffers and UnicodeString for UChar buffers.
+// TODO: We should use CharString for char buffers and UnicodeString for char16_t buffers.
// Then we could change this to work only with wchar_t buffers.
static inline UBool
u_growAnyBufferFromStatic(void *context,
_strToWCS(wchar_t *dest,
int32_t destCapacity,
int32_t *pDestLength,
- const UChar *src,
+ const char16_t *src,
int32_t srcLength,
UErrorCode *pErrorCode){
int32_t intTargetCapacity=0;
int count=0,retVal=0;
- const UChar *pSrcLimit =nullptr;
- const UChar *pSrc = src;
+ const char16_t *pSrcLimit =nullptr;
+ const char16_t *pSrc = src;
conv = u_getDefaultConverter(pErrorCode);
u_strToWCS(wchar_t *dest,
int32_t destCapacity,
int32_t *pDestLength,
- const UChar *src,
+ const char16_t *src,
int32_t srcLength,
UErrorCode *pErrorCode){
srcLength = u_strlen(src);
}
if(0 < srcLength && srcLength <= destCapacity){
- u_memcpy((UChar *)dest, src, srcLength);
+ u_memcpy((char16_t *)dest, src, srcLength);
}
if(pDestLength){
*pDestLength = srcLength;
}
- u_terminateUChars((UChar *)dest,destCapacity,srcLength,pErrorCode);
+ u_terminateUChars((char16_t *)dest,destCapacity,srcLength,pErrorCode);
return dest;
#if !defined(U_WCHAR_IS_UTF16) && !defined(U_WCHAR_IS_UTF32)
/* helper function */
-static UChar*
-_strFromWCS( UChar *dest,
+static char16_t*
+_strFromWCS( char16_t *dest,
int32_t destCapacity,
int32_t *pDestLength,
const wchar_t *src,
{
int32_t retVal =0, count =0 ;
UConverter* conv = nullptr;
- UChar* pTarget = nullptr;
- UChar* pTargetLimit = nullptr;
- UChar* target = nullptr;
+ char16_t* pTarget = nullptr;
+ char16_t* pTargetLimit = nullptr;
+ char16_t* target = nullptr;
- UChar uStack [_STACK_BUFFER_CAPACITY];
+ char16_t uStack [_STACK_BUFFER_CAPACITY];
wchar_t wStack[_STACK_BUFFER_CAPACITY];
wchar_t* pWStack = wStack;
}
#endif
-U_CAPI UChar* U_EXPORT2
-u_strFromWCS(UChar *dest,
+U_CAPI char16_t* U_EXPORT2
+u_strFromWCS(char16_t *dest,
int32_t destCapacity,
int32_t *pDestLength,
const wchar_t *src,
#ifdef U_WCHAR_IS_UTF16
/* wchar_t is UTF-16 just do a memcpy */
if(srcLength == -1){
- srcLength = u_strlen((const UChar *)src);
+ srcLength = u_strlen((const char16_t *)src);
}
if(0 < srcLength && srcLength <= destCapacity){
- u_memcpy(dest, (const UChar *)src, srcLength);
+ u_memcpy(dest, (const char16_t *)src, srcLength);
}
if(pDestLength){
*pDestLength = srcLength;
/* Appends a full case mapping result, see UCASE_MAX_STRING_LENGTH. */
inline int32_t
-appendResult(UChar *dest, int32_t destIndex, int32_t destCapacity,
- int32_t result, const UChar *s,
+appendResult(char16_t *dest, int32_t destIndex, int32_t destCapacity,
+ int32_t result, const char16_t *s,
int32_t cpLength, uint32_t options, icu::Edits *edits) {
UChar32 c;
int32_t length;
}
c=~result;
if(destIndex<destCapacity && c<=0xffff) { // BMP slightly-fastpath
- dest[destIndex++]=(UChar)c;
+ dest[destIndex++]=(char16_t)c;
return destIndex;
}
length=cpLength;
c=U_SENTINEL;
length=result;
} else if(destIndex<destCapacity && result<=0xffff) { // BMP slightly-fastpath
- dest[destIndex++]=(UChar)result;
+ dest[destIndex++]=(char16_t)result;
if(edits!=nullptr) {
edits->addReplace(cpLength, 1);
}
}
inline int32_t
-appendUChar(UChar *dest, int32_t destIndex, int32_t destCapacity, UChar c) {
+appendUChar(char16_t *dest, int32_t destIndex, int32_t destCapacity, char16_t c) {
if(destIndex<destCapacity) {
dest[destIndex]=c;
} else if(destIndex==INT32_MAX) {
}
int32_t
-appendNonEmptyUnchanged(UChar *dest, int32_t destIndex, int32_t destCapacity,
- const UChar *s, int32_t length, uint32_t options, icu::Edits *edits) {
+appendNonEmptyUnchanged(char16_t *dest, int32_t destIndex, int32_t destCapacity,
+ const char16_t *s, int32_t length, uint32_t options, icu::Edits *edits) {
if(edits!=nullptr) {
edits->addUnchanged(length);
}
}
inline int32_t
-appendUnchanged(UChar *dest, int32_t destIndex, int32_t destCapacity,
- const UChar *s, int32_t length, uint32_t options, icu::Edits *edits) {
+appendUnchanged(char16_t *dest, int32_t destIndex, int32_t destCapacity,
+ const char16_t *s, int32_t length, uint32_t options, icu::Edits *edits) {
if (length <= 0) {
return destIndex;
}
if(dir<0) {
if(csc->start<csc->index) {
- U16_PREV((const UChar *)csc->p, csc->start, csc->index, c);
+ U16_PREV((const char16_t *)csc->p, csc->start, csc->index, c);
return c;
}
} else {
if(csc->index<csc->limit) {
- U16_NEXT((const UChar *)csc->p, csc->index, csc->limit, c);
+ U16_NEXT((const char16_t *)csc->p, csc->index, csc->limit, c);
return c;
}
}
* caseLocale < 0: Case-folds [srcStart..srcLimit[.
*/
int32_t toLower(int32_t caseLocale, uint32_t options,
- UChar *dest, int32_t destCapacity,
- const UChar *src, UCaseContext *csc, int32_t srcStart, int32_t srcLimit,
+ char16_t *dest, int32_t destCapacity,
+ const char16_t *src, UCaseContext *csc, int32_t srcStart, int32_t srcLimit,
icu::Edits *edits, UErrorCode &errorCode) {
const int8_t *latinToLower;
if (caseLocale == UCASE_LOC_ROOT ||
int32_t srcIndex = srcStart;
for (;;) {
// fast path for simple cases
- UChar lead = 0;
+ char16_t lead = 0;
while (srcIndex < srcLimit) {
lead = src[srcIndex];
int32_t delta;
continue;
}
}
- lead += static_cast<UChar>(delta);
+ lead += static_cast<char16_t>(delta);
destIndex = appendUnchanged(dest, destIndex, destCapacity,
src + prev, srcIndex - 1 - prev, options, edits);
if (destIndex >= 0) {
}
// slow path
int32_t cpStart = srcIndex++;
- UChar trail;
+ char16_t trail;
UChar32 c;
if (U16_IS_LEAD(lead) && srcIndex < srcLimit && U16_IS_TRAIL(trail = src[srcIndex])) {
c = U16_GET_SUPPLEMENTARY(lead, trail);
} else {
c = lead;
}
- const UChar *s;
+ const char16_t *s;
if (caseLocale >= 0) {
csc->cpStart = cpStart;
csc->cpLimit = srcIndex;
}
int32_t toUpper(int32_t caseLocale, uint32_t options,
- UChar *dest, int32_t destCapacity,
- const UChar *src, UCaseContext *csc, int32_t srcLength,
+ char16_t *dest, int32_t destCapacity,
+ const char16_t *src, UCaseContext *csc, int32_t srcLength,
icu::Edits *edits, UErrorCode &errorCode) {
const int8_t *latinToUpper;
if (caseLocale == UCASE_LOC_TURKISH) {
int32_t srcIndex = 0;
for (;;) {
// fast path for simple cases
- UChar lead = 0;
+ char16_t lead = 0;
while (srcIndex < srcLength) {
lead = src[srcIndex];
int32_t delta;
continue;
}
}
- lead += static_cast<UChar>(delta);
+ lead += static_cast<char16_t>(delta);
destIndex = appendUnchanged(dest, destIndex, destCapacity,
src + prev, srcIndex - 1 - prev, options, edits);
if (destIndex >= 0) {
// slow path
int32_t cpStart;
csc->cpStart = cpStart = srcIndex++;
- UChar trail;
+ char16_t trail;
UChar32 c;
if (U16_IS_LEAD(lead) && srcIndex < srcLength && U16_IS_TRAIL(trail = src[srcIndex])) {
c = U16_GET_SUPPLEMENTARY(lead, trail);
c = lead;
}
csc->cpLimit = srcIndex;
- const UChar *s;
+ const char16_t *s;
c = ucase_toFullUpper(c, utf16_caseContextIterator, csc, &s, caseLocale);
if (c >= 0) {
destIndex = appendUnchanged(dest, destIndex, destCapacity,
*
* @return the src index after the titlecased sequence, or the start index if no Dutch IJ
*/
-int32_t maybeTitleDutchIJ(const UChar *src, UChar32 c, int32_t start, int32_t segmentLimit,
- UChar *dest, int32_t &destIndex, int32_t destCapacity, uint32_t options,
+int32_t maybeTitleDutchIJ(const char16_t *src, UChar32 c, int32_t start, int32_t segmentLimit,
+ char16_t *dest, int32_t &destIndex, int32_t destCapacity, uint32_t options,
icu::Edits *edits) {
U_ASSERT(start < segmentLimit);
int32_t unchanged2 = 0; // after the j (0 or 1)
// next character after the first letter
- UChar c2 = src[index++];
+ char16_t c2 = src[index++];
// Is the first letter an i/I with accent?
if (c == u'I') {
U_CFUNC int32_t U_CALLCONV
ustrcase_internalToTitle(int32_t caseLocale, uint32_t options, BreakIterator *iter,
- UChar *dest, int32_t destCapacity,
- const UChar *src, int32_t srcLength,
+ char16_t *dest, int32_t destCapacity,
+ const char16_t *src, int32_t srcLength,
icu::Edits *edits,
UErrorCode &errorCode) {
if (!ustrcase_checkTitleAdjustmentOptions(options, errorCode)) {
/* titlecase c which is from [titleStart..titleLimit[ */
csc.cpStart=titleStart;
csc.cpLimit=titleLimit;
- const UChar *s;
+ const char16_t *s;
c=ucase_toFullTitle(c, utf16_caseContextIterator, &csc, &s, caseLocale);
destIndex=appendResult(dest, destIndex, destCapacity, c, s,
titleLimit-titleStart, options, edits);
}
}
-UBool isFollowedByCasedLetter(const UChar *s, int32_t i, int32_t length) {
+UBool isFollowedByCasedLetter(const char16_t *s, int32_t i, int32_t length) {
while (i < length) {
UChar32 c;
U16_NEXT(s, i, length, c);
* TODO: Try to re-consolidate one way or another with the non-Greek function.
*/
int32_t toUpper(uint32_t options,
- UChar *dest, int32_t destCapacity,
- const UChar *src, int32_t srcLength,
+ char16_t *dest, int32_t destCapacity,
+ const char16_t *src, int32_t srcLength,
Edits *edits,
UErrorCode &errorCode) {
int32_t destIndex=0;
}
if (change) {
- destIndex=appendUChar(dest, destIndex, destCapacity, (UChar)upper);
+ destIndex=appendUChar(dest, destIndex, destCapacity, (char16_t)upper);
if (destIndex >= 0 && (data & HAS_EITHER_DIALYTIKA) != 0) {
destIndex=appendUChar(dest, destIndex, destCapacity, 0x308); // restore or add a dialytika
}
}
}
} else {
- const UChar *s;
+ const char16_t *s;
c=ucase_toFullUpper(c, nullptr, nullptr, &s, UCASE_LOC_GREEK);
destIndex = appendResult(dest, destIndex, destCapacity, c, s,
nextIndex - i, options, edits);
U_CFUNC int32_t U_CALLCONV
ustrcase_internalToLower(int32_t caseLocale, uint32_t options, UCASEMAP_BREAK_ITERATOR_UNUSED
- UChar *dest, int32_t destCapacity,
- const UChar *src, int32_t srcLength,
+ char16_t *dest, int32_t destCapacity,
+ const char16_t *src, int32_t srcLength,
icu::Edits *edits,
UErrorCode &errorCode) {
UCaseContext csc=UCASECONTEXT_INITIALIZER;
U_CFUNC int32_t U_CALLCONV
ustrcase_internalToUpper(int32_t caseLocale, uint32_t options, UCASEMAP_BREAK_ITERATOR_UNUSED
- UChar *dest, int32_t destCapacity,
- const UChar *src, int32_t srcLength,
+ char16_t *dest, int32_t destCapacity,
+ const char16_t *src, int32_t srcLength,
icu::Edits *edits,
UErrorCode &errorCode) {
int32_t destIndex;
U_CFUNC int32_t U_CALLCONV
ustrcase_internalFold(int32_t /* caseLocale */, uint32_t options, UCASEMAP_BREAK_ITERATOR_UNUSED
- UChar *dest, int32_t destCapacity,
- const UChar *src, int32_t srcLength,
+ char16_t *dest, int32_t destCapacity,
+ const char16_t *src, int32_t srcLength,
icu::Edits *edits,
UErrorCode &errorCode) {
int32_t destIndex = toLower(
U_CFUNC int32_t
ustrcase_map(int32_t caseLocale, uint32_t options, UCASEMAP_BREAK_ITERATOR_PARAM
- UChar *dest, int32_t destCapacity,
- const UChar *src, int32_t srcLength,
+ char16_t *dest, int32_t destCapacity,
+ const char16_t *src, int32_t srcLength,
UStringCaseMapper *stringCaseMapper,
icu::Edits *edits,
UErrorCode &errorCode) {
U_CFUNC int32_t
ustrcase_mapWithOverlap(int32_t caseLocale, uint32_t options, UCASEMAP_BREAK_ITERATOR_PARAM
- UChar *dest, int32_t destCapacity,
- const UChar *src, int32_t srcLength,
+ char16_t *dest, int32_t destCapacity,
+ const char16_t *src, int32_t srcLength,
UStringCaseMapper *stringCaseMapper,
UErrorCode &errorCode) {
- UChar buffer[300];
- UChar *temp;
+ char16_t buffer[300];
+ char16_t *temp;
int32_t destLength;
temp=buffer;
} else {
/* allocate a buffer */
- temp=(UChar *)uprv_malloc(destCapacity*U_SIZEOF_UCHAR);
+ temp=(char16_t *)uprv_malloc(destCapacity*U_SIZEOF_UCHAR);
if(temp==nullptr) {
errorCode=U_MEMORY_ALLOCATION_ERROR;
return 0;
/* public API functions */
U_CAPI int32_t U_EXPORT2
-u_strFoldCase(UChar *dest, int32_t destCapacity,
- const UChar *src, int32_t srcLength,
+u_strFoldCase(char16_t *dest, int32_t destCapacity,
+ const char16_t *src, int32_t srcLength,
uint32_t options,
UErrorCode *pErrorCode) {
return ustrcase_mapWithOverlap(
int32_t CaseMap::fold(
uint32_t options,
- const UChar *src, int32_t srcLength,
- UChar *dest, int32_t destCapacity, Edits *edits,
+ const char16_t *src, int32_t srcLength,
+ char16_t *dest, int32_t destCapacity, Edits *edits,
UErrorCode &errorCode) {
return ustrcase_map(
UCASE_LOC_ROOT, options, UCASEMAP_BREAK_ITERATOR_NULL
/* stack element for previous-level source/decomposition pointers */
struct CmpEquivLevel {
- const UChar *start, *s, *limit;
+ const char16_t *start, *s, *limit;
};
typedef struct CmpEquivLevel CmpEquivLevel;
* @return The result of comparison
*/
static int32_t _cmpFold(
- const UChar *s1, int32_t length1,
- const UChar *s2, int32_t length2,
+ const char16_t *s1, int32_t length1,
+ const char16_t *s2, int32_t length2,
uint32_t options,
int32_t *matchLen1, int32_t *matchLen2,
UErrorCode *pErrorCode) {
int32_t cmpRes = 0;
/* current-level start/limit - s1/s2 as current */
- const UChar *start1, *start2, *limit1, *limit2;
+ const char16_t *start1, *start2, *limit1, *limit2;
/* points to the original start address */
- const UChar *org1, *org2;
+ const char16_t *org1, *org2;
/* points to the end of match + 1 */
- const UChar *m1, *m2;
+ const char16_t *m1, *m2;
/* case folding variables */
- const UChar *p;
+ const char16_t *p;
int32_t length;
/* stacks of previous-level start/current/limit */
CmpEquivLevel stack1[2], stack2[2];
/* case folding buffers, only use current-level start/limit */
- UChar fold1[UCASE_MAX_STRING_LENGTH+1], fold2[UCASE_MAX_STRING_LENGTH+1];
+ char16_t fold1[UCASE_MAX_STRING_LENGTH+1], fold2[UCASE_MAX_STRING_LENGTH+1];
/* track which is the current level per string */
int32_t level1, level2;
* either variable c1, c2 is -1 only if the corresponding string is finished
*/
if(c1==c2) {
- const UChar *next1, *next2;
+ const char16_t *next1, *next2;
if(c1<0) {
cmpRes=0; /* c1==c2==-1 indicating end of strings */
/* get complete code points for c1, c2 for lookups if either is a surrogate */
cp1=c1;
if(U_IS_SURROGATE(c1)) {
- UChar c;
+ char16_t c;
if(U_IS_SURROGATE_LEAD(c1)) {
if(s1!=limit1 && U16_IS_TRAIL(c=*s1)) {
cp2=c2;
if(U_IS_SURROGATE(c2)) {
- UChar c;
+ char16_t c;
if(U_IS_SURROGATE_LEAD(c2)) {
if(s2!=limit2 && U16_IS_TRAIL(c=*s2)) {
/* internal function */
U_CFUNC int32_t
-u_strcmpFold(const UChar *s1, int32_t length1,
- const UChar *s2, int32_t length2,
+u_strcmpFold(const char16_t *s1, int32_t length1,
+ const char16_t *s2, int32_t length2,
uint32_t options,
UErrorCode *pErrorCode) {
return _cmpFold(s1, length1, s2, length2, options, nullptr, nullptr, pErrorCode);
/* public API functions */
U_CAPI int32_t U_EXPORT2
-u_strCaseCompare(const UChar *s1, int32_t length1,
- const UChar *s2, int32_t length2,
+u_strCaseCompare(const char16_t *s1, int32_t length1,
+ const char16_t *s2, int32_t length2,
uint32_t options,
UErrorCode *pErrorCode) {
/* argument checking */
}
U_CAPI int32_t U_EXPORT2
-u_strcasecmp(const UChar *s1, const UChar *s2, uint32_t options) {
+u_strcasecmp(const char16_t *s1, const char16_t *s2, uint32_t options) {
UErrorCode errorCode=U_ZERO_ERROR;
return u_strcmpFold(s1, -1, s2, -1,
options|U_COMPARE_IGNORE_CASE,
}
U_CAPI int32_t U_EXPORT2
-u_memcasecmp(const UChar *s1, const UChar *s2, int32_t length, uint32_t options) {
+u_memcasecmp(const char16_t *s1, const char16_t *s2, int32_t length, uint32_t options) {
UErrorCode errorCode=U_ZERO_ERROR;
return u_strcmpFold(s1, length, s2, length,
options|U_COMPARE_IGNORE_CASE,
}
U_CAPI int32_t U_EXPORT2
-u_strncasecmp(const UChar *s1, const UChar *s2, int32_t n, uint32_t options) {
+u_strncasecmp(const char16_t *s1, const char16_t *s2, int32_t n, uint32_t options) {
UErrorCode errorCode=U_ZERO_ERROR;
return u_strcmpFold(s1, n, s2, n,
options|(U_COMPARE_IGNORE_CASE|_STRNCMP_STYLE),
/* internal API - detect length of shared prefix */
U_CAPI void
-u_caseInsensitivePrefixMatch(const UChar *s1, int32_t length1,
- const UChar *s2, int32_t length2,
+u_caseInsensitivePrefixMatch(const char16_t *s1, int32_t length1,
+ const char16_t *s2, int32_t length2,
uint32_t options,
int32_t *matchLen1, int32_t *matchLen2,
UErrorCode *pErrorCode) {
/* public API functions */
U_CAPI int32_t U_EXPORT2
-u_strToLower(UChar *dest, int32_t destCapacity,
- const UChar *src, int32_t srcLength,
+u_strToLower(char16_t *dest, int32_t destCapacity,
+ const char16_t *src, int32_t srcLength,
const char *locale,
UErrorCode *pErrorCode) {
return ustrcase_mapWithOverlap(
}
U_CAPI int32_t U_EXPORT2
-u_strToUpper(UChar *dest, int32_t destCapacity,
- const UChar *src, int32_t srcLength,
+u_strToUpper(char16_t *dest, int32_t destCapacity,
+ const char16_t *src, int32_t srcLength,
const char *locale,
UErrorCode *pErrorCode) {
return ustrcase_mapWithOverlap(
int32_t CaseMap::toLower(
const char *locale, uint32_t options,
- const UChar *src, int32_t srcLength,
- UChar *dest, int32_t destCapacity, Edits *edits,
+ const char16_t *src, int32_t srcLength,
+ char16_t *dest, int32_t destCapacity, Edits *edits,
UErrorCode &errorCode) {
return ustrcase_map(
ustrcase_getCaseLocale(locale), options, UCASEMAP_BREAK_ITERATOR_NULL
int32_t CaseMap::toUpper(
const char *locale, uint32_t options,
- const UChar *src, int32_t srcLength,
- UChar *dest, int32_t destCapacity, Edits *edits,
+ const char16_t *src, int32_t srcLength,
+ char16_t *dest, int32_t destCapacity, Edits *edits,
UErrorCode &errorCode) {
return ustrcase_map(
ustrcase_getCaseLocale(locale), options, UCASEMAP_BREAK_ITERATOR_NULL
return nullptr;
}
-const UChar *
+const char16_t *
StringEnumeration::unext(int32_t *resultLength, UErrorCode &status) {
const UnicodeString *s=snext(status);
if(U_SUCCESS(status) && s!=nullptr) {
length=(int32_t)uprv_strlen(s);
}
- UChar *buffer=unistr.getBuffer(length+1);
+ char16_t *buffer=unistr.getBuffer(length+1);
if(buffer!=nullptr) {
u_charsToUChars(s, buffer, length);
buffer[length]=0;
const UnicodeString* UStringEnumeration::snext(UErrorCode& status) {
int32_t length;
- const UChar* str = uenum_unext(uenum, &length, &status);
+ const char16_t* str = uenum_unext(uenum, &length, &status);
if (str == 0 || U_FAILURE(status)) {
return 0;
}
/**
* Wrapper API to make StringEnumeration look like UEnumeration.
*/
-static const UChar* U_CALLCONV
+static const char16_t* U_CALLCONV
ustrenum_unext(UEnumeration* en,
int32_t* resultLength,
UErrorCode* ec)
return ((UCharStringEnumeration*)en)->count;
}
-static const UChar* U_CALLCONV
+static const char16_t* U_CALLCONV
ucharstrenum_unext(UEnumeration* en,
int32_t* resultLength,
UErrorCode* /*ec*/) {
if (e->index >= e->count) {
return nullptr;
}
- const UChar* result = ((const UChar**)e->uenum.context)[e->index++];
+ const char16_t* result = ((const char16_t**)e->uenum.context)[e->index++];
if (resultLength) {
*resultLength = (int32_t)u_strlen(result);
}
}
U_CAPI UEnumeration* U_EXPORT2
-uenum_openUCharStringsEnumeration(const UChar* const strings[], int32_t count,
+uenum_openUCharStringsEnumeration(const char16_t* const strings[], int32_t count,
UErrorCode* ec) {
UCharStringEnumeration* result = nullptr;
if (U_SUCCESS(*ec) && count >= 0 && (count == 0 || strings != 0)) {
/***
- * Fills in a UChar* string with the radix-based representation of a
+ * Fills in a char16_t* string with the radix-based representation of a
* uint32_t number padded with zeroes to minwidth. The result
* will be null terminated if there is room.
*
- * @param buffer UChar buffer to receive result
+ * @param buffer char16_t buffer to receive result
* @param capacity capacity of buffer
* @param i the unsigned number to be formatted
* @param radix the radix from 2..36
* null
*/
U_CAPI int32_t U_EXPORT2
-uprv_itou (UChar * buffer, int32_t capacity,
+uprv_itou (char16_t * buffer, int32_t capacity,
uint32_t i, uint32_t radix, int32_t minwidth)
{
int32_t length = 0;
int digit;
int32_t j;
- UChar temp;
+ char16_t temp;
do{
digit = (int)(i % radix);
- buffer[length++]=(UChar)(digit<=9?(0x0030+digit):(0x0030+digit+7));
+ buffer[length++]=(char16_t)(digit<=9?(0x0030+digit):(0x0030+digit+7));
i=i/radix;
} while(i && length<capacity);
while (length < minwidth){
- buffer[length++] = (UChar) 0x0030;/*zero padding */
+ buffer[length++] = (char16_t) 0x0030;/*zero padding */
}
/* null terminate the buffer */
if(length<capacity){
- buffer[length] = (UChar) 0x0000;
+ buffer[length] = (char16_t) 0x0000;
}
/* Reverses the string */
/* ANSI string.h - style functions ------------------------------------------ */
-/* U+ffff is the highest BMP code point, the highest one that fits into a 16-bit UChar */
+/* U+ffff is the highest BMP code point, the highest one that fits into a 16-bit char16_t */
#define U_BMP_MAX 0xffff
/* Forward binary string search functions ----------------------------------- */
* The limit pointer may be nullptr, all others must be real pointers.
*/
static inline UBool
-isMatchAtCPBoundary(const UChar *start, const UChar *match, const UChar *matchLimit, const UChar *limit) {
+isMatchAtCPBoundary(const char16_t *start, const char16_t *match, const char16_t *matchLimit, const char16_t *limit) {
if(U16_IS_TRAIL(*match) && start!=match && U16_IS_LEAD(*(match-1))) {
/* the leading edge of the match is in the middle of a surrogate pair */
return false;
return true;
}
-U_CAPI UChar * U_EXPORT2
-u_strFindFirst(const UChar *s, int32_t length,
- const UChar *sub, int32_t subLength) {
- const UChar *start, *p, *q, *subLimit;
- UChar c, cs, cq;
+U_CAPI char16_t * U_EXPORT2
+u_strFindFirst(const char16_t *s, int32_t length,
+ const char16_t *sub, int32_t subLength) {
+ const char16_t *start, *p, *q, *subLimit;
+ char16_t c, cs, cq;
if(sub==nullptr || subLength<-1) {
- return (UChar *)s;
+ return (char16_t *)s;
}
if(s==nullptr || length<-1) {
return nullptr;
if(length<0 && subLength<0) {
/* both strings are NUL-terminated */
if((cs=*sub++)==0) {
- return (UChar *)s;
+ return (char16_t *)s;
}
if(*sub==0 && !U16_IS_SURROGATE(cs)) {
/* the substring consists of a single, non-surrogate BMP code point */
while((c=*s++)!=0) {
if(c==cs) {
- /* found first substring UChar, compare rest */
+ /* found first substring char16_t, compare rest */
p=s;
q=sub;
for(;;) {
if((cq=*q)==0) {
if(isMatchAtCPBoundary(start, s-1, p, nullptr)) {
- return (UChar *)(s-1); /* well-formed match */
+ return (char16_t *)(s-1); /* well-formed match */
} else {
break; /* no match because surrogate pair is split */
}
subLength=u_strlen(sub);
}
if(subLength==0) {
- return (UChar *)s;
+ return (char16_t *)s;
}
/* get sub[0] to search for it fast */
/* s is NUL-terminated */
while((c=*s++)!=0) {
if(c==cs) {
- /* found first substring UChar, compare rest */
+ /* found first substring char16_t, compare rest */
p=s;
q=sub;
for(;;) {
if(q==subLimit) {
if(isMatchAtCPBoundary(start, s-1, p, nullptr)) {
- return (UChar *)(s-1); /* well-formed match */
+ return (char16_t *)(s-1); /* well-formed match */
} else {
break; /* no match because surrogate pair is split */
}
}
}
} else {
- const UChar *limit, *preLimit;
+ const char16_t *limit, *preLimit;
/* subLength was decremented above */
if(length<=subLength) {
while(s!=preLimit) {
c=*s++;
if(c==cs) {
- /* found first substring UChar, compare rest */
+ /* found first substring char16_t, compare rest */
p=s;
q=sub;
for(;;) {
if(q==subLimit) {
if(isMatchAtCPBoundary(start, s-1, p, limit)) {
- return (UChar *)(s-1); /* well-formed match */
+ return (char16_t *)(s-1); /* well-formed match */
} else {
break; /* no match because surrogate pair is split */
}
return nullptr;
}
-U_CAPI UChar * U_EXPORT2
-u_strstr(const UChar *s, const UChar *substring) {
+U_CAPI char16_t * U_EXPORT2
+u_strstr(const char16_t *s, const char16_t *substring) {
return u_strFindFirst(s, -1, substring, -1);
}
-U_CAPI UChar * U_EXPORT2
-u_strchr(const UChar *s, UChar c) {
+U_CAPI char16_t * U_EXPORT2
+u_strchr(const char16_t *s, char16_t c) {
if(U16_IS_SURROGATE(c)) {
/* make sure to not find half of a surrogate pair */
return u_strFindFirst(s, -1, &c, 1);
} else {
- UChar cs;
+ char16_t cs;
/* trivial search for a BMP code point */
for(;;) {
if((cs=*s)==c) {
- return (UChar *)s;
+ return (char16_t *)s;
}
if(cs==0) {
return nullptr;
}
}
-U_CAPI UChar * U_EXPORT2
-u_strchr32(const UChar *s, UChar32 c) {
+U_CAPI char16_t * U_EXPORT2
+u_strchr32(const char16_t *s, UChar32 c) {
if((uint32_t)c<=U_BMP_MAX) {
/* find BMP code point */
- return u_strchr(s, (UChar)c);
+ return u_strchr(s, (char16_t)c);
} else if((uint32_t)c<=UCHAR_MAX_VALUE) {
/* find supplementary code point as surrogate pair */
- UChar cs, lead=U16_LEAD(c), trail=U16_TRAIL(c);
+ char16_t cs, lead=U16_LEAD(c), trail=U16_TRAIL(c);
while((cs=*s++)!=0) {
if(cs==lead && *s==trail) {
- return (UChar *)(s-1);
+ return (char16_t *)(s-1);
}
}
return nullptr;
}
}
-U_CAPI UChar * U_EXPORT2
-u_memchr(const UChar *s, UChar c, int32_t count) {
+U_CAPI char16_t * U_EXPORT2
+u_memchr(const char16_t *s, char16_t c, int32_t count) {
if(count<=0) {
return nullptr; /* no string */
} else if(U16_IS_SURROGATE(c)) {
return u_strFindFirst(s, count, &c, 1);
} else {
/* trivial search for a BMP code point */
- const UChar *limit=s+count;
+ const char16_t *limit=s+count;
do {
if(*s==c) {
- return (UChar *)s;
+ return (char16_t *)s;
}
} while(++s!=limit);
return nullptr;
}
}
-U_CAPI UChar * U_EXPORT2
-u_memchr32(const UChar *s, UChar32 c, int32_t count) {
+U_CAPI char16_t * U_EXPORT2
+u_memchr32(const char16_t *s, UChar32 c, int32_t count) {
if((uint32_t)c<=U_BMP_MAX) {
/* find BMP code point */
- return u_memchr(s, (UChar)c, count);
+ return u_memchr(s, (char16_t)c, count);
} else if(count<2) {
/* too short for a surrogate pair */
return nullptr;
} else if((uint32_t)c<=UCHAR_MAX_VALUE) {
/* find supplementary code point as surrogate pair */
- const UChar *limit=s+count-1; /* -1 so that we do not need a separate check for the trail unit */
- UChar lead=U16_LEAD(c), trail=U16_TRAIL(c);
+ const char16_t *limit=s+count-1; /* -1 so that we do not need a separate check for the trail unit */
+ char16_t lead=U16_LEAD(c), trail=U16_TRAIL(c);
do {
if(*s==lead && *(s+1)==trail) {
- return (UChar *)s;
+ return (char16_t *)s;
}
} while(++s!=limit);
return nullptr;
/* Backward binary string search functions ---------------------------------- */
-U_CAPI UChar * U_EXPORT2
-u_strFindLast(const UChar *s, int32_t length,
- const UChar *sub, int32_t subLength) {
- const UChar *start, *limit, *p, *q, *subLimit;
- UChar c, cs;
+U_CAPI char16_t * U_EXPORT2
+u_strFindLast(const char16_t *s, int32_t length,
+ const char16_t *sub, int32_t subLength) {
+ const char16_t *start, *limit, *p, *q, *subLimit;
+ char16_t c, cs;
if(sub==nullptr || subLength<-1) {
- return (UChar *)s;
+ return (char16_t *)s;
}
if(s==nullptr || length<-1) {
return nullptr;
subLength=u_strlen(sub);
}
if(subLength==0) {
- return (UChar *)s;
+ return (char16_t *)s;
}
/* get sub[subLength-1] to search for it fast */
while(s!=limit) {
c=*(--limit);
if(c==cs) {
- /* found last substring UChar, compare rest */
+ /* found last substring char16_t, compare rest */
p=limit;
q=subLimit;
for(;;) {
if(q==sub) {
if(isMatchAtCPBoundary(start, p, limit+1, start+length)) {
- return (UChar *)p; /* well-formed match */
+ return (char16_t *)p; /* well-formed match */
} else {
break; /* no match because surrogate pair is split */
}
return nullptr;
}
-U_CAPI UChar * U_EXPORT2
-u_strrstr(const UChar *s, const UChar *substring) {
+U_CAPI char16_t * U_EXPORT2
+u_strrstr(const char16_t *s, const char16_t *substring) {
return u_strFindLast(s, -1, substring, -1);
}
-U_CAPI UChar * U_EXPORT2
-u_strrchr(const UChar *s, UChar c) {
+U_CAPI char16_t * U_EXPORT2
+u_strrchr(const char16_t *s, char16_t c) {
if(U16_IS_SURROGATE(c)) {
/* make sure to not find half of a surrogate pair */
return u_strFindLast(s, -1, &c, 1);
} else {
- const UChar *result=nullptr;
- UChar cs;
+ const char16_t *result=nullptr;
+ char16_t cs;
/* trivial search for a BMP code point */
for(;;) {
result=s;
}
if(cs==0) {
- return (UChar *)result;
+ return (char16_t *)result;
}
++s;
}
}
}
-U_CAPI UChar * U_EXPORT2
-u_strrchr32(const UChar *s, UChar32 c) {
+U_CAPI char16_t * U_EXPORT2
+u_strrchr32(const char16_t *s, UChar32 c) {
if((uint32_t)c<=U_BMP_MAX) {
/* find BMP code point */
- return u_strrchr(s, (UChar)c);
+ return u_strrchr(s, (char16_t)c);
} else if((uint32_t)c<=UCHAR_MAX_VALUE) {
/* find supplementary code point as surrogate pair */
- const UChar *result=nullptr;
- UChar cs, lead=U16_LEAD(c), trail=U16_TRAIL(c);
+ const char16_t *result=nullptr;
+ char16_t cs, lead=U16_LEAD(c), trail=U16_TRAIL(c);
while((cs=*s++)!=0) {
if(cs==lead && *s==trail) {
result=s-1;
}
}
- return (UChar *)result;
+ return (char16_t *)result;
} else {
/* not a Unicode code point, not findable */
return nullptr;
}
}
-U_CAPI UChar * U_EXPORT2
-u_memrchr(const UChar *s, UChar c, int32_t count) {
+U_CAPI char16_t * U_EXPORT2
+u_memrchr(const char16_t *s, char16_t c, int32_t count) {
if(count<=0) {
return nullptr; /* no string */
} else if(U16_IS_SURROGATE(c)) {
return u_strFindLast(s, count, &c, 1);
} else {
/* trivial search for a BMP code point */
- const UChar *limit=s+count;
+ const char16_t *limit=s+count;
do {
if(*(--limit)==c) {
- return (UChar *)limit;
+ return (char16_t *)limit;
}
} while(s!=limit);
return nullptr;
}
}
-U_CAPI UChar * U_EXPORT2
-u_memrchr32(const UChar *s, UChar32 c, int32_t count) {
+U_CAPI char16_t * U_EXPORT2
+u_memrchr32(const char16_t *s, UChar32 c, int32_t count) {
if((uint32_t)c<=U_BMP_MAX) {
/* find BMP code point */
- return u_memrchr(s, (UChar)c, count);
+ return u_memrchr(s, (char16_t)c, count);
} else if(count<2) {
/* too short for a surrogate pair */
return nullptr;
} else if((uint32_t)c<=UCHAR_MAX_VALUE) {
/* find supplementary code point as surrogate pair */
- const UChar *limit=s+count-1;
- UChar lead=U16_LEAD(c), trail=U16_TRAIL(c);
+ const char16_t *limit=s+count-1;
+ char16_t lead=U16_LEAD(c), trail=U16_TRAIL(c);
do {
if(*limit==trail && *(limit-1)==lead) {
- return (UChar *)(limit-1);
+ return (char16_t *)(limit-1);
}
} while(s!=--limit);
return nullptr;
* Return -(string length)-1 if there is no such code point.
*/
static int32_t
-_matchFromSet(const UChar *string, const UChar *matchSet, UBool polarity) {
+_matchFromSet(const char16_t *string, const char16_t *matchSet, UBool polarity) {
int32_t matchLen, matchBMPLen, strItr, matchItr;
UChar32 stringCh, matchCh;
- UChar c, c2;
+ char16_t c, c2;
/* first part of matchSet contains only BMP code points */
matchBMPLen = 0;
}
/* Search for a codepoint in a string that matches one of the matchSet codepoints. */
-U_CAPI UChar * U_EXPORT2
-u_strpbrk(const UChar *string, const UChar *matchSet)
+U_CAPI char16_t * U_EXPORT2
+u_strpbrk(const char16_t *string, const char16_t *matchSet)
{
int32_t idx = _matchFromSet(string, matchSet, true);
if(idx >= 0) {
- return (UChar *)string + idx;
+ return (char16_t *)string + idx;
} else {
return nullptr;
}
/* Search for a codepoint in a string that matches one of the matchSet codepoints. */
U_CAPI int32_t U_EXPORT2
-u_strcspn(const UChar *string, const UChar *matchSet)
+u_strcspn(const char16_t *string, const char16_t *matchSet)
{
int32_t idx = _matchFromSet(string, matchSet, true);
if(idx >= 0) {
/* Search for a codepoint in a string that does not match one of the matchSet codepoints. */
U_CAPI int32_t U_EXPORT2
-u_strspn(const UChar *string, const UChar *matchSet)
+u_strspn(const char16_t *string, const char16_t *matchSet)
{
int32_t idx = _matchFromSet(string, matchSet, false);
if(idx >= 0) {
/* ----- Text manipulation functions --- */
-U_CAPI UChar* U_EXPORT2
-u_strtok_r(UChar *src,
- const UChar *delim,
- UChar **saveState)
+U_CAPI char16_t* U_EXPORT2
+u_strtok_r(char16_t *src,
+ const char16_t *delim,
+ char16_t **saveState)
{
- UChar *tokSource;
- UChar *nextToken;
+ char16_t *tokSource;
+ char16_t *nextToken;
uint32_t nonDelimIdx;
/* If saveState is nullptr, the user messed up. */
/* Miscellaneous functions -------------------------------------------------- */
-U_CAPI UChar* U_EXPORT2
-u_strcat(UChar *dst,
- const UChar *src)
+U_CAPI char16_t* U_EXPORT2
+u_strcat(char16_t *dst,
+ const char16_t *src)
{
- UChar *anchor = dst; /* save a pointer to start of dst */
+ char16_t *anchor = dst; /* save a pointer to start of dst */
while(*dst != 0) { /* To end of first string */
++dst;
return anchor;
}
-U_CAPI UChar* U_EXPORT2
-u_strncat(UChar *dst,
- const UChar *src,
+U_CAPI char16_t* U_EXPORT2
+u_strncat(char16_t *dst,
+ const char16_t *src,
int32_t n )
{
if(n > 0) {
- UChar *anchor = dst; /* save a pointer to start of dst */
+ char16_t *anchor = dst; /* save a pointer to start of dst */
while(*dst != 0) { /* To end of first string */
++dst;
/* ----- Text property functions --- */
U_CAPI int32_t U_EXPORT2
-u_strcmp(const UChar *s1,
- const UChar *s2)
+u_strcmp(const char16_t *s1,
+ const char16_t *s2)
{
- UChar c1, c2;
+ char16_t c1, c2;
for(;;) {
c1=*s1++;
}
U_CFUNC int32_t U_EXPORT2
-uprv_strCompare(const UChar *s1, int32_t length1,
- const UChar *s2, int32_t length2,
+uprv_strCompare(const char16_t *s1, int32_t length1,
+ const char16_t *s2, int32_t length2,
UBool strncmpStyle, UBool codePointOrder) {
- const UChar *start1, *start2, *limit1, *limit2;
- UChar c1, c2;
+ const char16_t *start1, *start2, *limit1, *limit2;
+ char16_t c1, c2;
/* setup for fix-up */
start1=s1;
#endif
U_CAPI int32_t U_EXPORT2
-u_strCompare(const UChar *s1, int32_t length1,
- const UChar *s2, int32_t length2,
+u_strCompare(const char16_t *s1, int32_t length1,
+ const char16_t *s2, int32_t length2,
UBool codePointOrder) {
/* argument checking */
if(s1==nullptr || length1<-1 || s2==nullptr || length2<-1) {
/* String compare in code point order - u_strcmp() compares in code unit order. */
U_CAPI int32_t U_EXPORT2
-u_strcmpCodePointOrder(const UChar *s1, const UChar *s2) {
+u_strcmpCodePointOrder(const char16_t *s1, const char16_t *s2) {
return uprv_strCompare(s1, -1, s2, -1, false, true);
}
U_CAPI int32_t U_EXPORT2
-u_strncmp(const UChar *s1,
- const UChar *s2,
+u_strncmp(const char16_t *s1,
+ const char16_t *s2,
int32_t n)
{
if(n > 0) {
}
U_CAPI int32_t U_EXPORT2
-u_strncmpCodePointOrder(const UChar *s1, const UChar *s2, int32_t n) {
+u_strncmpCodePointOrder(const char16_t *s1, const char16_t *s2, int32_t n) {
return uprv_strCompare(s1, n, s2, n, true, true);
}
-U_CAPI UChar* U_EXPORT2
-u_strcpy(UChar *dst,
- const UChar *src)
+U_CAPI char16_t* U_EXPORT2
+u_strcpy(char16_t *dst,
+ const char16_t *src)
{
- UChar *anchor = dst; /* save a pointer to start of dst */
+ char16_t *anchor = dst; /* save a pointer to start of dst */
while((*(dst++) = *(src++)) != 0) { /* copy string 2 over */
}
return anchor;
}
-U_CAPI UChar* U_EXPORT2
-u_strncpy(UChar *dst,
- const UChar *src,
+U_CAPI char16_t* U_EXPORT2
+u_strncpy(char16_t *dst,
+ const char16_t *src,
int32_t n)
{
- UChar *anchor = dst; /* save a pointer to start of dst */
+ char16_t *anchor = dst; /* save a pointer to start of dst */
/* copy string 2 over */
while(n > 0 && (*(dst++) = *(src++)) != 0) {
}
U_CAPI int32_t U_EXPORT2
-u_strlen(const UChar *s)
+u_strlen(const char16_t *s)
{
#if U_SIZEOF_WCHAR_T == U_SIZEOF_UCHAR
return (int32_t)uprv_wcslen((const wchar_t *)s);
#else
- const UChar *t = s;
+ const char16_t *t = s;
while(*t != 0) {
++t;
}
}
U_CAPI int32_t U_EXPORT2
-u_countChar32(const UChar *s, int32_t length) {
+u_countChar32(const char16_t *s, int32_t length) {
int32_t count;
if(s==nullptr || length<-1) {
}
}
} else /* length==-1 */ {
- UChar c;
+ char16_t c;
for(;;) {
if((c=*s++)==0) {
}
U_CAPI UBool U_EXPORT2
-u_strHasMoreChar32Than(const UChar *s, int32_t length, int32_t number) {
+u_strHasMoreChar32Than(const char16_t *s, int32_t length, int32_t number) {
if(number<0) {
return true;
if(length==-1) {
/* s is NUL-terminated */
- UChar c;
+ char16_t c;
/* count code points until they exceed */
for(;;) {
}
} else {
/* length>=0 known */
- const UChar *limit;
+ const char16_t *limit;
int32_t maxSupplementary;
/* s contains at least (length+1)/2 code points: <=2 UChars per cp */
/*
* count code points until they exceed and also check that there are
- * no more than maxSupplementary supplementary code points (UChar pairs)
+ * no more than maxSupplementary supplementary code points (char16_t pairs)
*/
limit=s+length;
for(;;) {
}
}
-U_CAPI UChar * U_EXPORT2
-u_memcpy(UChar *dest, const UChar *src, int32_t count) {
+U_CAPI char16_t * U_EXPORT2
+u_memcpy(char16_t *dest, const char16_t *src, int32_t count) {
if(count > 0) {
uprv_memcpy(dest, src, (size_t)count*U_SIZEOF_UCHAR);
}
return dest;
}
-U_CAPI UChar * U_EXPORT2
-u_memmove(UChar *dest, const UChar *src, int32_t count) {
+U_CAPI char16_t * U_EXPORT2
+u_memmove(char16_t *dest, const char16_t *src, int32_t count) {
if(count > 0) {
uprv_memmove(dest, src, (size_t)count*U_SIZEOF_UCHAR);
}
return dest;
}
-U_CAPI UChar * U_EXPORT2
-u_memset(UChar *dest, UChar c, int32_t count) {
+U_CAPI char16_t * U_EXPORT2
+u_memset(char16_t *dest, char16_t c, int32_t count) {
if(count > 0) {
- UChar *ptr = dest;
- UChar *limit = dest + count;
+ char16_t *ptr = dest;
+ char16_t *limit = dest + count;
while (ptr < limit) {
*(ptr++) = c;
}
U_CAPI int32_t U_EXPORT2
-u_memcmp(const UChar *buf1, const UChar *buf2, int32_t count) {
+u_memcmp(const char16_t *buf1, const char16_t *buf2, int32_t count) {
if(count > 0) {
- const UChar *limit = buf1 + count;
+ const char16_t *limit = buf1 + count;
int32_t result;
while (buf1 < limit) {
}
U_CAPI int32_t U_EXPORT2
-u_memcmpCodePointOrder(const UChar *s1, const UChar *s2, int32_t count) {
+u_memcmpCodePointOrder(const char16_t *s1, const char16_t *s2, int32_t count) {
return uprv_strCompare(s1, count, s2, count, false, true);
}
/* u_unescape & support fns ------------------------------------------------- */
/* This map must be in ASCENDING ORDER OF THE ESCAPE CODE */
-static const UChar UNESCAPE_MAP[] = {
+static const char16_t UNESCAPE_MAP[] = {
/*" 0x22, 0x22 */
/*' 0x27, 0x27 */
/*? 0x3F, 0x3F */
enum { UNESCAPE_MAP_LENGTH = UPRV_LENGTHOF(UNESCAPE_MAP) };
/* Convert one octal digit to a numeric value 0..7, or -1 on failure */
-static int32_t _digit8(UChar c) {
+static int32_t _digit8(char16_t c) {
if (c >= u'0' && c <= u'7') {
return c - u'0';
}
}
/* Convert one hex digit to a numeric value 0..F, or -1 on failure */
-static int32_t _digit16(UChar c) {
+static int32_t _digit16(char16_t c) {
if (c >= u'0' && c <= u'9') {
return c - u'0';
}
goto err;
}
- /* Fetch first UChar after '\\' */
+ /* Fetch first char16_t after '\\' */
c = charAt((*offset)++, context);
/* Convert hexadecimal and octal escapes */
if (c == u'c' && *offset < length) {
c = charAt((*offset)++, context);
if (U16_IS_LEAD(c) && *offset < length) {
- UChar c2 = charAt(*offset, context);
+ char16_t c2 = charAt(*offset, context);
if (U16_IS_TRAIL(c2)) {
++(*offset);
c = U16_GET_SUPPLEMENTARY(c, c2);
* the backslash to generically escape the next character.
* Deal with surrogate pairs. */
if (U16_IS_LEAD(c) && *offset < length) {
- UChar c2 = charAt(*offset, context);
+ char16_t c2 = charAt(*offset, context);
if (U16_IS_TRAIL(c2)) {
++(*offset);
return U16_GET_SUPPLEMENTARY(c, c2);
return (UChar32)0xFFFFFFFF;
}
-/* u_unescapeAt() callback to return a UChar from a char* */
-static UChar U_CALLCONV
+/* u_unescapeAt() callback to return a char16_t from a char* */
+static char16_t U_CALLCONV
_charPtr_charAt(int32_t offset, void *context) {
- UChar c16;
+ char16_t c16;
/* It would be more efficient to access the invariant tables
* directly but there is no API for that. */
u_charsToUChars(((char*) context) + offset, &c16, 1);
}
/* Append an escape-free segment of the text; used by u_unescape() */
-static void _appendUChars(UChar *dest, int32_t destCapacity,
+static void _appendUChars(char16_t *dest, int32_t destCapacity,
const char *src, int32_t srcLen) {
if (destCapacity < 0) {
destCapacity = 0;
u_charsToUChars(src, dest, srcLen);
}
-/* Do an invariant conversion of char* -> UChar*, with escape parsing */
+/* Do an invariant conversion of char* -> char16_t*, with escape parsing */
U_CAPI int32_t U_EXPORT2
-u_unescape(const char *src, UChar *dest, int32_t destCapacity) {
+u_unescape(const char *src, char16_t *dest, int32_t destCapacity) {
const char *segment = src;
int32_t i = 0;
char c;
} \
} UPRV_BLOCK_MACRO_END
-U_CAPI UChar U_EXPORT2
-u_asciiToUpper(UChar c) {
+U_CAPI char16_t U_EXPORT2
+u_asciiToUpper(char16_t c) {
if (u'a' <= c && c <= u'z') {
c = c + u'A' - u'a';
}
}
U_CAPI int32_t U_EXPORT2
-u_terminateUChars(UChar *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode) {
+u_terminateUChars(char16_t *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode) {
__TERMINATE_STRING(dest, destCapacity, length, pErrorCode);
return length;
}
/* Used by UnicodeString to compute its hashcode - Not public API. */
U_CAPI int32_t U_EXPORT2
-ustr_hashUCharsN(const UChar *str, int32_t length) {
- STRING_HASH(UChar, str, length, *p);
+ustr_hashUCharsN(const char16_t *str, int32_t length) {
+ STRING_HASH(char16_t, str, length, *p);
}
U_CAPI int32_t U_EXPORT2
#include "ustr_imp.h"
#include "uassert.h"
-U_CAPI UChar* U_EXPORT2
-u_strFromUTF32WithSub(UChar *dest,
+U_CAPI char16_t* U_EXPORT2
+u_strFromUTF32WithSub(char16_t *dest,
int32_t destCapacity,
int32_t *pDestLength,
const UChar32 *src,
UErrorCode *pErrorCode) {
const UChar32 *srcLimit;
UChar32 ch;
- UChar *destLimit;
- UChar *pDest;
+ char16_t *destLimit;
+ char16_t *pDest;
int32_t reqLength;
int32_t numSubstitutions;
((uint32_t)ch < 0xd800 || (0xe000 <= ch && ch <= 0xffff))) {
++src;
if(pDest < destLimit) {
- *pDest++ = (UChar)ch;
+ *pDest++ = (char16_t)ch;
} else {
++reqLength;
}
/* usually "loops" once; twice only for writing subchar */
if((uint32_t)ch < 0xd800 || (0xe000 <= ch && ch <= 0xffff)) {
if(pDest < destLimit) {
- *pDest++ = (UChar)ch;
+ *pDest++ = (char16_t)ch;
} else {
++reqLength;
}
return dest;
}
-U_CAPI UChar* U_EXPORT2
-u_strFromUTF32(UChar *dest,
+U_CAPI char16_t* U_EXPORT2
+u_strFromUTF32(char16_t *dest,
int32_t destCapacity,
int32_t *pDestLength,
const UChar32 *src,
u_strToUTF32WithSub(UChar32 *dest,
int32_t destCapacity,
int32_t *pDestLength,
- const UChar *src,
+ const char16_t *src,
int32_t srcLength,
UChar32 subchar, int32_t *pNumSubstitutions,
UErrorCode *pErrorCode) {
- const UChar *srcLimit;
+ const char16_t *srcLimit;
UChar32 ch;
- UChar ch2;
+ char16_t ch2;
UChar32 *destLimit;
UChar32 *pDest;
int32_t reqLength;
u_strToUTF32(UChar32 *dest,
int32_t destCapacity,
int32_t *pDestLength,
- const UChar *src,
+ const char16_t *src,
int32_t srcLength,
UErrorCode *pErrorCode) {
return u_strToUTF32WithSub(
pErrorCode);
}
-U_CAPI UChar* U_EXPORT2
-u_strFromUTF8WithSub(UChar *dest,
+U_CAPI char16_t* U_EXPORT2
+u_strFromUTF8WithSub(char16_t *dest,
int32_t destCapacity,
int32_t *pDestLength,
const char* src,
if(pNumSubstitutions!=nullptr) {
*pNumSubstitutions=0;
}
- UChar *pDest = dest;
- UChar *pDestLimit = dest+destCapacity;
+ char16_t *pDest = dest;
+ char16_t *pDestLimit = dest+destCapacity;
int32_t reqLength = 0;
int32_t numSubstitutions=0;
// modified copy of U8_NEXT()
++i;
if(U8_IS_SINGLE(c)) {
- *pDest++=(UChar)c;
+ *pDest++=(char16_t)c;
} else {
uint8_t __t1, __t2;
if( /* handle U+0800..U+FFFF inline */
*pErrorCode = U_INVALID_CHAR_FOUND;
return nullptr;
} else if(c<=0xFFFF) {
- *(pDest++)=(UChar)c;
+ *(pDest++)=(char16_t)c;
} else {
*(pDest++)=U16_LEAD(c);
if(pDest<pDestLimit) {
for(;;) {
/*
* Each iteration of the inner loop progresses by at most 3 UTF-8
- * bytes and one UChar, for most characters.
+ * bytes and one char16_t, for most characters.
* For supplementary code points (4 & 2), which are rare,
* there is an additional adjustment.
*/
// modified copy of U8_NEXT()
c = (uint8_t)src[i++];
if(U8_IS_SINGLE(c)) {
- *pDest++=(UChar)c;
+ *pDest++=(char16_t)c;
} else {
uint8_t __t1, __t2;
if( /* handle U+0800..U+FFFF inline */
*pErrorCode = U_INVALID_CHAR_FOUND;
return nullptr;
} else if(c<=0xFFFF) {
- *(pDest++)=(UChar)c;
+ *(pDest++)=(char16_t)c;
} else {
*(pDest++)=U16_LEAD(c);
*(pDest++)=U16_TRAIL(c);
// modified copy of U8_NEXT()
c = (uint8_t)src[i++];
if(U8_IS_SINGLE(c)) {
- *pDest++=(UChar)c;
+ *pDest++=(char16_t)c;
} else {
uint8_t __t1, __t2;
if( /* handle U+0800..U+FFFF inline */
*pErrorCode = U_INVALID_CHAR_FOUND;
return nullptr;
} else if(c<=0xFFFF) {
- *(pDest++)=(UChar)c;
+ *(pDest++)=(char16_t)c;
} else {
*(pDest++)=U16_LEAD(c);
if(pDest<pDestLimit) {
return dest;
}
-U_CAPI UChar* U_EXPORT2
-u_strFromUTF8(UChar *dest,
+U_CAPI char16_t* U_EXPORT2
+u_strFromUTF8(char16_t *dest,
int32_t destCapacity,
int32_t *pDestLength,
const char* src,
pErrorCode);
}
-U_CAPI UChar * U_EXPORT2
-u_strFromUTF8Lenient(UChar *dest,
+U_CAPI char16_t * U_EXPORT2
+u_strFromUTF8Lenient(char16_t *dest,
int32_t destCapacity,
int32_t *pDestLength,
const char *src,
int32_t srcLength,
UErrorCode *pErrorCode) {
- UChar *pDest = dest;
+ char16_t *pDest = dest;
UChar32 ch;
int32_t reqLength = 0;
uint8_t* pSrc = (uint8_t*) src;
if(srcLength < 0) {
/* Transform a NUL-terminated string. */
- UChar *pDestLimit = (dest!=nullptr)?(dest+destCapacity):nullptr;
+ char16_t *pDestLimit = (dest!=nullptr)?(dest+destCapacity):nullptr;
uint8_t t1, t2, t3; /* trail bytes */
while(((ch = *pSrc) != 0) && (pDest < pDestLimit)) {
* a single-byte sequence for better character boundary
* resynchronization after illegal sequences.
*/
- *pDest++=(UChar)ch;
+ *pDest++=(char16_t)ch;
++pSrc;
continue;
} else if(ch < 0xe0) { /* U+0080..U+07FF */
if((t1 = pSrc[1]) != 0) {
/* 0x3080 = (0xc0 << 6) + 0x80 */
- *pDest++ = (UChar)((ch << 6) + t1 - 0x3080);
+ *pDest++ = (char16_t)((ch << 6) + t1 - 0x3080);
pSrc += 2;
continue;
}
} else if(ch < 0xf0) { /* U+0800..U+FFFF */
if((t1 = pSrc[1]) != 0 && (t2 = pSrc[2]) != 0) {
- /* no need for (ch & 0xf) because the upper bits are truncated after <<12 in the cast to (UChar) */
+ /* no need for (ch & 0xf) because the upper bits are truncated after <<12 in the cast to (char16_t) */
/* 0x2080 = (0x80 << 6) + 0x80 */
- *pDest++ = (UChar)((ch << 12) + (t1 << 6) + t2 - 0x2080);
+ *pDest++ = (char16_t)((ch << 12) + (t1 << 6) + t2 - 0x2080);
pSrc += 3;
continue;
}
* a single-byte sequence for better character boundary
* resynchronization after illegal sequences.
*/
- *pDest++=(UChar)ch;
+ *pDest++=(char16_t)ch;
} else if(ch < 0xe0) { /* U+0080..U+07FF */
/* 0x3080 = (0xc0 << 6) + 0x80 */
- *pDest++ = (UChar)((ch << 6) + *pSrc++ - 0x3080);
+ *pDest++ = (char16_t)((ch << 6) + *pSrc++ - 0x3080);
} else if(ch < 0xf0) { /* U+0800..U+FFFF */
- /* no need for (ch & 0xf) because the upper bits are truncated after <<12 in the cast to (UChar) */
+ /* no need for (ch & 0xf) because the upper bits are truncated after <<12 in the cast to (char16_t) */
/* 0x2080 = (0x80 << 6) + 0x80 */
ch = (ch << 12) + (*pSrc++ << 6);
- *pDest++ = (UChar)(ch + *pSrc++ - 0x2080);
+ *pDest++ = (char16_t)(ch + *pSrc++ - 0x2080);
} else /* f0..f4 */ { /* U+10000..U+10FFFF */
/* 0x3c82080 = (0xf0 << 18) + (0x80 << 12) + (0x80 << 6) + 0x80 */
ch = (ch << 18) + (*pSrc++ << 12);
* a single-byte sequence for better character boundary
* resynchronization after illegal sequences.
*/
- *pDest++=(UChar)ch;
+ *pDest++=(char16_t)ch;
continue;
} else if(ch < 0xe0) { /* U+0080..U+07FF */
if(pSrc < pSrcLimit) {
/* 0x3080 = (0xc0 << 6) + 0x80 */
- *pDest++ = (UChar)((ch << 6) + *pSrc++ - 0x3080);
+ *pDest++ = (char16_t)((ch << 6) + *pSrc++ - 0x3080);
continue;
}
} else if(ch < 0xf0) { /* U+0800..U+FFFF */
if((pSrcLimit - pSrc) >= 2) {
- /* no need for (ch & 0xf) because the upper bits are truncated after <<12 in the cast to (UChar) */
+ /* no need for (ch & 0xf) because the upper bits are truncated after <<12 in the cast to (char16_t) */
/* 0x2080 = (0x80 << 6) + 0x80 */
ch = (ch << 12) + (*pSrc++ << 6);
- *pDest++ = (UChar)(ch + *pSrc++ - 0x2080);
+ *pDest++ = (char16_t)(ch + *pSrc++ - 0x2080);
pSrc += 3;
continue;
}
u_strToUTF8WithSub(char *dest,
int32_t destCapacity,
int32_t *pDestLength,
- const UChar *pSrc,
+ const char16_t *pSrc,
int32_t srcLength,
UChar32 subchar, int32_t *pNumSubstitutions,
UErrorCode *pErrorCode){
}
}
} else {
- const UChar *pSrcLimit = (pSrc!=nullptr)?(pSrc+srcLength):nullptr;
+ const char16_t *pSrcLimit = (pSrc!=nullptr)?(pSrc+srcLength):nullptr;
int32_t count;
/* Faster loop without ongoing checking for pSrcLimit and pDestLimit. */
for(;;) {
/*
* Each iteration of the inner loop progresses by at most 3 UTF-8
- * bytes and one UChar, for most characters.
+ * bytes and one char16_t, for most characters.
* For supplementary code points (4 & 2), which are rare,
* there is an additional adjustment.
*/
u_strToUTF8(char *dest,
int32_t destCapacity,
int32_t *pDestLength,
- const UChar *pSrc,
+ const char16_t *pSrc,
int32_t srcLength,
UErrorCode *pErrorCode){
return u_strToUTF8WithSub(
pErrorCode);
}
-U_CAPI UChar* U_EXPORT2
+U_CAPI char16_t* U_EXPORT2
u_strFromJavaModifiedUTF8WithSub(
- UChar *dest,
+ char16_t *dest,
int32_t destCapacity,
int32_t *pDestLength,
const char *src,
if(pNumSubstitutions!=nullptr) {
*pNumSubstitutions=0;
}
- UChar *pDest = dest;
- UChar *pDestLimit = dest+destCapacity;
+ char16_t *pDest = dest;
+ char16_t *pDestLimit = dest+destCapacity;
int32_t reqLength = 0;
int32_t numSubstitutions=0;
*/
UChar32 c;
while(((c = (uint8_t)*src) != 0) && c <= 0x7f && (pDest < pDestLimit)) {
- *pDest++=(UChar)c;
+ *pDest++=(char16_t)c;
++src;
}
if(c == 0) {
}
/*
* Each iteration of the inner loop progresses by at most 3 UTF-8
- * bytes and one UChar.
+ * bytes and one char16_t.
*/
if(subchar > 0xFFFF) {
break;
do {
ch = (uint8_t)src[i++];
if(U8_IS_SINGLE(ch)) {
- *pDest++=(UChar)ch;
+ *pDest++=(char16_t)ch;
} else {
if(ch >= 0xe0) {
if( /* handle U+0000..U+FFFF inline */
(t1 = (uint8_t)(src[i] - 0x80)) <= 0x3f &&
(t2 = (uint8_t)(src[i+1] - 0x80)) <= 0x3f
) {
- /* no need for (ch & 0xf) because the upper bits are truncated after <<12 in the cast to (UChar) */
- *pDest++ = (UChar)((ch << 12) | (t1 << 6) | t2);
+ /* no need for (ch & 0xf) because the upper bits are truncated after <<12 in the cast to (char16_t) */
+ *pDest++ = (char16_t)((ch << 12) | (t1 << 6) | t2);
i += 2;
continue;
}
ch >= 0xc0 &&
(t1 = (uint8_t)(src[i] - 0x80)) <= 0x3f
) {
- *pDest++ = (UChar)(((ch & 0x1f) << 6) | t1);
+ *pDest++ = (char16_t)(((ch & 0x1f) << 6) | t1);
++i;
continue;
}
/* function call for error cases */
utf8_nextCharSafeBody((const uint8_t *)src, &(i), srcLength, ch, -1);
++numSubstitutions;
- *(pDest++)=(UChar)subchar;
+ *(pDest++)=(char16_t)subchar;
}
}
} while(--count > 0);
while(i < srcLength && (pDest < pDestLimit)) {
ch = (uint8_t)src[i++];
if(U8_IS_SINGLE(ch)){
- *pDest++=(UChar)ch;
+ *pDest++=(char16_t)ch;
} else {
if(ch >= 0xe0) {
if( /* handle U+0000..U+FFFF inline */
(t1 = (uint8_t)(src[i] - 0x80)) <= 0x3f &&
(t2 = (uint8_t)(src[i+1] - 0x80)) <= 0x3f
) {
- /* no need for (ch & 0xf) because the upper bits are truncated after <<12 in the cast to (UChar) */
- *pDest++ = (UChar)((ch << 12) | (t1 << 6) | t2);
+ /* no need for (ch & 0xf) because the upper bits are truncated after <<12 in the cast to (char16_t) */
+ *pDest++ = (char16_t)((ch << 12) | (t1 << 6) | t2);
i += 2;
continue;
}
i < srcLength &&
(t1 = (uint8_t)(src[i] - 0x80)) <= 0x3f
) {
- *pDest++ = (UChar)(((ch & 0x1f) << 6) | t1);
+ *pDest++ = (char16_t)(((ch & 0x1f) << 6) | t1);
++i;
continue;
}
utf8_nextCharSafeBody((const uint8_t *)src, &(i), srcLength, ch, -1);
++numSubstitutions;
if(subchar<=0xFFFF) {
- *(pDest++)=(UChar)subchar;
+ *(pDest++)=(char16_t)subchar;
} else {
*(pDest++)=U16_LEAD(subchar);
if(pDest<pDestLimit) {
char *dest,
int32_t destCapacity,
int32_t *pDestLength,
- const UChar *src,
+ const char16_t *src,
int32_t srcLength,
UErrorCode *pErrorCode) {
int32_t reqLength=0;
uint32_t ch=0;
uint8_t *pDest = (uint8_t *)dest;
uint8_t *pDestLimit = pDest + destCapacity;
- const UChar *pSrcLimit;
+ const char16_t *pSrcLimit;
int32_t count;
/* args check */
srcLength = (int32_t)(pSrcLimit - src);
if(count >= srcLength && srcLength > 0 && *src <= 0x7f) {
/* fast ASCII loop */
- const UChar *prevSrc = src;
+ const char16_t *prevSrc = src;
int32_t delta;
while(src < pSrcLimit && (ch = *src) <= 0x7f && ch != 0) {
*pDest++=(uint8_t)ch;
}
/*
* Each iteration of the inner loop progresses by at most 3 UTF-8
- * bytes and one UChar.
+ * bytes and one char16_t.
*/
count /= 3;
if(count > srcLength) {
// The convention is that the index must always be on a code point boundary.
// Adjust the index position if it is in the middle of a surrogate pair.
if (ut->chunkOffset<ut->chunkLength) {
- UChar c= ut->chunkContents[ut->chunkOffset];
+ char16_t c= ut->chunkContents[ut->chunkOffset];
if (U16_IS_TRAIL(c)) {
if (ut->chunkOffset==0) {
ut->pFuncs->access(ut, ut->chunkNativeStart, false);
}
if (ut->chunkOffset>0) {
- UChar lead = ut->chunkContents[ut->chunkOffset-1];
+ char16_t lead = ut->chunkContents[ut->chunkOffset-1];
if (U16_IS_LEAD(lead)) {
ut->chunkOffset--;
}
int32_t i = ut->chunkOffset - 1;
int64_t result;
if (i >= 0) {
- UChar c = ut->chunkContents[i];
+ char16_t c = ut->chunkContents[i];
if (U16_IS_TRAIL(c) == false) {
if (i <= ut->nativeIndexingLimit) {
result = ut->chunkNativeStart + i;
U_CAPI int32_t U_EXPORT2
utext_extract(UText *ut,
int64_t start, int64_t limit,
- UChar *dest, int32_t destCapacity,
+ char16_t *dest, int32_t destCapacity,
UErrorCode *status) {
return ut->pFuncs->extract(ut, start, limit, dest, destCapacity, status);
}
U_CAPI int32_t U_EXPORT2
utext_replace(UText *ut,
int64_t nativeStart, int64_t nativeLimit,
- const UChar *replacementText, int32_t replacementLength,
+ const char16_t *replacementText, int32_t replacementLength,
UErrorCode *status)
{
if (U_FAILURE(*status)) {
//------------------------------------------------------------------------------
// Chunk size.
-// Must be less than 85 (256/3), because of byte mapping from UChar indexes to native indexes.
-// Worst case is three native bytes to one UChar. (Supplemenaries are 4 native bytes
+// Must be less than 85 (256/3), because of byte mapping from char16_t indexes to native indexes.
+// Worst case is three native bytes to one char16_t. (Supplemenaries are 4 native bytes
// to two UChars.)
// The longest illegal byte sequence treated as a single error (and converted to U+FFFD)
// is a three-byte sequence (truncated four-byte sequence).
//
// UTF8Buf Two of these structs will be set up in the UText's extra allocated space.
-// Each contains the UChar chunk buffer, the to and from native maps, and
+// Each contains the char16_t chunk buffer, the to and from native maps, and
// header info.
//
// because backwards iteration fills the buffers starting at the end and
//
struct UTF8Buf {
- int32_t bufNativeStart; // Native index of first char in UChar buf
+ int32_t bufNativeStart; // Native index of first char in char16_t buf
int32_t bufNativeLimit; // Native index following last char in buf.
int32_t bufStartIdx; // First filled position in buf.
int32_t bufLimitIdx; // Limit of filled range in buf.
// Set to bufNativeStart when filling forwards.
// Set to computed value when filling backwards.
- UChar buf[UTF8_TEXT_CHUNK_SIZE+4]; // The UChar buffer. Requires one extra position beyond the
+ char16_t buf[UTF8_TEXT_CHUNK_SIZE+4]; // The char16_t buffer. Requires one extra position beyond the
// the chunk size, to allow for surrogate at the end.
// Length must be identical to mapToNative array, below,
// because of the way indexing works when the array is
// filled backwards during a reverse iteration. Thus,
// the additional extra size.
- uint8_t mapToNative[UTF8_TEXT_CHUNK_SIZE+4]; // map UChar index in buf to
+ uint8_t mapToNative[UTF8_TEXT_CHUNK_SIZE+4]; // map char16_t index in buf to
// native offset from bufNativeStart.
// Requires two extra slots,
// one for a supplementary starting in the last normal position,
nulTerminated = true;
}
- UChar *buf = u8b_swap->buf;
+ char16_t *buf = u8b_swap->buf;
uint8_t *mapToNative = u8b_swap->mapToNative;
uint8_t *mapToUChars = u8b_swap->mapToUChars;
int32_t destIx = 0;
if (c>0 && c<0x80) {
// Special case ASCII range for speed.
// zero is excluded to simplify bounds checking.
- buf[destIx] = (UChar)c;
+ buf[destIx] = (char16_t)c;
mapToNative[destIx] = (uint8_t)(srcIx - ix);
mapToUChars[srcIx-ix] = (uint8_t)destIx;
srcIx++;
ut->q = ut->p;
ut->p = u8b_swap;
- UChar *buf = u8b_swap->buf;
+ char16_t *buf = u8b_swap->buf;
uint8_t *mapToNative = u8b_swap->mapToNative;
uint8_t *mapToUChars = u8b_swap->mapToUChars;
int32_t toUCharsMapStart = ix - sizeof(UTF8Buf::mapToUChars) + 1;
c = s8[srcIx];
if (c<0x80) {
// Special case ASCII range for speed.
- buf[destIx] = (UChar)c;
+ buf[destIx] = (char16_t)c;
U_ASSERT(toUCharsMapStart <= srcIx);
mapToUChars[srcIx - toUCharsMapStart] = (uint8_t)destIx;
mapToNative[destIx] = (uint8_t)(srcIx - toUCharsMapStart);
// Store the character in UTF-16 buffer.
if (c<0x10000) {
- buf[destIx] = (UChar)c;
+ buf[destIx] = (char16_t)c;
mapToNative[destIx] = (uint8_t)(srcIx - toUCharsMapStart);
} else {
buf[destIx] = U16_TRAIL(c);
// Inserts a Replacement Char rather than failing on invalid UTF-8
// Removes unnecessary features.
//
-static UChar*
-utext_strFromUTF8(UChar *dest,
+static char16_t*
+utext_strFromUTF8(char16_t *dest,
int32_t destCapacity,
int32_t *pDestLength,
const char* src,
)
{
- UChar *pDest = dest;
- UChar *pDestLimit = (dest!=nullptr)?(dest+destCapacity):nullptr;
+ char16_t *pDest = dest;
+ char16_t *pDestLimit = (dest!=nullptr)?(dest+destCapacity):nullptr;
UChar32 ch=0;
int32_t index = 0;
int32_t reqLength = 0;
while((index < srcLength)&&(pDest<pDestLimit)){
ch = pSrc[index++];
if(ch <=0x7f){
- *pDest++=(UChar)ch;
+ *pDest++=(char16_t)ch;
}else{
ch=utf8_nextCharSafeBody(pSrc, &index, srcLength, ch, -3);
if(U_IS_BMP(ch)){
- *(pDest++)=(UChar)ch;
+ *(pDest++)=(char16_t)ch;
}else{
*(pDest++)=U16_LEAD(ch);
if(pDest<pDestLimit){
static int32_t U_CALLCONV
utf8TextExtract(UText *ut,
int64_t start, int64_t limit,
- UChar *dest, int32_t destCapacity,
+ char16_t *dest, int32_t destCapacity,
UErrorCode *pErrorCode) {
if(U_FAILURE(*pErrorCode)) {
return 0;
* Chunk UChars.
* +1 to simplify filling with surrogate pair at the end.
*/
- UChar s[REP_TEXT_CHUNK_SIZE+1];
+ char16_t s[REP_TEXT_CHUNK_SIZE+1];
};
* Compute start/limit boundaries around index, for a segment of text
* to be extracted.
* To allow for the possibility that our user gave an index to the trailing
- * half of a surrogate pair, we must request one extra preceding UChar when
+ * half of a surrogate pair, we must request one extra preceding char16_t when
* going in the forward direction. This will ensure that the buffer has the
* entire code point at the specified index.
*/
// Figure out the bounds of the chunk to extract for reverse iteration.
// Need to worry about chunk not splitting surrogate pairs, and while still
// containing the data we need.
- // Fix by requesting a chunk that includes an extra UChar at the end.
+ // Fix by requesting a chunk that includes an extra char16_t at the end.
// If this turns out to be a lead surrogate, we can lop it off and still have
// the data we wanted.
ut->chunkNativeStart = index32 + 1 - REP_TEXT_CHUNK_SIZE;
}
}
- // if the first UChar in the chunk could be the trailing half of a surrogate pair,
+ // if the first char16_t in the chunk could be the trailing half of a surrogate pair,
// trim it off.
if(ut->chunkNativeStart>0 && U16_IS_TRAIL(ex->s[0])) {
++(ut->chunkContents);
static int32_t U_CALLCONV
repTextExtract(UText *ut,
int64_t start, int64_t limit,
- UChar *dest, int32_t destCapacity,
+ char16_t *dest, int32_t destCapacity,
UErrorCode *status) {
const Replaceable *rep=(const Replaceable *)ut->context;
int32_t length=rep->length();
static int32_t U_CALLCONV
repTextReplace(UText *ut,
int64_t start, int64_t limit,
- const UChar *src, int32_t length,
+ const char16_t *src, int32_t length,
UErrorCode *status) {
Replaceable *rep=(Replaceable *)ut->context;
int32_t oldLength;
static int32_t U_CALLCONV
unistrTextExtract(UText *t,
int64_t start, int64_t limit,
- UChar *dest, int32_t destCapacity,
+ char16_t *dest, int32_t destCapacity,
UErrorCode *pErrorCode) {
const UnicodeString *us=(const UnicodeString *)t->context;
int32_t length=us->length();
static int32_t U_CALLCONV
unistrTextReplace(UText *ut,
int64_t start, int64_t limit,
- const UChar *src, int32_t length,
+ const char16_t *src, int32_t length,
UErrorCode *pErrorCode) {
UnicodeString *us=(UnicodeString *)ut->context;
int32_t oldLength;
//------------------------------------------------------------------------------
//
-// UText implementation for const UChar * strings
+// UText implementation for const char16_t * strings
//
// Use of UText data members:
// context pointer to UnicodeString
int32_t len = (int32_t)utext_nativeLength(dest);
// The cloned string IS going to be NUL terminated, whether or not the original was.
- const UChar *srcStr = (const UChar *)src->context;
- UChar *copyStr = (UChar *)uprv_malloc((len+1) * sizeof(UChar));
+ const char16_t *srcStr = (const char16_t *)src->context;
+ char16_t *copyStr = (char16_t *)uprv_malloc((len+1) * sizeof(char16_t));
if (copyStr == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
} else {
// All that needs to be done here is delete the string if the UText
// owns it. This occurs if the UText was created by cloning.
if (ut->providerProperties & I32_FLAG(UTEXT_PROVIDER_OWNS_TEXT)) {
- UChar *s = (UChar *)ut->context;
+ char16_t *s = (char16_t *)ut->context;
uprv_free(s);
ut->context = nullptr;
}
// null terminated, we don't yet know the length. Scan for it.
// Access is not convenient for doing this
// because the current iteration position can't be changed.
- const UChar *str = (const UChar *)ut->context;
+ const char16_t *str = (const char16_t *)ut->context;
for (;;) {
if (str[ut->chunkNativeLimit] == 0) {
break;
static UBool U_CALLCONV
ucstrTextAccess(UText *ut, int64_t index, UBool forward) {
- const UChar *str = (const UChar *)ut->context;
+ const char16_t *str = (const char16_t *)ut->context;
// pin the requested index to the bounds of the string,
// and set current iteration position.
static int32_t U_CALLCONV
ucstrTextExtract(UText *ut,
int64_t start, int64_t limit,
- UChar *dest, int32_t destCapacity,
+ char16_t *dest, int32_t destCapacity,
UErrorCode *pErrorCode)
{
if(U_FAILURE(*pErrorCode)) {
return 0;
}
- //const UChar *s=(const UChar *)ut->context;
+ //const char16_t *s=(const char16_t *)ut->context;
int32_t si, di;
int32_t start32;
// Pins 'start' to the length of the string, if it came in out-of-bounds.
// Snaps 'start' to the beginning of a code point.
ucstrTextAccess(ut, start, true);
- const UChar *s=ut->chunkContents;
+ const char16_t *s=ut->chunkContents;
start32 = ut->chunkOffset;
int32_t strLength=(int32_t)ut->a;
U_CDECL_END
-static const UChar gEmptyUString[] = {0};
+static const char16_t gEmptyUString[] = {0};
U_CAPI UText * U_EXPORT2
-utext_openUChars(UText *ut, const UChar *s, int64_t length, UErrorCode *status) {
+utext_openUChars(UText *ut, const char16_t *s, int64_t length, UErrorCode *status) {
if (U_FAILURE(*status)) {
return nullptr;
}
// Find the native index of the start of the buffer containing what we want.
neededIndex -= neededIndex % CIBufSize;
- UChar *buf = nullptr;
+ char16_t *buf = nullptr;
UBool needChunkSetup = true;
int i;
if (ut->chunkNativeStart == neededIndex) {
needChunkSetup = false;
} else if (ut->b == neededIndex) {
// The first buffer (buffer p) has what we need.
- buf = (UChar *)ut->p;
+ buf = (char16_t *)ut->p;
} else if (ut->c == neededIndex) {
// The second buffer (buffer q) has what we need.
- buf = (UChar *)ut->q;
+ buf = (char16_t *)ut->q;
} else {
// Neither buffer already has what we need.
// Load new data from the character iterator.
// Use the buf that is not the current buffer.
- buf = (UChar *)ut->p;
+ buf = (char16_t *)ut->p;
if (ut->p == ut->chunkContents) {
- buf = (UChar *)ut->q;
+ buf = (char16_t *)ut->q;
}
ci->setIndex(neededIndex);
for (i=0; i<CIBufSize; i++) {
static int32_t U_CALLCONV
charIterTextExtract(UText *ut,
int64_t start, int64_t limit,
- UChar *dest, int32_t destCapacity,
+ char16_t *dest, int32_t destCapacity,
UErrorCode *status)
{
if(U_FAILURE(*status)) {
}
// Extra space in UText for 2 buffers of CIBufSize UChars each.
- int32_t extraSpace = 2 * CIBufSize * sizeof(UChar);
+ int32_t extraSpace = 2 * CIBufSize * sizeof(char16_t);
ut = utext_setup(ut, extraSpace, status);
if (U_SUCCESS(*status)) {
ut->pFuncs = &charIterFuncs;
ut->a = ci->endIndex(); // Length of text
ut->p = ut->pExtra; // First buffer
ut->b = -1; // Native index of first buffer contents
- ut->q = (UChar*)ut->pExtra+CIBufSize; // Second buffer
+ ut->q = (char16_t*)ut->pExtra+CIBufSize; // Second buffer
ut->c = -1; // Native index of second buffer contents
// Initialize current chunk contents to be empty.
// so that getNativeIndex() will correctly compute to zero
// if no call to Access() has ever been made. They can't be both
// zero without Access() thinking that the chunk is valid.
- ut->chunkContents = (UChar *)ut->p;
+ ut->chunkContents = (char16_t *)ut->p;
ut->chunkNativeStart = -1;
ut->chunkOffset = 1;
ut->chunkNativeLimit = 0;
#include "patternprops.h"
#include "util.h"
-// Define UChar constants using hex for EBCDIC compatibility
+// Define char16_t constants using hex for EBCDIC compatibility
-static const UChar BACKSLASH = 0x005C; /*\*/
-static const UChar UPPER_U = 0x0055; /*U*/
-static const UChar LOWER_U = 0x0075; /*u*/
-static const UChar APOSTROPHE = 0x0027; // '\''
-static const UChar SPACE = 0x0020; // ' '
+static const char16_t BACKSLASH = 0x005C; /*\*/
+static const char16_t UPPER_U = 0x0055; /*U*/
+static const char16_t LOWER_U = 0x0075; /*u*/
+static const char16_t APOSTROPHE = 0x0027; // '\''
+static const char16_t SPACE = 0x0020; // ' '
// "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-static const UChar DIGITS[] = {
+static const char16_t DIGITS[] = {
48,49,50,51,52,53,54,55,56,57,
65,66,67,68,69,70,71,72,73,74,
75,76,77,78,79,80,81,82,83,84,
int32_t radix, int32_t minDigits) {
if (radix < 2 || radix > 36) {
// Bogus radix
- return result.append((UChar)63/*?*/);
+ return result.append((char16_t)63/*?*/);
}
// Handle negatives
if (n < 0) {
n = -n;
- result.append((UChar)45/*-*/);
+ result.append((char16_t)45/*-*/);
}
// First determine the number of digits
int32_t nn = n;
/*
int32_t ICU_Utility::quotedIndexOf(const UnicodeString& text,
int32_t start, int32_t limit,
- UChar charToFind) {
+ char16_t charToFind) {
for (int32_t i=start; i<limit; ++i) {
- UChar c = text.charAt(i);
+ char16_t c = text.charAt(i);
if (c == BACKSLASH) {
++i;
} else if (c == APOSTROPHE) {
int32_t ICU_Utility::skipWhitespace(const UnicodeString& str, int32_t& pos,
UBool advance) {
int32_t p = pos;
- const UChar* s = str.getBuffer();
+ const char16_t* s = str.getBuffer();
p = (int32_t)(PatternProps::skipWhiteSpace(s + p, str.length() - p) - s);
if (advance) {
pos = p;
* @return true if 'ch' is seen preceded by zero or more
* whitespace characters.
*/
-UBool ICU_Utility::parseChar(const UnicodeString& id, int32_t& pos, UChar ch) {
+UBool ICU_Utility::parseChar(const UnicodeString& id, int32_t& pos, char16_t ch) {
int32_t start = pos;
skipWhitespace(id, pos, true);
if (pos == id.length() ||
int32_t ICU_Utility::parseAsciiInteger(const UnicodeString& str, int32_t& pos) {
int32_t result = 0;
- UChar c;
+ char16_t c;
while (pos < str.length() && (c = str.charAt(pos)) >= u'0' && c <= u'9') {
result = result * 10 + (c - u'0');
pos++;
//?FOR FUTURE USE. DISABLE FOR NOW for coverage reasons.
// static int32_t quotedIndexOf(const UnicodeString& text,
// int32_t start, int32_t limit,
-// UChar c);
+// char16_t c);
/**
* Skip over a sequence of zero or more white space characters at pos.
* @return true if 'ch' is seen preceded by zero or more
* whitespace characters.
*/
- static UBool parseChar(const UnicodeString& id, int32_t& pos, UChar ch);
+ static UBool parseChar(const UnicodeString& id, int32_t& pos, char16_t ch);
/**
* Parse a pattern string starting at offset pos. Keywords are
int32_t p;
int32_t intCount = 0; // number of integers parsed
for (int32_t i=0; i<pattern.length(); ++i) {
- UChar cpat = pattern.charAt(i);
- UChar c;
+ char16_t cpat = pattern.charAt(i);
+ char16_t c;
switch (cpat) {
case 32 /*' '*/:
if (pos >= limit) {
if (pos >= limit) {
return -1;
}
- c = (UChar) u_tolower(rule.charAt(pos++));
+ c = (char16_t) u_tolower(rule.charAt(pos++));
if (c != cpat) {
return -1;
}
-static void outputUString(const UChar *s, int32_t len,
+static void outputUString(const char16_t *s, int32_t len,
char *outBuf, int32_t *outIx, int32_t capacity, int32_t indent) {
int32_t i = 0;
- UChar c;
+ char16_t c;
if (s==nullptr) {
outputString(nullptr, outBuf, outIx, capacity, indent);
return;
break;
case 'S':
- /* UChar * string, with length, len==-1 for NUL terminated. */
+ /* char16_t * string, with length, len==-1 for NUL terminated. */
ptrArg = va_arg(args, char *); /* Ptr */
intArg =(int32_t)va_arg(args, int32_t); /* Length */
- outputUString((const UChar *)ptrArg, intArg, outBuf, &outIx, capacity, indent);
+ outputUString((const char16_t *)ptrArg, intArg, outBuf, &outIx, capacity, indent);
break;
case 'b':
case 'S':
charsToOutput = 0;
- outputUString((const UChar *)*ptrPtr, -1, outBuf, &outIx, capacity, indent);
+ outputUString((const char16_t *)*ptrPtr, -1, outBuf, &outIx, capacity, indent);
outputChar('\n', outBuf, &outIx, capacity, indent);
longArg = *ptrPtr==nullptr? 0: 1; /* for test for nullptr term. array. */
ptrPtr++;
// Use the Forward/Backward subclasses below.
class UTrie2StringIterator : public UMemory {
public:
- UTrie2StringIterator(const UTrie2 *t, const UChar *p) :
+ UTrie2StringIterator(const UTrie2 *t, const char16_t *p) :
trie(t), codePointStart(p), codePointLimit(p), codePoint(U_SENTINEL) {}
const UTrie2 *trie;
- const UChar *codePointStart, *codePointLimit;
+ const char16_t *codePointStart, *codePointLimit;
UChar32 codePoint;
};
class BackwardUTrie2StringIterator : public UTrie2StringIterator {
public:
- BackwardUTrie2StringIterator(const UTrie2 *t, const UChar *s, const UChar *p) :
+ BackwardUTrie2StringIterator(const UTrie2 *t, const char16_t *s, const char16_t *p) :
UTrie2StringIterator(t, p), start(s) {}
uint16_t previous16();
- const UChar *start;
+ const char16_t *start;
};
class ForwardUTrie2StringIterator : public UTrie2StringIterator {
public:
// Iteration limit l can be nullptr.
// In that case, the caller must detect c==0 and stop.
- ForwardUTrie2StringIterator(const UTrie2 *t, const UChar *p, const UChar *l) :
+ ForwardUTrie2StringIterator(const UTrie2 *t, const char16_t *p, const char16_t *l) :
UTrie2StringIterator(t, p), limit(l) {}
uint16_t next16();
- const UChar *limit;
+ const char16_t *limit;
};
U_NAMESPACE_END
U_CAPI UTrie2 * U_EXPORT2
utrie2_cloneAsThawed(const UTrie2 *other, UErrorCode *pErrorCode) {
NewTrieAndStatus context;
- UChar lead;
+ char16_t lead;
if(U_FAILURE(*pErrorCode)) {
return nullptr;
U_CAPI UTrie2 * U_EXPORT2
utrie2_fromUTrie(const UTrie *trie1, uint32_t errorValue, UErrorCode *pErrorCode) {
NewTrieAndStatus context;
- UChar lead;
+ char16_t lead;
if(U_FAILURE(*pErrorCode)) {
return nullptr;
static inline UBool
isASCIIString(const UnicodeString &dest) {
- const UChar *s=dest.getBuffer();
- const UChar *limit=s+dest.length();
+ const char16_t *s=dest.getBuffer();
+ const char16_t *limit=s+dest.length();
while(s<limit) {
if(*s++>0x7f) {
return false;
}
static UBool
-isASCIIOkBiDi(const UChar *s, int32_t length);
+isASCIIOkBiDi(const char16_t *s, int32_t length);
static UBool
isASCIIOkBiDi(const char *s, int32_t length);
UBool toASCII, IDNAInfo &info, UErrorCode &errorCode) const;
void
- checkLabelBiDi(const UChar *label, int32_t labelLength, IDNAInfo &info) const;
+ checkLabelBiDi(const char16_t *label, int32_t labelLength, IDNAInfo &info) const;
UBool
- isLabelOkContextJ(const UChar *label, int32_t labelLength) const;
+ isLabelOkContextJ(const char16_t *label, int32_t labelLength) const;
void
- checkLabelContextO(const UChar *label, int32_t labelLength, IDNAInfo &info) const;
+ checkLabelContextO(const char16_t *label, int32_t labelLength, IDNAInfo &info) const;
const Normalizer2 &uts46Norm2; // uts46.nrm
uint32_t options;
dest.setToBogus();
return dest;
}
- const UChar *srcArray=src.getBuffer();
+ const char16_t *srcArray=src.getBuffer();
if(&dest==&src || srcArray==nullptr) {
errorCode=U_ILLEGAL_ARGUMENT_ERROR;
dest.setToBogus();
info.errors|=UIDNA_ERROR_EMPTY_LABEL;
return dest;
}
- UChar *destArray=dest.getBuffer(srcLength);
+ char16_t *destArray=dest.getBuffer(srcLength);
if(destArray==nullptr) {
errorCode=U_MEMORY_ALLOCATION_ERROR;
return dest;
dest.releaseBuffer(i);
return dest;
}
- UChar c=srcArray[i];
+ char16_t c=srcArray[i];
if(c>0x7f) {
break;
}
UBool doMapDevChars=
toASCII ? (options&UIDNA_NONTRANSITIONAL_TO_ASCII)==0 :
(options&UIDNA_NONTRANSITIONAL_TO_UNICODE)==0;
- const UChar *destArray=dest.getBuffer();
+ const char16_t *destArray=dest.getBuffer();
int32_t destLength=dest.length();
int32_t labelLimit=labelStart;
while(labelLimit<destLength) {
- UChar c=destArray[labelLimit];
+ char16_t c=destArray[labelLimit];
if(c==0x2e && !isLabel) {
int32_t labelLength=labelLimit-labelStart;
int32_t newLength=processLabel(dest, labelStart, labelLength,
return 0;
}
int32_t length=dest.length();
- UChar *s=dest.getBuffer(dest[mappingStart]==0xdf ? length+1 : length);
+ char16_t *s=dest.getBuffer(dest[mappingStart]==0xdf ? length+1 : length);
if(s==nullptr) {
errorCode=U_MEMORY_ALLOCATION_ERROR;
return length;
UBool didMapDevChars=false;
int32_t readIndex=mappingStart, writeIndex=mappingStart;
do {
- UChar c=s[readIndex++];
+ char16_t c=s[readIndex++];
switch(c) {
case 0xdf:
// Map sharp s to ss.
}
UnicodeString fromPunycode;
UnicodeString *labelString;
- const UChar *label=dest.getBuffer()+labelStart;
+ const char16_t *label=dest.getBuffer()+labelStart;
int32_t destLabelStart=labelStart;
int32_t destLabelLength=labelLength;
UBool wasPunycode;
return markBadACELabel(dest, labelStart, labelLength, toASCII, info, errorCode);
}
wasPunycode=true;
- UChar *unicodeBuffer=fromPunycode.getBuffer(-1); // capacity==-1: most labels should fit
+ char16_t *unicodeBuffer=fromPunycode.getBuffer(-1); // capacity==-1: most labels should fit
if(unicodeBuffer==nullptr) {
// Should never occur if we used capacity==-1 which uses the internal buffer.
errorCode=U_MEMORY_ALLOCATION_ERROR;
// in a non-Punycode label or U+FFFD itself in a Punycode label.
// We also check for dots which can come from the input to a single-label function.
// Ok to cast away const because we own the UnicodeString.
- UChar *s=(UChar *)label;
- const UChar *limit=label+labelLength;
- UChar oredChars=0;
+ char16_t *s=(char16_t *)label;
+ const char16_t *limit=label+labelLength;
+ char16_t oredChars=0;
// If we enforce STD3 rules, then ASCII characters other than LDH and dot are disallowed.
UBool disallowNonLDHDot=(options&UIDNA_USE_STD3_RULES)!=0;
do {
- UChar c=*s;
+ char16_t c=*s;
if(c<=0x7f) {
if(c==0x2e) {
info.labelErrors|=UIDNA_ERROR_LABEL_HAS_DOT;
U16_NEXT_UNSAFE(label, cpLength, c);
if((U_GET_GC_MASK(c)&U_GC_M_MASK)!=0) {
info.labelErrors|=UIDNA_ERROR_LEADING_COMBINING_MARK;
- labelString->replace(labelStart, cpLength, (UChar)0xfffd);
+ labelString->replace(labelStart, cpLength, (char16_t)0xfffd);
label=labelString->getBuffer()+labelStart;
labelLength+=1-cpLength;
if(labelString==&dest) {
} else if(oredChars>=0x80) {
// Contains non-ASCII characters.
UnicodeString punycode;
- UChar *buffer=punycode.getBuffer(63); // 63==maximum DNS label length
+ char16_t *buffer=punycode.getBuffer(63); // 63==maximum DNS label length
if(buffer==nullptr) {
errorCode=U_MEMORY_ALLOCATION_ERROR;
return destLabelLength;
UBool disallowNonLDHDot=(options&UIDNA_USE_STD3_RULES)!=0;
UBool isASCII=true;
UBool onlyLDH=true;
- const UChar *label=dest.getBuffer()+labelStart;
- const UChar *limit=label+labelLength;
+ const char16_t *label=dest.getBuffer()+labelStart;
+ const char16_t *limit=label+labelLength;
// Start after the initial "xn--".
// Ok to cast away const because we own the UnicodeString.
- for(UChar *s=const_cast<UChar *>(label+4); s<limit; ++s) {
- UChar c=*s;
+ for(char16_t *s=const_cast<char16_t *>(label+4); s<limit; ++s) {
+ char16_t c=*s;
if(c<=0x7f) {
if(c==0x2e) {
info.labelErrors|=UIDNA_ERROR_LABEL_HAS_DOT;
}
}
if(onlyLDH) {
- dest.insert(labelStart+labelLength, (UChar)0xfffd);
+ dest.insert(labelStart+labelLength, (char16_t)0xfffd);
if(dest.isBogus()) {
errorCode=U_MEMORY_ALLOCATION_ERROR;
return 0;
// that a domain name is a BiDi domain name (has an RTL label) only after
// processing several earlier labels.
void
-UTS46::checkLabelBiDi(const UChar *label, int32_t labelLength, IDNAInfo &info) const {
+UTS46::checkLabelBiDi(const char16_t *label, int32_t labelLength, IDNAInfo &info) const {
// IDNA2008 BiDi rule
// Get the directionality of the first character.
UChar32 c;
// Cannot contain uppercase A-Z.
// s[length-1] must be the trailing dot.
static UBool
-isASCIIOkBiDi(const UChar *s, int32_t length) {
+isASCIIOkBiDi(const char16_t *s, int32_t length) {
int32_t labelStart=0;
for(int32_t i=0; i<length; ++i) {
- UChar c=s[i];
+ char16_t c=s[i];
if(c==0x2e) { // dot
if(i>labelStart) {
c=s[i-1];
}
UBool
-UTS46::isLabelOkContextJ(const UChar *label, int32_t labelLength) const {
+UTS46::isLabelOkContextJ(const char16_t *label, int32_t labelLength) const {
// [IDNA2008-Tables]
// 200C..200D ; CONTEXTJ # ZERO WIDTH NON-JOINER..ZERO WIDTH JOINER
for(int32_t i=0; i<labelLength; ++i) {
}
void
-UTS46::checkLabelContextO(const UChar *label, int32_t labelLength, IDNAInfo &info) const {
+UTS46::checkLabelContextO(const char16_t *label, int32_t labelLength, IDNAInfo &info) const {
int32_t labelEnd=labelLength-1; // inclusive
int32_t arabicDigits=0; // -1 for 066x, +1 for 06Fx
for(int32_t i=0; i<=labelEnd; ++i) {
U_CAPI int32_t U_EXPORT2
uidna_labelToASCII(const UIDNA *idna,
- const UChar *label, int32_t length,
- UChar *dest, int32_t capacity,
+ const char16_t *label, int32_t length,
+ char16_t *dest, int32_t capacity,
UIDNAInfo *pInfo, UErrorCode *pErrorCode) {
if(!checkArgs(label, length, dest, capacity, pInfo, pErrorCode)) {
return 0;
U_CAPI int32_t U_EXPORT2
uidna_labelToUnicode(const UIDNA *idna,
- const UChar *label, int32_t length,
- UChar *dest, int32_t capacity,
+ const char16_t *label, int32_t length,
+ char16_t *dest, int32_t capacity,
UIDNAInfo *pInfo, UErrorCode *pErrorCode) {
if(!checkArgs(label, length, dest, capacity, pInfo, pErrorCode)) {
return 0;
U_CAPI int32_t U_EXPORT2
uidna_nameToASCII(const UIDNA *idna,
- const UChar *name, int32_t length,
- UChar *dest, int32_t capacity,
+ const char16_t *name, int32_t length,
+ char16_t *dest, int32_t capacity,
UIDNAInfo *pInfo, UErrorCode *pErrorCode) {
if(!checkArgs(name, length, dest, capacity, pInfo, pErrorCode)) {
return 0;
U_CAPI int32_t U_EXPORT2
uidna_nameToUnicode(const UIDNA *idna,
- const UChar *name, int32_t length,
- UChar *dest, int32_t capacity,
+ const char16_t *name, int32_t length,
+ char16_t *dest, int32_t capacity,
UIDNAInfo *pInfo, UErrorCode *pErrorCode) {
if(!checkArgs(name, length, dest, capacity, pInfo, pErrorCode)) {
return 0;
int geoId = GetUserGeoID(GEOCLASS_NATION);
int regionCodeLen = GetGeoInfoW(geoId, GEO_ISO2, regionCodeW, UPRV_LENGTHOF(regionCodeW), 0);
- const UChar *icuTZ16 = nullptr;
+ const char16_t *icuTZ16 = nullptr;
int32_t tzListLen = 0;
if (regionCodeLen != 0) {
scriptCode = USCRIPT_COMMON;
for (scriptStart = scriptEnd; scriptEnd < charLimit; scriptEnd += 1) {
- UChar high = charArray[scriptEnd];
+ char16_t high = charArray[scriptEnd];
UChar32 ch = high;
// if the character is a high surrogate and it's not the last one
// in the text, see if it's followed by a low surrogate
if (high >= 0xD800 && high <= 0xDBFF && scriptEnd < charLimit - 1)
{
- UChar low = charArray[scriptEnd + 1];
+ char16_t low = charArray[scriptEnd + 1];
// if it is followed by a low surrogate,
// consume it and form the full character
public:
ScriptRun();
- ScriptRun(const UChar chars[], int32_t length);
+ ScriptRun(const char16_t chars[], int32_t length);
- ScriptRun(const UChar chars[], int32_t start, int32_t length);
+ ScriptRun(const char16_t chars[], int32_t start, int32_t length);
void reset();
void reset(int32_t start, int32_t count);
- void reset(const UChar chars[], int32_t start, int32_t length);
+ void reset(const char16_t chars[], int32_t start, int32_t length);
int32_t getScriptStart();
int32_t charStart;
int32_t charLimit;
- const UChar *charArray;
+ const char16_t *charArray;
int32_t scriptStart;
int32_t scriptEnd;
reset(nullptr, 0, 0);
}
-inline ScriptRun::ScriptRun(const UChar chars[], int32_t length)
+inline ScriptRun::ScriptRun(const char16_t chars[], int32_t length)
{
reset(chars, 0, length);
}
-inline ScriptRun::ScriptRun(const UChar chars[], int32_t start, int32_t length)
+inline ScriptRun::ScriptRun(const char16_t chars[], int32_t start, int32_t length)
{
reset(chars, start, length);
}
reset();
}
-inline void ScriptRun::reset(const UChar chars[], int32_t start, int32_t length)
+inline void ScriptRun::reset(const char16_t chars[], int32_t start, int32_t length)
{
charArray = chars;
#include <stdio.h>
-UChar testChars[] = {
+char16_t testChars[] = {
0x0020, 0x0946, 0x0939, 0x093F, 0x0928, 0x094D, 0x0926, 0x0940, 0x0020,
0x0627, 0x0644, 0x0639, 0x0631, 0x0628, 0x064A, 0x0629, 0x0020,
0x0420, 0x0443, 0x0441, 0x0441, 0x043A, 0x0438, 0x0439, 0x0020,
// all of these characters are on the BMP
// do not include FF or VT in case they are part of a paragraph
// (important for bidi contexts)
- static const UChar paraEnds[] = {
+ static const char16_t paraEnds[] = {
0xd, 0xa, 0x85, 0x2028, 0x2029
};
enum {
}
}
- const UChar *u = s.getBuffer(), *limit = u + s.length();
- UChar c;
+ const char16_t *u = s.getBuffer(), *limit = u + s.length();
+ char16_t c;
while (u < limit) {
c = *u++;
CNV_ADDS_FEFF // automatically adds/detects the U+FEFF signature character
};
-static inline UChar
+static inline char16_t
nibbleToHex(uint8_t n) {
n &= 0xf;
return
n <= 9 ?
- (UChar)(0x30 + n) :
- (UChar)((0x61 - 10) + n);
+ (char16_t)(0x30 + n) :
+ (char16_t)((0x61 - 10) + n);
}
// check the converter's Unicode signature properties;
if (result == CNV_WITH_FEFF) {
// test if the output charset emits a signature anyway
- const UChar a[1] = { 0x61 }; // "a"
- const UChar *in;
+ const char16_t a[1] = { 0x61 }; // "a"
+ const char16_t *in;
char buffer[20];
char *out;
uint32_t infoffset = 0, outfoffset = 0; /* Where we are in the file, for error reporting. */
- const UChar *unibuf, *unibufbp;
- UChar *unibufp;
+ const char16_t *unibuf, *unibufbp;
+ char16_t *unibufp;
size_t rd, wr;
initMsg(pname);
if (parse.line >= 0) {
- UChar linebuf[20], offsetbuf[20];
+ char16_t linebuf[20], offsetbuf[20];
uprv_itou(linebuf, 20, parse.line, 10, 0);
uprv_itou(offsetbuf, 20, parse.offset, 10, 0);
u_wmsg(stderr, "cantCreateTranslitParseErr", str.getTerminatedBuffer(),
UnicodeString str;
for (i = 0; i < errorLength; ++i) {
if (i > 0) {
- str.append((UChar)uSP);
+ str.append((char16_t)uSP);
}
str.append(nibbleToHex((uint8_t)errorBytes[i] >> 4));
str.append(nibbleToHex((uint8_t)errorBytes[i]));
if (u.charAt(0) == uSig) {
u.remove(0, 1);
- // account for the removed UChar and offset
+ // account for the removed char16_t and offset
--ulen;
if (useOffsets) {
// and possible/necessary
if (sig > 0) {
if (u.charAt(0) != uSig && cnvSigType(convto) == CNV_WITH_FEFF) {
- u.insert(0, (UChar)uSig);
+ u.insert(0, (char16_t)uSig);
if (useOffsets) {
// insert a pseudo-offset into fromoffsets[] as well
fromoffsets[0] = -1;
}
- // account for the additional UChar and offset
+ // account for the additional char16_t and offset
++ulen;
}
sig = 0;
if (err == U_BUFFER_OVERFLOW_ERROR) {
err = U_ZERO_ERROR;
} else if (U_FAILURE(err)) {
- UChar errorUChars[4];
+ char16_t errorUChars[4];
const char *errtag;
char pos[32];
UChar32 c;
UnicodeString str;
for (i = 0; i < errorLength;) {
if (i > 0) {
- str.append((UChar)uSP);
+ str.append((char16_t)uSP);
}
U16_NEXT(errorUChars, i, errorLength, c);
if (c >= 0x100000) {
}
static void usage(const char *pname, int ecode) {
- const UChar *msg;
+ const char16_t *msg;
int32_t msgLen;
UErrorCode err = U_ZERO_ERROR;
FILE *fp = ecode ? stderr : stdout;
* Prefix string for Chinese index buckets.
* See http://unicode.org/repos/cldr/trunk/specs/ldml/tr35-collation.html#Collation_Indexes
*/
-const UChar BASE[1] = { 0xFDD0 };
+const char16_t BASE[1] = { 0xFDD0 };
const int32_t BASE_LENGTH = 1;
UBool isOneLabelBetterThanOther(const Normalizer2 &nfkdNormalizer,
if (!current.startsWith(BASE, BASE_LENGTH)) {
return current;
}
- UChar rest = current.charAt(BASE_LENGTH);
+ char16_t rest = current.charAt(BASE_LENGTH);
if (0x2800 < rest && rest <= 0x28FF) { // stroke count
int32_t count = rest-0x2800;
- temp.setTo((UChar)(0x30 + count % 10));
+ temp.setTo((char16_t)(0x30 + count % 10));
if (count >= 10) {
count /= 10;
- temp.insert(0, (UChar)(0x30 + count % 10));
+ temp.insert(0, (char16_t)(0x30 + count % 10));
if (count >= 10) {
count /= 10;
- temp.insert(0, (UChar)(0x30 + count));
+ temp.insert(0, (char16_t)(0x30 + count));
}
}
- return temp.append((UChar)0x5283);
+ return temp.append((char16_t)0x5283);
}
return temp.setTo(current, BASE_LENGTH);
}
bucketList->adoptElement(bucket.orphan(), errorCode);
if (U_FAILURE(errorCode)) { return nullptr; }
// Remember ASCII and Pinyin buckets for Pinyin redirects.
- UChar c;
+ char16_t c;
if (current.length() == 1 && 0x41 <= (c = current.charAt(0)) && c <= 0x5A) { // A-Z
asciiBuckets[c - 0x41] = (Bucket *)bucketList->lastElement();
} else if (current.length() == BASE_LENGTH + 1 && current.startsWith(BASE, BASE_LENGTH) &&
// For example, after ... Q R S Sch we add Sch\uFFFF->S
// and after ... Q R S Sch Sch\uFFFF St we add St\uFFFF->S.
bucket.adoptInsteadAndCheckErrorCode(new Bucket(emptyString_,
- UnicodeString(current).append((UChar)0xFFFF),
+ UnicodeString(current).append((char16_t)0xFFFF),
U_ALPHAINDEX_NORMAL),
errorCode);
if (U_FAILURE(errorCode)) {
while (iter.next()) {
const UnicodeString &s = iter.getString();
U_ASSERT (s.startsWith(BASE, BASE_LENGTH));
- UChar c = s.charAt(s.length() - 1);
+ char16_t c = s.charAt(s.length() - 1);
if (0x41 <= c && c <= 0x5A) { // A-Z
// There are Pinyin labels, add ASCII A-Z labels as well.
initialLabels_->add(0x41, 0x5A); // A-Z
/*
* Return the string with interspersed CGJs. Input must have more than 2 codepoints.
*/
-static const UChar CGJ = 0x034F;
+static const char16_t CGJ = 0x034F;
UnicodeString AlphabeticIndex::separated(const UnicodeString &item) {
UnicodeString result;
if (item.length() == 0) {
return;
}
- inflowLabel_.setTo((UChar)0x2026); // Ellipsis
+ inflowLabel_.setTo((char16_t)0x2026); // Ellipsis
overflowLabel_ = inflowLabel_;
underflowLabel_ = inflowLabel_;
//------------------------------------------------------------
// Constants
-static const UChar TARGET_SEP = 45; // '-'
-static const UChar VARIANT_SEP = 47; // '/'
-static const UChar ANY[] = {0x41,0x6E,0x79,0}; // "Any"
-static const UChar NULL_ID[] = {78,117,108,108,0}; // "Null"
-static const UChar LATIN_PIVOT[] = {0x2D,0x4C,0x61,0x74,0x6E,0x3B,0x4C,0x61,0x74,0x6E,0x2D,0}; // "-Latn;Latn-"
+static const char16_t TARGET_SEP = 45; // '-'
+static const char16_t VARIANT_SEP = 47; // '/'
+static const char16_t ANY[] = {0x41,0x6E,0x79,0}; // "Any"
+static const char16_t NULL_ID[] = {78,117,108,108,0}; // "Null"
+static const char16_t LATIN_PIVOT[] = {0x2D,0x4C,0x61,0x74,0x6E,0x3B,0x4C,0x61,0x74,0x6E,0x2D,0}; // "-Latn;Latn-"
// initial size for an Any-XXXX transform's cache of script-XXXX transforms
// (will grow as necessary, but we don't expect to have source text with more than 7 scripts)
* NFD text - there are never Hangul characters included.
*/
U_CFUNC UChar32
-u_writeIdenticalLevelRun(UChar32 prev, const UChar *s, int32_t length, icu::ByteSink &sink) {
+u_writeIdenticalLevelRun(UChar32 prev, const char16_t *s, int32_t length, icu::ByteSink &sink) {
char scratch[64];
int32_t capacity;
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(BreakTransliterator)
-static const UChar SPACE = 32; // ' '
+static const char16_t SPACE = 32; // ' '
/**
int32_t calKeyLen = calendarKeyword.length();
int32_t keyLen = 0;
- int32_t keywordIdx = id.indexOf((UChar)0x003D); /* '=' */
+ int32_t keywordIdx = id.indexOf((char16_t)0x003D); /* '=' */
if (id[0] == 0x40/*'@'*/
&& id.compareBetween(1, keywordIdx+1, calendarKeyword, 0, calKeyLen) == 0)
{
if (U_SUCCESS(status) && order != nullptr) {
// the first calendar type is the default for the region
int32_t len = 0;
- const UChar *uCalType = ures_getStringByIndex(order, 0, &len, &status);
+ const char16_t *uCalType = ures_getStringByIndex(order, 0, &len, &status);
if (len < (int32_t)sizeof(calTypeBuf)) {
u_UCharsToChars(uCalType, calTypeBuf, len);
*(calTypeBuf + len) = 0; // terminate;
{
if (U_SUCCESS(status)) {
for(int32_t i=0;gCalTypes[i] != nullptr;i++) {
- UnicodeString id((UChar)0x40); /* '@' a variant character */
+ UnicodeString id((char16_t)0x40); /* '@' a variant character */
id.append(UNICODE_STRING_SIMPLE("calendar="));
id.append(UnicodeString(gCalTypes[i], -1, US_INV));
result.put(id, (void*)this, status);
if (ret == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
} else {
- ret->append((UChar)0x40); // '@' is a variant character
+ ret->append((char16_t)0x40); // '@' is a variant character
ret->append(UNICODE_STRING("calendar=", 9));
ret->append(UnicodeString(gCalTypes[getCalendarTypeForLocale(loc.getName())], -1, US_INV));
}
csc.limit = offsets.contextLimit;
UnicodeString tmp;
- const UChar *s;
+ const char16_t *s;
UChar32 c;
int32_t textPos, delta, result;
// Special characters used by ChoiceFormat. There are two characters
// used interchangeably to indicate <=. Either is parsed, but only
// LESS_EQUAL is generated by toPattern().
-#define SINGLE_QUOTE ((UChar)0x0027) /*'*/
-#define LESS_THAN ((UChar)0x003C) /*<*/
-#define LESS_EQUAL ((UChar)0x0023) /*#*/
-#define LESS_EQUAL2 ((UChar)0x2264)
-#define VERTICAL_BAR ((UChar)0x007C) /*|*/
-#define MINUS ((UChar)0x002D) /*-*/
+#define SINGLE_QUOTE ((char16_t)0x0027) /*'*/
+#define LESS_THAN ((char16_t)0x003C) /*<*/
+#define LESS_EQUAL ((char16_t)0x0023) /*#*/
+#define LESS_EQUAL2 ((char16_t)0x2264)
+#define VERTICAL_BAR ((char16_t)0x007C) /*|*/
+#define MINUS ((char16_t)0x002D) /*-*/
-static const UChar LEFT_CURLY_BRACE = 0x7B; /*{*/
-static const UChar RIGHT_CURLY_BRACE = 0x7D; /*}*/
+static const char16_t LEFT_CURLY_BRACE = 0x7B; /*{*/
+static const char16_t RIGHT_CURLY_BRACE = 0x7D; /*}*/
#ifdef INFINITY
#undef INFINITY
#endif
-#define INFINITY ((UChar)0x221E)
+#define INFINITY ((char16_t)0x221E)
-//static const UChar gPositiveInfinity[] = {INFINITY, 0};
-//static const UChar gNegativeInfinity[] = {MINUS, INFINITY, 0};
+//static const char16_t gPositiveInfinity[] = {INFINITY, 0};
+//static const char16_t gNegativeInfinity[] = {MINUS, INFINITY, 0};
#define POSITIVE_INF_STRLEN 1
#define NEGATIVE_INF_STRLEN 2
int32_t textLength = text.length();
int32_t nestingLevel = 0;
for (int32_t j = 0; j < textLength; ++j) {
- UChar c = text[j];
+ char16_t c = text[j];
if (c == SINGLE_QUOTE && nestingLevel == 0) {
// Double each top-level apostrophe.
result.append(c);
double boundary = pattern.getNumericValue(part);
// Fetch the ARG_SELECTOR character.
int32_t selectorIndex = pattern.getPatternIndex(partIndex++);
- UChar boundaryChar = pattern.getPatternString().charAt(selectorIndex);
+ char16_t boundaryChar = pattern.getPatternString().charAt(selectorIndex);
if (boundaryChar == LESS_THAN ? !(number > boundary) : !(number >= boundary)) {
// The number is in the interval between the previous boundary and the current one.
// Return with the sub-message between them.
if (0 < newOffset && newOffset < string_.length()) {
int32_t offset = newOffset;
do {
- UChar c = string_.charAt(offset);
+ char16_t c = string_.charAt(offset);
if (!rbc_->isUnsafe(c) ||
(U16_IS_LEAD(c) && !rbc_->isUnsafe(string_.char32At(offset)))) {
break;
}
string_ = source;
- const UChar *s = string_.getBuffer();
+ const char16_t *s = string_.getBuffer();
CollationIterator *newIter;
UBool numeric = rbc_->settings->isNumeric();
if (rbc_->settings->dontCheckFCD()) {
}
// implement deprecated, previously abstract method
-Collator::EComparisonResult Collator::compare(const UChar* source, int32_t sourceLength,
- const UChar* target, int32_t targetLength)
+Collator::EComparisonResult Collator::compare(const char16_t* source, int32_t sourceLength,
+ const char16_t* target, int32_t targetLength)
const
{
UErrorCode ec = U_ZERO_ERROR;
// It does not work with certain types of contextual mappings.
int32_t nfdLength = nfdString.length();
if(nfdLength >= 2) {
- UChar c = nfdString.charAt(0);
+ char16_t c = nfdString.charAt(0);
if(Hangul::isJamoL(c) || Hangul::isJamoV(c)) {
// While handling a Hangul syllable, contractions starting with Jamo L or V
// would not see the following Jamo of that syllable.
int64_t cases = 0;
if(numTailoredPrimaries > 0) {
- const UChar *s = nfdString.getBuffer();
+ const char16_t *s = nfdString.getBuffer();
UTF16CollationIterator baseCEs(baseData, false, s, s, s + nfdString.length());
int32_t baseCEsLength = baseCEs.fetchCEs(errorCode) - 1;
if(U_FAILURE(errorCode)) {
U_NAMESPACE_USE
U_CAPI UCollator * U_EXPORT2
-ucol_openRules(const UChar *rules, int32_t rulesLength,
+ucol_openRules(const char16_t *rules, int32_t rulesLength,
UColAttributeValue normalizationMode, UCollationStrength strength,
UParseError *parseError, UErrorCode *pErrorCode) {
if(U_FAILURE(*pErrorCode)) { return nullptr; }
USet *unsafe,
UErrorCode *status)
{
- UChar buffer[internalBufferSize];
+ char16_t buffer[internalBufferSize];
int32_t len = 0;
uset_clear(unsafe);
// cccpattern = "[[:^tccc=0:][:^lccc=0:]]", unfortunately variant
- static const UChar cccpattern[25] = { 0x5b, 0x5b, 0x3a, 0x5e, 0x74, 0x63, 0x63, 0x63, 0x3d, 0x30, 0x3a, 0x5d,
+ static const char16_t cccpattern[25] = { 0x5b, 0x5b, 0x3a, 0x5e, 0x74, 0x63, 0x63, 0x63, 0x3d, 0x30, 0x3a, 0x5d,
0x5b, 0x3a, 0x5e, 0x6c, 0x63, 0x63, 0x63, 0x3d, 0x30, 0x3a, 0x5d, 0x5d, 0x00 };
// add chars that fail the fcd check
* Returns the CE32 from two contexts words.
* Access to the defaultCE32 for contraction and prefix matching.
*/
- static uint32_t readCE32(const UChar *p) {
+ static uint32_t readCE32(const char16_t *p) {
return ((uint32_t)p[0] << 16) | p[1];
}
/** Array of CE values for expansions and OFFSET_TAG. */
const int64_t *ces;
/** Array of prefix and contraction-suffix matching data. */
- const UChar *contexts;
+ const char16_t *contexts;
/** Base collation data, or nullptr if this data itself is a base. */
const CollationData *base;
/**
if (s.length() > cLength) {
// Check that there's no modern Hangul in contractions.
for (int32_t i = 0; i < s.length(); ++i) {
- UChar c = s.charAt(i);
+ char16_t c = s.charAt(i);
if ((c >= 0x1100 && c < 0x1100 + 19) || (c >= 0x1161 && c < 0x1161 + 21) || (c >= 0x11A7 && c < 0x11A7 + 28) || (c >= 0xAC00 && c < 0xD7A4)) {
errorCode = U_UNSUPPORTED_ERROR;
return;
if(!isBuilderContextCE32(oldCE32)) {
// Replace the simple oldCE32 with a builder context CE32
// pointing to a new ConditionalCE32 list head.
- int32_t index = addConditionalCE32(UnicodeString((UChar)0), oldCE32, errorCode);
+ int32_t index = addConditionalCE32(UnicodeString((char16_t)0), oldCE32, errorCode);
if(U_FAILURE(errorCode)) { return; }
uint32_t contextCE32 = makeBuilderContextCE32(index);
utrie2_set32(trie, c, contextCE32, &errorCode);
cond->builtCE32 = Collation::NO_CE32;
}
UnicodeString suffix(s, cLength);
- UnicodeString context((UChar)prefix.length());
+ UnicodeString context((char16_t)prefix.length());
context.append(prefix).append(suffix);
unsafeBackwardSet.addAll(suffix);
for(;;) {
case Collation::PREFIX_TAG: {
// Flatten prefixes and nested suffixes (contractions)
// into a linear list of ConditionalCE32.
- const UChar *p = base->contexts + Collation::indexFromCE32(ce32);
+ const char16_t *p = base->contexts + Collation::indexFromCE32(ce32);
ce32 = CollationData::readCE32(p); // Default if no prefix match.
if(!withContext) {
return copyFromBaseCE32(c, ce32, false, errorCode);
}
ConditionalCE32 head;
- UnicodeString context((UChar)0);
+ UnicodeString context((char16_t)0);
int32_t index;
if(Collation::isContractionCE32(ce32)) {
index = copyContractionsFromBaseCE32(context, c, ce32, &head, errorCode);
while(prefixes.next(errorCode)) {
context = prefixes.getString();
context.reverse();
- context.insert(0, (UChar)context.length());
+ context.insert(0, (char16_t)context.length());
ce32 = (uint32_t)prefixes.getValue();
if(Collation::isContractionCE32(ce32)) {
index = copyContractionsFromBaseCE32(context, c, ce32, cond, errorCode);
}
case Collation::CONTRACTION_TAG: {
if(!withContext) {
- const UChar *p = base->contexts + Collation::indexFromCE32(ce32);
+ const char16_t *p = base->contexts + Collation::indexFromCE32(ce32);
ce32 = CollationData::readCE32(p); // Default if no suffix match.
return copyFromBaseCE32(c, ce32, false, errorCode);
}
ConditionalCE32 head;
- UnicodeString context((UChar)0);
+ UnicodeString context((char16_t)0);
copyContractionsFromBaseCE32(context, c, ce32, &head, errorCode);
ce32 = makeBuilderContextCE32(head.next);
contextChars.add(c);
CollationDataBuilder::copyContractionsFromBaseCE32(UnicodeString &context, UChar32 c, uint32_t ce32,
ConditionalCE32 *cond, UErrorCode &errorCode) {
if(U_FAILURE(errorCode)) { return 0; }
- const UChar *p = base->contexts + Collation::indexFromCE32(ce32);
+ const char16_t *p = base->contexts + Collation::indexFromCE32(ce32);
int32_t index;
if((ce32 & Collation::CONTRACT_SINGLE_CP_NO_MATCH) != 0) {
// No match on the single code point.
void
CollationDataBuilder::setLeadSurrogates(UErrorCode &errorCode) {
- for(UChar lead = 0xd800; lead < 0xdc00; ++lead) {
+ for(char16_t lead = 0xd800; lead < 0xdc00; ++lead) {
int32_t value = -1;
utrie2_enumForLeadSurrogate(trie, lead, nullptr, enumRangeLeadValue, &value);
utrie2_set32ForLeadSurrogateCodeUnit(
// Mark each lead surrogate as "unsafe"
// if any of its 1024 associated supplementary code points is "unsafe".
UChar32 c = 0x10000;
- for(UChar lead = 0xd800; lead < 0xdc00; ++lead, c += 0x400) {
+ for(char16_t lead = 0xd800; lead < 0xdc00; ++lead, c += 0x400) {
if(unsafeBackwardSet.containsSome(c, c + 0x3ff)) {
unsafeBackwardSet.add(lead);
}
CollationDataBuilder::addContextTrie(uint32_t defaultCE32, UCharsTrieBuilder &trieBuilder,
UErrorCode &errorCode) {
UnicodeString context;
- context.append((UChar)(defaultCE32 >> 16)).append((UChar)defaultCE32);
+ context.append((char16_t)(defaultCE32 >> 16)).append((char16_t)defaultCE32);
UnicodeString trieString;
context.append(trieBuilder.buildUnicodeString(USTRINGTRIE_BUILD_SMALL, trieString, errorCode));
if(U_FAILURE(errorCode)) { return -1; }
errorCode = U_INVALID_FORMAT_ERROR; // Tailored contexts without tailored trie.
return;
}
- data->contexts = reinterpret_cast<const UChar *>(inBytes + offset);
+ data->contexts = reinterpret_cast<const char16_t *>(inBytes + offset);
data->contextsLength = length / 2;
}
// Mark each lead surrogate as "unsafe"
// if any of its 1024 associated supplementary code points is "unsafe".
UChar32 c = 0x10000;
- for(UChar lead = 0xd800; lead < 0xdc00; ++lead, c += 0x400) {
+ for(char16_t lead = 0xd800; lead < 0xdc00; ++lead, c += 0x400) {
if(!tailoring.unsafeBackwardSet->containsNone(c, c + 0x3ff)) {
tailoring.unsafeBackwardSet->add(lead);
}
/** Byte offset to uint32_t rootElements[]. */
IX_ROOT_ELEMENTS_OFFSET, // 12
- /** Byte offset to UChar *contexts[]. */
+ /** Byte offset to char16_t *contexts[]. */
IX_CONTEXTS_OFFSET,
/** Byte offset to uint16_t [] with serialized unsafeBackwardSet. */
IX_UNSAFE_BWD_OFFSET,
* Compact storage for all of the CEs that occur in the root collation.
* See the CollationRootElements class.
*
- * UChar *contexts[];
+ * char16_t *contexts[];
* Serialized UCharsTrie structures with prefix (pre-context) and contraction mappings.
*
* uint16_t unsafeBackwardSet[]; -- see UnicodeSet::serialize()
UnicodeString scripts;
indexes[CollationDataReader::IX_SCRIPTS_OFFSET] = totalSize;
if(isBase) {
- scripts.append((UChar)data.numScripts);
- scripts.append(reinterpret_cast<const UChar *>(data.scriptsIndex), data.numScripts + 16);
- scripts.append(reinterpret_cast<const UChar *>(data.scriptStarts), data.scriptStartsLength);
+ scripts.append((char16_t)data.numScripts);
+ scripts.append(reinterpret_cast<const char16_t *>(data.scriptsIndex), data.numScripts + 16);
+ scripts.append(reinterpret_cast<const char16_t *>(data.scriptStarts), data.scriptStartsLength);
totalSize += scripts.length() * 2;
}
int32_t
CollationFastLatin::compareUTF16(const uint16_t *table, const uint16_t *primaries, int32_t options,
- const UChar *left, int32_t leftLength,
- const UChar *right, int32_t rightLength) {
+ const char16_t *left, int32_t leftLength,
+ const char16_t *right, int32_t rightLength) {
// This is a modified copy of CollationCompare::compareUpToQuaternary(),
// optimized for common Latin text.
// Keep them in sync!
uint32_t
CollationFastLatin::nextPair(const uint16_t *table, UChar32 c, uint32_t ce,
- const UChar *s16, const uint8_t *s8, int32_t &sIndex, int32_t &sLength) {
+ const char16_t *s16, const uint8_t *s8, int32_t &sIndex, int32_t &sLength) {
if(ce >= MIN_LONG || ce < CONTRACTION) {
return ce; // simple or special mini CE
} else if(ce >= EXPANSION) {
*/
static const int32_t BAIL_OUT_RESULT = -2;
- static inline int32_t getCharIndex(UChar c) {
+ static inline int32_t getCharIndex(char16_t c) {
if(c <= LATIN_MAX) {
return c;
} else if(PUNCT_START <= c && c < PUNCT_LIMIT) {
uint16_t *primaries, int32_t capacity);
static int32_t compareUTF16(const uint16_t *table, const uint16_t *primaries, int32_t options,
- const UChar *left, int32_t leftLength,
- const UChar *right, int32_t rightLength);
+ const char16_t *left, int32_t leftLength,
+ const char16_t *right, int32_t rightLength);
static int32_t compareUTF8(const uint16_t *table, const uint16_t *primaries, int32_t options,
const uint8_t *left, int32_t leftLength,
const uint8_t *s8, int32_t &sIndex);
static uint32_t nextPair(const uint16_t *table, UChar32 c, uint32_t ce,
- const UChar *s16, const uint8_t *s8, int32_t &sIndex, int32_t &sLength);
+ const char16_t *s16, const uint8_t *s8, int32_t &sIndex, int32_t &sLength);
static inline uint32_t getPrimaries(uint32_t variableTop, uint32_t pair) {
uint32_t ce = pair & 0xffff;
if(U_FAILURE(errorCode)) { return false; }
headerLength = 1 + NUM_SPECIAL_GROUPS;
uint32_t r0 = (CollationFastLatin::VERSION << 8) | headerLength;
- result.append((UChar)r0);
+ result.append((char16_t)r0);
// The first few reordering groups should be special groups
// (space, punct, ..., digit) followed by Latn, then Grek and other scripts.
for(int32_t i = 0; i < NUM_SPECIAL_GROUPS; ++i) {
// missing data
return false;
}
- result.append((UChar)0); // reserve a slot for this group
+ result.append((char16_t)0); // reserve a slot for this group
}
firstDigitPrimary = data.getFirstPrimaryForGroup(UCOL_REORDER_CODE_DIGIT);
CollationFastLatinBuilder::getCEs(const CollationData &data, UErrorCode &errorCode) {
if(U_FAILURE(errorCode)) { return; }
int32_t i = 0;
- for(UChar c = 0;; ++i, ++c) {
+ for(char16_t c = 0;; ++i, ++c) {
if(c == CollationFastLatin::LATIN_LIMIT) {
c = CollationFastLatin::PUNCT_START;
} else if(c == CollationFastLatin::PUNCT_LIMIT) {
CollationFastLatinBuilder::getCEsFromContractionCE32(const CollationData &data, uint32_t ce32,
UErrorCode &errorCode) {
if(U_FAILURE(errorCode)) { return false; }
- const UChar *p = data.contexts + Collation::indexFromCE32(ce32);
+ const char16_t *p = data.contexts + Collation::indexFromCE32(ce32);
ce32 = CollationData::readCE32(p); // Default if no suffix match.
// Since the original ce32 is not a prefix mapping,
// the default ce32 must not be another contraction.
U_ASSERT(pri <= CollationFastLatin::MAX_LONG);
// Set the group's header entry to the
// last "long primary" in or before the group.
- result.setCharAt(1 + group, (UChar)pri);
+ result.setCharAt(1 + group, (char16_t)pri);
if(++group < NUM_SPECIAL_GROUPS) {
lastGroupPrimary = lastSpecialPrimaries[group];
} else {
if(U_FAILURE(errorCode)) { return false; }
int32_t miniCEsStart = result.length();
for(int32_t i = 0; i < CollationFastLatin::NUM_FAST_CHARS; ++i) {
- result.append((UChar)0); // initialize to completely ignorable
+ result.append((char16_t)0); // initialize to completely ignorable
}
int32_t indexBase = result.length();
for(int32_t i = 0; i < CollationFastLatin::NUM_FAST_CHARS; ++i) {
if(expansionIndex > (int32_t)CollationFastLatin::INDEX_MASK) {
miniCE = CollationFastLatin::BAIL_OUT;
} else {
- result.append((UChar)(miniCE >> 16)).append((UChar)miniCE);
+ result.append((char16_t)(miniCE >> 16)).append((char16_t)miniCE);
miniCE = CollationFastLatin::EXPANSION | expansionIndex;
}
}
- result.setCharAt(miniCEsStart + i, (UChar)miniCE);
+ result.setCharAt(miniCEsStart + i, (char16_t)miniCE);
}
return U_SUCCESS(errorCode);
}
int64_t cce1 = contractionCEs.elementAti(index + 2);
uint32_t miniCE = encodeTwoCEs(cce0, cce1);
if(miniCE == CollationFastLatin::BAIL_OUT) {
- result.append((UChar)(x | (1 << CollationFastLatin::CONTR_LENGTH_SHIFT)));
+ result.append((char16_t)(x | (1 << CollationFastLatin::CONTR_LENGTH_SHIFT)));
} else if(miniCE <= 0xffff) {
- result.append((UChar)(x | (2 << CollationFastLatin::CONTR_LENGTH_SHIFT)));
- result.append((UChar)miniCE);
+ result.append((char16_t)(x | (2 << CollationFastLatin::CONTR_LENGTH_SHIFT)));
+ result.append((char16_t)miniCE);
} else {
- result.append((UChar)(x | (3 << CollationFastLatin::CONTR_LENGTH_SHIFT)));
- result.append((UChar)(miniCE >> 16)).append((UChar)miniCE);
+ result.append((char16_t)(x | (3 << CollationFastLatin::CONTR_LENGTH_SHIFT)));
+ result.append((char16_t)(miniCE >> 16)).append((char16_t)miniCE);
}
firstTriple = false;
}
// and if so, then we could truncate the result and reuse the other list.
// However, that seems unlikely.
result.setCharAt(headerLength + i,
- (UChar)(CollationFastLatin::CONTRACTION | contractionIndex));
+ (char16_t)(CollationFastLatin::CONTRACTION | contractionIndex));
}
if(result.length() > firstContractionIndex) {
// Terminate the last contraction list.
- result.append((UChar)CollationFastLatin::CONTR_CHAR_MASK);
+ result.append((char16_t)CollationFastLatin::CONTR_CHAR_MASK);
}
if(result.isBogus()) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
return (c < 0) ? Collation::FALLBACK_CE32 : data->getCE32(c);
}
-UChar
+char16_t
CollationIterator::handleGetTrailSurrogate() {
return 0;
}
if(forward) { forwardNumCodePoints(1, errorCode); }
break;
case Collation::CONTRACTION_TAG: {
- const UChar *p = d->contexts + Collation::indexFromCE32(ce32);
+ const char16_t *p = d->contexts + Collation::indexFromCE32(ce32);
uint32_t defaultCE32 = CollationData::readCE32(p); // Default if no suffix match.
if(!forward) {
// Backward contractions are handled by previousCEUnsafe().
case Collation::LEAD_SURROGATE_TAG: {
U_ASSERT(forward); // Backward iteration should never see lead surrogate code _unit_ data.
U_ASSERT(U16_IS_LEAD(c));
- UChar trail;
+ char16_t trail;
if(U16_IS_TRAIL(trail = handleGetTrailSurrogate())) {
c = U16_GET_SUPPLEMENTARY(c, trail);
ce32 &= Collation::LEAD_TYPE_MASK;
uint32_t
CollationIterator::getCE32FromPrefix(const CollationData *d, uint32_t ce32,
UErrorCode &errorCode) {
- const UChar *p = d->contexts + Collation::indexFromCE32(ce32);
+ const char16_t *p = d->contexts + Collation::indexFromCE32(ce32);
ce32 = CollationData::readCE32(p); // Default if no prefix match.
p += 2;
// Number of code points read before the original code point.
uint32_t
CollationIterator::nextCE32FromContraction(const CollationData *d, uint32_t contractionCE32,
- const UChar *p, uint32_t ce32, UChar32 c,
+ const char16_t *p, uint32_t ce32, UChar32 c,
UErrorCode &errorCode) {
// c: next code point after the original one
* if a trail surrogate follows the lead surrogate.
* Otherwise returns any other code unit and does not advance.
*/
- virtual UChar handleGetTrailSurrogate();
+ virtual char16_t handleGetTrailSurrogate();
/**
* Called when handleNextCE32() returns with c==0, to see whether it is a NUL terminator.
uint32_t nextCE32FromContraction(
const CollationData *d, uint32_t contractionCE32,
- const UChar *p, uint32_t ce32, UChar32 c,
+ const char16_t *p, uint32_t ce32, UChar32 c,
UErrorCode &errorCode);
uint32_t nextCE32FromDiscontiguousContraction(
namespace {
-static const UChar BEFORE[] = { 0x5b, 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0 }; // "[before"
+static const char16_t BEFORE[] = { 0x5b, 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0 }; // "[before"
const int32_t BEFORE_LENGTH = 7;
} // namespace
ruleIndex = 0;
while(ruleIndex < rules->length()) {
- UChar c = rules->charAt(ruleIndex);
+ char16_t c = rules->charAt(ruleIndex);
if(PatternProps::isWhiteSpace(c)) {
++ruleIndex;
continue;
if(U_FAILURE(errorCode)) { return UCOL_DEFAULT; }
int32_t i = skipWhiteSpace(ruleIndex + 1);
int32_t j;
- UChar c;
+ char16_t c;
int32_t resetStrength;
if(rules->compare(i, BEFORE_LENGTH, BEFORE, 0, BEFORE_LENGTH) == 0 &&
(j = i + BEFORE_LENGTH) < rules->length() &&
if(ruleIndex >= rules->length()) { return UCOL_DEFAULT; }
int32_t strength;
int32_t i = ruleIndex;
- UChar c = rules->charAt(i++);
+ char16_t c = rules->charAt(i++);
switch(c) {
case 0x3c: // '<'
if(i < rules->length() && rules->charAt(i) == 0x3c) { // <<
UnicodeString prefix, str, extension;
i = parseTailoringString(i, str, errorCode);
if(U_FAILURE(errorCode)) { return; }
- UChar next = (i < rules->length()) ? rules->charAt(i) : 0;
+ char16_t next = (i < rules->length()) ? rules->charAt(i) : 0;
if(next == 0x7c) { // '|' separates the context prefix from the string.
prefix = str;
i = parseTailoringString(i + 1, str, errorCode);
if(c == 0x27) { // apostrophe
if(i < rules->length() && rules->charAt(i) == 0x27) {
// Double apostrophe, encodes a single one.
- raw.append((UChar)0x27);
+ raw.append((char16_t)0x27);
++i;
continue;
}
break;
}
}
- raw.append((UChar)c);
+ raw.append((char16_t)c);
}
} else if(c == 0x5c) { // backslash
if(i == rules->length()) {
--i;
break;
} else {
- raw.append((UChar)c);
+ raw.append((char16_t)c);
}
}
for(int32_t j = 0; j < raw.length();) {
++j;
for(int32_t pos = 0; pos < UPRV_LENGTHOF(positions); ++pos) {
if(raw == UnicodeString(positions[pos], -1, US_INV)) {
- str.setTo((UChar)POS_LEAD).append((UChar)(POS_BASE + pos));
+ str.setTo((char16_t)POS_LEAD).append((char16_t)(POS_BASE + pos));
return j;
}
}
if(raw == UNICODE_STRING_SIMPLE("top")) {
- str.setTo((UChar)POS_LEAD).append((UChar)(POS_BASE + LAST_REGULAR));
+ str.setTo((char16_t)POS_LEAD).append((char16_t)(POS_BASE + LAST_REGULAR));
return j;
}
if(raw == UNICODE_STRING_SIMPLE("variable top")) {
- str.setTo((UChar)POS_LEAD).append((UChar)(POS_BASE + LAST_VARIABLE));
+ str.setTo((char16_t)POS_LEAD).append((char16_t)(POS_BASE + LAST_VARIABLE));
return j;
}
}
return;
}
UnicodeString v;
- int32_t valueIndex = raw.lastIndexOf((UChar)0x20);
+ int32_t valueIndex = raw.lastIndexOf((char16_t)0x20);
if(valueIndex >= 0) {
v.setTo(raw, valueIndex + 1);
raw.truncate(valueIndex);
}
if(raw == UNICODE_STRING_SIMPLE("strength") && v.length() == 1) {
int32_t value = UCOL_DEFAULT;
- UChar c = v.charAt(0);
+ char16_t c = v.charAt(0);
if(0x31 <= c && c <= 0x34) { // 1..4
value = UCOL_PRIMARY + (c - 0x31);
} else if(c == 0x49) { // 'I'
CharString word;
while(i < raw.length()) {
++i; // skip the word-separating space
- int32_t limit = raw.indexOf((UChar)0x20, i);
+ int32_t limit = raw.indexOf((char16_t)0x20, i);
if(limit < 0) { limit = raw.length(); }
word.clear().appendInvariantChars(raw.tempSubStringBetween(i, limit), errorCode);
if(U_FAILURE(errorCode)) { return; }
setParseError("unbalanced UnicodeSet pattern brackets", errorCode);
return j;
}
- UChar c = rules->charAt(j++);
+ char16_t c = rules->charAt(j++);
if(c == 0x5b) { // '['
++level;
} else if(c == 0x5d) { // ']'
int32_t
CollationRuleParser::readWords(int32_t i, UnicodeString &raw) const {
- static const UChar sp = 0x20;
+ static const char16_t sp = 0x20;
raw.remove();
i = skipWhiteSpace(i);
for(;;) {
if(i >= rules->length()) { return 0; }
- UChar c = rules->charAt(i);
+ char16_t c = rules->charAt(i);
if(isSyntaxChar(c) && c != 0x2d && c != 0x5f) { // syntax except -_
if(raw.isEmpty()) { return i; }
if(raw.endsWith(&sp, 1)) { // remove trailing space
CollationRuleParser::skipComment(int32_t i) const {
// skip to past the newline
while(i < rules->length()) {
- UChar c = rules->charAt(i++);
+ char16_t c = rules->charAt(i++);
// LF or FF or CR or NEL or LS or PS
if(c == 0xa || c == 0xc || c == 0xd || c == 0x85 || c == 0x2028 || c == 0x2029) {
// Unicode Newline Guidelines: "A readline function should stop at NLF, LS, FF, or PS."
*
* The second contraction character is POS_BASE + Position.
*/
- static const UChar POS_LEAD = 0xfffe;
+ static const char16_t POS_LEAD = 0xfffe;
/**
* Base for the second character of contractions that encode special reset positions.
* Braille characters U+28xx are printable and normalization-inert.
* @see POS_LEAD
*/
- static const UChar POS_BASE = 0x2800;
+ static const char16_t POS_BASE = 0x2800;
class U_I18N_API Sink : public UObject {
public:
void
TailoredSet::compare(UChar32 c, uint32_t ce32, uint32_t baseCE32) {
if(Collation::isPrefixCE32(ce32)) {
- const UChar *p = data->contexts + Collation::indexFromCE32(ce32);
+ const char16_t *p = data->contexts + Collation::indexFromCE32(ce32);
ce32 = data->getFinalCE32(CollationData::readCE32(p));
if(Collation::isPrefixCE32(baseCE32)) {
- const UChar *q = baseData->contexts + Collation::indexFromCE32(baseCE32);
+ const char16_t *q = baseData->contexts + Collation::indexFromCE32(baseCE32);
baseCE32 = baseData->getFinalCE32(CollationData::readCE32(q));
comparePrefixes(c, p + 2, q + 2);
} else {
addPrefixes(data, c, p + 2);
}
} else if(Collation::isPrefixCE32(baseCE32)) {
- const UChar *q = baseData->contexts + Collation::indexFromCE32(baseCE32);
+ const char16_t *q = baseData->contexts + Collation::indexFromCE32(baseCE32);
baseCE32 = baseData->getFinalCE32(CollationData::readCE32(q));
addPrefixes(baseData, c, q + 2);
}
if(Collation::isContractionCE32(ce32)) {
- const UChar *p = data->contexts + Collation::indexFromCE32(ce32);
+ const char16_t *p = data->contexts + Collation::indexFromCE32(ce32);
if((ce32 & Collation::CONTRACT_SINGLE_CP_NO_MATCH) != 0) {
ce32 = Collation::NO_CE32;
} else {
ce32 = data->getFinalCE32(CollationData::readCE32(p));
}
if(Collation::isContractionCE32(baseCE32)) {
- const UChar *q = baseData->contexts + Collation::indexFromCE32(baseCE32);
+ const char16_t *q = baseData->contexts + Collation::indexFromCE32(baseCE32);
if((baseCE32 & Collation::CONTRACT_SINGLE_CP_NO_MATCH) != 0) {
baseCE32 = Collation::NO_CE32;
} else {
addContractions(c, p + 2);
}
} else if(Collation::isContractionCE32(baseCE32)) {
- const UChar *q = baseData->contexts + Collation::indexFromCE32(baseCE32);
+ const char16_t *q = baseData->contexts + Collation::indexFromCE32(baseCE32);
baseCE32 = baseData->getFinalCE32(CollationData::readCE32(q));
addContractions(c, q + 2);
}
}
}
} else if(tag == Collation::HANGUL_TAG) {
- UChar jamos[3];
+ char16_t jamos[3];
int32_t length = Hangul::decompose(c, jamos);
if(tailored->contains(jamos[0]) || tailored->contains(jamos[1]) ||
(length == 3 && tailored->contains(jamos[2]))) {
}
void
-TailoredSet::comparePrefixes(UChar32 c, const UChar *p, const UChar *q) {
+TailoredSet::comparePrefixes(UChar32 c, const char16_t *p, const char16_t *q) {
// Parallel iteration over prefixes of both tables.
UCharsTrie::Iterator prefixes(p, 0, errorCode);
UCharsTrie::Iterator basePrefixes(q, 0, errorCode);
const UnicodeString *bp = nullptr; // Base prefix.
// Use a string with a U+FFFF as the limit sentinel.
// U+FFFF is untailorable and will not occur in prefixes.
- UnicodeString none((UChar)0xffff);
+ UnicodeString none((char16_t)0xffff);
for(;;) {
if(tp == nullptr) {
if(prefixes.next(errorCode)) {
}
void
-TailoredSet::compareContractions(UChar32 c, const UChar *p, const UChar *q) {
+TailoredSet::compareContractions(UChar32 c, const char16_t *p, const char16_t *q) {
// Parallel iteration over suffixes of both tables.
UCharsTrie::Iterator suffixes(p, 0, errorCode);
UCharsTrie::Iterator baseSuffixes(q, 0, errorCode);
// Use a string with two U+FFFF as the limit sentinel.
// U+FFFF is untailorable and will not occur in contractions except maybe
// as a single suffix character for a root-collator boundary contraction.
- UnicodeString none((UChar)0xffff);
- none.append((UChar)0xffff);
+ UnicodeString none((char16_t)0xffff);
+ none.append((char16_t)0xffff);
for(;;) {
if(ts == nullptr) {
if(suffixes.next(errorCode)) {
}
void
-TailoredSet::addPrefixes(const CollationData *d, UChar32 c, const UChar *p) {
+TailoredSet::addPrefixes(const CollationData *d, UChar32 c, const char16_t *p) {
UCharsTrie::Iterator prefixes(p, 0, errorCode);
while(prefixes.next(errorCode)) {
addPrefix(d, prefixes.getString(), c, (uint32_t)prefixes.getValue());
setPrefix(pfx);
ce32 = d->getFinalCE32(ce32);
if(Collation::isContractionCE32(ce32)) {
- const UChar *p = d->contexts + Collation::indexFromCE32(ce32);
+ const char16_t *p = d->contexts + Collation::indexFromCE32(ce32);
addContractions(c, p + 2);
}
tailored->add(UnicodeString(unreversedPrefix).append(c));
}
void
-TailoredSet::addContractions(UChar32 c, const UChar *p) {
+TailoredSet::addContractions(UChar32 c, const char16_t *p) {
UCharsTrie::Iterator suffixes(p, 0, errorCode);
while(suffixes.next(errorCode)) {
addSuffix(c, suffixes.getString());
// TODO: This should be optimized,
// especially if [start..end] is the complete Hangul range. (assert that)
UTF16CollationIterator iter(data, false, nullptr, nullptr, nullptr);
- UChar hangul[1] = { 0 };
+ char16_t hangul[1] = { 0 };
for(UChar32 c = start; c <= end; ++c) {
- hangul[0] = (UChar)c;
+ hangul[0] = (char16_t)c;
iter.setText(hangul, hangul + 1);
int32_t length = iter.fetchCEs(errorCode);
if(U_FAILURE(errorCode)) { return; }
void
ContractionsAndExpansions::handlePrefixes(
UChar32 start, UChar32 end, uint32_t ce32) {
- const UChar *p = data->contexts + Collation::indexFromCE32(ce32);
+ const char16_t *p = data->contexts + Collation::indexFromCE32(ce32);
ce32 = CollationData::readCE32(p); // Default if no prefix match.
handleCE32(start, end, ce32);
if(!addPrefixes) { return; }
void
ContractionsAndExpansions::handleContractions(
UChar32 start, UChar32 end, uint32_t ce32) {
- const UChar *p = data->contexts + Collation::indexFromCE32(ce32);
+ const char16_t *p = data->contexts + Collation::indexFromCE32(ce32);
if((ce32 & Collation::CONTRACT_SINGLE_CP_NO_MATCH) != 0) {
// No match on the single code point.
// We are underneath a prefix, and the default mapping is just
private:
void compare(UChar32 c, uint32_t ce32, uint32_t baseCE32);
- void comparePrefixes(UChar32 c, const UChar *p, const UChar *q);
- void compareContractions(UChar32 c, const UChar *p, const UChar *q);
+ void comparePrefixes(UChar32 c, const char16_t *p, const char16_t *q);
+ void compareContractions(UChar32 c, const char16_t *p, const char16_t *q);
- void addPrefixes(const CollationData *d, UChar32 c, const UChar *p);
+ void addPrefixes(const CollationData *d, UChar32 c, const char16_t *p);
void addPrefix(const CollationData *d, const UnicodeString &pfx, UChar32 c, uint32_t ce32);
- void addContractions(UChar32 c, const UChar *p);
+ void addContractions(UChar32 c, const char16_t *p);
void addSuffix(UChar32 c, const UnicodeString &sfx);
void add(UChar32 c);
#include "cmemory.h"
// keep in sync with Transliterator
-//static const UChar ID_SEP = 0x002D; /*-*/
-static const UChar ID_DELIM = 0x003B; /*;*/
-static const UChar NEWLINE = 10;
+//static const char16_t ID_SEP = 0x002D; /*-*/
+static const char16_t ID_DELIM = 0x003B; /*;*/
+static const char16_t NEWLINE = 10;
-static const UChar COLON_COLON[] = {0x3A, 0x3A, 0}; //"::"
+static const char16_t COLON_COLON[] = {0x3A, 0x3A, 0}; //"::"
U_NAMESPACE_BEGIN
-const UChar CompoundTransliterator::PASS_STRING[] = { 0x0025, 0x0050, 0x0061, 0x0073, 0x0073, 0 }; // "%Pass"
+const char16_t CompoundTransliterator::PASS_STRING[] = { 0x0025, 0x0050, 0x0061, 0x0073, 0x0073, 0 }; // "%Pass"
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(CompoundTransliterator)
/**
* Append c to buf, unless buf is empty or buf already ends in c.
*/
-static void _smartAppend(UnicodeString& buf, UChar c) {
+static void _smartAppend(UnicodeString& buf, char16_t c) {
if (buf.length() != 0 &&
buf.charAt(buf.length() - 1) != c) {
buf.append(c);
static UClassID U_EXPORT2 getStaticClassID();
/* @internal */
- static const UChar PASS_STRING[];
+ static const char16_t PASS_STRING[];
private:
return confidence;
}
-int32_t CharsetMatch::getUChars(UChar *buf, int32_t cap, UErrorCode *status) const
+int32_t CharsetMatch::getUChars(char16_t *buf, int32_t cap, UErrorCode *status) const
{
UConverter *conv = ucnv_open(getName(), status);
int32_t result = ucnv_toUChars(conv, buf, cap, (const char *) textIn->fRawInput, textIn->fRawLength, status);
int32_t getConfidence()const;
- int32_t getUChars(UChar *buf, int32_t cap, UErrorCode *status) const;
+ int32_t getUChars(char16_t *buf, int32_t cap, UErrorCode *status) const;
};
U_NAMESPACE_END
// NULs are a contra-indication, they will appear commonly if the actual encoding is UTF-32.
// NULs should be rare in actual text.
-static int32_t adjustConfidence(UChar codeUnit, int32_t confidence) {
+static int32_t adjustConfidence(char16_t codeUnit, int32_t confidence) {
if (codeUnit == 0) {
confidence -= 10;
} else if ((codeUnit >= 0x20 && codeUnit <= 0xff) || codeUnit == 0x0a) {
int32_t bytesToCheck = (length > 30) ? 30 : length;
for (int32_t charIndex=0; charIndex<bytesToCheck-1; charIndex+=2) {
- UChar codeUnit = (input[charIndex] << 8) | input[charIndex + 1];
+ char16_t codeUnit = (input[charIndex] << 8) | input[charIndex + 1];
if (charIndex == 0 && codeUnit == 0xFEFF) {
confidence = 100;
break;
int32_t bytesToCheck = (length > 30) ? 30 : length;
for (int32_t charIndex=0; charIndex<bytesToCheck-1; charIndex+=2) {
- UChar codeUnit = input[charIndex] | (input[charIndex + 1] << 8);
+ char16_t codeUnit = input[charIndex] | (input[charIndex + 1] << 8);
if (charIndex == 0 && codeUnit == 0xFEFF) {
confidence = 100; // UTF-16 BOM
if (length >= 4 && input[2] == 0 && input[3] == 0) {
U_NAMESPACE_BEGIN
-static const UChar gNumberPatternSeparator = 0x3B; // ;
+static const char16_t gNumberPatternSeparator = 0x3B; // ;
U_CDECL_BEGIN
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(CurrencyPluralInfo)
-static const UChar gDefaultCurrencyPluralPattern[] = {'0', '.', '#', '#', ' ', 0xA4, 0xA4, 0xA4, 0};
-static const UChar gTripleCurrencySign[] = {0xA4, 0xA4, 0xA4, 0};
-static const UChar gPluralCountOther[] = {0x6F, 0x74, 0x68, 0x65, 0x72, 0};
-static const UChar gPart0[] = {0x7B, 0x30, 0x7D, 0};
-static const UChar gPart1[] = {0x7B, 0x31, 0x7D, 0};
+static const char16_t gDefaultCurrencyPluralPattern[] = {'0', '.', '#', '#', ' ', 0xA4, 0xA4, 0xA4, 0};
+static const char16_t gTripleCurrencySign[] = {0xA4, 0xA4, 0xA4, 0};
+static const char16_t gPluralCountOther[] = {0x6F, 0x74, 0x68, 0x65, 0x72, 0};
+static const char16_t gPart0[] = {0x7B, 0x30, 0x7D, 0};
+static const char16_t gPart1[] = {0x7B, 0x31, 0x7D, 0};
static const char gNumberElementsTag[]="NumberElements";
static const char gLatnTag[]="latn";
ures_getByKeyWithFallback(numElements.getAlias(), ns->getName(), rb.getAlias(), &ec);
ures_getByKeyWithFallback(rb.getAlias(), gPatternsTag, rb.getAlias(), &ec);
int32_t ptnLen;
- const UChar* numberStylePattern = ures_getStringByKeyWithFallback(rb.getAlias(), gDecimalFormatTag, &ptnLen, &ec);
+ const char16_t* numberStylePattern = ures_getStringByKeyWithFallback(rb.getAlias(), gDecimalFormatTag, &ptnLen, &ec);
// Fall back to "latn" if num sys specific pattern isn't there.
if ( ec == U_MISSING_RESOURCE_ERROR && (uprv_strcmp(ns->getName(), gLatnTag) != 0)) {
ec = U_ZERO_ERROR;
numberStylePattern = ures_getStringByKeyWithFallback(rb.getAlias(), gDecimalFormatTag, &ptnLen, &ec);
}
int32_t numberStylePatternLen = ptnLen;
- const UChar* negNumberStylePattern = nullptr;
+ const char16_t* negNumberStylePattern = nullptr;
int32_t negNumberStylePatternLen = 0;
// TODO: Java
// parse to check whether there is ";" separator in the numberStylePattern
while (((pluralCount = keywords->next(nullptr, ec)) != nullptr) && U_SUCCESS(ec)) {
int32_t ptnLength;
UErrorCode err = U_ZERO_ERROR;
- const UChar* patternChars = ures_getStringByKeyWithFallback(currencyRes.getAlias(), pluralCount, &ptnLength, &err);
+ const char16_t* patternChars = ures_getStringByKeyWithFallback(currencyRes.getAlias(), pluralCount, &ptnLength, &err);
if (err == U_MEMORY_ALLOCATION_ERROR || patternChars == nullptr) {
ec = err;
break;
isoCode[3] = 0;
}
if (useDefault) {
- uprv_memcpy(isoCode, kDefaultCurrency, sizeof(UChar) * 4);
+ uprv_memcpy(isoCode, kDefaultCurrency, sizeof(char16_t) * 4);
}
char simpleIsoCode[4];
u_UCharsToChars(isoCode, simpleIsoCode, 4);
static const char gSymbols[] = "symbols";
static const char gNumberElementsLatnSymbols[] = "NumberElements/latn/symbols";
-static const UChar INTL_CURRENCY_SYMBOL_STR[] = {0xa4, 0xa4, 0};
+static const char16_t INTL_CURRENCY_SYMBOL_STR[] = {0xa4, 0xa4, 0};
// List of field names to be loaded from the data files.
// These are parallel with the enum ENumberFormatSymbol in unicode/dcfmtsym.h.
// Get the default currency from the currency API.
UErrorCode internalStatus = U_ZERO_ERROR; // don't propagate failures out
- UChar curriso[4];
+ char16_t curriso[4];
UnicodeString tempStr;
int32_t currisoLength = ucurr_forLocale(locStr, curriso, UPRV_LENGTHOF(curriso), &internalStatus);
if (U_SUCCESS(internalStatus) && currisoLength == 3) {
* cannot initialize a static array with class constructors.
* markus 2000may25
*/
- fSymbols[kDecimalSeparatorSymbol] = (UChar)0x2e; // '.' decimal separator
+ fSymbols[kDecimalSeparatorSymbol] = (char16_t)0x2e; // '.' decimal separator
fSymbols[kGroupingSeparatorSymbol].remove(); // group (thousands) separator
- fSymbols[kPatternSeparatorSymbol] = (UChar)0x3b; // ';' pattern separator
- fSymbols[kPercentSymbol] = (UChar)0x25; // '%' percent sign
- fSymbols[kZeroDigitSymbol] = (UChar)0x30; // '0' native 0 digit
- fSymbols[kOneDigitSymbol] = (UChar)0x31; // '1' native 1 digit
- fSymbols[kTwoDigitSymbol] = (UChar)0x32; // '2' native 2 digit
- fSymbols[kThreeDigitSymbol] = (UChar)0x33; // '3' native 3 digit
- fSymbols[kFourDigitSymbol] = (UChar)0x34; // '4' native 4 digit
- fSymbols[kFiveDigitSymbol] = (UChar)0x35; // '5' native 5 digit
- fSymbols[kSixDigitSymbol] = (UChar)0x36; // '6' native 6 digit
- fSymbols[kSevenDigitSymbol] = (UChar)0x37; // '7' native 7 digit
- fSymbols[kEightDigitSymbol] = (UChar)0x38; // '8' native 8 digit
- fSymbols[kNineDigitSymbol] = (UChar)0x39; // '9' native 9 digit
- fSymbols[kDigitSymbol] = (UChar)0x23; // '#' pattern digit
- fSymbols[kPlusSignSymbol] = (UChar)0x002b; // '+' plus sign
- fSymbols[kMinusSignSymbol] = (UChar)0x2d; // '-' minus sign
- fSymbols[kCurrencySymbol] = (UChar)0xa4; // 'OX' currency symbol
+ fSymbols[kPatternSeparatorSymbol] = (char16_t)0x3b; // ';' pattern separator
+ fSymbols[kPercentSymbol] = (char16_t)0x25; // '%' percent sign
+ fSymbols[kZeroDigitSymbol] = (char16_t)0x30; // '0' native 0 digit
+ fSymbols[kOneDigitSymbol] = (char16_t)0x31; // '1' native 1 digit
+ fSymbols[kTwoDigitSymbol] = (char16_t)0x32; // '2' native 2 digit
+ fSymbols[kThreeDigitSymbol] = (char16_t)0x33; // '3' native 3 digit
+ fSymbols[kFourDigitSymbol] = (char16_t)0x34; // '4' native 4 digit
+ fSymbols[kFiveDigitSymbol] = (char16_t)0x35; // '5' native 5 digit
+ fSymbols[kSixDigitSymbol] = (char16_t)0x36; // '6' native 6 digit
+ fSymbols[kSevenDigitSymbol] = (char16_t)0x37; // '7' native 7 digit
+ fSymbols[kEightDigitSymbol] = (char16_t)0x38; // '8' native 8 digit
+ fSymbols[kNineDigitSymbol] = (char16_t)0x39; // '9' native 9 digit
+ fSymbols[kDigitSymbol] = (char16_t)0x23; // '#' pattern digit
+ fSymbols[kPlusSignSymbol] = (char16_t)0x002b; // '+' plus sign
+ fSymbols[kMinusSignSymbol] = (char16_t)0x2d; // '-' minus sign
+ fSymbols[kCurrencySymbol] = (char16_t)0xa4; // 'OX' currency symbol
fSymbols[kIntlCurrencySymbol].setTo(true, INTL_CURRENCY_SYMBOL_STR, 2);
- fSymbols[kMonetarySeparatorSymbol] = (UChar)0x2e; // '.' monetary decimal separator
- fSymbols[kExponentialSymbol] = (UChar)0x45; // 'E' exponential
- fSymbols[kPerMillSymbol] = (UChar)0x2030; // '%o' per mill
- fSymbols[kPadEscapeSymbol] = (UChar)0x2a; // '*' pad escape symbol
- fSymbols[kInfinitySymbol] = (UChar)0x221e; // 'oo' infinite
- fSymbols[kNaNSymbol] = (UChar)0xfffd; // SUB NaN
- fSymbols[kSignificantDigitSymbol] = (UChar)0x0040; // '@' significant digit
+ fSymbols[kMonetarySeparatorSymbol] = (char16_t)0x2e; // '.' monetary decimal separator
+ fSymbols[kExponentialSymbol] = (char16_t)0x45; // 'E' exponential
+ fSymbols[kPerMillSymbol] = (char16_t)0x2030; // '%o' per mill
+ fSymbols[kPadEscapeSymbol] = (char16_t)0x2a; // '*' pad escape symbol
+ fSymbols[kInfinitySymbol] = (char16_t)0x221e; // 'oo' infinite
+ fSymbols[kNaNSymbol] = (char16_t)0xfffd; // SUB NaN
+ fSymbols[kSignificantDigitSymbol] = (char16_t)0x0040; // '@' significant digit
fSymbols[kMonetaryGroupingSeparatorSymbol].remove(); //
- fSymbols[kExponentMultiplicationSymbol] = (UChar)0xd7; // 'x' multiplication symbol for exponents
+ fSymbols[kExponentMultiplicationSymbol] = (char16_t)0xd7; // 'x' multiplication symbol for exponents
fSymbols[kApproximatelySignSymbol] = u'~'; // '~' approximately sign
fIsCustomCurrencySymbol = false;
fIsCustomIntlCurrencySymbol = false;
nsName[0] = 0;
}
-void DecimalFormatSymbols::setCurrency(const UChar* currency, UErrorCode& status) {
+void DecimalFormatSymbols::setCurrency(const char16_t* currency, UErrorCode& status) {
// TODO: If this method is made public:
// - Adopt ICU4J behavior of not allowing currency to be null.
// - Also verify that the length of currency is 3.
#include "unicode/unistr.h"
-#define QUOTE ((UChar)0x0027)
-#define LOW_LINE ((UChar)0x005F)
-#define COLON ((UChar)0x003A)
-#define LEFT_CURLY_BRACKET ((UChar)0x007B)
-#define RIGHT_CURLY_BRACKET ((UChar)0x007D)
-#define SPACE ((UChar)0x0020)
-#define EN_DASH ((UChar)0x2013)
-#define SOLIDUS ((UChar)0x002F)
-#define PERCENT ((UChar)0x0025)
+#define QUOTE ((char16_t)0x0027)
+#define LOW_LINE ((char16_t)0x005F)
+#define COLON ((char16_t)0x003A)
+#define LEFT_CURLY_BRACKET ((char16_t)0x007B)
+#define RIGHT_CURLY_BRACKET ((char16_t)0x007D)
+#define SPACE ((char16_t)0x0020)
+#define EN_DASH ((char16_t)0x2013)
+#define SOLIDUS ((char16_t)0x002F)
+#define PERCENT ((char16_t)0x0025)
-#define DIGIT_ZERO ((UChar)0x0030)
-#define DIGIT_ONE ((UChar)0x0031)
+#define DIGIT_ZERO ((char16_t)0x0030)
+#define DIGIT_ONE ((char16_t)0x0031)
-#define LOW_A ((UChar)0x0061)
-#define LOW_B ((UChar)0x0062)
-#define LOW_C ((UChar)0x0063)
-#define LOW_D ((UChar)0x0064)
-#define LOW_E ((UChar)0x0065)
-#define LOW_F ((UChar)0x0066)
-#define LOW_G ((UChar)0x0067)
-#define LOW_H ((UChar)0x0068)
-#define LOW_I ((UChar)0x0069)
-#define LOW_J ((UChar)0x006a)
-#define LOW_K ((UChar)0x006B)
-#define LOW_L ((UChar)0x006C)
-#define LOW_M ((UChar)0x006D)
-#define LOW_N ((UChar)0x006E)
-#define LOW_O ((UChar)0x006F)
-#define LOW_P ((UChar)0x0070)
-#define LOW_Q ((UChar)0x0071)
-#define LOW_R ((UChar)0x0072)
-#define LOW_S ((UChar)0x0073)
-#define LOW_T ((UChar)0x0074)
-#define LOW_U ((UChar)0x0075)
-#define LOW_V ((UChar)0x0076)
-#define LOW_W ((UChar)0x0077)
-#define LOW_Y ((UChar)0x0079)
-#define LOW_Z ((UChar)0x007A)
+#define LOW_A ((char16_t)0x0061)
+#define LOW_B ((char16_t)0x0062)
+#define LOW_C ((char16_t)0x0063)
+#define LOW_D ((char16_t)0x0064)
+#define LOW_E ((char16_t)0x0065)
+#define LOW_F ((char16_t)0x0066)
+#define LOW_G ((char16_t)0x0067)
+#define LOW_H ((char16_t)0x0068)
+#define LOW_I ((char16_t)0x0069)
+#define LOW_J ((char16_t)0x006a)
+#define LOW_K ((char16_t)0x006B)
+#define LOW_L ((char16_t)0x006C)
+#define LOW_M ((char16_t)0x006D)
+#define LOW_N ((char16_t)0x006E)
+#define LOW_O ((char16_t)0x006F)
+#define LOW_P ((char16_t)0x0070)
+#define LOW_Q ((char16_t)0x0071)
+#define LOW_R ((char16_t)0x0072)
+#define LOW_S ((char16_t)0x0073)
+#define LOW_T ((char16_t)0x0074)
+#define LOW_U ((char16_t)0x0075)
+#define LOW_V ((char16_t)0x0076)
+#define LOW_W ((char16_t)0x0077)
+#define LOW_Y ((char16_t)0x0079)
+#define LOW_Z ((char16_t)0x007A)
-#define CAP_A ((UChar)0x0041)
-#define CAP_C ((UChar)0x0043)
-#define CAP_D ((UChar)0x0044)
-#define CAP_E ((UChar)0x0045)
-#define CAP_F ((UChar)0x0046)
-#define CAP_G ((UChar)0x0047)
-#define CAP_H ((UChar)0x0048)
-#define CAP_K ((UChar)0x004B)
-#define CAP_L ((UChar)0x004C)
-#define CAP_M ((UChar)0x004D)
-#define CAP_N ((UChar)0x004E)
-#define CAP_O ((UChar)0x004F)
-#define CAP_P ((UChar)0x0050)
-#define CAP_Q ((UChar)0x0051)
-#define CAP_S ((UChar)0x0053)
-#define CAP_T ((UChar)0x0054)
-#define CAP_U ((UChar)0x0055)
-#define CAP_V ((UChar)0x0056)
-#define CAP_W ((UChar)0x0057)
-#define CAP_Y ((UChar)0x0059)
-#define CAP_Z ((UChar)0x005A)
+#define CAP_A ((char16_t)0x0041)
+#define CAP_C ((char16_t)0x0043)
+#define CAP_D ((char16_t)0x0044)
+#define CAP_E ((char16_t)0x0045)
+#define CAP_F ((char16_t)0x0046)
+#define CAP_G ((char16_t)0x0047)
+#define CAP_H ((char16_t)0x0048)
+#define CAP_K ((char16_t)0x004B)
+#define CAP_L ((char16_t)0x004C)
+#define CAP_M ((char16_t)0x004D)
+#define CAP_N ((char16_t)0x004E)
+#define CAP_O ((char16_t)0x004F)
+#define CAP_P ((char16_t)0x0050)
+#define CAP_Q ((char16_t)0x0051)
+#define CAP_S ((char16_t)0x0053)
+#define CAP_T ((char16_t)0x0054)
+#define CAP_U ((char16_t)0x0055)
+#define CAP_V ((char16_t)0x0056)
+#define CAP_W ((char16_t)0x0057)
+#define CAP_Y ((char16_t)0x0059)
+#define CAP_Z ((char16_t)0x005A)
#endif /* #if !UCONFIG_NO_FORMATTING */
* Unlocalized date-time pattern characters. For example: 'y', 'd', etc. All
* locales use the same these unlocalized pattern characters.
*/
-static const UChar gPatternChars[] = {
+static const char16_t gPatternChars[] = {
// if UDAT_HAS_PATTERN_CHAR_FOR_TIME_SEPARATOR:
// GyMdkHmsSEDFwWahKzYeugAZvcLQqVUOXxrbB:
// else:
// files. They aren't designed for actual use, just for backup.
// These are the month names and abbreviations of last resort.
-static const UChar gLastResortMonthNames[13][3] =
+static const char16_t gLastResortMonthNames[13][3] =
{
{0x0030, 0x0031, 0x0000}, /* "01" */
{0x0030, 0x0032, 0x0000}, /* "02" */
};
// These are the weekday names and abbreviations of last resort.
-static const UChar gLastResortDayNames[8][2] =
+static const char16_t gLastResortDayNames[8][2] =
{
{0x0030, 0x0000}, /* "0" */
{0x0031, 0x0000}, /* "1" */
};
// These are the quarter names and abbreviations of last resort.
-static const UChar gLastResortQuarters[4][2] =
+static const char16_t gLastResortQuarters[4][2] =
{
{0x0031, 0x0000}, /* "1" */
{0x0032, 0x0000}, /* "2" */
};
// These are the am/pm and BC/AD markers of last resort.
-static const UChar gLastResortAmPmMarkers[2][3] =
+static const char16_t gLastResortAmPmMarkers[2][3] =
{
{0x0041, 0x004D, 0x0000}, /* "AM" */
{0x0050, 0x004D, 0x0000} /* "PM" */
};
-static const UChar gLastResortEras[2][3] =
+static const char16_t gLastResortEras[2][3] =
{
{0x0042, 0x0043, 0x0000}, /* "BC" */
{0x0041, 0x0044, 0x0000} /* "AD" */
}
UDateFormatField U_EXPORT2
-DateFormatSymbols::getPatternCharIndex(UChar c) {
- const UChar *p = u_strchr(gPatternChars, c);
+DateFormatSymbols::getPatternCharIndex(char16_t c) {
+ const char16_t *p = u_strchr(gPatternChars, c);
if (p == nullptr) {
return UDAT_FIELD_COUNT;
} else {
}
UBool U_EXPORT2
-DateFormatSymbols::isNumericPatternChar(UChar c, int32_t count) {
+DateFormatSymbols::isNumericPatternChar(char16_t c, int32_t count) {
return isNumericField(getPatternCharIndex(c), count);
}
namespace {
// Constants declarations
-static const UChar kCalendarAliasPrefixUChar[] = {
+static const char16_t kCalendarAliasPrefixUChar[] = {
SOLIDUS, CAP_L, CAP_O, CAP_C, CAP_A, CAP_L, CAP_E, SOLIDUS,
LOW_C, LOW_A, LOW_L, LOW_E, LOW_N, LOW_D, LOW_A, LOW_R, SOLIDUS
};
-static const UChar kGregorianTagUChar[] = {
+static const char16_t kGregorianTagUChar[] = {
LOW_G, LOW_R, LOW_E, LOW_G, LOW_O, LOW_R, LOW_I, LOW_A, LOW_N
};
-static const UChar kVariantTagUChar[] = {
+static const char16_t kVariantTagUChar[] = {
PERCENT, LOW_V, LOW_A, LOW_R, LOW_I, LOW_A, LOW_N, LOW_T
};
-static const UChar kLeapTagUChar[] = {
+static const char16_t kLeapTagUChar[] = {
LOW_L, LOW_E, LOW_A, LOW_P
};
-static const UChar kCyclicNameSetsTagUChar[] = {
+static const char16_t kCyclicNameSetsTagUChar[] = {
LOW_C, LOW_Y, LOW_C, LOW_L, LOW_I, LOW_C, CAP_N, LOW_A, LOW_M, LOW_E, CAP_S, LOW_E, LOW_T, LOW_S
};
-static const UChar kYearsTagUChar[] = {
+static const char16_t kYearsTagUChar[] = {
SOLIDUS, LOW_Y, LOW_E, LOW_A, LOW_R, LOW_S
};
-static const UChar kZodiacsUChar[] = {
+static const char16_t kZodiacsUChar[] = {
SOLIDUS, LOW_Z, LOW_O, LOW_D, LOW_I, LOW_A, LOW_C, LOW_S
};
-static const UChar kDayPartsTagUChar[] = {
+static const char16_t kDayPartsTagUChar[] = {
SOLIDUS, LOW_D, LOW_A, LOW_Y, CAP_P, LOW_A, LOW_R, LOW_T, LOW_S
};
-static const UChar kFormatTagUChar[] = {
+static const char16_t kFormatTagUChar[] = {
SOLIDUS, LOW_F, LOW_O, LOW_R, LOW_M, LOW_A, LOW_T
};
-static const UChar kAbbrTagUChar[] = {
+static const char16_t kAbbrTagUChar[] = {
SOLIDUS, LOW_A, LOW_B, LOW_B, LOW_R, LOW_E, LOW_V, LOW_I, LOW_A, LOW_T, LOW_E, LOW_D
};
}
U_ASSERT(stringMap != nullptr);
int32_t valueStringSize;
- const UChar *valueString = value.getString(valueStringSize, errorCode);
+ const char16_t *valueString = value.getString(valueStringSize, errorCode);
if (U_FAILURE(errorCode)) { return; }
LocalPointer<UnicodeString> valueUString(new UnicodeString(true, valueString, valueStringSize), errorCode);
stringMap->put(keyUString, valueUString.orphan(), errorCode);
if (value.getType() == URES_ALIAS) {
int32_t aliasPathSize;
- const UChar* aliasPathUChar = value.getAliasString(aliasPathSize, errorCode);
+ const char16_t* aliasPathUChar = value.getAliasString(aliasPathSize, errorCode);
if (U_FAILURE(errorCode)) { return NONE; }
UnicodeString aliasPath(aliasPathUChar, aliasPathSize);
const int32_t aliasPrefixLength = UPRV_LENGTHOF(kCalendarAliasPrefixUChar);
//------------------------------------------------------
static void
-initField(UnicodeString **field, int32_t& length, const UChar *data, LastResortSize numStr, LastResortSize strLen, UErrorCode &status) {
+initField(UnicodeString **field, int32_t& length, const char16_t *data, LastResortSize numStr, LastResortSize strLen, UErrorCode &status) {
if (U_SUCCESS(status)) {
length = numStr;
*field = newUnicodeStringArray((size_t)numStr);
status = U_USING_FALLBACK_WARNING;
//TODO(fabalbon): make sure we are storing las resort data for all fields in here.
- initField(&fEras, fErasCount, (const UChar *)gLastResortEras, kEraNum, kEraLen, status);
- initField(&fEraNames, fEraNamesCount, (const UChar *)gLastResortEras, kEraNum, kEraLen, status);
- initField(&fNarrowEras, fNarrowErasCount, (const UChar *)gLastResortEras, kEraNum, kEraLen, status);
- initField(&fMonths, fMonthsCount, (const UChar *)gLastResortMonthNames, kMonthNum, kMonthLen, status);
- initField(&fShortMonths, fShortMonthsCount, (const UChar *)gLastResortMonthNames, kMonthNum, kMonthLen, status);
- initField(&fNarrowMonths, fNarrowMonthsCount, (const UChar *)gLastResortMonthNames, kMonthNum, kMonthLen, status);
- initField(&fStandaloneMonths, fStandaloneMonthsCount, (const UChar *)gLastResortMonthNames, kMonthNum, kMonthLen, status);
- initField(&fStandaloneShortMonths, fStandaloneShortMonthsCount, (const UChar *)gLastResortMonthNames, kMonthNum, kMonthLen, status);
- initField(&fStandaloneNarrowMonths, fStandaloneNarrowMonthsCount, (const UChar *)gLastResortMonthNames, kMonthNum, kMonthLen, status);
- initField(&fWeekdays, fWeekdaysCount, (const UChar *)gLastResortDayNames, kDayNum, kDayLen, status);
- initField(&fShortWeekdays, fShortWeekdaysCount, (const UChar *)gLastResortDayNames, kDayNum, kDayLen, status);
- initField(&fShorterWeekdays, fShorterWeekdaysCount, (const UChar *)gLastResortDayNames, kDayNum, kDayLen, status);
- initField(&fNarrowWeekdays, fNarrowWeekdaysCount, (const UChar *)gLastResortDayNames, kDayNum, kDayLen, status);
- initField(&fStandaloneWeekdays, fStandaloneWeekdaysCount, (const UChar *)gLastResortDayNames, kDayNum, kDayLen, status);
- initField(&fStandaloneShortWeekdays, fStandaloneShortWeekdaysCount, (const UChar *)gLastResortDayNames, kDayNum, kDayLen, status);
- initField(&fStandaloneShorterWeekdays, fStandaloneShorterWeekdaysCount, (const UChar *)gLastResortDayNames, kDayNum, kDayLen, status);
- initField(&fStandaloneNarrowWeekdays, fStandaloneNarrowWeekdaysCount, (const UChar *)gLastResortDayNames, kDayNum, kDayLen, status);
- initField(&fAmPms, fAmPmsCount, (const UChar *)gLastResortAmPmMarkers, kAmPmNum, kAmPmLen, status);
- initField(&fNarrowAmPms, fNarrowAmPmsCount, (const UChar *)gLastResortAmPmMarkers, kAmPmNum, kAmPmLen, status);
- initField(&fQuarters, fQuartersCount, (const UChar *)gLastResortQuarters, kQuarterNum, kQuarterLen, status);
- initField(&fShortQuarters, fShortQuartersCount, (const UChar *)gLastResortQuarters, kQuarterNum, kQuarterLen, status);
- initField(&fNarrowQuarters, fNarrowQuartersCount, (const UChar *)gLastResortQuarters, kQuarterNum, kQuarterLen, status);
- initField(&fStandaloneQuarters, fStandaloneQuartersCount, (const UChar *)gLastResortQuarters, kQuarterNum, kQuarterLen, status);
- initField(&fStandaloneShortQuarters, fStandaloneShortQuartersCount, (const UChar *)gLastResortQuarters, kQuarterNum, kQuarterLen, status);
- initField(&fStandaloneNarrowQuarters, fStandaloneNarrowQuartersCount, (const UChar *)gLastResortQuarters, kQuarterNum, kQuarterLen, status);
+ initField(&fEras, fErasCount, (const char16_t *)gLastResortEras, kEraNum, kEraLen, status);
+ initField(&fEraNames, fEraNamesCount, (const char16_t *)gLastResortEras, kEraNum, kEraLen, status);
+ initField(&fNarrowEras, fNarrowErasCount, (const char16_t *)gLastResortEras, kEraNum, kEraLen, status);
+ initField(&fMonths, fMonthsCount, (const char16_t *)gLastResortMonthNames, kMonthNum, kMonthLen, status);
+ initField(&fShortMonths, fShortMonthsCount, (const char16_t *)gLastResortMonthNames, kMonthNum, kMonthLen, status);
+ initField(&fNarrowMonths, fNarrowMonthsCount, (const char16_t *)gLastResortMonthNames, kMonthNum, kMonthLen, status);
+ initField(&fStandaloneMonths, fStandaloneMonthsCount, (const char16_t *)gLastResortMonthNames, kMonthNum, kMonthLen, status);
+ initField(&fStandaloneShortMonths, fStandaloneShortMonthsCount, (const char16_t *)gLastResortMonthNames, kMonthNum, kMonthLen, status);
+ initField(&fStandaloneNarrowMonths, fStandaloneNarrowMonthsCount, (const char16_t *)gLastResortMonthNames, kMonthNum, kMonthLen, status);
+ initField(&fWeekdays, fWeekdaysCount, (const char16_t *)gLastResortDayNames, kDayNum, kDayLen, status);
+ initField(&fShortWeekdays, fShortWeekdaysCount, (const char16_t *)gLastResortDayNames, kDayNum, kDayLen, status);
+ initField(&fShorterWeekdays, fShorterWeekdaysCount, (const char16_t *)gLastResortDayNames, kDayNum, kDayLen, status);
+ initField(&fNarrowWeekdays, fNarrowWeekdaysCount, (const char16_t *)gLastResortDayNames, kDayNum, kDayLen, status);
+ initField(&fStandaloneWeekdays, fStandaloneWeekdaysCount, (const char16_t *)gLastResortDayNames, kDayNum, kDayLen, status);
+ initField(&fStandaloneShortWeekdays, fStandaloneShortWeekdaysCount, (const char16_t *)gLastResortDayNames, kDayNum, kDayLen, status);
+ initField(&fStandaloneShorterWeekdays, fStandaloneShorterWeekdaysCount, (const char16_t *)gLastResortDayNames, kDayNum, kDayLen, status);
+ initField(&fStandaloneNarrowWeekdays, fStandaloneNarrowWeekdaysCount, (const char16_t *)gLastResortDayNames, kDayNum, kDayLen, status);
+ initField(&fAmPms, fAmPmsCount, (const char16_t *)gLastResortAmPmMarkers, kAmPmNum, kAmPmLen, status);
+ initField(&fNarrowAmPms, fNarrowAmPmsCount, (const char16_t *)gLastResortAmPmMarkers, kAmPmNum, kAmPmLen, status);
+ initField(&fQuarters, fQuartersCount, (const char16_t *)gLastResortQuarters, kQuarterNum, kQuarterLen, status);
+ initField(&fShortQuarters, fShortQuartersCount, (const char16_t *)gLastResortQuarters, kQuarterNum, kQuarterLen, status);
+ initField(&fNarrowQuarters, fNarrowQuartersCount, (const char16_t *)gLastResortQuarters, kQuarterNum, kQuarterLen, status);
+ initField(&fStandaloneQuarters, fStandaloneQuartersCount, (const char16_t *)gLastResortQuarters, kQuarterNum, kQuarterLen, status);
+ initField(&fStandaloneShortQuarters, fStandaloneShortQuartersCount, (const char16_t *)gLastResortQuarters, kQuarterNum, kQuarterLen, status);
+ initField(&fStandaloneNarrowQuarters, fStandaloneNarrowQuartersCount, (const char16_t *)gLastResortQuarters, kQuarterNum, kQuarterLen, status);
fLocalPatternChars.setTo(true, gPatternChars, PATTERN_CHARS_LEN);
}
}
#include "unicode/unistr.h"
-#define QUOTE ((UChar)0x0027)
-#define LOW_LINE ((UChar)0x005F)
-#define COLON ((UChar)0x003A)
-#define LEFT_CURLY_BRACKET ((UChar)0x007B)
-#define RIGHT_CURLY_BRACKET ((UChar)0x007D)
-#define SPACE ((UChar)0x0020)
-#define EN_DASH ((UChar)0x2013)
-#define SOLIDUS ((UChar)0x002F)
+#define QUOTE ((char16_t)0x0027)
+#define LOW_LINE ((char16_t)0x005F)
+#define COLON ((char16_t)0x003A)
+#define LEFT_CURLY_BRACKET ((char16_t)0x007B)
+#define RIGHT_CURLY_BRACKET ((char16_t)0x007D)
+#define SPACE ((char16_t)0x0020)
+#define EN_DASH ((char16_t)0x2013)
+#define SOLIDUS ((char16_t)0x002F)
-#define DIGIT_ZERO ((UChar)0x0030)
-#define DIGIT_ONE ((UChar)0x0031)
+#define DIGIT_ZERO ((char16_t)0x0030)
+#define DIGIT_ONE ((char16_t)0x0031)
-#define LOW_A ((UChar)0x0061)
-#define LOW_B ((UChar)0x0062)
-#define LOW_C ((UChar)0x0063)
-#define LOW_D ((UChar)0x0064)
-#define LOW_E ((UChar)0x0065)
-#define LOW_F ((UChar)0x0066)
-#define LOW_G ((UChar)0x0067)
-#define LOW_H ((UChar)0x0068)
-#define LOW_I ((UChar)0x0069)
-#define LOW_J ((UChar)0x006a)
-#define LOW_K ((UChar)0x006B)
-#define LOW_L ((UChar)0x006C)
-#define LOW_M ((UChar)0x006D)
-#define LOW_N ((UChar)0x006E)
-#define LOW_O ((UChar)0x006F)
-#define LOW_P ((UChar)0x0070)
-#define LOW_Q ((UChar)0x0071)
-#define LOW_R ((UChar)0x0072)
-#define LOW_S ((UChar)0x0073)
-#define LOW_T ((UChar)0x0074)
-#define LOW_U ((UChar)0x0075)
-#define LOW_V ((UChar)0x0076)
-#define LOW_W ((UChar)0x0077)
-#define LOW_Y ((UChar)0x0079)
-#define LOW_Z ((UChar)0x007A)
+#define LOW_A ((char16_t)0x0061)
+#define LOW_B ((char16_t)0x0062)
+#define LOW_C ((char16_t)0x0063)
+#define LOW_D ((char16_t)0x0064)
+#define LOW_E ((char16_t)0x0065)
+#define LOW_F ((char16_t)0x0066)
+#define LOW_G ((char16_t)0x0067)
+#define LOW_H ((char16_t)0x0068)
+#define LOW_I ((char16_t)0x0069)
+#define LOW_J ((char16_t)0x006a)
+#define LOW_K ((char16_t)0x006B)
+#define LOW_L ((char16_t)0x006C)
+#define LOW_M ((char16_t)0x006D)
+#define LOW_N ((char16_t)0x006E)
+#define LOW_O ((char16_t)0x006F)
+#define LOW_P ((char16_t)0x0070)
+#define LOW_Q ((char16_t)0x0071)
+#define LOW_R ((char16_t)0x0072)
+#define LOW_S ((char16_t)0x0073)
+#define LOW_T ((char16_t)0x0074)
+#define LOW_U ((char16_t)0x0075)
+#define LOW_V ((char16_t)0x0076)
+#define LOW_W ((char16_t)0x0077)
+#define LOW_Y ((char16_t)0x0079)
+#define LOW_Z ((char16_t)0x007A)
-#define CAP_A ((UChar)0x0041)
-#define CAP_B ((UChar)0x0042)
-#define CAP_C ((UChar)0x0043)
-#define CAP_D ((UChar)0x0044)
-#define CAP_E ((UChar)0x0045)
-#define CAP_F ((UChar)0x0046)
-#define CAP_G ((UChar)0x0047)
-#define CAP_J ((UChar)0x004A)
-#define CAP_H ((UChar)0x0048)
-#define CAP_K ((UChar)0x004B)
-#define CAP_L ((UChar)0x004C)
-#define CAP_M ((UChar)0x004D)
-#define CAP_O ((UChar)0x004F)
-#define CAP_Q ((UChar)0x0051)
-#define CAP_S ((UChar)0x0053)
-#define CAP_T ((UChar)0x0054)
-#define CAP_U ((UChar)0x0055)
-#define CAP_V ((UChar)0x0056)
-#define CAP_W ((UChar)0x0057)
-#define CAP_Y ((UChar)0x0059)
-#define CAP_Z ((UChar)0x005A)
+#define CAP_A ((char16_t)0x0041)
+#define CAP_B ((char16_t)0x0042)
+#define CAP_C ((char16_t)0x0043)
+#define CAP_D ((char16_t)0x0044)
+#define CAP_E ((char16_t)0x0045)
+#define CAP_F ((char16_t)0x0046)
+#define CAP_G ((char16_t)0x0047)
+#define CAP_J ((char16_t)0x004A)
+#define CAP_H ((char16_t)0x0048)
+#define CAP_K ((char16_t)0x004B)
+#define CAP_L ((char16_t)0x004C)
+#define CAP_M ((char16_t)0x004D)
+#define CAP_O ((char16_t)0x004F)
+#define CAP_Q ((char16_t)0x0051)
+#define CAP_S ((char16_t)0x0053)
+#define CAP_T ((char16_t)0x0054)
+#define CAP_U ((char16_t)0x0055)
+#define CAP_V ((char16_t)0x0056)
+#define CAP_W ((char16_t)0x0057)
+#define CAP_Y ((char16_t)0x0059)
+#define CAP_Z ((char16_t)0x005A)
//#define MINIMUM_SUPPORTED_CALENDAR_FIELD UCAL_MINUTE
#endif
-static const UChar gDateFormatSkeleton[][11] = {
+static const char16_t gDateFormatSkeleton[][11] = {
//yMMMMEEEEd
{LOW_Y, CAP_M, CAP_M, CAP_M, CAP_M, CAP_E, CAP_E, CAP_E, CAP_E, LOW_D, 0},
//yMMMMd
// latestFirst:
-static const UChar gLaterFirstPrefix[] = {LOW_L, LOW_A, LOW_T, LOW_E, LOW_S,LOW_T, CAP_F, LOW_I, LOW_R, LOW_S, LOW_T, COLON};
+static const char16_t gLaterFirstPrefix[] = {LOW_L, LOW_A, LOW_T, LOW_E, LOW_S,LOW_T, CAP_F, LOW_I, LOW_R, LOW_S, LOW_T, COLON};
// earliestFirst:
-static const UChar gEarlierFirstPrefix[] = {LOW_E, LOW_A, LOW_R, LOW_L, LOW_I, LOW_E, LOW_S, LOW_T, CAP_F, LOW_I, LOW_R, LOW_S, LOW_T, COLON};
+static const char16_t gEarlierFirstPrefix[] = {LOW_E, LOW_A, LOW_R, LOW_L, LOW_I, LOW_E, LOW_S, LOW_T, CAP_F, LOW_I, LOW_R, LOW_S, LOW_T, COLON};
class FormattedDateIntervalData : public FormattedValueFieldPositionIteratorImpl {
dateTimePatternsRes.getAlias(), &status);
int32_t dateTimeFormatLength;
- const UChar* dateTimeFormat = ures_getStringByIndex(
+ const char16_t* dateTimeFormat = ures_getStringByIndex(
dateTimePatternsRes.getAlias(),
(int32_t)DateFormat::kDateTime,
&dateTimeFormatLength, &status);
DateIntervalFormat::normalizeHourMetacharacters(const UnicodeString& skeleton) const {
UnicodeString result = skeleton;
- UChar hourMetachar = u'\0';
- UChar dayPeriodChar = u'\0';
+ char16_t hourMetachar = u'\0';
+ char16_t dayPeriodChar = u'\0';
int32_t hourFieldStart = 0;
int32_t hourFieldLength = 0;
int32_t dayPeriodStart = 0;
int32_t dayPeriodLength = 0;
for (int32_t i = 0; i < result.length(); i++) {
- UChar c = result[i];
+ char16_t c = result[i];
if (c == LOW_J || c == CAP_J || c == CAP_C || c == LOW_H || c == CAP_H || c == LOW_K || c == CAP_K) {
if (hourMetachar == u'\0') {
hourMetachar = c;
if (hourMetachar != u'\0') {
UErrorCode err = U_ZERO_ERROR;
- UChar hourChar = CAP_H;
+ char16_t hourChar = CAP_H;
UnicodeString convertedPattern = DateFormat::getBestPattern(fLocale, UnicodeString(hourMetachar), err);
if (U_SUCCESS(err)) {
int32_t mCount = 0;
int32_t vCount = 0;
int32_t zCount = 0;
- UChar hourChar = u'\0';
+ char16_t hourChar = u'\0';
int32_t i;
for (i = 0; i < skeleton.length(); ++i) {
- UChar ch = skeleton[i];
+ char16_t ch = skeleton[i];
switch ( ch ) {
case CAP_E:
dateSkeleton.append(ch);
// need to look for it from skeleton 'yMMMd',
// if found, adjust field width in interval pattern from
// "MMM" to "MMMM".
- UChar fieldLetter = fgCalendarFieldToPatternLetter[field];
+ char16_t fieldLetter = fgCalendarFieldToPatternLetter[field];
if ( extendedSkeleton ) {
*extendedSkeleton = *skeleton;
*extendedBestSkeleton = *bestSkeleton;
int32_t U_EXPORT2
DateIntervalFormat::splitPatternInto2Part(const UnicodeString& intervalPattern) {
UBool inQuote = false;
- UChar prevCh = 0;
+ char16_t prevCh = 0;
int32_t count = 0;
/* repeatedPattern used to record whether a pattern has already seen.
int32_t i;
UBool foundRepetition = false;
for (i = 0; i < intervalPattern.length(); ++i) {
- UChar ch = intervalPattern.charAt(i);
+ char16_t ch = intervalPattern.charAt(i);
if (ch != prevCh && count > 0) {
// check the repeativeness of pattern letter
DateIntervalFormat::fieldExistsInSkeleton(UCalendarDateFields field,
const UnicodeString& skeleton)
{
- const UChar fieldChar = fgCalendarFieldToPatternLetter[field];
+ const char16_t fieldChar = fgCalendarFieldToPatternLetter[field];
return ( (skeleton.indexOf(fieldChar) == -1)?false:true ) ;
}
}
UBool inQuote = false;
- UChar prevCh = 0;
+ char16_t prevCh = 0;
int32_t count = 0;
// loop through the pattern string character by character
int32_t adjustedPtnLength = adjustedPtn.length();
int32_t i;
for (i = 0; i < adjustedPtnLength; ++i) {
- UChar ch = adjustedPtn.charAt(i);
+ char16_t ch = adjustedPtn.charAt(i);
if (ch != prevCh && count > 0) {
// check the repeativeness of pattern letter
- UChar skeletonChar = prevCh;
+ char16_t skeletonChar = prevCh;
if ( skeletonChar == CAP_L ) {
// there is no "L" (always be "M") in skeleton,
// but there is "L" in pattern.
if ( count > 0 ) {
// last item
// check the repeativeness of pattern letter
- UChar skeletonChar = prevCh;
+ char16_t skeletonChar = prevCh;
if ( skeletonChar == CAP_L ) {
// there is no "L" (always be "M") in skeleton,
// but there is "L" in pattern.
-const UChar
+const char16_t
DateIntervalFormat::fgCalendarFieldToPatternLetter[] =
{
/*GyM*/ CAP_G, LOW_Y, CAP_M,
static const char gFallbackPatternTag[]="fallback";
// {0}
-static const UChar gFirstPattern[] = {LEFT_CURLY_BRACKET, DIGIT_ZERO, RIGHT_CURLY_BRACKET};
+static const char16_t gFirstPattern[] = {LEFT_CURLY_BRACKET, DIGIT_ZERO, RIGHT_CURLY_BRACKET};
// {1}
-static const UChar gSecondPattern[] = {LEFT_CURLY_BRACKET, DIGIT_ONE, RIGHT_CURLY_BRACKET};
+static const char16_t gSecondPattern[] = {LEFT_CURLY_BRACKET, DIGIT_ONE, RIGHT_CURLY_BRACKET};
// default fall-back
-static const UChar gDefaultFallbackPattern[] = {LEFT_CURLY_BRACKET, DIGIT_ZERO, RIGHT_CURLY_BRACKET, SPACE, EN_DASH, SPACE, LEFT_CURLY_BRACKET, DIGIT_ONE, RIGHT_CURLY_BRACKET, 0};
+static const char16_t gDefaultFallbackPattern[] = {LEFT_CURLY_BRACKET, DIGIT_ZERO, RIGHT_CURLY_BRACKET, SPACE, EN_DASH, SPACE, LEFT_CURLY_BRACKET, DIGIT_ONE, RIGHT_CURLY_BRACKET, 0};
DateIntervalInfo::DateIntervalInfo(UErrorCode& status)
: fFallbackIntervalPattern(gDefaultFallbackPattern),
static const int32_t PATH_PREFIX_LENGTH = 17;
-static const UChar PATH_PREFIX[] = {SOLIDUS, CAP_L, CAP_O, CAP_C, CAP_A, CAP_L, CAP_E, SOLIDUS,
+static const char16_t PATH_PREFIX[] = {SOLIDUS, CAP_L, CAP_O, CAP_C, CAP_A, CAP_L, CAP_E, SOLIDUS,
LOW_C, LOW_A, LOW_L, LOW_E, LOW_N, LOW_D, LOW_A, LOW_R, SOLIDUS};
static const int32_t PATH_SUFFIX_LENGTH = 16;
-static const UChar PATH_SUFFIX[] = {SOLIDUS, LOW_I, LOW_N, LOW_T, LOW_E, LOW_R, LOW_V, LOW_A,
+static const char16_t PATH_SUFFIX[] = {SOLIDUS, LOW_I, LOW_N, LOW_T, LOW_E, LOW_R, LOW_V, LOW_A,
LOW_L, CAP_F, LOW_O, LOW_R, LOW_M, LOW_A, LOW_T, LOW_S};
/**
UResourceBundle *calTypeBundle, *itvDtPtnResource;
// Get the fallback pattern
- const UChar* resStr = nullptr;
+ const char16_t* resStr = nullptr;
int32_t resStrLen = 0;
calTypeBundle = ures_getByKeyWithFallback(calBundle, calendarTypeToUse, nullptr, &status);
itvDtPtnResource = ures_getByKeyWithFallback(calTypeBundle,
#include "uarrsort.h"
struct UResAEntry {
- UChar *key;
+ char16_t *key;
UResourceBundle *item;
};
aiter->entries[i].item = ures_getByIndex(aiter->bund, i, nullptr, status);
const char *akey = ures_getKey(aiter->entries[i].item);
int32_t len = uprv_strlen(akey)+1;
- aiter->entries[i].key = (UChar*)uprv_malloc(len*sizeof(UChar));
+ aiter->entries[i].key = (char16_t*)uprv_malloc(len*sizeof(char16_t));
u_charsToUChars(akey, aiter->entries[i].key, len);
}
uprv_sortArray(aiter->entries, aiter->num, sizeof(UResAEntry), ures_a_codepointSort, nullptr, true, status);
#endif
}
-static const UChar *ures_a_getNextString(UResourceBundleAIterator *aiter, int32_t *len, const char **key, UErrorCode *err) {
+static const char16_t *ures_a_getNextString(UResourceBundleAIterator *aiter, int32_t *len, const char **key, UErrorCode *err) {
#if !defined(U_SORT_ASCII_BUNDLE_ITERATOR)
return ures_getNextString(aiter->bund, len, key, err);
#else
if(U_FAILURE(*err)) return nullptr;
UResourceBundle *item = aiter->entries[aiter->cursor].item;
- const UChar* ret = ures_getString(item, len, err);
+ const char16_t* ret = ures_getString(item, len, err);
*key = ures_getKey(item);
aiter->cursor++;
return ret;
// *****************************************************************************
// class DateTimePatternGenerator
// *****************************************************************************
-static const UChar Canonical_Items[] = {
+static const char16_t Canonical_Items[] = {
// GyQMwWEDFdaHmsSv
CAP_G, LOW_Y, CAP_Q, CAP_M, LOW_W, CAP_W, CAP_E,
CAP_D, CAP_F, LOW_D, LOW_A, // The UDATPG_x_FIELD constants and these fields have a different order than in ICU4J
static constexpr int32_t UDATPG_FIELD_KEY_MAX = 24; // max length of CLDR field tag (type + width)
// For appendItems
-static const UChar UDATPG_ItemFormat[]= {0x7B, 0x30, 0x7D, 0x20, 0x251C, 0x7B, 0x32, 0x7D, 0x3A,
+static const char16_t UDATPG_ItemFormat[]= {0x7B, 0x30, 0x7D, 0x20, 0x251C, 0x7B, 0x32, 0x7D, 0x3A,
0x20, 0x7B, 0x31, 0x7D, 0x2524, 0}; // {0} \u251C{2}: {1}\u2524
-//static const UChar repeatedPatterns[6]={CAP_G, CAP_E, LOW_Z, LOW_V, CAP_Q, 0}; // "GEzvQ"
+//static const char16_t repeatedPatterns[6]={CAP_G, CAP_E, LOW_Z, LOW_V, CAP_Q, 0}; // "GEzvQ"
static const char DT_DateTimePatternsTag[]="DateTimePatterns";
static const char DT_DateAtTimePatternsTag[]="DateTimePatterns%atTime";
mmss+=field;
}
else {
- UChar ch=field.charAt(0);
+ char16_t ch=field.charAt(0);
if (ch==LOW_M) {
gotMm=true;
mmss+=field;
U_ASSERT(i < 20);
if (i < 10) {
// F0, F1, ..., F9
- valueStr += (UChar)(i+0x30);
+ valueStr += (char16_t)(i+0x30);
} else {
// F10, F11, ...
- valueStr += (UChar)0x31;
- valueStr += (UChar)(i-10 + 0x30);
+ valueStr += (char16_t)0x31;
+ valueStr += (char16_t)(i-10 + 0x30);
}
// NUL-terminate for the C API.
valueStr.getTerminatedBuffer();
UBool inQuoted = false;
int32_t patPos, patLen = patternForm.length();
for (patPos = 0; patPos < patLen; patPos++) {
- UChar patChr = patternForm.charAt(patPos);
+ char16_t patChr = patternForm.charAt(patPos);
if (patChr == SINGLE_QUOTE) {
inQuoted = !inQuoted;
} else if (!inQuoted) {
}
int32_t hourLen = 1 + (extraLen & 1);
int32_t dayPeriodLen = (extraLen < 2)? 1: 3 + (extraLen >> 1);
- UChar hourChar = LOW_H;
- UChar dayPeriodChar = LOW_A;
+ char16_t hourChar = LOW_H;
+ char16_t dayPeriodChar = LOW_A;
if (patChr == LOW_J) {
hourChar = fDefaultHourFormatChar;
} else {
DateTimePatternGenerator::setDateTimeFromCalendar(const Locale& locale, UErrorCode& status) {
if (U_FAILURE(status)) { return; }
- const UChar *resStr;
+ const char16_t *resStr;
int32_t resStrLen = 0;
LocalUResourceBundlePointer calData(ures_open(nullptr, locale.getBaseName(), &status));
// a) The length of the field in the skeleton (skelFieldLen) is equal to reqFieldLen.
// b) The pattern field is numeric and the skeleton field is not, or vice versa.
- UChar reqFieldChar = dtMatcher->skeleton.original.getFieldChar(typeValue);
+ char16_t reqFieldChar = dtMatcher->skeleton.original.getFieldChar(typeValue);
int32_t reqFieldLen = dtMatcher->skeleton.original.getFieldLength(typeValue);
if (reqFieldChar == CAP_E && reqFieldLen < 3)
reqFieldLen = 3; // 1-3 for E are equivalent to 3 for c,e
adjFieldLen = field.length();
}
}
- UChar c = (typeValue!= UDATPG_HOUR_FIELD
+ char16_t c = (typeValue!= UDATPG_HOUR_FIELD
&& typeValue!= UDATPG_MONTH_FIELD
&& typeValue!= UDATPG_WEEKDAY_FIELD
&& (typeValue!= UDATPG_YEAR_FIELD || reqFieldChar==CAP_Y))
}
PtnElem*
-PatternMap::getHeader(UChar baseChar) const {
+PatternMap::getHeader(char16_t baseChar) const {
PtnElem* curElem;
if ( (baseChar >= CAP_A) && (baseChar <= CAP_Z) ) {
const UnicodeString& value,// mapped pattern value
UBool skeletonWasSpecified,
UErrorCode &status) {
- UChar baseChar = basePattern.charAt(0);
+ char16_t baseChar = basePattern.charAt(0);
PtnElem *curElem, *baseElem;
status = U_ZERO_ERROR;
}
// find boot entry
- UChar baseChar = skeleton.getFirstChar();
+ char16_t baseChar = skeleton.getFirstChar();
if ((curElem=getHeader(baseChar))==nullptr) {
return nullptr; // no match
}
const dtTypeElem *row = &dtTypes[canonicalIndex];
int32_t field = row->field;
skeletonResult.original.populate(field, value);
- UChar repeatChar = row->patternChar;
+ char16_t repeatChar = row->patternChar;
int32_t repeatCount = row->minLen;
skeletonResult.baseOriginal.populate(field, repeatChar, repeatCount);
int16_t subField = row->type;
}
// check the current char is between A-Z or a-z
do {
- UChar c=pattern.charAt(curLoc);
+ char16_t c=pattern.charAt(curLoc);
if ( (c>=CAP_A && c<=CAP_Z) || (c>=LOW_A && c<=LOW_Z) ) {
curLoc++;
}
if (len == 0) {
return -1;
}
- UChar ch = s.charAt(0);
+ char16_t ch = s.charAt(0);
// Verify that all are the same character.
for (int32_t l = 1; l < len; l++) {
UBool
FormatParser::isPatternSeparator(const UnicodeString& field) const {
for (int32_t i=0; i<field.length(); ++i ) {
- UChar c= field.charAt(i);
+ char16_t c= field.charAt(i);
if ( (c==SINGLE_QUOTE) || (c==BACKSLASH) || (c==SPACE) || (c==COLON) ||
(c==QUOTATION_MARK) || (c==COMMA) || (c==HYPHEN) ||(items[i].charAt(0)==DOT) ) {
continue;
lengths[field] = 0;
}
-UChar SkeletonFields::getFieldChar(int32_t field) const {
+char16_t SkeletonFields::getFieldChar(int32_t field) const {
return chars[field];
}
populate(field, value.charAt(0), value.length());
}
-void SkeletonFields::populate(int32_t field, UChar ch, int32_t length) {
+void SkeletonFields::populate(int32_t field, char16_t ch, int32_t length) {
chars[field] = (int8_t) ch;
lengths[field] = (int8_t) length;
}
}
UnicodeString& SkeletonFields::appendFieldTo(int32_t field, UnicodeString& string) const {
- UChar ch(chars[field]);
+ char16_t ch(chars[field]);
int32_t length = (int32_t) lengths[field];
for (int32_t i=0; i<length; i++) {
return string;
}
-UChar SkeletonFields::getFirstChar() const {
+char16_t SkeletonFields::getFirstChar() const {
for (int32_t i = 0; i < UDATPG_FIELD_COUNT; ++i) {
if (lengths[i] != 0) {
return chars[i];
return result;
}
-UChar
+char16_t
PtnSkeleton::getFirstChar() const {
return baseOriginal.getFirstChar();
}
#define EXTRA_FIELD 0x10000
#define MISSING_FIELD 0x1000
#define MAX_STRING_ENUMERATION 200
-#define SINGLE_QUOTE ((UChar)0x0027)
-#define FORWARDSLASH ((UChar)0x002F)
-#define BACKSLASH ((UChar)0x005C)
-#define SPACE ((UChar)0x0020)
-#define QUOTATION_MARK ((UChar)0x0022)
-#define ASTERISK ((UChar)0x002A)
-#define PLUSSITN ((UChar)0x002B)
-#define COMMA ((UChar)0x002C)
-#define HYPHEN ((UChar)0x002D)
-#define DOT ((UChar)0x002E)
-#define COLON ((UChar)0x003A)
-#define CAP_A ((UChar)0x0041)
-#define CAP_B ((UChar)0x0042)
-#define CAP_C ((UChar)0x0043)
-#define CAP_D ((UChar)0x0044)
-#define CAP_E ((UChar)0x0045)
-#define CAP_F ((UChar)0x0046)
-#define CAP_G ((UChar)0x0047)
-#define CAP_H ((UChar)0x0048)
-#define CAP_J ((UChar)0x004A)
-#define CAP_K ((UChar)0x004B)
-#define CAP_L ((UChar)0x004C)
-#define CAP_M ((UChar)0x004D)
-#define CAP_O ((UChar)0x004F)
-#define CAP_Q ((UChar)0x0051)
-#define CAP_S ((UChar)0x0053)
-#define CAP_T ((UChar)0x0054)
-#define CAP_U ((UChar)0x0055)
-#define CAP_V ((UChar)0x0056)
-#define CAP_W ((UChar)0x0057)
-#define CAP_X ((UChar)0x0058)
-#define CAP_Y ((UChar)0x0059)
-#define CAP_Z ((UChar)0x005A)
-#define LOWLINE ((UChar)0x005F)
-#define LOW_A ((UChar)0x0061)
-#define LOW_B ((UChar)0x0062)
-#define LOW_C ((UChar)0x0063)
-#define LOW_D ((UChar)0x0064)
-#define LOW_E ((UChar)0x0065)
-#define LOW_F ((UChar)0x0066)
-#define LOW_G ((UChar)0x0067)
-#define LOW_H ((UChar)0x0068)
-#define LOW_I ((UChar)0x0069)
-#define LOW_J ((UChar)0x006A)
-#define LOW_K ((UChar)0x006B)
-#define LOW_L ((UChar)0x006C)
-#define LOW_M ((UChar)0x006D)
-#define LOW_N ((UChar)0x006E)
-#define LOW_O ((UChar)0x006F)
-#define LOW_P ((UChar)0x0070)
-#define LOW_Q ((UChar)0x0071)
-#define LOW_R ((UChar)0x0072)
-#define LOW_S ((UChar)0x0073)
-#define LOW_T ((UChar)0x0074)
-#define LOW_U ((UChar)0x0075)
-#define LOW_V ((UChar)0x0076)
-#define LOW_W ((UChar)0x0077)
-#define LOW_X ((UChar)0x0078)
-#define LOW_Y ((UChar)0x0079)
-#define LOW_Z ((UChar)0x007A)
+#define SINGLE_QUOTE ((char16_t)0x0027)
+#define FORWARDSLASH ((char16_t)0x002F)
+#define BACKSLASH ((char16_t)0x005C)
+#define SPACE ((char16_t)0x0020)
+#define QUOTATION_MARK ((char16_t)0x0022)
+#define ASTERISK ((char16_t)0x002A)
+#define PLUSSITN ((char16_t)0x002B)
+#define COMMA ((char16_t)0x002C)
+#define HYPHEN ((char16_t)0x002D)
+#define DOT ((char16_t)0x002E)
+#define COLON ((char16_t)0x003A)
+#define CAP_A ((char16_t)0x0041)
+#define CAP_B ((char16_t)0x0042)
+#define CAP_C ((char16_t)0x0043)
+#define CAP_D ((char16_t)0x0044)
+#define CAP_E ((char16_t)0x0045)
+#define CAP_F ((char16_t)0x0046)
+#define CAP_G ((char16_t)0x0047)
+#define CAP_H ((char16_t)0x0048)
+#define CAP_J ((char16_t)0x004A)
+#define CAP_K ((char16_t)0x004B)
+#define CAP_L ((char16_t)0x004C)
+#define CAP_M ((char16_t)0x004D)
+#define CAP_O ((char16_t)0x004F)
+#define CAP_Q ((char16_t)0x0051)
+#define CAP_S ((char16_t)0x0053)
+#define CAP_T ((char16_t)0x0054)
+#define CAP_U ((char16_t)0x0055)
+#define CAP_V ((char16_t)0x0056)
+#define CAP_W ((char16_t)0x0057)
+#define CAP_X ((char16_t)0x0058)
+#define CAP_Y ((char16_t)0x0059)
+#define CAP_Z ((char16_t)0x005A)
+#define LOWLINE ((char16_t)0x005F)
+#define LOW_A ((char16_t)0x0061)
+#define LOW_B ((char16_t)0x0062)
+#define LOW_C ((char16_t)0x0063)
+#define LOW_D ((char16_t)0x0064)
+#define LOW_E ((char16_t)0x0065)
+#define LOW_F ((char16_t)0x0066)
+#define LOW_G ((char16_t)0x0067)
+#define LOW_H ((char16_t)0x0068)
+#define LOW_I ((char16_t)0x0069)
+#define LOW_J ((char16_t)0x006A)
+#define LOW_K ((char16_t)0x006B)
+#define LOW_L ((char16_t)0x006C)
+#define LOW_M ((char16_t)0x006D)
+#define LOW_N ((char16_t)0x006E)
+#define LOW_O ((char16_t)0x006F)
+#define LOW_P ((char16_t)0x0070)
+#define LOW_Q ((char16_t)0x0071)
+#define LOW_R ((char16_t)0x0072)
+#define LOW_S ((char16_t)0x0073)
+#define LOW_T ((char16_t)0x0074)
+#define LOW_U ((char16_t)0x0075)
+#define LOW_V ((char16_t)0x0076)
+#define LOW_W ((char16_t)0x0077)
+#define LOW_X ((char16_t)0x0078)
+#define LOW_Y ((char16_t)0x0079)
+#define LOW_Z ((char16_t)0x007A)
#define DT_NARROW -0x101
#define DT_SHORTER -0x102
#define DT_SHORT -0x103
}dtStrEnum;
typedef struct dtTypeElem {
- UChar patternChar;
+ char16_t patternChar;
UDateTimePatternField field;
int16_t type;
int16_t minLen;
void clear();
void copyFrom(const SkeletonFields& other);
void clearField(int32_t field);
- UChar getFieldChar(int32_t field) const;
+ char16_t getFieldChar(int32_t field) const;
int32_t getFieldLength(int32_t field) const;
void populate(int32_t field, const UnicodeString& value);
- void populate(int32_t field, UChar repeatChar, int32_t repeatCount);
+ void populate(int32_t field, char16_t repeatChar, int32_t repeatCount);
UBool isFieldEmpty(int32_t field) const;
UnicodeString& appendTo(UnicodeString& string) const;
UnicodeString& appendFieldTo(int32_t field, UnicodeString& string) const;
- UChar getFirstChar() const;
+ char16_t getFirstChar() const;
inline bool operator==(const SkeletonFields& other) const;
inline bool operator!=(const SkeletonFields& other) const;
UBool equals(const PtnSkeleton& other) const;
UnicodeString getSkeleton() const;
UnicodeString getBaseSkeleton() const;
- UChar getFirstChar() const;
+ char16_t getFirstChar() const;
// TODO: Why is this virtual, as well as the other destructors in this file? We don't want
// vtables when we don't use class objects polymorphically.
const UnicodeString* getPatternFromBasePattern(const UnicodeString& basePattern, UBool& skeletonWasSpecified) const;
const UnicodeString* getPatternFromSkeleton(const PtnSkeleton& skeleton, const PtnSkeleton** specifiedSkeletonPtr = 0) const;
void copyFrom(const PatternMap& other, UErrorCode& status);
- PtnElem* getHeader(UChar baseChar) const;
+ PtnElem* getHeader(char16_t baseChar) const;
UBool equals(const PatternMap& other) const;
private:
UBool isDupAllowed;
static const int32_t MAX_INT32 = 0x7FFFFFFF;
static const int32_t MIN_INT32 = 0xFFFFFFFF;
-static const UChar VAL_FALSE[] = {0x66, 0x61, 0x6c, 0x73, 0x65}; // "false"
-static const UChar VAL_FALSE_LEN = 5;
+static const char16_t VAL_FALSE[] = {0x66, 0x61, 0x6c, 0x73, 0x65}; // "false"
+static const char16_t VAL_FALSE_LEN = 5;
static UBool isSet(int startDate) {
return startDate != 0;
}
startDates[eraIdx] = encodeDate(fields[0], fields[1], fields[2]);
} else if (uprv_strcmp(key, "named") == 0) {
- const UChar *val = ures_getString(res.getAlias(), &len, &status);
+ const char16_t *val = ures_getString(res.getAlias(), &len, &status);
if (u_strncmp(val, VAL_FALSE, VAL_FALSE_LEN) == 0) {
hasName = false;
}
U_NAMESPACE_BEGIN
-static const UChar UNIPRE[] = {85,43,0}; // "U+"
-static const UChar BS_u[] = {92,117,0}; // "\\u"
-static const UChar BS_U[] = {92,85,0}; // "\\U"
-static const UChar XMLPRE[] = {38,35,120,0}; // "&#x"
-static const UChar XML10PRE[] = {38,35,0}; // "&#"
-static const UChar PERLPRE[] = {92,120,123,0}; // "\\x{"
-static const UChar SEMI[] = {59,0}; // ";"
-static const UChar RBRACE[] = {125,0}; // "}"
+static const char16_t UNIPRE[] = {85,43,0}; // "U+"
+static const char16_t BS_u[] = {92,117,0}; // "\\u"
+static const char16_t BS_U[] = {92,85,0}; // "\\U"
+static const char16_t XMLPRE[] = {38,35,120,0}; // "&#x"
+static const char16_t XML10PRE[] = {38,35,0}; // "&#"
+static const char16_t PERLPRE[] = {92,120,123,0}; // "\\x{"
+static const char16_t SEMI[] = {59,0}; // ";"
+static const char16_t RBRACE[] = {125,0}; // "}"
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(EscapeTransliterator)
return ret;
}
-U_CAPI const UChar* U_EXPORT2
+U_CAPI const char16_t* U_EXPORT2
ufmt_getUChars(UFormattable *fmt, int32_t *len, UErrorCode *status) {
Formattable *obj = Formattable::fromUFormattable(fmt);
}
-U_CAPI const UChar* U_EXPORT2
+U_CAPI const char16_t* U_EXPORT2
ufmtval_getString(
const UFormattedValue* ufmtval,
int32_t* pLength,
#include "unicode/uniset.h"
#include "funcrepl.h"
-static const UChar AMPERSAND = 38; // '&'
-static const UChar OPEN[] = {40,32,0}; // "( "
-static const UChar CLOSE[] = {32,41,0}; // " )"
+static const char16_t AMPERSAND = 38; // '&'
+static const char16_t OPEN[] = {40,32,0}; // "( "
+static const char16_t CLOSE[] = {32,41,0}; // " )"
U_NAMESPACE_BEGIN
int32_t resLen = 0;
const char* curLocaleName = locale.getName();
UErrorCode key_status = U_ZERO_ERROR;
- const UChar* s = ures_getStringByKey(locRes.getAlias(), curLocaleName, &resLen, &key_status);
+ const char16_t* s = ures_getStringByKey(locRes.getAlias(), curLocaleName, &resLen, &key_status);
if (s == nullptr) {
key_status = U_ZERO_ERROR;
char parentLocaleName[ULOC_FULLNAME_CAPACITY];
#if U_PLATFORM_HAS_WINUWP_API == 1
// UWP doesn't allow access to getenv(), but we can call GetEnvironmentVariableW to do the same thing.
- UChar varName[26] = {};
+ char16_t varName[26] = {};
u_charsToUChars(TENTATIVE_ERA_VAR_NAME, varName, static_cast<int32_t>(uprv_strlen(TENTATIVE_ERA_VAR_NAME)));
WCHAR varValue[5] = {};
DWORD ret = GetEnvironmentVariableW(reinterpret_cast<WCHAR*>(varName), varValue, UPRV_LENGTHOF(varValue));
return nullptr;
}
-static const UChar solidus = 0x2F;
-static const UChar aliasPrefix[] = { 0x6C,0x69,0x73,0x74,0x50,0x61,0x74,0x74,0x65,0x72,0x6E,0x2F }; // "listPattern/"
+static const char16_t solidus = 0x2F;
+static const char16_t aliasPrefix[] = { 0x6C,0x69,0x73,0x74,0x50,0x61,0x74,0x74,0x65,0x72,0x6E,0x2F }; // "listPattern/"
enum {
kAliasPrefixLen = UPRV_LENGTHOF(aliasPrefix),
kStyleLenMax = 24 // longest currently is 14
UnicodeString &result,
UErrorCode &status) {
int32_t len = 0;
- const UChar *resStr = ures_getString(resource, &len, &status);
+ const char16_t *resStr = ures_getString(resource, &len, &status);
if (U_FAILURE(status)) {
return false;
}
getString(patternBundle.getAlias(), result, status);
// Replace 'h' with 'H'
int32_t len = result.length();
- UChar *buffer = result.getBuffer(len);
+ char16_t *buffer = result.getBuffer(len);
for (int32_t i = 0; i < len; ++i) {
if (buffer[i] == 0x68) { // 'h'
buffer[i] = 0x48; // 'H'
const Formattable& amtNumber = measure.getNumber();
const MeasureUnit& amtUnit = measure.getUnit();
if (isCurrency(amtUnit)) {
- UChar isoCode[4];
+ char16_t isoCode[4];
u_charsToUChars(amtUnit.getSubtype(), isoCode, 4);
return cache->getCurrencyFormat(fWidth)->format(
new CurrencyAmount(amtNumber, isoCode, status),
break;
}
int32_t len;
- const UChar* uTarget = value.getString(len, status);
+ const char16_t* uTarget = value.getString(len, status);
CharString target;
target.appendInvariantChars(uTarget, len, status);
if (U_FAILURE(status)) { return; }
*
* For example: "kilogram" -> "mass", "meter-per-second" -> "speed".
*
- * In C++ unitQuantity values are collected in order into a UChar* array, while
+ * In C++ unitQuantity values are collected in order into a char16_t* array, while
* unitQuantity keys are added added to a TrieBuilder, with associated values
- * being the index into the aforementioned UChar* array.
+ * being the index into the aforementioned char16_t* array.
*/
class CategoriesSink : public icu::ResourceSink {
public:
/**
* Constructor.
- * @param out Array of UChar* to which unitQuantity values will be saved.
+ * @param out Array of char16_t* to which unitQuantity values will be saved.
* The pointers returned not owned: they point directly at the resource
* strings in static memory.
* @param outSize The size of the `out` array.
* each unitQuantity will be added, each with value being the offset
* into `out`.
*/
- explicit CategoriesSink(const UChar **out, int32_t &outSize, BytesTrieBuilder &trieBuilder)
+ explicit CategoriesSink(const char16_t **out, int32_t &outSize, BytesTrieBuilder &trieBuilder)
: outQuantitiesArray(out), outSize(outSize), trieBuilder(trieBuilder), outIndex(0) {}
void put(const char * /*key*/, ResourceValue &value, UBool /*noFallback*/, UErrorCode &status) override {
}
private:
- const UChar **outQuantitiesArray;
+ const char16_t **outQuantitiesArray;
int32_t &outSize;
BytesTrieBuilder &trieBuilder;
char *gSerializedUnitExtrasStemTrie = nullptr;
-// Array of UChar* pointing at the unit categories (aka "quantities", aka
+// Array of char16_t* pointing at the unit categories (aka "quantities", aka
// "types"), as found in the `unitQuantities` resource. The array memory itself
-// is owned by this pointer, but the individual UChar* in that array point at
+// is owned by this pointer, but the individual char16_t* in that array point at
// static memory.
-const UChar **gCategories = nullptr;
+const char16_t **gCategories = nullptr;
// Number of items in `gCategories`.
int32_t gCategoriesCount = 0;
// Serialized BytesTrie for mapping from base units to indices into gCategories.
ures_getByKey(unitsBundle.getAlias(), CATEGORY_TABLE_NAME, nullptr, &status));
if (U_FAILURE(status)) { return; }
gCategoriesCount = unitQuantities.getAlias()->fSize;
- size_t quantitiesMallocSize = sizeof(UChar *) * gCategoriesCount;
- gCategories = static_cast<const UChar **>(uprv_malloc(quantitiesMallocSize));
+ size_t quantitiesMallocSize = sizeof(char16_t *) * gCategoriesCount;
+ gCategories = static_cast<const char16_t **>(uprv_malloc(quantitiesMallocSize));
if (gCategories == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
// class MessageFormat
// *****************************************************************************
-#define SINGLE_QUOTE ((UChar)0x0027)
-#define COMMA ((UChar)0x002C)
-#define LEFT_CURLY_BRACE ((UChar)0x007B)
-#define RIGHT_CURLY_BRACE ((UChar)0x007D)
+#define SINGLE_QUOTE ((char16_t)0x0027)
+#define COMMA ((char16_t)0x002C)
+#define LEFT_CURLY_BRACE ((char16_t)0x007B)
+#define RIGHT_CURLY_BRACE ((char16_t)0x007D)
//---------------------------------------
// static data
-static const UChar ID_NUMBER[] = {
+static const char16_t ID_NUMBER[] = {
0x6E, 0x75, 0x6D, 0x62, 0x65, 0x72, 0 /* "number" */
};
-static const UChar ID_DATE[] = {
+static const char16_t ID_DATE[] = {
0x64, 0x61, 0x74, 0x65, 0 /* "date" */
};
-static const UChar ID_TIME[] = {
+static const char16_t ID_TIME[] = {
0x74, 0x69, 0x6D, 0x65, 0 /* "time" */
};
-static const UChar ID_SPELLOUT[] = {
+static const char16_t ID_SPELLOUT[] = {
0x73, 0x70, 0x65, 0x6c, 0x6c, 0x6f, 0x75, 0x74, 0 /* "spellout" */
};
-static const UChar ID_ORDINAL[] = {
+static const char16_t ID_ORDINAL[] = {
0x6f, 0x72, 0x64, 0x69, 0x6e, 0x61, 0x6c, 0 /* "ordinal" */
};
-static const UChar ID_DURATION[] = {
+static const char16_t ID_DURATION[] = {
0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0 /* "duration" */
};
// MessageFormat Type List Number, Date, Time or Choice
-static const UChar * const TYPE_IDS[] = {
+static const char16_t * const TYPE_IDS[] = {
ID_NUMBER,
ID_DATE,
ID_TIME,
nullptr,
};
-static const UChar ID_EMPTY[] = {
+static const char16_t ID_EMPTY[] = {
0 /* empty string, used for default so that null can mark end of list */
};
-static const UChar ID_CURRENCY[] = {
+static const char16_t ID_CURRENCY[] = {
0x63, 0x75, 0x72, 0x72, 0x65, 0x6E, 0x63, 0x79, 0 /* "currency" */
};
-static const UChar ID_PERCENT[] = {
+static const char16_t ID_PERCENT[] = {
0x70, 0x65, 0x72, 0x63, 0x65, 0x6E, 0x74, 0 /* "percent" */
};
-static const UChar ID_INTEGER[] = {
+static const char16_t ID_INTEGER[] = {
0x69, 0x6E, 0x74, 0x65, 0x67, 0x65, 0x72, 0 /* "integer" */
};
// NumberFormat modifier list, default, currency, percent or integer
-static const UChar * const NUMBER_STYLE_IDS[] = {
+static const char16_t * const NUMBER_STYLE_IDS[] = {
ID_EMPTY,
ID_CURRENCY,
ID_PERCENT,
nullptr,
};
-static const UChar ID_SHORT[] = {
+static const char16_t ID_SHORT[] = {
0x73, 0x68, 0x6F, 0x72, 0x74, 0 /* "short" */
};
-static const UChar ID_MEDIUM[] = {
+static const char16_t ID_MEDIUM[] = {
0x6D, 0x65, 0x64, 0x69, 0x75, 0x6D, 0 /* "medium" */
};
-static const UChar ID_LONG[] = {
+static const char16_t ID_LONG[] = {
0x6C, 0x6F, 0x6E, 0x67, 0 /* "long" */
};
-static const UChar ID_FULL[] = {
+static const char16_t ID_FULL[] = {
0x66, 0x75, 0x6C, 0x6C, 0 /* "full" */
};
// DateFormat modifier list, default, short, medium, long or full
-static const UChar * const DATE_STYLE_IDS[] = {
+static const char16_t * const DATE_STYLE_IDS[] = {
ID_EMPTY,
ID_SHORT,
ID_MEDIUM,
static const int32_t DEFAULT_INITIAL_CAPACITY = 10;
-static const UChar NULL_STRING[] = {
+static const char16_t NULL_STRING[] = {
0x6E, 0x75, 0x6C, 0x6C, 0 // "null"
};
-static const UChar OTHER_STRING[] = {
+static const char16_t OTHER_STRING[] = {
0x6F, 0x74, 0x68, 0x65, 0x72, 0 // "other"
};
* the given UnicodeString.
*/
static UnicodeString& itos(int32_t i, UnicodeString& appendTo) {
- UChar temp[16];
+ char16_t temp[16];
uprv_itou(temp,16,i,10,0); // 10 == radix
appendTo.append(temp, -1);
return appendTo;
app.appendString(s.getBuffer(), s.length());
len += s.length();
}
- void append(const UChar* s, const int32_t sLength) {
+ void append(const char16_t* s, const int32_t sLength) {
app.appendString(s, sLength);
len += sLength;
}
UnicodeString result;
if (U_SUCCESS(status)) {
int32_t plen = pattern.length();
- const UChar* pat = pattern.getBuffer();
+ const char16_t* pat = pattern.getBuffer();
int32_t blen = plen * 2 + 1; // space for null termination, convenience
- UChar* buf = result.getBuffer(blen);
+ char16_t* buf = result.getBuffer(blen);
if (buf == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
} else {
//-------------------------------------
// Finds the string, s, in the string array, list.
int32_t MessageFormat::findKeyword(const UnicodeString& s,
- const UChar * const *list)
+ const char16_t * const *list)
{
if (s.isEmpty()) {
return 0; // default
}
int32_t length = s.length();
- const UChar *ps = PatternProps::trimWhiteSpace(s.getBuffer(), length);
+ const char16_t *ps = PatternProps::trimWhiteSpace(s.getBuffer(), length);
UnicodeString buffer(false, ps, length);
// Trims the space characters and turns all characters
// in s to lower case.
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(NameUnicodeTransliterator)
-static const UChar OPEN[] = {92,78,126,123,126,0}; // "\N~{~"
-static const UChar OPEN_DELIM = 92; // '\\' first char of OPEN
-static const UChar CLOSE_DELIM = 125; // '}'
-static const UChar SPACE = 32; // ' '
+static const char16_t OPEN[] = {92,78,126,123,126,0}; // "\N~{~"
+static const char16_t OPEN_DELIM = 92; // '\\' first char of OPEN
+static const char16_t CLOSE_DELIM = 125; // '}'
+static const char16_t SPACE = 32; // ' '
U_CDECL_BEGIN
}
static void U_CALLCONV
-_set_addString(USet *set, const UChar *str, int32_t length) {
+_set_addString(USet *set, const char16_t *str, int32_t length) {
((UnicodeSet *)set)->add(UnicodeString((UBool)(length<0), str, length));
}*/
}
#endif
-static const UChar gPercent = 0x0025;
-static const UChar gColon = 0x003a;
-static const UChar gSemicolon = 0x003b;
-static const UChar gLineFeed = 0x000a;
+static const char16_t gPercent = 0x0025;
+static const char16_t gColon = 0x003a;
+static const char16_t gSemicolon = 0x003b;
+static const char16_t gLineFeed = 0x000a;
-static const UChar gPercentPercent[] =
+static const char16_t gPercentPercent[] =
{
0x25, 0x25, 0
}; /* "%%" */
-static const UChar gNoparse[] =
+static const char16_t gNoparse[] =
{
0x40, 0x6E, 0x6F, 0x70, 0x61, 0x72, 0x73, 0x65, 0
}; /* "@noparse" */
0x77u, 0x78u, 0x79u, 0x7au,
};
-static const UChar kUMinus = (UChar)0x002d;
+static const char16_t kUMinus = (char16_t)0x002d;
#ifdef RBNF_DEBUG
static const char kMinus = '-';
return result;
}
-int64_t util64_utoi(const UChar* str, uint32_t radix)
+int64_t util64_utoi(const char16_t* str, uint32_t radix)
{
if (radix > 36) {
radix = 36;
neg = 1;
}
int64_t result = 0;
- UChar c;
+ char16_t c;
uint8_t b;
while (((c = *str++) < 0x0080) && (b = digitInfo[c]) && ((b &= 0x7f) < radix)) {
result *= lradix;
}
#endif
-uint32_t util64_tou(int64_t w, UChar* buf, uint32_t len, uint32_t radix, UBool raw)
+uint32_t util64_tou(int64_t w, char16_t* buf, uint32_t len, uint32_t radix, UBool raw)
{
if (radix > 36) {
radix = 36;
}
int64_t base = radix;
- UChar* p = buf;
+ char16_t* p = buf;
if (len && (w < 0) && (radix == 10) && !raw) {
w = -w;
*p++ = kUMinus;
--len;
} else if (len && (w == 0)) {
- *p++ = (UChar)raw ? 0 : asciiDigits[0];
+ *p++ = (char16_t)raw ? 0 : asciiDigits[0];
--len;
}
int64_t n = w / base;
int64_t m = n * base;
int32_t d = (int32_t)(w-m);
- *p++ = (UChar)(raw ? d : asciiDigits[d]);
+ *p++ = (char16_t)(raw ? d : asciiDigits[d]);
w = n;
--len;
}
++buf;
}
while (--p > buf) {
- UChar c = *p;
+ char16_t c = *p;
*p = *buf;
*buf = c;
++buf;
uint64_t util64_pow(uint32_t radix, uint16_t exponent);
// convert n to digit string in buffer, return length of string
-uint32_t util64_tou(int64_t n, UChar* buffer, uint32_t buflen, uint32_t radix = 10, UBool raw = false);
+uint32_t util64_tou(int64_t n, char16_t* buffer, uint32_t buflen, uint32_t radix = 10, UBool raw = false);
#ifdef RBNF_DEBUG
-int64_t util64_utoi(const UChar* str, uint32_t radix = 10);
+int64_t util64_utoi(const char16_t* str, uint32_t radix = 10);
uint32_t util64_toa(int64_t n, char* buffer, uint32_t buflen, uint32_t radix = 10, UBool raw = false);
int64_t util64_atoi(const char* str, uint32_t radix);
#endif
rulePatternFormat = nullptr;
}
-static const UChar gLeftBracket = 0x005b;
-static const UChar gRightBracket = 0x005d;
-static const UChar gColon = 0x003a;
-static const UChar gZero = 0x0030;
-static const UChar gNine = 0x0039;
-static const UChar gSpace = 0x0020;
-static const UChar gSlash = 0x002f;
-static const UChar gGreaterThan = 0x003e;
-static const UChar gLessThan = 0x003c;
-static const UChar gComma = 0x002c;
-static const UChar gDot = 0x002e;
-static const UChar gTick = 0x0027;
-//static const UChar gMinus = 0x002d;
-static const UChar gSemicolon = 0x003b;
-static const UChar gX = 0x0078;
-
-static const UChar gMinusX[] = {0x2D, 0x78, 0}; /* "-x" */
-static const UChar gInf[] = {0x49, 0x6E, 0x66, 0}; /* "Inf" */
-static const UChar gNaN[] = {0x4E, 0x61, 0x4E, 0}; /* "NaN" */
-
-static const UChar gDollarOpenParenthesis[] = {0x24, 0x28, 0}; /* "$(" */
-static const UChar gClosedParenthesisDollar[] = {0x29, 0x24, 0}; /* ")$" */
-
-static const UChar gLessLess[] = {0x3C, 0x3C, 0}; /* "<<" */
-static const UChar gLessPercent[] = {0x3C, 0x25, 0}; /* "<%" */
-static const UChar gLessHash[] = {0x3C, 0x23, 0}; /* "<#" */
-static const UChar gLessZero[] = {0x3C, 0x30, 0}; /* "<0" */
-static const UChar gGreaterGreater[] = {0x3E, 0x3E, 0}; /* ">>" */
-static const UChar gGreaterPercent[] = {0x3E, 0x25, 0}; /* ">%" */
-static const UChar gGreaterHash[] = {0x3E, 0x23, 0}; /* ">#" */
-static const UChar gGreaterZero[] = {0x3E, 0x30, 0}; /* ">0" */
-static const UChar gEqualPercent[] = {0x3D, 0x25, 0}; /* "=%" */
-static const UChar gEqualHash[] = {0x3D, 0x23, 0}; /* "=#" */
-static const UChar gEqualZero[] = {0x3D, 0x30, 0}; /* "=0" */
-static const UChar gGreaterGreaterGreater[] = {0x3E, 0x3E, 0x3E, 0}; /* ">>>" */
-
-static const UChar * const RULE_PREFIXES[] = {
+static const char16_t gLeftBracket = 0x005b;
+static const char16_t gRightBracket = 0x005d;
+static const char16_t gColon = 0x003a;
+static const char16_t gZero = 0x0030;
+static const char16_t gNine = 0x0039;
+static const char16_t gSpace = 0x0020;
+static const char16_t gSlash = 0x002f;
+static const char16_t gGreaterThan = 0x003e;
+static const char16_t gLessThan = 0x003c;
+static const char16_t gComma = 0x002c;
+static const char16_t gDot = 0x002e;
+static const char16_t gTick = 0x0027;
+//static const char16_t gMinus = 0x002d;
+static const char16_t gSemicolon = 0x003b;
+static const char16_t gX = 0x0078;
+
+static const char16_t gMinusX[] = {0x2D, 0x78, 0}; /* "-x" */
+static const char16_t gInf[] = {0x49, 0x6E, 0x66, 0}; /* "Inf" */
+static const char16_t gNaN[] = {0x4E, 0x61, 0x4E, 0}; /* "NaN" */
+
+static const char16_t gDollarOpenParenthesis[] = {0x24, 0x28, 0}; /* "$(" */
+static const char16_t gClosedParenthesisDollar[] = {0x29, 0x24, 0}; /* ")$" */
+
+static const char16_t gLessLess[] = {0x3C, 0x3C, 0}; /* "<<" */
+static const char16_t gLessPercent[] = {0x3C, 0x25, 0}; /* "<%" */
+static const char16_t gLessHash[] = {0x3C, 0x23, 0}; /* "<#" */
+static const char16_t gLessZero[] = {0x3C, 0x30, 0}; /* "<0" */
+static const char16_t gGreaterGreater[] = {0x3E, 0x3E, 0}; /* ">>" */
+static const char16_t gGreaterPercent[] = {0x3E, 0x25, 0}; /* ">%" */
+static const char16_t gGreaterHash[] = {0x3E, 0x23, 0}; /* ">#" */
+static const char16_t gGreaterZero[] = {0x3E, 0x30, 0}; /* ">0" */
+static const char16_t gEqualPercent[] = {0x3D, 0x25, 0}; /* "=%" */
+static const char16_t gEqualHash[] = {0x3D, 0x23, 0}; /* "=#" */
+static const char16_t gEqualZero[] = {0x3D, 0x30, 0}; /* "=0" */
+static const char16_t gGreaterGreaterGreater[] = {0x3E, 0x3E, 0x3E, 0}; /* ">>>" */
+
+static const char16_t * const RULE_PREFIXES[] = {
gLessLess, gLessPercent, gLessHash, gLessZero,
gGreaterGreater, gGreaterPercent,gGreaterHash, gGreaterZero,
gEqualPercent, gEqualHash, gEqualZero, nullptr
// for one of the special rules. If it does, set the base
// value to the correct identifier value
int descriptorLength = descriptor.length();
- UChar firstChar = descriptor.charAt(0);
- UChar lastChar = descriptor.charAt(descriptorLength - 1);
+ char16_t firstChar = descriptor.charAt(0);
+ char16_t lastChar = descriptor.charAt(descriptorLength - 1);
if (firstChar >= gZero && firstChar <= gNine && lastChar != gX) {
// if the rule descriptor begins with a digit, it's a descriptor
// for a normal rule
// just build up the value as we encounter the digits.
int64_t val = 0;
p = 0;
- UChar c = gSpace;
+ char16_t c = gSpace;
// begin parsing the descriptor: copy digits
// into "tempValue", skip periods, commas, and spaces,
// otherwise the substitution token ends with the same character
// it began with
} else {
- UChar c = fRuleText.charAt(subStart);
+ char16_t c = fRuleText.charAt(subStart);
subEnd = fRuleText.indexOf(c, subStart + 1);
// special case for '<%foo<<'
if (c == gLessThan && subEnd != -1 && subEnd < fRuleText.length() - 1 && fRuleText.charAt(subEnd+1) == c) {
*/
static void util_append64(UnicodeString& result, int64_t n)
{
- UChar buffer[256];
+ char16_t buffer[256];
int32_t len = util64_tou(n, buffer, sizeof(buffer));
UnicodeString temp(buffer, len);
result.append(temp);
int64_t getBaseValue() const { return baseValue; }
void setBaseValue(int64_t value, UErrorCode& status);
- UChar getDecimalPoint() const { return decimalPoint; }
+ char16_t getDecimalPoint() const { return decimalPoint; }
int64_t getDivisor() const;
int64_t baseValue;
int32_t radix;
int16_t exponent;
- UChar decimalPoint;
+ char16_t decimalPoint;
UnicodeString fRuleText;
NFSubstitution* sub1;
NFSubstitution* sub2;
#if U_HAVE_RBNF
-static const UChar gLessThan = 0x003c;
-static const UChar gEquals = 0x003d;
-static const UChar gGreaterThan = 0x003e;
-static const UChar gPercent = 0x0025;
-static const UChar gPound = 0x0023;
-static const UChar gZero = 0x0030;
-static const UChar gSpace = 0x0020;
-
-static const UChar gEqualsEquals[] =
+static const char16_t gLessThan = 0x003c;
+static const char16_t gEquals = 0x003d;
+static const char16_t gGreaterThan = 0x003e;
+static const char16_t gPercent = 0x0025;
+static const char16_t gPound = 0x0023;
+static const char16_t gZero = 0x0030;
+static const char16_t gSpace = 0x0020;
+
+static const char16_t gEqualsEquals[] =
{
0x3D, 0x3D, 0
}; /* "==" */
-static const UChar gGreaterGreaterGreaterThan[] =
+static const char16_t gGreaterGreaterGreaterThan[] =
{
0x3E, 0x3E, 0x3E, 0
}; /* ">>>" */
-static const UChar gGreaterGreaterThan[] =
+static const char16_t gGreaterGreaterThan[] =
{
0x3E, 0x3E, 0
}; /* ">>" */
virtual double transformNumber(double number) const override { return number; }
virtual double composeRuleValue(double newRuleValue, double /*oldRuleValue*/) const override { return newRuleValue; }
virtual double calcUpperBound(double oldUpperBound) const override { return oldUpperBound; }
- virtual UChar tokenChar() const override { return (UChar)0x003d; } // '='
+ virtual char16_t tokenChar() const override { return (char16_t)0x003d; } // '='
public:
static UClassID getStaticClassID(void);
virtual double calcUpperBound(double /*oldUpperBound*/) const override { return static_cast<double>(divisor); }
- virtual UChar tokenChar() const override { return (UChar)0x003c; } // '<'
+ virtual char16_t tokenChar() const override { return (char16_t)0x003c; } // '<'
public:
static UClassID getStaticClassID(void);
virtual UBool isModulusSubstitution() const override { return true; }
- virtual UChar tokenChar() const override { return (UChar)0x003e; } // '>'
+ virtual char16_t tokenChar() const override { return (char16_t)0x003e; } // '>'
virtual void toString(UnicodeString& result) const override;
virtual double transformNumber(double number) const override { return uprv_floor(number); }
virtual double composeRuleValue(double newRuleValue, double oldRuleValue) const override { return newRuleValue + oldRuleValue; }
virtual double calcUpperBound(double /*oldUpperBound*/) const override { return DBL_MAX; }
- virtual UChar tokenChar() const override { return (UChar)0x003c; } // '<'
+ virtual char16_t tokenChar() const override { return (char16_t)0x003c; } // '<'
public:
static UClassID getStaticClassID(void);
virtual double composeRuleValue(double newRuleValue, double oldRuleValue) const override { return newRuleValue + oldRuleValue; }
virtual double calcUpperBound(double /*oldUpperBound*/) const override { return 0.0; }
- virtual UChar tokenChar() const override { return (UChar)0x003e; } // '>'
+ virtual char16_t tokenChar() const override { return (char16_t)0x003e; } // '>'
public:
static UClassID getStaticClassID(void);
virtual double transformNumber(double number) const override { return uprv_fabs(number); }
virtual double composeRuleValue(double newRuleValue, double /*oldRuleValue*/) const override { return -newRuleValue; }
virtual double calcUpperBound(double /*oldUpperBound*/) const override { return DBL_MAX; }
- virtual UChar tokenChar() const override { return (UChar)0x003e; } // '>'
+ virtual char16_t tokenChar() const override { return (char16_t)0x003e; } // '>'
public:
static UClassID getStaticClassID(void);
virtual double composeRuleValue(double newRuleValue, double oldRuleValue) const override { return newRuleValue / oldRuleValue; }
virtual double calcUpperBound(double /*oldUpperBound*/) const override { return denominator; }
- virtual UChar tokenChar() const override { return (UChar)0x003c; } // '<'
+ virtual char16_t tokenChar() const override { return (char16_t)0x003c; } // '<'
private:
- static const UChar LTLT[2];
+ static const char16_t LTLT[2];
public:
static UClassID getStaticClassID(void);
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(NumeratorSubstitution)
-const UChar NumeratorSubstitution::LTLT[] = { 0x003c, 0x003c };
+const char16_t NumeratorSubstitution::LTLT[] = { 0x003c, 0x003c };
U_NAMESPACE_END
* substitutions of this type. Used by toString().
* @return This substitution's token character.
*/
- virtual UChar tokenChar() const = 0;
+ virtual char16_t tokenChar() const = 0;
/**
* Returns true if this is a modulus substitution. (We didn't do this
U_CAPI UNumberFormatter* U_EXPORT2
-unumf_openForSkeletonAndLocale(const UChar* skeleton, int32_t skeletonLen, const char* locale,
+unumf_openForSkeletonAndLocale(const char16_t* skeleton, int32_t skeletonLen, const char* locale,
UErrorCode* ec) {
auto* impl = new UNumberFormatterData();
if (impl == nullptr) {
}
U_CAPI UNumberFormatter* U_EXPORT2
-unumf_openForSkeletonAndLocaleWithError(const UChar* skeleton, int32_t skeletonLen, const char* locale,
+unumf_openForSkeletonAndLocaleWithError(const char16_t* skeleton, int32_t skeletonLen, const char* locale,
UParseError* perror, UErrorCode* ec) {
auto* impl = new UNumberFormatterData();
if (impl == nullptr) {
}
U_CAPI int32_t U_EXPORT2
-unumf_resultToString(const UFormattedNumber* uresult, UChar* buffer, int32_t bufferCapacity,
+unumf_resultToString(const UFormattedNumber* uresult, char16_t* buffer, int32_t bufferCapacity,
UErrorCode* ec) {
const auto* result = UFormattedNumberApiHelper::validate(uresult, *ec);
if (U_FAILURE(*ec)) { return 0; }
// A dummy object used when a "0" compact decimal entry is encountered. This is necessary
// in order to prevent falling back to root. Object equality ("==") is intended.
-const UChar *USE_FALLBACK = u"<USE FALLBACK>";
+const char16_t *USE_FALLBACK = u"<USE FALLBACK>";
/** Produces a string like "NumberElements/latn/patternsShort/decimalFormat". */
void getResourceBundleKey(const char *nsName, CompactStyle compactStyle, CompactType compactType,
return magnitude * StandardPlural::COUNT + plural;
}
-int32_t countZeros(const UChar *patternString, int32_t patternLength) {
+int32_t countZeros(const char16_t *patternString, int32_t patternLength) {
// NOTE: This strategy for computing the number of zeros is a hack for efficiency.
// It could break if there are any 0s that aren't part of the main pattern.
int32_t numZeros = 0;
return multipliers[magnitude];
}
-const UChar *CompactData::getPattern(
+const char16_t *CompactData::getPattern(
int32_t magnitude,
const PluralRules *rules,
const DecimalQuantity &dq) const {
if (magnitude > largestMagnitude) {
magnitude = largestMagnitude;
}
- const UChar *patternString = nullptr;
+ const char16_t *patternString = nullptr;
if (dq.hasIntegerValue()) {
int64_t i = dq.toLong(true);
if (i == 0) {
// Insert pattern into the UVector if the UVector does not already contain the pattern.
// Search the UVector from the end since identical patterns are likely to be adjacent.
for (int32_t i = output.size() - 1; i >= 0; i--) {
- if (u_strcmp(pattern, static_cast<const UChar *>(output[i])) == 0) {
+ if (u_strcmp(pattern, static_cast<const char16_t *>(output[i])) == 0) {
goto continue_outer;
}
}
// The string was not found; add it to the UVector.
// Note: must cast off const from pattern to store it in a UVector, which expects (void *)
- output.addElement(const_cast<UChar *>(pattern), status);
+ output.addElement(const_cast<char16_t *>(pattern), status);
continue_outer:
continue;
// The value "0" means that we need to use the default pattern and not fall back
// to parent locales. Example locale where this is relevant: 'it'.
int32_t patternLength;
- const UChar *patternString = value.getString(patternLength, status);
+ const char16_t *patternString = value.getString(patternLength, status);
if (U_FAILURE(status)) { return; }
if (u_strcmp(patternString, u"0") == 0) {
patternString = USE_FALLBACK;
}
for (int32_t i = 0; i < precomputedModsLength; i++) {
- auto patternString = static_cast<const UChar *>(allPatterns[i]);
+ auto patternString = static_cast<const char16_t *>(allPatterns[i]);
UnicodeString hello(patternString);
CompactModInfo &info = precomputedMods[i];
ParsedPatternInfo patternInfo;
magnitude -= multiplier;
}
- const UChar *patternString = data.getPattern(magnitude, rules, quantity);
+ const char16_t *patternString = data.getPattern(magnitude, rules, quantity);
if (patternString == nullptr) {
// Use the default (non-compact) modifier.
// No need to take any action.
int32_t getMultiplier(int32_t magnitude) const U_OVERRIDE;
- const UChar *getPattern(
+ const char16_t *getPattern(
int32_t magnitude,
const PluralRules *rules,
const DecimalQuantity &dq) const;
void getUniquePatterns(UVector &output, UErrorCode &status) const;
private:
- const UChar *patterns[(COMPACT_MAX_DIGITS + 1) * StandardPlural::COUNT];
+ const char16_t *patterns[(COMPACT_MAX_DIGITS + 1) * StandardPlural::COUNT];
int8_t multipliers[COMPACT_MAX_DIGITS + 1];
int8_t largestMagnitude;
UBool isEmpty;
struct CompactModInfo {
const ImmutablePatternModifier *mod;
- const UChar* patternString;
+ const char16_t* patternString;
};
class CompactHandler : public MicroPropsGenerator, public UMemory {
void extractCorePattern(const UnicodeString &pattern,
UnicodeString &coreUnit,
PlaceholderPosition &placeholderPosition,
- UChar &joinerChar) {
+ char16_t &joinerChar) {
joinerChar = 0;
int32_t len = pattern.length();
if (pattern.startsWith(u"{0}", 3)) {
UErrorCode localStatus = status;
int32_t resultLen = 0;
- const UChar *result =
+ const char16_t *result =
ures_getStringByKeyWithFallback(unitsBundle.getAlias(), key.data(), &resultLen, &localStatus);
if (U_SUCCESS(localStatus)) {
status = localStatus;
UErrorCode localStatus = status;
int32_t len = 0;
- const UChar *ptr =
+ const char16_t *ptr =
ures_getStringByKeyWithFallback(unitsBundle.getAlias(), key.data(), &len, &localStatus);
if (U_FAILURE(localStatus) && width != UNUM_UNIT_WIDTH_SHORT) {
// Fall back to short, which contains more compound data
////////////////////////
// TODO: promote this somewhere? It's based on patternprops.cpp' trimWhitespace
-const UChar *trimSpaceChars(const UChar *s, int32_t &length) {
+const char16_t *trimSpaceChars(const char16_t *s, int32_t &length) {
if (length <= 0 || (!u_isJavaSpaceChar(s[0]) && !u_isJavaSpaceChar(s[length - 1]))) {
return s;
}
}
UnicodeString denominatorPattern = denominatorFormatter.getTextWithNoArguments();
int32_t trimmedLen = denominatorPattern.length();
- const UChar *trimmed = trimSpaceChars(denominatorPattern.getBuffer(), trimmedLen);
+ const char16_t *trimmed = trimSpaceChars(denominatorPattern.getBuffer(), trimmedLen);
UnicodeString denominatorString(false, trimmed, trimmedLen);
// 9. If the denominatorString is empty, set result to
// [numeratorString], otherwise set result to format(perPattern,
}
PlaceholderPosition globalPlaceholder[ARRAY_LENGTH];
- UChar globalJoinerChar = 0;
+ char16_t globalJoinerChar = 0;
// Numbered list items are from the algorithms at
// https://unicode.org/reports/tr35/tr35-general.html#compound-units:
//
// 4.6. Extract(corePattern, coreUnit, placeholder, placeholderPosition) from that pattern.
UnicodeString coreUnit;
PlaceholderPosition placeholderPosition;
- UChar joinerChar;
+ char16_t joinerChar;
extractCorePattern(getWithPlural(singleUnitArray, plural, status), coreUnit,
placeholderPosition, joinerChar);
UnicodeString result;
int state = 0;
for (int offset = 0; offset < input.length(); offset++) {
- UChar ch = input.charAt(offset);
+ char16_t ch = input.charAt(offset);
// Handle a quote character (state shift)
if (ch == u'\'') {
void number::impl::parseIncrementOption(const StringSegment &segment,
Precision &outPrecision,
UErrorCode &status) {
- // Need to do char <-> UChar conversion...
+ // Need to do char <-> char16_t conversion...
U_ASSERT(U_SUCCESS(status));
CharString buffer;
SKELETON_UCHAR_TO_CHAR(buffer, segment.toTempUnicodeString(), 0, segment.length(), status);
status = U_NUMBER_SKELETON_SYNTAX_ERROR;
return;
}
- const UChar* currencyCode = segment.toTempUnicodeString().getBuffer();
+ const char16_t* currencyCode = segment.toTempUnicodeString().getBuffer();
UErrorCode localStatus = U_ZERO_ERROR;
CurrencyUnit currency(currencyCode, localStatus);
if (U_FAILURE(localStatus)) {
return;
}
- // Need to do char <-> UChar conversion...
+ // Need to do char <-> char16_t conversion...
CharString type;
SKELETON_UCHAR_TO_CHAR(type, stemString, 0, firstHyphen, status);
CharString subType;
void blueprint_helpers::parseIdentifierUnitOption(const StringSegment& segment, MacroProps& macros,
UErrorCode& status) {
- // Need to do char <-> UChar conversion...
+ // Need to do char <-> char16_t conversion...
U_ASSERT(U_SUCCESS(status));
CharString buffer;
SKELETON_UCHAR_TO_CHAR(buffer, segment.toTempUnicodeString(), 0, segment.length(), status);
void blueprint_helpers::parseUnitUsageOption(const StringSegment &segment, MacroProps ¯os,
UErrorCode &status) {
- // Need to do char <-> UChar conversion...
+ // Need to do char <-> char16_t conversion...
U_ASSERT(U_SUCCESS(status));
CharString buffer;
SKELETON_UCHAR_TO_CHAR(buffer, segment.toTempUnicodeString(), 0, segment.length(), status);
void blueprint_helpers::parseNumberingSystemOption(const StringSegment& segment, MacroProps& macros,
UErrorCode& status) {
- // Need to do char <-> UChar conversion...
+ // Need to do char <-> char16_t conversion...
U_ASSERT(U_SUCCESS(status));
CharString buffer;
SKELETON_UCHAR_TO_CHAR(buffer, segment.toTempUnicodeString(), 0, segment.length(), status);
void blueprint_helpers::generateNumberingSystemOption(const NumberingSystem& ns, UnicodeString& sb,
UErrorCode&) {
- // Need to do char <-> UChar conversion...
+ // Need to do char <-> char16_t conversion...
sb.append(UnicodeString(ns.getName(), -1, US_INV));
}
void blueprint_helpers::parseScaleOption(const StringSegment& segment, MacroProps& macros,
UErrorCode& status) {
- // Need to do char <-> UChar conversion...
+ // Need to do char <-> char16_t conversion...
U_ASSERT(U_SUCCESS(status));
CharString buffer;
SKELETON_UCHAR_TO_CHAR(buffer, segment.toTempUnicodeString(), 0, segment.length(), status);
// If no number pattern can be located for a locale, this is the last
// resort. The patterns are same as the ones in root locale.
-static const UChar gLastResortDecimalPat[] = {
+static const char16_t gLastResortDecimalPat[] = {
0x23, 0x2C, 0x23, 0x23, 0x30, 0x2E, 0x23, 0x23, 0x23, 0 /* "#,##0.###" */
};
-static const UChar gLastResortCurrencyPat[] = {
+static const char16_t gLastResortCurrencyPat[] = {
0xA4, 0xA0, 0x23, 0x2C, 0x23, 0x23, 0x30, 0x2E, 0x30, 0x30, 0 /* "\u00A4\u00A0#,##0.00" */
};
-static const UChar gLastResortPercentPat[] = {
+static const char16_t gLastResortPercentPat[] = {
0x23, 0x2C, 0x23, 0x23, 0x30, 0x25, 0 /* "#,##0%" */
};
-static const UChar gLastResortScientificPat[] = {
+static const char16_t gLastResortScientificPat[] = {
0x23, 0x45, 0x30, 0 /* "#E0" */
};
-static const UChar gLastResortIsoCurrencyPat[] = {
+static const char16_t gLastResortIsoCurrencyPat[] = {
0xA4, 0xA4, 0xA0, 0x23, 0x2C, 0x23, 0x23, 0x30, 0x2E, 0x30, 0x30, 0 /* "\u00A4\u00A4\u00A0#,##0.00" */
};
-static const UChar gLastResortPluralCurrencyPat[] = {
+static const char16_t gLastResortPluralCurrencyPat[] = {
0x23, 0x2C, 0x23, 0x23, 0x30, 0x2E, 0x23, 0x23, 0x23, 0x20, 0xA4, 0xA4, 0xA4, 0 /* "#,##0.### \u00A4\u00A4\u00A4*/
};
-static const UChar gLastResortAccountingCurrencyPat[] = {
+static const char16_t gLastResortAccountingCurrencyPat[] = {
0xA4, 0xA0, 0x23, 0x2C, 0x23, 0x23, 0x30, 0x2E, 0x30, 0x30, 0 /* "\u00A4\u00A0#,##0.00" */
};
-static const UChar gSingleCurrencySign[] = {0xA4, 0};
-static const UChar gDoubleCurrencySign[] = {0xA4, 0xA4, 0};
+static const char16_t gSingleCurrencySign[] = {0xA4, 0};
+static const char16_t gDoubleCurrencySign[] = {0xA4, 0xA4, 0};
-static const UChar gSlash = 0x2f;
+static const char16_t gSlash = 0x2f;
// If the maximum base 10 exponent were 4, then the largest number would
// be 99,999 which has 5 digits.
const int32_t icu::NumberFormat::gDefaultMaxIntegerDigits = 2000000000;
const int32_t icu::NumberFormat::gDefaultMinIntegerDigits = 127;
-static const UChar * const gLastResortNumberPatterns[UNUM_FORMAT_STYLE_COUNT] = {
+static const char16_t * const gLastResortNumberPatterns[UNUM_FORMAT_STYLE_COUNT] = {
nullptr, // UNUM_PATTERN_DECIMAL
gLastResortDecimalPat, // UNUM_DECIMAL
gLastResortCurrencyPat, // UNUM_CURRENCY
*/
class ArgExtractor {
const Formattable* num;
- UChar save[4];
+ char16_t save[4];
UBool fWasCurrency;
public:
~ArgExtractor();
const Formattable* number(void) const;
- const UChar *iso(void) const;
+ const char16_t *iso(void) const;
UBool wasCurrency(void) const;
};
return fWasCurrency;
}
-inline const UChar *
+inline const char16_t *
ArgExtractor::iso(void) const {
return save;
}
if (o != nullptr && (amt = dynamic_cast<const CurrencyAmount*>(o)) != nullptr) {
// getISOCurrency() returns a pointer to internal storage, so we
// copy it to retain it across the call to setCurrency().
- //const UChar* curr = amt->getISOCurrency();
+ //const char16_t* curr = amt->getISOCurrency();
u_strcpy(save, amt->getISOCurrency());
num = &amt->getNumber();
fWasCurrency=true;
ArgExtractor arg(*this, obj, status);
const Formattable *n = arg.number();
- const UChar *iso = arg.iso();
+ const char16_t *iso = arg.iso();
if(arg.wasCurrency() && u_strcmp(iso, getCurrency())) {
// trying to format a different currency.
ArgExtractor arg(*this, obj, status);
const Formattable *n = arg.number();
- const UChar *iso = arg.iso();
+ const char16_t *iso = arg.iso();
if(arg.wasCurrency() && u_strcmp(iso, getCurrency())) {
// trying to format a different currency.
int32_t start = pos.getIndex();
parse(text, parseResult, pos);
if (pos.getIndex() != start) {
- UChar curr[4];
+ char16_t curr[4];
UErrorCode ec = U_ZERO_ERROR;
getEffectiveCurrency(curr, ec);
if (U_SUCCESS(ec)) {
// -------------------------------------
-void NumberFormat::setCurrency(const UChar* theCurrency, UErrorCode& ec) {
+void NumberFormat::setCurrency(const char16_t* theCurrency, UErrorCode& ec) {
if (U_FAILURE(ec)) {
return;
}
return fCurrency;
}
-void NumberFormat::getEffectiveCurrency(UChar* result, UErrorCode& ec) const {
- const UChar* c = getCurrency();
+void NumberFormat::getEffectiveCurrency(char16_t* result, UErrorCode& ec) const {
+ const char16_t* c = getCurrency();
if (*c != 0) {
u_strncpy(result, c, 3);
result[3] = 0;
}
if(style==UNUM_CURRENCY || style == UNUM_CURRENCY_ISO || style == UNUM_CURRENCY_ACCOUNTING
|| style == UNUM_CASH_CURRENCY || style == UNUM_CURRENCY_STANDARD){
- const UChar* currPattern = symbolsToAdopt->getCurrencyPattern();
+ const char16_t* currPattern = symbolsToAdopt->getCurrencyPattern();
if(currPattern!=nullptr){
pattern.setTo(currPattern, u_strlen(currPattern));
}
// Note: These need to be outside of the numparse::impl namespace, or Clang will generate a compile error.
#if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN
template class U_I18N_API MaybeStackArray<numparse::impl::CodePointMatcher*, 8>;
-template class U_I18N_API MaybeStackArray<UChar, 4>;
+template class U_I18N_API MaybeStackArray<char16_t, 4>;
template class U_I18N_API MemoryPool<numparse::impl::CodePointMatcher, 8>;
template class U_I18N_API numparse::impl::CompactUnicodeString<4>;
#endif
UnicodeString toString() const override;
private:
- UChar fCurrencyCode[4];
+ char16_t fCurrencyCode[4];
UnicodeString fCurrency1;
UnicodeString fCurrency2;
CompactUnicodeString(const UnicodeString& text, UErrorCode& status)
: fBuffer(text.length() + 1, status) {
if (U_FAILURE(status)) { return; }
- uprv_memcpy(fBuffer.getAlias(), text.getBuffer(), sizeof(UChar) * text.length());
+ uprv_memcpy(fBuffer.getAlias(), text.getBuffer(), sizeof(char16_t) * text.length());
fBuffer[text.length()] = 0;
}
}
private:
- MaybeStackArray<UChar, stackCapacity> fBuffer;
+ MaybeStackArray<char16_t, stackCapacity> fBuffer;
};
/**
* The currency that got consumed.
*/
- UChar currencyCode[4];
+ char16_t currencyCode[4];
ParsedNumber();
}
}
-inline static void copyCurrencyCode(UChar* dest, const UChar* src) {
- uprv_memcpy(dest, src, sizeof(UChar) * 3);
+inline static void copyCurrencyCode(char16_t* dest, const char16_t* src) {
+ uprv_memcpy(dest, src, sizeof(char16_t) * 3);
dest[3] = 0;
}
U_CAPI UNumberRangeFormatter* U_EXPORT2
unumrf_openForSkeletonWithCollapseAndIdentityFallback(
- const UChar* skeleton,
+ const char16_t* skeleton,
int32_t skeletonLen,
UNumberRangeCollapse collapse,
UNumberRangeIdentityFallback identityFallback,
while (!nsResolved) {
localStatus = U_ZERO_ERROR;
count = 0;
- const UChar *nsName = ures_getStringByKeyWithFallback(numberElementsRes.getAlias(), buffer, &count, &localStatus);
+ const char16_t *nsName = ures_getStringByKeyWithFallback(numberElementsRes.getAlias(), buffer, &count, &localStatus);
// Don't stomp on the catastrophic failure of OOM.
if (localStatus == U_MEMORY_ALLOCATION_ERROR) {
status = U_MEMORY_ALLOCATION_ERROR;
// Process final rule and data, if any
if (U_SUCCESS(ec)) {
- const UChar *ruleIdUStr = ures_getStringByKey(res, kFINALRULE, &len, &ec);
+ const char16_t *ruleIdUStr = ures_getStringByKey(res, kFINALRULE, &len, &ec);
ures_getByKey(res, kFINALRAW, r.getAlias(), &ec);
int32_t ruleRaw = ures_getInt(r.getAlias(), &ec);
ures_getByKey(res, kFINALYEAR, r.getAlias(), &ec);
* Internal API returning the canonical ID of this zone.
* This ID won't be affected by setID().
*/
- const UChar *getCanonicalID() const;
+ const char16_t *getCanonicalID() const;
private:
/**
/*
* Canonical (CLDR) ID of this zone
*/
- const UChar *canonicalID;
+ const char16_t *canonicalID;
/* BasicTimeZone support */
void clearTransitionRules(void);
return typeOffsets[1];
}
-inline const UChar*
+inline const char16_t*
OlsonTimeZone::getCanonicalID() const {
return canonicalID;
}
int32_t setLen;
// Not all languages are covered: fail gracefully
UErrorCode internalStatus = U_ZERO_ERROR;
- const UChar* set = ures_getStringByKeyWithFallback(rb.getAlias(), dataPath.data(), &setLen, &internalStatus);
+ const char16_t* set = ures_getStringByKeyWithFallback(rb.getAlias(), dataPath.data(), &setLen, &internalStatus);
if (U_FAILURE(internalStatus)) { return; }
dataPath.clear();
using number::impl::DecimalQuantity;
-static const UChar OTHER_STRING[] = {
+static const char16_t OTHER_STRING[] = {
0x6F, 0x74, 0x68, 0x65, 0x72, 0 // "other"
};
using icu::number::impl::DecimalQuantity;
using icu::number::impl::RoundingMode;
-static const UChar PLURAL_KEYWORD_OTHER[]={LOW_O,LOW_T,LOW_H,LOW_E,LOW_R,0};
-static const UChar PLURAL_DEFAULT_RULE[]={LOW_O,LOW_T,LOW_H,LOW_E,LOW_R,COLON,SPACE,LOW_N,0};
-static const UChar PK_IN[]={LOW_I,LOW_N,0};
-static const UChar PK_NOT[]={LOW_N,LOW_O,LOW_T,0};
-static const UChar PK_IS[]={LOW_I,LOW_S,0};
-static const UChar PK_MOD[]={LOW_M,LOW_O,LOW_D,0};
-static const UChar PK_AND[]={LOW_A,LOW_N,LOW_D,0};
-static const UChar PK_OR[]={LOW_O,LOW_R,0};
-static const UChar PK_VAR_N[]={LOW_N,0};
-static const UChar PK_VAR_I[]={LOW_I,0};
-static const UChar PK_VAR_F[]={LOW_F,0};
-static const UChar PK_VAR_T[]={LOW_T,0};
-static const UChar PK_VAR_E[]={LOW_E,0};
-static const UChar PK_VAR_C[]={LOW_C,0};
-static const UChar PK_VAR_V[]={LOW_V,0};
-static const UChar PK_WITHIN[]={LOW_W,LOW_I,LOW_T,LOW_H,LOW_I,LOW_N,0};
-static const UChar PK_DECIMAL[]={LOW_D,LOW_E,LOW_C,LOW_I,LOW_M,LOW_A,LOW_L,0};
-static const UChar PK_INTEGER[]={LOW_I,LOW_N,LOW_T,LOW_E,LOW_G,LOW_E,LOW_R,0};
+static const char16_t PLURAL_KEYWORD_OTHER[]={LOW_O,LOW_T,LOW_H,LOW_E,LOW_R,0};
+static const char16_t PLURAL_DEFAULT_RULE[]={LOW_O,LOW_T,LOW_H,LOW_E,LOW_R,COLON,SPACE,LOW_N,0};
+static const char16_t PK_IN[]={LOW_I,LOW_N,0};
+static const char16_t PK_NOT[]={LOW_N,LOW_O,LOW_T,0};
+static const char16_t PK_IS[]={LOW_I,LOW_S,0};
+static const char16_t PK_MOD[]={LOW_M,LOW_O,LOW_D,0};
+static const char16_t PK_AND[]={LOW_A,LOW_N,LOW_D,0};
+static const char16_t PK_OR[]={LOW_O,LOW_R,0};
+static const char16_t PK_VAR_N[]={LOW_N,0};
+static const char16_t PK_VAR_I[]={LOW_I,0};
+static const char16_t PK_VAR_F[]={LOW_F,0};
+static const char16_t PK_VAR_T[]={LOW_T,0};
+static const char16_t PK_VAR_E[]={LOW_E,0};
+static const char16_t PK_VAR_C[]={LOW_C,0};
+static const char16_t PK_VAR_V[]={LOW_V,0};
+static const char16_t PK_WITHIN[]={LOW_W,LOW_I,LOW_T,LOW_H,LOW_I,LOW_N,0};
+static const char16_t PK_DECIMAL[]={LOW_D,LOW_E,LOW_C,LOW_I,LOW_M,LOW_A,LOW_L,0};
+static const char16_t PK_INTEGER[]={LOW_I,LOW_N,LOW_T,LOW_E,LOW_G,LOW_E,LOW_R,0};
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(PluralRules)
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(PluralKeywordEnumeration)
}
int32_t resLen=0;
const char *curLocaleName=locale.getBaseName();
- const UChar* s = ures_getStringByKey(locRes.getAlias(), curLocaleName, &resLen, &errCode);
+ const char16_t* s = ures_getStringByKey(locRes.getAlias(), curLocaleName, &resLen, &errCode);
if (s == nullptr) {
// Check parent locales.
void
RuleChain::dumpRules(UnicodeString& result) {
- UChar digitString[16];
+ char16_t digitString[16];
if ( ruleHeader != nullptr ) {
result += fKeyword;
return;
}
- UChar ch;
+ char16_t ch;
while (ruleIndex < ruleSrc->length()) {
ch = ruleSrc->charAt(ruleIndex);
type = charType(ch);
}
tokenType
-PluralRuleParser::charType(UChar ch) {
+PluralRuleParser::charType(char16_t ch) {
if ((ch>=U_ZERO) && (ch<=U_NINE)) {
return tNumber;
}
// TODO: Remove this and replace with u"" literals. Was for EBCDIC compatibility.
-static const UChar DOT = ((UChar) 0x002E);
-static const UChar SINGLE_QUOTE = ((UChar) 0x0027);
-static const UChar SLASH = ((UChar) 0x002F);
-static const UChar BACKSLASH = ((UChar) 0x005C);
-static const UChar SPACE = ((UChar) 0x0020);
-static const UChar EXCLAMATION = ((UChar) 0x0021);
-static const UChar QUOTATION_MARK = ((UChar) 0x0022);
-static const UChar NUMBER_SIGN = ((UChar) 0x0023);
-static const UChar PERCENT_SIGN = ((UChar) 0x0025);
-static const UChar ASTERISK = ((UChar) 0x002A);
-static const UChar COMMA = ((UChar) 0x002C);
-static const UChar HYPHEN = ((UChar) 0x002D);
-static const UChar U_ZERO = ((UChar) 0x0030);
-static const UChar U_ONE = ((UChar) 0x0031);
-static const UChar U_TWO = ((UChar) 0x0032);
-static const UChar U_THREE = ((UChar) 0x0033);
-static const UChar U_FOUR = ((UChar) 0x0034);
-static const UChar U_FIVE = ((UChar) 0x0035);
-static const UChar U_SIX = ((UChar) 0x0036);
-static const UChar U_SEVEN = ((UChar) 0x0037);
-static const UChar U_EIGHT = ((UChar) 0x0038);
-static const UChar U_NINE = ((UChar) 0x0039);
-static const UChar COLON = ((UChar) 0x003A);
-static const UChar SEMI_COLON = ((UChar) 0x003B);
-static const UChar EQUALS = ((UChar) 0x003D);
-static const UChar AT = ((UChar) 0x0040);
-static const UChar CAP_A = ((UChar) 0x0041);
-static const UChar CAP_B = ((UChar) 0x0042);
-static const UChar CAP_R = ((UChar) 0x0052);
-static const UChar CAP_Z = ((UChar) 0x005A);
-static const UChar LOWLINE = ((UChar) 0x005F);
-static const UChar LEFTBRACE = ((UChar) 0x007B);
-static const UChar RIGHTBRACE = ((UChar) 0x007D);
-static const UChar TILDE = ((UChar) 0x007E);
-static const UChar ELLIPSIS = ((UChar) 0x2026);
-
-static const UChar LOW_A = ((UChar) 0x0061);
-static const UChar LOW_B = ((UChar) 0x0062);
-static const UChar LOW_C = ((UChar) 0x0063);
-static const UChar LOW_D = ((UChar) 0x0064);
-static const UChar LOW_E = ((UChar) 0x0065);
-static const UChar LOW_F = ((UChar) 0x0066);
-static const UChar LOW_G = ((UChar) 0x0067);
-static const UChar LOW_H = ((UChar) 0x0068);
-static const UChar LOW_I = ((UChar) 0x0069);
-static const UChar LOW_J = ((UChar) 0x006a);
-static const UChar LOW_K = ((UChar) 0x006B);
-static const UChar LOW_L = ((UChar) 0x006C);
-static const UChar LOW_M = ((UChar) 0x006D);
-static const UChar LOW_N = ((UChar) 0x006E);
-static const UChar LOW_O = ((UChar) 0x006F);
-static const UChar LOW_P = ((UChar) 0x0070);
-static const UChar LOW_Q = ((UChar) 0x0071);
-static const UChar LOW_R = ((UChar) 0x0072);
-static const UChar LOW_S = ((UChar) 0x0073);
-static const UChar LOW_T = ((UChar) 0x0074);
-static const UChar LOW_U = ((UChar) 0x0075);
-static const UChar LOW_V = ((UChar) 0x0076);
-static const UChar LOW_W = ((UChar) 0x0077);
-static const UChar LOW_Y = ((UChar) 0x0079);
-static const UChar LOW_Z = ((UChar) 0x007A);
+static const char16_t DOT = ((char16_t) 0x002E);
+static const char16_t SINGLE_QUOTE = ((char16_t) 0x0027);
+static const char16_t SLASH = ((char16_t) 0x002F);
+static const char16_t BACKSLASH = ((char16_t) 0x005C);
+static const char16_t SPACE = ((char16_t) 0x0020);
+static const char16_t EXCLAMATION = ((char16_t) 0x0021);
+static const char16_t QUOTATION_MARK = ((char16_t) 0x0022);
+static const char16_t NUMBER_SIGN = ((char16_t) 0x0023);
+static const char16_t PERCENT_SIGN = ((char16_t) 0x0025);
+static const char16_t ASTERISK = ((char16_t) 0x002A);
+static const char16_t COMMA = ((char16_t) 0x002C);
+static const char16_t HYPHEN = ((char16_t) 0x002D);
+static const char16_t U_ZERO = ((char16_t) 0x0030);
+static const char16_t U_ONE = ((char16_t) 0x0031);
+static const char16_t U_TWO = ((char16_t) 0x0032);
+static const char16_t U_THREE = ((char16_t) 0x0033);
+static const char16_t U_FOUR = ((char16_t) 0x0034);
+static const char16_t U_FIVE = ((char16_t) 0x0035);
+static const char16_t U_SIX = ((char16_t) 0x0036);
+static const char16_t U_SEVEN = ((char16_t) 0x0037);
+static const char16_t U_EIGHT = ((char16_t) 0x0038);
+static const char16_t U_NINE = ((char16_t) 0x0039);
+static const char16_t COLON = ((char16_t) 0x003A);
+static const char16_t SEMI_COLON = ((char16_t) 0x003B);
+static const char16_t EQUALS = ((char16_t) 0x003D);
+static const char16_t AT = ((char16_t) 0x0040);
+static const char16_t CAP_A = ((char16_t) 0x0041);
+static const char16_t CAP_B = ((char16_t) 0x0042);
+static const char16_t CAP_R = ((char16_t) 0x0052);
+static const char16_t CAP_Z = ((char16_t) 0x005A);
+static const char16_t LOWLINE = ((char16_t) 0x005F);
+static const char16_t LEFTBRACE = ((char16_t) 0x007B);
+static const char16_t RIGHTBRACE = ((char16_t) 0x007D);
+static const char16_t TILDE = ((char16_t) 0x007E);
+static const char16_t ELLIPSIS = ((char16_t) 0x2026);
+
+static const char16_t LOW_A = ((char16_t) 0x0061);
+static const char16_t LOW_B = ((char16_t) 0x0062);
+static const char16_t LOW_C = ((char16_t) 0x0063);
+static const char16_t LOW_D = ((char16_t) 0x0064);
+static const char16_t LOW_E = ((char16_t) 0x0065);
+static const char16_t LOW_F = ((char16_t) 0x0066);
+static const char16_t LOW_G = ((char16_t) 0x0067);
+static const char16_t LOW_H = ((char16_t) 0x0068);
+static const char16_t LOW_I = ((char16_t) 0x0069);
+static const char16_t LOW_J = ((char16_t) 0x006a);
+static const char16_t LOW_K = ((char16_t) 0x006B);
+static const char16_t LOW_L = ((char16_t) 0x006C);
+static const char16_t LOW_M = ((char16_t) 0x006D);
+static const char16_t LOW_N = ((char16_t) 0x006E);
+static const char16_t LOW_O = ((char16_t) 0x006F);
+static const char16_t LOW_P = ((char16_t) 0x0070);
+static const char16_t LOW_Q = ((char16_t) 0x0071);
+static const char16_t LOW_R = ((char16_t) 0x0072);
+static const char16_t LOW_S = ((char16_t) 0x0073);
+static const char16_t LOW_T = ((char16_t) 0x0074);
+static const char16_t LOW_U = ((char16_t) 0x0075);
+static const char16_t LOW_V = ((char16_t) 0x0076);
+static const char16_t LOW_W = ((char16_t) 0x0077);
+static const char16_t LOW_Y = ((char16_t) 0x0079);
+static const char16_t LOW_Z = ((char16_t) 0x007A);
}
private:
static tokenType getKeyType(const UnicodeString& token, tokenType type);
- static tokenType charType(UChar ch);
+ static tokenType charType(char16_t ch);
static UBool isValidKeyword(const UnicodeString& token);
const UnicodeString *ruleSrc; // The rules string.
matcher->toMatcher()->toPattern(result, escapeUnprintable);
if (minCount == 0) {
if (maxCount == 1) {
- return result.append((UChar)63); /*?*/
+ return result.append((char16_t)63); /*?*/
} else if (maxCount == MAX) {
- return result.append((UChar)42); /***/
+ return result.append((char16_t)42); /***/
}
// else fall through
} else if (minCount == 1 && maxCount == MAX) {
- return result.append((UChar)43); /*+*/
+ return result.append((char16_t)43); /*+*/
}
- result.append((UChar)123); /*{*/
+ result.append((char16_t)123); /*{*/
ICU_Utility::appendNumber(result, minCount);
- result.append((UChar)44); /*,*/
+ result.append((char16_t)44); /*,*/
if (maxCount != MAX) {
ICU_Utility::appendNumber(result, maxCount);
}
- result.append((UChar)125); /*}*/
+ result.append((char16_t)125); /*}*/
return result;
}
#define U_ICUDATA_RBNF U_ICUDATA_NAME U_TREE_SEPARATOR_STRING "rbnf"
-static const UChar gPercentPercent[] =
+static const char16_t gPercentPercent[] =
{
0x25, 0x25, 0
}; /* "%%" */
// All urbnf objects are created through openRules, so we init all of the
// Unicode string constants required by rbnf, nfrs, or nfr here.
-static const UChar gLenientParse[] =
+static const char16_t gLenientParse[] =
{
0x25, 0x25, 0x6C, 0x65, 0x6E, 0x69, 0x65, 0x6E, 0x74, 0x2D, 0x70, 0x61, 0x72, 0x73, 0x65, 0x3A, 0
}; /* "%%lenient-parse:" */
-static const UChar gSemiColon = 0x003B;
-static const UChar gSemiPercent[] =
+static const char16_t gSemiColon = 0x003B;
+static const char16_t gSemiPercent[] =
{
0x3B, 0x25, 0
}; /* ";%" */
inline bool operator!=(const LocalizationInfo* rhs) const { return !operator==(rhs); }
virtual int32_t getNumberOfRuleSets(void) const = 0;
- virtual const UChar* getRuleSetName(int32_t index) const = 0;
+ virtual const char16_t* getRuleSetName(int32_t index) const = 0;
virtual int32_t getNumberOfDisplayLocales(void) const = 0;
- virtual const UChar* getLocaleName(int32_t index) const = 0;
- virtual const UChar* getDisplayName(int32_t localeIndex, int32_t ruleIndex) const = 0;
+ virtual const char16_t* getLocaleName(int32_t index) const = 0;
+ virtual const char16_t* getDisplayName(int32_t localeIndex, int32_t ruleIndex) const = 0;
- virtual int32_t indexForLocale(const UChar* locale) const;
- virtual int32_t indexForRuleSet(const UChar* ruleset) const;
+ virtual int32_t indexForLocale(const char16_t* locale) const;
+ virtual int32_t indexForRuleSet(const char16_t* ruleset) const;
// virtual UClassID getDynamicClassID() const = 0;
// static UClassID getStaticClassID(void);
// if both strings are nullptr, this returns true
static UBool
-streq(const UChar* lhs, const UChar* rhs) {
+streq(const char16_t* lhs, const char16_t* rhs) {
if (rhs == lhs) {
return true;
}
int32_t dlc = getNumberOfDisplayLocales();
if (dlc == rhs->getNumberOfDisplayLocales()) {
for (int i = 0; i < dlc; ++i) {
- const UChar* locale = getLocaleName(i);
+ const char16_t* locale = getLocaleName(i);
int32_t ix = rhs->indexForLocale(locale);
// if no locale, ix is -1, getLocaleName returns null, so streq returns false
if (!streq(locale, rhs->getLocaleName(ix))) {
}
int32_t
-LocalizationInfo::indexForLocale(const UChar* locale) const {
+LocalizationInfo::indexForLocale(const char16_t* locale) const {
for (int i = 0; i < getNumberOfDisplayLocales(); ++i) {
if (streq(locale, getLocaleName(i))) {
return i;
}
int32_t
-LocalizationInfo::indexForRuleSet(const UChar* ruleset) const {
+LocalizationInfo::indexForRuleSet(const char16_t* ruleset) const {
if (ruleset) {
for (int i = 0; i < getNumberOfRuleSets(); ++i) {
if (streq(ruleset, getRuleSetName(i))) {
class LocDataParser;
class StringLocalizationInfo : public LocalizationInfo {
- UChar* info;
- UChar*** data;
+ char16_t* info;
+ char16_t*** data;
int32_t numRuleSets;
int32_t numLocales;
friend class LocDataParser;
- StringLocalizationInfo(UChar* i, UChar*** d, int32_t numRS, int32_t numLocs)
+ StringLocalizationInfo(char16_t* i, char16_t*** d, int32_t numRS, int32_t numLocs)
: info(i), data(d), numRuleSets(numRS), numLocales(numLocs)
{
}
virtual ~StringLocalizationInfo();
virtual int32_t getNumberOfRuleSets(void) const override { return numRuleSets; }
- virtual const UChar* getRuleSetName(int32_t index) const override;
+ virtual const char16_t* getRuleSetName(int32_t index) const override;
virtual int32_t getNumberOfDisplayLocales(void) const override { return numLocales; }
- virtual const UChar* getLocaleName(int32_t index) const override;
- virtual const UChar* getDisplayName(int32_t localeIndex, int32_t ruleIndex) const override;
+ virtual const char16_t* getLocaleName(int32_t index) const override;
+ virtual const char16_t* getDisplayName(int32_t localeIndex, int32_t ruleIndex) const override;
// virtual UClassID getDynamicClassID() const;
// static UClassID getStaticClassID(void);
* Utility for parsing a localization string and returning a StringLocalizationInfo*.
*/
class LocDataParser {
- UChar* data;
- const UChar* e;
- UChar* p;
- UChar ch;
+ char16_t* data;
+ const char16_t* e;
+ char16_t* p;
+ char16_t ch;
UParseError& pe;
UErrorCode& ec;
* On a successful parse, return a StringLocalizationInfo*, otherwise delete locData, set perror and status,
* and return nullptr. The StringLocalizationInfo will adopt locData if it is created.
*/
- StringLocalizationInfo* parse(UChar* data, int32_t len);
+ StringLocalizationInfo* parse(char16_t* data, int32_t len);
private:
++p;
ch = 0xffff;
}
- inline UBool checkInc(UChar c) {
+ inline UBool checkInc(char16_t c) {
if (p < e && (ch == c || *p == c)) {
inc();
return true;
}
return false;
}
- inline UBool check(UChar c) {
+ inline UBool check(char16_t c) {
return p < e && (ch == c || *p == c);
}
inline void skipWhitespace(void) {
inc();
}
}
- inline UBool inList(UChar c, const UChar* list) const {
+ inline UBool inList(char16_t c, const char16_t* list) const {
if (*list == SPACE && PatternProps::isWhiteSpace(c)) {
return true;
}
StringLocalizationInfo* doParse(void);
- UChar** nextArray(int32_t& requiredLength);
- UChar* nextString(void);
+ char16_t** nextArray(int32_t& requiredLength);
+ char16_t* nextString(void);
};
#ifdef RBNF_DEBUG
#endif
-static const UChar DQUOTE_STOPLIST[] = {
+static const char16_t DQUOTE_STOPLIST[] = {
QUOTE, 0
};
-static const UChar SQUOTE_STOPLIST[] = {
+static const char16_t SQUOTE_STOPLIST[] = {
TICK, 0
};
-static const UChar NOQUOTE_STOPLIST[] = {
+static const char16_t NOQUOTE_STOPLIST[] = {
SPACE, COMMA, CLOSE_ANGLE, OPEN_ANGLE, TICK, QUOTE, 0
};
}
StringLocalizationInfo*
-LocDataParser::parse(UChar* _data, int32_t len) {
+LocDataParser::parse(char16_t* _data, int32_t len) {
if (U_FAILURE(ec)) {
if (_data) uprv_free(_data);
return nullptr;
int32_t requiredLength = -1;
while (mightHaveNext) {
mightHaveNext = false;
- UChar** elem = nextArray(requiredLength);
+ char16_t** elem = nextArray(requiredLength);
skipWhitespace();
UBool haveComma = check(COMMA);
if (elem) {
array.add(nullptr, ec);
if (U_SUCCESS(ec)) {
int32_t numLocs = array.length() - 2; // subtract first, nullptr
- UChar*** result = (UChar***)array.release();
+ char16_t*** result = (char16_t***)array.release();
return new StringLocalizationInfo(data, result, requiredLength-2, numLocs); // subtract first, nullptr
}
ERROR("Unknown error");
}
-UChar**
+char16_t**
LocDataParser::nextArray(int32_t& requiredLength) {
if (U_FAILURE(ec)) {
return nullptr;
UBool mightHaveNext = true;
while (mightHaveNext) {
mightHaveNext = false;
- UChar* elem = nextString();
+ char16_t* elem = nextString();
skipWhitespace();
UBool haveComma = check(COMMA);
if (elem) {
ERROR("Array not of required length");
}
- return (UChar**)array.release();
+ return (char16_t**)array.release();
}
ERROR("Unknown Error");
}
-UChar*
+char16_t*
LocDataParser::nextString() {
- UChar* result = nullptr;
+ char16_t* result = nullptr;
skipWhitespace();
if (p < e) {
- const UChar* terminators;
- UChar c = *p;
+ const char16_t* terminators;
+ char16_t c = *p;
UBool haveQuote = c == QUOTE || c == TICK;
if (haveQuote) {
inc();
} else {
terminators = NOQUOTE_STOPLIST;
}
- UChar* start = p;
+ char16_t* start = p;
while (p < e && !inList(*p, terminators)) ++p;
if (p == e) {
ERROR("Unexpected end of data");
}
- UChar x = *p;
+ char16_t x = *p;
if (p > start) {
ch = x;
*p = 0x0; // terminate by writing to data
return;
}
- const UChar* start = p - U_PARSE_CONTEXT_LEN - 1;
+ const char16_t* start = p - U_PARSE_CONTEXT_LEN - 1;
if (start < data) {
start = data;
}
- for (UChar* x = p; --x >= start;) {
+ for (char16_t* x = p; --x >= start;) {
if (!*x) {
start = x+1;
break;
}
}
- const UChar* limit = p + U_PARSE_CONTEXT_LEN - 1;
+ const char16_t* limit = p + U_PARSE_CONTEXT_LEN - 1;
if (limit > e) {
limit = e;
}
UnicodeString msg;
msg.append(start, p - start);
- msg.append((UChar)0x002f); /* SOLIDUS/SLASH */
+ msg.append((char16_t)0x002f); /* SOLIDUS/SLASH */
msg.append(p, limit-p);
msg.append(UNICODE_STRING_SIMPLE("'"));
return nullptr; // no error;
}
- UChar* p = (UChar*)uprv_malloc(len * sizeof(UChar));
+ char16_t* p = (char16_t*)uprv_malloc(len * sizeof(char16_t));
if (!p) {
status = U_MEMORY_ALLOCATION_ERROR;
return nullptr;
}
StringLocalizationInfo::~StringLocalizationInfo() {
- for (UChar*** p = (UChar***)data; *p; ++p) {
+ for (char16_t*** p = (char16_t***)data; *p; ++p) {
// remaining data is simply pointer into our unicode string data.
if (*p) uprv_free(*p);
}
}
-const UChar*
+const char16_t*
StringLocalizationInfo::getRuleSetName(int32_t index) const {
if (index >= 0 && index < getNumberOfRuleSets()) {
return data[0][index];
return nullptr;
}
-const UChar*
+const char16_t*
StringLocalizationInfo::getLocaleName(int32_t index) const {
if (index >= 0 && index < getNumberOfDisplayLocales()) {
return data[index+1][0];
return nullptr;
}
-const UChar*
+const char16_t*
StringLocalizationInfo::getDisplayName(int32_t localeIndex, int32_t ruleIndex) const {
if (localeIndex >= 0 && localeIndex < getNumberOfDisplayLocales() &&
ruleIndex >= 0 && ruleIndex < getNumberOfRuleSets()) {
if (localizations && index >= 0 && index < localizations->getNumberOfRuleSets()) {
UnicodeString localeName(localeParam.getBaseName(), -1, UnicodeString::kInvariant);
int32_t len = localeName.length();
- UChar* localeStr = localeName.getBuffer(len + 1);
+ char16_t* localeStr = localeName.getBuffer(len + 1);
while (len >= 0) {
localeStr[len] = 0;
int32_t ix = localizations->indexForLocale(localeStr);
Hashtable variableNames;
/**
- * Map category variable (UChar) to set (UnicodeFunctor).
+ * Map category variable (char16_t) to set (UnicodeFunctor).
* Variables that correspond to a set of characters are mapped
* from variable name to a stand-in character in data.variableNames.
* The stand-in then serves as a key in this hash to lookup the
* variablesBase through variablesBase +
* variablesLength - 1 represent UnicodeFunctor objects.
*/
- UChar variablesBase;
+ char16_t variablesBase;
/**
* The length of variables.
#include "putilimp.h"
// Operators
-#define VARIABLE_DEF_OP ((UChar)0x003D) /*=*/
-#define FORWARD_RULE_OP ((UChar)0x003E) /*>*/
-#define REVERSE_RULE_OP ((UChar)0x003C) /*<*/
-#define FWDREV_RULE_OP ((UChar)0x007E) /*~*/ // internal rep of <> op
+#define VARIABLE_DEF_OP ((char16_t)0x003D) /*=*/
+#define FORWARD_RULE_OP ((char16_t)0x003E) /*>*/
+#define REVERSE_RULE_OP ((char16_t)0x003C) /*<*/
+#define FWDREV_RULE_OP ((char16_t)0x007E) /*~*/ // internal rep of <> op
// Other special characters
-#define QUOTE ((UChar)0x0027) /*'*/
-#define ESCAPE ((UChar)0x005C) /*\*/
-#define END_OF_RULE ((UChar)0x003B) /*;*/
-#define RULE_COMMENT_CHAR ((UChar)0x0023) /*#*/
-
-#define SEGMENT_OPEN ((UChar)0x0028) /*(*/
-#define SEGMENT_CLOSE ((UChar)0x0029) /*)*/
-#define CONTEXT_ANTE ((UChar)0x007B) /*{*/
-#define CONTEXT_POST ((UChar)0x007D) /*}*/
-#define CURSOR_POS ((UChar)0x007C) /*|*/
-#define CURSOR_OFFSET ((UChar)0x0040) /*@*/
-#define ANCHOR_START ((UChar)0x005E) /*^*/
-#define KLEENE_STAR ((UChar)0x002A) /***/
-#define ONE_OR_MORE ((UChar)0x002B) /*+*/
-#define ZERO_OR_ONE ((UChar)0x003F) /*?*/
-
-#define DOT ((UChar)46) /*.*/
-
-static const UChar DOT_SET[] = { // "[^[:Zp:][:Zl:]\r\n$]";
+#define QUOTE ((char16_t)0x0027) /*'*/
+#define ESCAPE ((char16_t)0x005C) /*\*/
+#define END_OF_RULE ((char16_t)0x003B) /*;*/
+#define RULE_COMMENT_CHAR ((char16_t)0x0023) /*#*/
+
+#define SEGMENT_OPEN ((char16_t)0x0028) /*(*/
+#define SEGMENT_CLOSE ((char16_t)0x0029) /*)*/
+#define CONTEXT_ANTE ((char16_t)0x007B) /*{*/
+#define CONTEXT_POST ((char16_t)0x007D) /*}*/
+#define CURSOR_POS ((char16_t)0x007C) /*|*/
+#define CURSOR_OFFSET ((char16_t)0x0040) /*@*/
+#define ANCHOR_START ((char16_t)0x005E) /*^*/
+#define KLEENE_STAR ((char16_t)0x002A) /***/
+#define ONE_OR_MORE ((char16_t)0x002B) /*+*/
+#define ZERO_OR_ONE ((char16_t)0x003F) /*?*/
+
+#define DOT ((char16_t)46) /*.*/
+
+static const char16_t DOT_SET[] = { // "[^[:Zp:][:Zl:]\r\n$]";
91, 94, 91, 58, 90, 112, 58, 93, 91, 58, 90,
108, 58, 93, 92, 114, 92, 110, 36, 93, 0
};
// A function is denoted &Source-Target/Variant(text)
-#define FUNCTION ((UChar)38) /*&*/
+#define FUNCTION ((char16_t)38) /*&*/
// Aliases for some of the syntax characters. These are provided so
// transliteration rules can be expressed in XML without clashing with
// XML syntax characters '<', '>', and '&'.
-#define ALT_REVERSE_RULE_OP ((UChar)0x2190) // Left Arrow
-#define ALT_FORWARD_RULE_OP ((UChar)0x2192) // Right Arrow
-#define ALT_FWDREV_RULE_OP ((UChar)0x2194) // Left Right Arrow
-#define ALT_FUNCTION ((UChar)0x2206) // Increment (~Greek Capital Delta)
+#define ALT_REVERSE_RULE_OP ((char16_t)0x2190) // Left Arrow
+#define ALT_FORWARD_RULE_OP ((char16_t)0x2192) // Right Arrow
+#define ALT_FWDREV_RULE_OP ((char16_t)0x2194) // Left Right Arrow
+#define ALT_FUNCTION ((char16_t)0x2206) // Increment (~Greek Capital Delta)
// Special characters disallowed at the top level
-static const UChar ILLEGAL_TOP[] = {41,0}; // ")"
+static const char16_t ILLEGAL_TOP[] = {41,0}; // ")"
// Special characters disallowed within a segment
-static const UChar ILLEGAL_SEG[] = {123,125,124,64,0}; // "{}|@"
+static const char16_t ILLEGAL_SEG[] = {123,125,124,64,0}; // "{}|@"
// Special characters disallowed within a function argument
-static const UChar ILLEGAL_FUNC[] = {94,40,46,42,43,63,123,125,124,64,0}; // "^(.*+?{}|@"
+static const char16_t ILLEGAL_FUNC[] = {94,40,46,42,43,63,123,125,124,64,0}; // "^(.*+?{}|@"
// By definition, the ANCHOR_END special character is a
// trailing SymbolTable.SYMBOL_REF character.
// private static final char ANCHOR_END = '$';
-static const UChar gOPERATORS[] = { // "=><"
+static const char16_t gOPERATORS[] = { // "=><"
VARIABLE_DEF_OP, FORWARD_RULE_OP, REVERSE_RULE_OP,
ALT_FORWARD_RULE_OP, ALT_REVERSE_RULE_OP, ALT_FWDREV_RULE_OP,
0
};
-static const UChar HALF_ENDERS[] = { // "=><;"
+static const char16_t HALF_ENDERS[] = { // "=><;"
VARIABLE_DEF_OP, FORWARD_RULE_OP, REVERSE_RULE_OP,
ALT_FORWARD_RULE_OP, ALT_REVERSE_RULE_OP, ALT_FWDREV_RULE_OP,
END_OF_RULE,
// These are also used in Transliterator::toRules()
static const int32_t ID_TOKEN_LEN = 2;
-static const UChar ID_TOKEN[] = { 0x3A, 0x3A }; // ':', ':'
+static const char16_t ID_TOKEN[] = { 0x3A, 0x3A }; // ':', ':'
/*
commented out until we do real ::BEGIN/::END functionality
static const int32_t BEGIN_TOKEN_LEN = 5;
-static const UChar BEGIN_TOKEN[] = { 0x42, 0x45, 0x47, 0x49, 0x4e }; // 'BEGIN'
+static const char16_t BEGIN_TOKEN[] = { 0x42, 0x45, 0x47, 0x49, 0x4e }; // 'BEGIN'
static const int32_t END_TOKEN_LEN = 3;
-static const UChar END_TOKEN[] = { 0x45, 0x4e, 0x44 }; // 'END'
+static const char16_t END_TOKEN[] = { 0x45, 0x4e, 0x44 }; // 'END'
*/
U_NAMESPACE_BEGIN
int32_t i = start;
UnicodeString result;
while (i < limit) {
- UChar c = text.charAt(i);
+ char16_t c = text.charAt(i);
if ((i==start && !u_isIDStart(c)) || !u_isIDPart(c)) {
break;
}
while (pos < limit && !done) {
// Since all syntax characters are in the BMP, fetching
// 16-bit code units suffices here.
- UChar c = rule.charAt(pos++);
+ char16_t c = rule.charAt(pos++);
if (PatternProps::isWhiteSpace(c)) {
// Ignore whitespace. Note that this is not Unicode
// spaces, but Java spaces -- a subset, representing
return;
}
- dotStandIn = (UChar) -1;
+ dotStandIn = (char16_t) -1;
UnicodeString *tempstr = nullptr; // used for memory allocation error checking
UnicodeString str; // scratch
int32_t compoundFilterOffset = -1;
while (pos < limit && U_SUCCESS(status)) {
- UChar c = rule.charAt(pos++);
+ char16_t c = rule.charAt(pos++);
if (PatternProps::isWhiteSpace(c)) {
// Ignore leading whitespace.
continue;
}
// Skip lines starting with the comment character
if (c == RULE_COMMENT_CHAR) {
- pos = rule.indexOf((UChar)0x000A /*\n*/, pos) + 1;
+ pos = rule.indexOf((char16_t)0x000A /*\n*/, pos) + 1;
if (pos == 0) {
break; // No "\n" found; rest of rule is a comment
}
return;
}
- curData->variablesBase = (UChar) start;
+ curData->variablesBase = (char16_t) start;
if (dataVector.size() == 0) {
- variableNext = (UChar) start;
- variableLimit = (UChar) (end + 1);
+ variableNext = (char16_t) start;
+ variableLimit = (char16_t) (end + 1);
}
}
//TODO Finish
}
-static const UChar PRAGMA_USE[] = {0x75,0x73,0x65,0x20,0}; // "use "
+static const char16_t PRAGMA_USE[] = {0x75,0x73,0x65,0x20,0}; // "use "
-static const UChar PRAGMA_VARIABLE_RANGE[] = {0x7E,0x76,0x61,0x72,0x69,0x61,0x62,0x6C,0x65,0x20,0x72,0x61,0x6E,0x67,0x65,0x20,0x23,0x20,0x23,0x7E,0x3B,0}; // "~variable range # #~;"
+static const char16_t PRAGMA_VARIABLE_RANGE[] = {0x7E,0x76,0x61,0x72,0x69,0x61,0x62,0x6C,0x65,0x20,0x72,0x61,0x6E,0x67,0x65,0x20,0x23,0x20,0x23,0x7E,0x3B,0}; // "~variable range # #~;"
-static const UChar PRAGMA_MAXIMUM_BACKUP[] = {0x7E,0x6D,0x61,0x78,0x69,0x6D,0x75,0x6D,0x20,0x62,0x61,0x63,0x6B,0x75,0x70,0x20,0x23,0x7E,0x3B,0}; // "~maximum backup #~;"
+static const char16_t PRAGMA_MAXIMUM_BACKUP[] = {0x7E,0x6D,0x61,0x78,0x69,0x6D,0x75,0x6D,0x20,0x62,0x61,0x63,0x6B,0x75,0x70,0x20,0x23,0x7E,0x3B,0}; // "~maximum backup #~;"
-static const UChar PRAGMA_NFD_RULES[] = {0x7E,0x6E,0x66,0x64,0x20,0x72,0x75,0x6C,0x65,0x73,0x7E,0x3B,0}; // "~nfd rules~;"
+static const char16_t PRAGMA_NFD_RULES[] = {0x7E,0x6E,0x66,0x64,0x20,0x72,0x75,0x6C,0x65,0x73,0x7E,0x3B,0}; // "~nfd rules~;"
-static const UChar PRAGMA_NFC_RULES[] = {0x7E,0x6E,0x66,0x63,0x20,0x72,0x75,0x6C,0x65,0x73,0x7E,0x3B,0}; // "~nfc rules~;"
+static const char16_t PRAGMA_NFC_RULES[] = {0x7E,0x6E,0x66,0x63,0x20,0x72,0x75,0x6C,0x65,0x73,0x7E,0x3B,0}; // "~nfc rules~;"
/**
* Return true if the given rule looks like a pragma.
int32_t TransliteratorParser::parseRule(const UnicodeString& rule, int32_t pos, int32_t limit, UErrorCode& status) {
// Locate the left side, operator, and right side
int32_t start = pos;
- UChar op = 0;
+ char16_t op = 0;
int32_t i;
// Set up segments data
* Parse a UnicodeSet out, store it, and return the stand-in character
* used to represent it.
*/
-UChar TransliteratorParser::parseSet(const UnicodeString& rule,
+char16_t TransliteratorParser::parseSet(const UnicodeString& rule,
ParsePosition& pos,
UErrorCode& status) {
UnicodeSet* set = new UnicodeSet(rule, pos, USET_IGNORE_SPACE, parseData, status);
// Null pointer check
if (set == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
- return (UChar)0x0000; // Return empty character with error.
+ return (char16_t)0x0000; // Return empty character with error.
}
set->compact();
return generateStandInFor(set, status);
* Generate and return a stand-in for a new UnicodeFunctor. Store
* the matcher (adopt it).
*/
-UChar TransliteratorParser::generateStandInFor(UnicodeFunctor* adopted, UErrorCode& status) {
+char16_t TransliteratorParser::generateStandInFor(UnicodeFunctor* adopted, UErrorCode& status) {
// assert(obj != null);
// Look up previous stand-in, if any. This is a short list
// (typical n is 0, 1, or 2); linear search is optimal.
for (int32_t i=0; i<variablesVector.size(); ++i) {
if (variablesVector.elementAt(i) == adopted) { // [sic] pointer comparison
- return (UChar) (curData->variablesBase + i);
+ return (char16_t) (curData->variablesBase + i);
}
}
/**
* Return the standin for segment seg (1-based).
*/
-UChar TransliteratorParser::getSegmentStandin(int32_t seg, UErrorCode& status) {
+char16_t TransliteratorParser::getSegmentStandin(int32_t seg, UErrorCode& status) {
// Special character used to indicate an empty spot
- UChar empty = curData->variablesBase - 1;
+ char16_t empty = curData->variablesBase - 1;
while (segmentStandins.length() < seg) {
segmentStandins.append(empty);
}
- UChar c = segmentStandins.charAt(seg-1);
+ char16_t c = segmentStandins.charAt(seg-1);
if (c == empty) {
if (variableNext >= variableLimit) {
status = U_VARIABLE_RANGE_EXHAUSTED;
* Return the stand-in for the dot set. It is allocated the first
* time and reused thereafter.
*/
-UChar TransliteratorParser::getDotStandIn(UErrorCode& status) {
- if (dotStandIn == (UChar) -1) {
+char16_t TransliteratorParser::getDotStandIn(UErrorCode& status) {
+ if (dotStandIn == (char16_t) -1) {
UnicodeSet* tempus = new UnicodeSet(UnicodeString(true, DOT_SET, -1), status);
// Null pointer check.
if (tempus == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
- return (UChar)0x0000;
+ return (char16_t)0x0000;
}
dotStandIn = generateStandInFor(tempus, status);
}
status = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
- buf.append((UChar) --variableLimit);
+ buf.append((char16_t) --variableLimit);
} else {
//throw new IllegalArgumentException("Undefined variable $"
// + name);
U_NAMESPACE_END
U_CAPI int32_t
-utrans_stripRules(const UChar *source, int32_t sourceLen, UChar *target, UErrorCode *status) {
+utrans_stripRules(const char16_t *source, int32_t sourceLen, char16_t *target, UErrorCode *status) {
U_NAMESPACE_USE
- //const UChar *sourceStart = source;
- const UChar *targetStart = target;
- const UChar *sourceLimit = source+sourceLen;
- UChar *targetLimit = target+sourceLen;
+ //const char16_t *sourceStart = source;
+ const char16_t *targetStart = target;
+ const char16_t *sourceLimit = source+sourceLen;
+ char16_t *targetLimit = target+sourceLen;
UChar32 c = 0;
UBool quoted = false;
int32_t index;
continue;
}
- /* Append UChar * after dissembling if c > 0xffff*/
+ /* Append char16_t * after dissembling if c > 0xffff*/
index=0;
U16_APPEND_UNSAFE(target, index, c);
target+=index;
* <code>variableLimit</code>. At any point during parsing, available
* variables are <code>variableNext..variableLimit-1</code>.
*/
- UChar variableNext;
+ char16_t variableNext;
/**
* The last available stand-in for variables. This is discovered
* dynamically. At any point during parsing, available variables are
* <code>variableNext..variableLimit-1</code>.
*/
- UChar variableLimit;
+ char16_t variableLimit;
/**
* When we encounter an undefined variable, we do not immediately signal
* patterns. This is allocated the first time it is needed, and
* reused thereafter.
*/
- UChar dotStandIn;
+ char16_t dotStandIn;
public:
* @param pos the position in pattern at which to start parsing.
* @return the stand-in character used to represent it.
*/
- UChar parseSet(const UnicodeString& rule,
- ParsePosition& pos,
- UErrorCode& status);
+ char16_t parseSet(const UnicodeString& rule,
+ ParsePosition& pos,
+ UErrorCode& status);
/**
* Generate and return a stand-in for a new UnicodeFunctor. Store
* @param adopted the UnicodeFunctor to be adopted.
* @return a stand-in for a new UnicodeFunctor.
*/
- UChar generateStandInFor(UnicodeFunctor* adopted, UErrorCode& status);
+ char16_t generateStandInFor(UnicodeFunctor* adopted, UErrorCode& status);
/**
* Return the standin for segment seg (1-based).
* @param seg the given segment.
* @return the standIn character for the given segment.
*/
- UChar getSegmentStandin(int32_t seg, UErrorCode& status);
+ char16_t getSegmentStandin(int32_t seg, UErrorCode& status);
/**
* Set the object for segment seg (1-based).
* time and reused thereafter.
* @return the stand-in for the dot set.
*/
- UChar getDotStandIn(UErrorCode& status);
+ char16_t getDotStandIn(UErrorCode& status);
/**
* Append the value of the given variable name to the given
#include "util.h"
#include "putilimp.h"
-static const UChar FORWARD_OP[] = {32,62,32,0}; // " > "
+static const char16_t FORWARD_OP[] = {32,62,32,0}; // " > "
U_NAMESPACE_BEGIN
// Emit start anchor
if ((flags & ANCHOR_START) != 0) {
- rule.append((UChar)94/*^*/);
+ rule.append((char16_t)94/*^*/);
}
// Emit the input pattern
ICU_Utility::appendToRule(rule, anteContext, escapeUnprintable, quoteBuf);
if (emitBraces) {
- ICU_Utility::appendToRule(rule, (UChar) 0x007B /*{*/, true, escapeUnprintable, quoteBuf);
+ ICU_Utility::appendToRule(rule, (char16_t) 0x007B /*{*/, true, escapeUnprintable, quoteBuf);
}
ICU_Utility::appendToRule(rule, key, escapeUnprintable, quoteBuf);
if (emitBraces) {
- ICU_Utility::appendToRule(rule, (UChar) 0x007D /*}*/, true, escapeUnprintable, quoteBuf);
+ ICU_Utility::appendToRule(rule, (char16_t) 0x007D /*}*/, true, escapeUnprintable, quoteBuf);
}
ICU_Utility::appendToRule(rule, postContext, escapeUnprintable, quoteBuf);
// Emit end anchor
if ((flags & ANCHOR_END) != 0) {
- rule.append((UChar)36/*$*/);
+ rule.append((char16_t)36/*$*/);
}
ICU_Utility::appendToRule(rule, UnicodeString(true, FORWARD_OP, 3), true, escapeUnprintable, quoteBuf);
ICU_Utility::appendToRule(rule, output->toReplacer()->toReplacerPattern(str, escapeUnprintable),
true, escapeUnprintable, quoteBuf);
- ICU_Utility::appendToRule(rule, (UChar) 0x003B /*;*/, true, escapeUnprintable, quoteBuf);
+ ICU_Utility::appendToRule(rule, (char16_t) 0x003B /*;*/, true, escapeUnprintable, quoteBuf);
return rule;
}
input.extractBetween(pos.start, pos.limit, c);
input.extractBetween(pos.limit, pos.contextLimit, d);
input.extractBetween(pos.contextLimit, input.length(), e);
- appendTo.append(a).append((UChar)123/*{*/).append(b).
- append((UChar)124/*|*/).append(c).append((UChar)124/*|*/).append(d).
- append((UChar)125/*}*/).append(e);
+ appendTo.append(a).append((char16_t)123/*{*/).append(b).
+ append((char16_t)124/*|*/).append(c).append((char16_t)124/*|*/).append(d).
+ append((char16_t)125/*}*/).append(e);
} else {
appendTo.append("INVALID UTransPosition");
//appendTo.append((UnicodeString)"INVALID UTransPosition {cs=" +
UnicodeString& _appendHex(uint32_t number,
int32_t digits,
UnicodeString& target) {
- static const UChar digitString[] = {
+ static const char16_t digitString[] = {
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0
};
if (rule) {
UnicodeString r;
rule->toRule(r, true);
- buf.append((UChar)32).append(r);
+ buf.append((char16_t)32).append(r);
}
buf.append(UnicodeString(" => ", ""));
UnicodeString* text = (UnicodeString*)&theText;
ruleSource.truncate(0);
for (i=0; i<count; ++i) {
if (i != 0) {
- ruleSource.append((UChar) 0x000A /*\n*/);
+ ruleSource.append((char16_t) 0x000A /*\n*/);
}
TransliterationRule *r =
(TransliterationRule*) ruleVector->elementAt(i);
}
}
-static const UChar chAmp = 0x26; // '&'
-static const UChar chDash = 0x2d; // '-'
+static const char16_t chAmp = 0x26; // '&'
+static const char16_t chDash = 0x2d; // '-'
//------------------------------------------------------------------------------
0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2,
0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x1, 0x1, 0x1, 0};
- static const UChar RECaseFixData[] = {
+ static const char16_t RECaseFixData[] = {
0x1e9a, 0xfb00, 0xfb01, 0xfb02, 0xfb03, 0xfb04, 0x1e96, 0x130, 0x1f0, 0xdf,
0x1e9e, 0xfb05, 0xfb06, 0x1e97, 0x1e98, 0x1e99, 0x149, 0x1fb4, 0x1fc4, 0x1fb3,
0x1fb6, 0x1fb7, 0x1fbc, 0x1fc3, 0x1fc6, 0x1fc7, 0x1fcc, 0x390, 0x1fd2, 0x1fd3,
// Numeric because there is no portable way to enter them as literals.
// (Think EBCDIC).
//
-static const UChar chCR = 0x0d; // New lines, for terminating comments.
-static const UChar chLF = 0x0a; // Line Feed
-static const UChar chPound = 0x23; // '#', introduces a comment.
-static const UChar chDigit0 = 0x30; // '0'
-static const UChar chDigit7 = 0x37; // '9'
-static const UChar chColon = 0x3A; // ':'
-static const UChar chE = 0x45; // 'E'
-static const UChar chQ = 0x51; // 'Q'
-//static const UChar chN = 0x4E; // 'N'
-static const UChar chP = 0x50; // 'P'
-static const UChar chBackSlash = 0x5c; // '\' introduces a char escape
-//static const UChar chLBracket = 0x5b; // '['
-static const UChar chRBracket = 0x5d; // ']'
-static const UChar chUp = 0x5e; // '^'
-static const UChar chLowerP = 0x70;
-static const UChar chLBrace = 0x7b; // '{'
-static const UChar chRBrace = 0x7d; // '}'
-static const UChar chNEL = 0x85; // NEL newline variant
-static const UChar chLS = 0x2028; // Unicode Line Separator
+static const char16_t chCR = 0x0d; // New lines, for terminating comments.
+static const char16_t chLF = 0x0a; // Line Feed
+static const char16_t chPound = 0x23; // '#', introduces a comment.
+static const char16_t chDigit0 = 0x30; // '0'
+static const char16_t chDigit7 = 0x37; // '9'
+static const char16_t chColon = 0x3A; // ':'
+static const char16_t chE = 0x45; // 'E'
+static const char16_t chQ = 0x51; // 'Q'
+//static const char16_t chN = 0x4E; // 'N'
+static const char16_t chP = 0x50; // 'P'
+static const char16_t chBackSlash = 0x5c; // '\' introduces a char escape
+//static const char16_t chLBracket = 0x5b; // '['
+static const char16_t chRBracket = 0x5d; // ']'
+static const char16_t chUp = 0x5e; // '^'
+static const char16_t chLowerP = 0x70;
+static const char16_t chLBrace = 0x7b; // '{'
+static const char16_t chRBrace = 0x7d; // '}'
+static const char16_t chNEL = 0x85; // NEL newline variant
+static const char16_t chLS = 0x2028; // Unicode Line Separator
//------------------------------------------------------------------------------
-CaseFoldingUCharIterator::CaseFoldingUCharIterator(const UChar *chars, int64_t start, int64_t limit) :
+CaseFoldingUCharIterator::CaseFoldingUCharIterator(const char16_t *chars, int64_t start, int64_t limit) :
fChars(chars), fIndex(start), fLimit(limit), fFoldChars(nullptr), fFoldLength(0) {
}
// folding of the same code point from the original UText.
private:
UText &fUText;
- const UChar *fFoldChars;
+ const char16_t *fFoldChars;
int32_t fFoldLength;
int32_t fFoldIndex;
};
-// Case folded UChar * string iterator.
-// Wraps a UChar *, provides a case-folded enumeration over its contents.
+// Case folded char16_t * string iterator.
+// Wraps a char16_t *, provides a case-folded enumeration over its contents.
// Used in implementing case insensitive matching constructs.
// Implementation in rematch.cpp
class CaseFoldingUCharIterator: public UMemory {
public:
- CaseFoldingUCharIterator(const UChar *chars, int64_t start, int64_t limit);
+ CaseFoldingUCharIterator(const char16_t *chars, int64_t start, int64_t limit);
~CaseFoldingUCharIterator();
UChar32 next(); // Next case folded character
int64_t getIndex(); // Return the current input buffer index.
private:
- const UChar *fChars;
+ const char16_t *fChars;
int64_t fIndex;
int64_t fLimit;
- const UChar *fFoldChars;
+ const char16_t *fFoldChars;
int32_t fFoldLength;
int32_t fFoldIndex;
U_NAMESPACE_BEGIN
-U_CFUNC UChar U_CALLCONV
+U_CFUNC char16_t U_CALLCONV
uregex_utext_unescape_charAt(int32_t offset, void *ct) {
struct URegexUTextUnescapeCharContext *context = (struct URegexUTextUnescapeCharContext *)ct;
UChar32 c;
// !!!: Doesn't handle characters outside BMP
if (U_IS_BMP(c)) {
- return (UChar)c;
+ return (char16_t)c;
} else {
return 0;
}
}
-U_CFUNC UChar U_CALLCONV
+U_CFUNC char16_t U_CALLCONV
uregex_ucstr_unescape_charAt(int32_t offset, void *context) {
- return ((UChar *)context)[offset];
+ return ((char16_t *)context)[offset];
}
U_NAMESPACE_END
static UHashtable *numericCodeMap = nullptr;
static UVector *allRegions = nullptr;
-static const UChar UNKNOWN_REGION_ID [] = { 0x5A, 0x5A, 0 }; /* "ZZ" */
-static const UChar OUTLYING_OCEANIA_REGION_ID [] = { 0x51, 0x4F, 0 }; /* "QO" */
-static const UChar WORLD_ID [] = { 0x30, 0x30, 0x31, 0 }; /* "001" */
-static const UChar RANGE_MARKER = 0x7E; /* '~' */
+static const char16_t UNKNOWN_REGION_ID [] = { 0x5A, 0x5A, 0 }; /* "ZZ" */
+static const char16_t OUTLYING_OCEANIA_REGION_ID [] = { 0x51, 0x4F, 0 }; /* "QO" */
+static const char16_t WORLD_ID [] = { 0x30, 0x30, 0x31, 0 }; /* "001" */
+static const char16_t RANGE_MARKER = 0x7E; /* '~' */
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(RegionNameEnumeration)
while (U_SUCCESS(status) && ures_hasNext(regionRegular.getAlias())) {
UnicodeString regionName = ures_getNextUnicodeString(regionRegular.getAlias(),nullptr,&status);
int32_t rangeMarkerLocation = regionName.indexOf(RANGE_MARKER);
- UChar buf[6];
+ char16_t buf[6];
regionName.extract(buf,6,status);
if ( rangeMarkerLocation > 0 ) {
- UChar endRange = regionName.charAt(rangeMarkerLocation+1);
+ char16_t endRange = regionName.charAt(rangeMarkerLocation+1);
buf[rangeMarkerLocation] = 0;
while (U_SUCCESS(status) && buf[rangeMarkerLocation-1] <= endRange) {
LocalPointer<UnicodeString> newRegion(new UnicodeString(buf), status);
while (U_SUCCESS(status) && ures_hasNext(regionMacro.getAlias())) {
UnicodeString regionName = ures_getNextUnicodeString(regionMacro.getAlias(),nullptr,&status);
int32_t rangeMarkerLocation = regionName.indexOf(RANGE_MARKER);
- UChar buf[6];
+ char16_t buf[6];
regionName.extract(buf,6,status);
if ( rangeMarkerLocation > 0 ) {
- UChar endRange = regionName.charAt(rangeMarkerLocation+1);
+ char16_t endRange = regionName.charAt(rangeMarkerLocation+1);
buf[rangeMarkerLocation] = 0;
while ( buf[rangeMarkerLocation-1] <= endRange && U_SUCCESS(status)) {
LocalPointer<UnicodeString> newRegion(new UnicodeString(buf), status);
UnicodeString &result,
UErrorCode &status) {
int32_t len = 0;
- const UChar *resStr = ures_getStringByIndex(
+ const char16_t *resStr = ures_getStringByIndex(
resource, idx, &len, &status);
if (U_FAILURE(status)) {
return false;
// Utility functions
static UDateRelativeDateTimeFormatterStyle styleFromAliasUnicodeString(UnicodeString s) {
- static const UChar narrow[7] = {0x002D, 0x006E, 0x0061, 0x0072, 0x0072, 0x006F, 0x0077};
- static const UChar sshort[6] = {0x002D, 0x0073, 0x0068, 0x006F, 0x0072, 0x0074,};
+ static const char16_t narrow[7] = {0x002D, 0x006E, 0x0061, 0x0072, 0x0072, 0x006F, 0x0077};
+ static const char16_t sshort[6] = {0x002D, 0x0073, 0x0068, 0x006F, 0x0072, 0x0074,};
if (s.endsWith(narrow, 7)) {
return UDAT_STYLE_NARROW;
}
ureldatefmt_formatNumeric( const URelativeDateTimeFormatter* reldatefmt,
double offset,
URelativeDateTimeUnit unit,
- UChar* result,
+ char16_t* result,
int32_t resultCapacity,
UErrorCode* status)
{
ureldatefmt_format( const URelativeDateTimeFormatter* reldatefmt,
double offset,
URelativeDateTimeUnit unit,
- UChar* result,
+ char16_t* result,
int32_t resultCapacity,
UErrorCode* status)
{
U_CAPI int32_t U_EXPORT2
ureldatefmt_combineDateAndTime( const URelativeDateTimeFormatter* reldatefmt,
- const UChar * relativeDateString,
+ const char16_t * relativeDateString,
int32_t relativeDateStringLen,
- const UChar * timeString,
+ const char16_t * timeString,
int32_t timeStringLen,
- UChar* result,
+ char16_t* result,
int32_t resultCapacity,
UErrorCode* status )
{
struct URelativeString {
int32_t offset; /** offset of this item, such as, the relative date **/
int32_t len; /** length of the string **/
- const UChar* string; /** string, or nullptr if not set **/
+ const char16_t* string; /** string, or nullptr if not set **/
};
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(RelativeDateFormat)
return false;
}
-static const UChar APOSTROPHE = (UChar)0x0027;
+static const char16_t APOSTROPHE = (char16_t)0x0027;
UnicodeString& RelativeDateFormat::format( Calendar& cal,
UnicodeString& appendTo,
// look up string
int32_t len = 0;
- const UChar *theString = getStringForDay(dayDiff, len, status);
+ const char16_t *theString = getStringForDay(dayDiff, len, status);
if(U_SUCCESS(status) && (theString!=nullptr)) {
// found a relative string
relativeDayString.setTo(theString, len);
}
-const UChar *RelativeDateFormat::getStringForDay(int32_t day, int32_t &len, UErrorCode &status) const {
+const char16_t *RelativeDateFormat::getStringForDay(int32_t day, int32_t &len, UErrorCode &status) const {
if(U_FAILURE(status)) {
return nullptr;
}
} // Namespace
-static const UChar patItem1[] = {0x7B,0x31,0x7D}; // "{1}"
+static const char16_t patItem1[] = {0x7B,0x31,0x7D}; // "{1}"
static const int32_t patItem1Len = 3;
void RelativeDateFormat::loadDates(UErrorCode &status) {
}
}
- const UChar *resStr = ures_getStringByIndex(dateTimePatterns.getAlias(), glueIndex, &resStrLen, &status);
+ const char16_t *resStr = ures_getStringByIndex(dateTimePatterns.getAlias(), glueIndex, &resStrLen, &status);
if (U_SUCCESS(status) && resStrLen >= patItem1Len && u_strncmp(resStr,patItem1,patItem1Len)==0) {
fCombinedHasDateAtStart = true;
}
* @param len on output, length of string.
* @return the string, or nullptr if none at that location.
*/
- const UChar *getStringForDay(int32_t day, int32_t &len, UErrorCode &status) const;
+ const char16_t *getStringForDay(int32_t day, int32_t &len, UErrorCode &status) const;
/**
* Load the Date string array
}
-static const UChar BACKSLASH = 0x5c;
-static const UChar DOLLARSIGN = 0x24;
-static const UChar LEFTBRACKET = 0x7b;
-static const UChar RIGHTBRACKET = 0x7d;
+static const char16_t BACKSLASH = 0x5c;
+static const char16_t DOLLARSIGN = 0x24;
+static const char16_t LEFTBRACKET = 0x7b;
+static const char16_t RIGHTBRACKET = 0x7d;
//--------------------------------------------------------------------------------
//
UErrorCode lengthStatus = U_ZERO_ERROR;
len16 = utext_extract(fInputText, fAppendPosition, fMatchStart, nullptr, 0, &lengthStatus);
}
- UChar *inputChars = (UChar *)uprv_malloc(sizeof(UChar)*(len16+1));
+ char16_t *inputChars = (char16_t *)uprv_malloc(sizeof(char16_t)*(len16+1));
if (inputChars == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return *this;
UChar32 escapedChar = u_unescapeAt(uregex_utext_unescape_charAt, &offset, INT32_MAX, &context);
if (escapedChar != (UChar32)0xFFFFFFFF) {
if (U_IS_BMP(escapedChar)) {
- UChar c16 = (UChar)escapedChar;
+ char16_t c16 = (char16_t)escapedChar;
destLen += utext_replace(dest, destLen, destLen, &c16, 1, &status);
} else {
- UChar surrogate[2];
+ char16_t surrogate[2];
surrogate[0] = U16_LEAD(escapedChar);
surrogate[1] = U16_TRAIL(escapedChar);
if (U_SUCCESS(status)) {
(void)UTEXT_NEXT32(replacement);
// Plain backslash escape. Just put out the escaped character.
if (U_IS_BMP(c)) {
- UChar c16 = (UChar)c;
+ char16_t c16 = (char16_t)c;
destLen += utext_replace(dest, destLen, destLen, &c16, 1, &status);
} else {
- UChar surrogate[2];
+ char16_t surrogate[2];
surrogate[0] = U16_LEAD(c);
surrogate[1] = U16_TRAIL(c);
if (U_SUCCESS(status)) {
} else if (c != DOLLARSIGN) {
// Normal char, not a $. Copy it out without further checks.
if (U_IS_BMP(c)) {
- UChar c16 = (UChar)c;
+ char16_t c16 = (char16_t)c;
destLen += utext_replace(dest, destLen, destLen, &c16, 1, &status);
} else {
- UChar surrogate[2];
+ char16_t surrogate[2];
surrogate[0] = U16_LEAD(c);
surrogate[1] = U16_TRAIL(c);
if (U_SUCCESS(status)) {
status = U_ZERO_ERROR; // buffer overflow
}
- UChar *inputChars = (UChar *)uprv_malloc(sizeof(UChar)*(len16));
+ char16_t *inputChars = (char16_t *)uprv_malloc(sizeof(char16_t)*(len16));
if (inputChars == nullptr) {
fDeferredStatus = U_MEMORY_ALLOCATION_ERROR;
} else {
startPos = (int32_t)fActiveStart;
}
- const UChar *inputBuf = fInputText->chunkContents;
+ const char16_t *inputBuf = fInputText->chunkContents;
if (fMatch) {
// Save the position of any previous successful match.
}
status = U_ZERO_ERROR;
- UChar *buf = result.getBuffer(length);
+ char16_t *buf = result.getBuffer(length);
if (buf == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
} else {
UErrorCode lengthStatus = U_ZERO_ERROR;
len16 = utext_extract(fInputText, s, e, nullptr, 0, &lengthStatus);
}
- UChar *groupChars = (UChar *)uprv_malloc(sizeof(UChar)*(len16+1));
+ char16_t *groupChars = (char16_t *)uprv_malloc(sizeof(char16_t)*(len16+1));
if (groupChars == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
UnicodeString *result = new UnicodeString(len16, 0, 0);
- UChar *inputChars = result->getBuffer(len16);
+ char16_t *inputChars = result->getBuffer(len16);
utext_extract(fInputText, 0, fInputLength, inputChars, len16, &status); // unterminated warning
result->releaseBuffer(len16);
UErrorCode lengthStatus = U_ZERO_ERROR;
input16Len = utext_extract(fInputText, 0, fInputLength, nullptr, 0, &lengthStatus); // buffer overflow error
}
- UChar *inputChars = (UChar *)uprv_malloc(sizeof(UChar)*(input16Len));
+ char16_t *inputChars = (char16_t *)uprv_malloc(sizeof(char16_t)*(input16Len));
if (inputChars == nullptr) {
return dest;
}
return *this;
}
-/*RegexMatcher &RegexMatcher::reset(const UChar *) {
+/*RegexMatcher &RegexMatcher::reset(const char16_t *) {
fDeferredStatus = U_INTERNAL_PROGRAM_ERROR;
return *this;
}*/
return dest;
}
*status = U_ZERO_ERROR;
- MaybeStackArray<UChar, 40> buffer;
+ MaybeStackArray<char16_t, 40> buffer;
if (length >= buffer.getCapacity()) {
- UChar *newBuf = buffer.resize(length+1); // Leave space for terminating Nul.
+ char16_t *newBuf = buffer.resize(length+1); // Leave space for terminating Nul.
if (newBuf == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
}
return nullptr;
}
int32_t ownedLength = 0;
- UChar *ownedBuf = buffer.orphanOrClone(length+1, ownedLength);
+ char16_t *ownedBuf = buffer.orphanOrClone(length+1, ownedLength);
if (ownedBuf == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
return nullptr;
UErrorCode lengthStatus = U_ZERO_ERROR;
int32_t remaining16Length =
utext_extract(input, nextOutputStringStart, fActiveLimit, nullptr, 0, &lengthStatus);
- UChar *remainingChars = (UChar *)uprv_malloc(sizeof(UChar)*(remaining16Length+1));
+ char16_t *remainingChars = (char16_t *)uprv_malloc(sizeof(char16_t)*(remaining16Length+1));
if (remainingChars == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
break;
} else {
UErrorCode lengthStatus = U_ZERO_ERROR;
int32_t remaining16Length = utext_extract(input, nextOutputStringStart, fMatchStart, nullptr, 0, &lengthStatus);
- UChar *remainingChars = (UChar *)uprv_malloc(sizeof(UChar)*(remaining16Length+1));
+ char16_t *remainingChars = (char16_t *)uprv_malloc(sizeof(char16_t)*(remaining16Length+1));
if (remainingChars == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
break;
if (dest[i] == nullptr) {
dest[i] = utext_openUChars(nullptr, nullptr, 0, &status);
} else {
- static const UChar emptyString[] = {(UChar)0};
+ static const char16_t emptyString[] = {(char16_t)0};
utext_replace(dest[i], 0, utext_nativeLength(dest[i]), emptyString, 0, &status);
}
}
} else {
UErrorCode lengthStatus = U_ZERO_ERROR;
int32_t remaining16Length = utext_extract(input, nextOutputStringStart, fActiveLimit, nullptr, 0, &lengthStatus);
- UChar *remainingChars = (UChar *)uprv_malloc(sizeof(UChar)*(remaining16Length+1));
+ char16_t *remainingChars = (char16_t *)uprv_malloc(sizeof(char16_t)*(remaining16Length+1));
if (remainingChars == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
break;
UBool isBoundary = false;
UBool cIsWord = false;
- const UChar *inputBuf = fInputText->chunkContents;
+ const char16_t *inputBuf = fInputText->chunkContents;
if (pos >= fLookLimit) {
fHitEnd = true;
//
int64_t *pat = fPattern->fCompiledPat->getBuffer();
- const UChar *litText = fPattern->fLiteralText.getBuffer();
+ const char16_t *litText = fPattern->fLiteralText.getBuffer();
UVector *fSets = fPattern->fSets;
fFrameSize = fPattern->fFrameSize;
U_ASSERT(opType == URX_STRING_LEN);
U_ASSERT(stringLen >= 2);
- const UChar *patternString = litText+stringStartIdx;
+ const char16_t *patternString = litText+stringStartIdx;
int32_t patternStringIndex = 0;
UTEXT_SETNATIVEINDEX(fInputText, fp->fInputIdx);
UChar32 inputChar;
// offset to the string text, and one for the length.
// The compiled string has already been case folded.
{
- const UChar *patternString = litText + opValue;
+ const char16_t *patternString = litText + opValue;
int32_t patternStringIdx = 0;
op = (int32_t)pat[fp->fPatIdx];
//
int64_t *pat = fPattern->fCompiledPat->getBuffer();
- const UChar *litText = fPattern->fLiteralText.getBuffer();
+ const char16_t *litText = fPattern->fLiteralText.getBuffer();
UVector *fSets = fPattern->fSets;
- const UChar *inputBuf = fInputText->chunkContents;
+ const char16_t *inputBuf = fInputText->chunkContents;
fFrameSize = fPattern->fFrameSize;
REStackFrame *fp = resetStack();
U_ASSERT(opType == URX_STRING_LEN);
U_ASSERT(stringLen >= 2);
- const UChar * pInp = inputBuf + fp->fInputIdx;
- const UChar * pInpLimit = inputBuf + fActiveLimit;
- const UChar * pPat = litText+stringStartIdx;
- const UChar * pEnd = pInp + stringLen;
+ const char16_t * pInp = inputBuf + fp->fInputIdx;
+ const char16_t * pInpLimit = inputBuf + fActiveLimit;
+ const char16_t * pPat = litText+stringStartIdx;
+ const char16_t * pEnd = pInp + stringLen;
UBool success = true;
while (pInp < pEnd) {
if (pInp >= pInpLimit) {
}
// Check whether character just before the current pos is a new-line
// unless we are at the end of input
- UChar c = inputBuf[fp->fInputIdx - 1];
+ char16_t c = inputBuf[fp->fInputIdx - 1];
if ((fp->fInputIdx < fAnchorLimit) &&
isLineTerminator(c)) {
// It's a new-line. ^ is true. Success.
}
// Check whether character just before the current pos is a new-line
U_ASSERT(fp->fInputIdx <= fAnchorLimit);
- UChar c = inputBuf[fp->fInputIdx - 1];
+ char16_t c = inputBuf[fp->fInputIdx - 1];
if (c != 0x0a) {
// Not at the start of a line. Back-track out.
fp = (REStackFrame *)fStack->popFrame(fFrameSize);
if (isLineTerminator(c)) {
if (c == 0x0d && fp->fInputIdx < fActiveLimit) {
// Check for CR/LF sequence. Consume both together when found.
- UChar c2;
+ char16_t c2;
U16_NEXT(inputBuf, fp->fInputIdx, fActiveLimit, c2);
if (c2 != 0x0a) {
U16_PREV(inputBuf, 0, fp->fInputIdx, c2);
// offset to the string text, and one for the length.
// The compiled string has already been case folded.
{
- const UChar *patternString = litText + opValue;
+ const char16_t *patternString = litText + opValue;
op = (int32_t)pat[fp->fPatIdx];
fp->fPatIdx++;
#include "remtrans.h"
#include "unicode/unifilt.h"
-static const UChar CURR_ID[] = {65, 110, 121, 45, 0x52, 0x65, 0x6D, 0x6F, 0x76, 0x65, 0x00}; /* "Any-Remove" */
+static const char16_t CURR_ID[] = {65, 110, 121, 45, 0x52, 0x65, 0x6D, 0x6F, 0x76, 0x65, 0x00}; /* "Any-Remove" */
U_NAMESPACE_BEGIN
UnicodeString result;
status = U_ZERO_ERROR;
- UChar *resultChars = result.getBuffer(len16);
+ char16_t *resultChars = result.getBuffer(len16);
utext_extract(fPattern, 0, nativeLen, resultChars, len16, &status); // unterminated warning
result.releaseBuffer(len16);
}
uint32_t
-RuleBasedCollator::setVariableTop(const UChar *varTop, int32_t len, UErrorCode &errorCode) {
+RuleBasedCollator::setVariableTop(const char16_t *varTop, int32_t len, UErrorCode &errorCode) {
if(U_FAILURE(errorCode)) { return 0; }
if(varTop == nullptr && len !=0) {
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
}
UCollationResult
-RuleBasedCollator::compare(const UChar *left, int32_t leftLength,
- const UChar *right, int32_t rightLength,
+RuleBasedCollator::compare(const char16_t *left, int32_t leftLength,
+ const char16_t *right, int32_t rightLength,
UErrorCode &errorCode) const {
if(U_FAILURE(errorCode)) { return UCOL_EQUAL; }
if((left == nullptr && leftLength != 0) || (right == nullptr && rightLength != 0)) {
*/
virtual UChar32 nextRawCodePoint() = 0;
private:
- const UChar *decomp;
- UChar buffer[4];
+ const char16_t *decomp;
+ char16_t buffer[4];
int32_t index;
int32_t length;
};
class UTF16NFDIterator : public NFDIterator {
public:
- UTF16NFDIterator(const UChar *text, const UChar *textLimit) : s(text), limit(textLimit) {}
+ UTF16NFDIterator(const char16_t *text, const char16_t *textLimit) : s(text), limit(textLimit) {}
protected:
virtual UChar32 nextRawCodePoint() override {
if(s == limit) { return U_SENTINEL; }
s = nullptr;
return U_SENTINEL;
}
- UChar trail;
+ char16_t trail;
if(U16_IS_LEAD(c) && s != limit && U16_IS_TRAIL(trail = *s)) {
++s;
c = U16_GET_SUPPLEMENTARY(c, trail);
return c;
}
- const UChar *s;
- const UChar *limit;
+ const char16_t *s;
+ const char16_t *limit;
};
class FCDUTF16NFDIterator : public UTF16NFDIterator {
public:
- FCDUTF16NFDIterator(const Normalizer2Impl &nfcImpl, const UChar *text, const UChar *textLimit)
+ FCDUTF16NFDIterator(const Normalizer2Impl &nfcImpl, const char16_t *text, const char16_t *textLimit)
: UTF16NFDIterator(nullptr, nullptr) {
UErrorCode errorCode = U_ZERO_ERROR;
- const UChar *spanLimit = nfcImpl.makeFCD(text, textLimit, nullptr, errorCode);
+ const char16_t *spanLimit = nfcImpl.makeFCD(text, textLimit, nullptr, errorCode);
if(U_FAILURE(errorCode)) { return; }
if(spanLimit == textLimit || (textLimit == nullptr && *spanLimit == 0)) {
s = text;
} // namespace
UCollationResult
-RuleBasedCollator::doCompare(const UChar *left, int32_t leftLength,
- const UChar *right, int32_t rightLength,
+RuleBasedCollator::doCompare(const char16_t *left, int32_t leftLength,
+ const char16_t *right, int32_t rightLength,
UErrorCode &errorCode) const {
// U_FAILURE(errorCode) checked by caller.
if(left == right && leftLength == rightLength) {
}
// Identical-prefix test.
- const UChar *leftLimit;
- const UChar *rightLimit;
+ const char16_t *leftLimit;
+ const char16_t *rightLimit;
int32_t equalPrefixLength = 0;
if(leftLength < 0) {
leftLimit = nullptr;
rightLimit = nullptr;
- UChar c;
+ char16_t c;
while((c = left[equalPrefixLength]) == right[equalPrefixLength]) {
if(c == 0) { return UCOL_EQUAL; }
++equalPrefixLength;
}
CollationKey &
-RuleBasedCollator::getCollationKey(const UChar *s, int32_t length, CollationKey& key,
+RuleBasedCollator::getCollationKey(const char16_t *s, int32_t length, CollationKey& key,
UErrorCode &errorCode) const {
if(U_FAILURE(errorCode)) {
return key.setToBogus();
}
int32_t
-RuleBasedCollator::getSortKey(const UChar *s, int32_t length,
+RuleBasedCollator::getSortKey(const char16_t *s, int32_t length,
uint8_t *dest, int32_t capacity) const {
if((s == nullptr && length != 0) || capacity < 0 || (dest == nullptr && capacity > 0)) {
return 0;
}
void
-RuleBasedCollator::writeSortKey(const UChar *s, int32_t length,
+RuleBasedCollator::writeSortKey(const char16_t *s, int32_t length,
SortKeyByteSink &sink, UErrorCode &errorCode) const {
if(U_FAILURE(errorCode)) { return; }
- const UChar *limit = (length >= 0) ? s + length : nullptr;
+ const char16_t *limit = (length >= 0) ? s + length : nullptr;
UBool numeric = settings->isNumeric();
CollationKeys::LevelCallback callback;
if(settings->dontCheckFCD()) {
}
void
-RuleBasedCollator::writeIdenticalLevel(const UChar *s, const UChar *limit,
+RuleBasedCollator::writeIdenticalLevel(const char16_t *s, const char16_t *limit,
SortKeyByteSink &sink, UErrorCode &errorCode) const {
// NFD quick check
- const UChar *nfdQCYesLimit = data->nfcImpl.decompose(s, limit, nullptr, errorCode);
+ const char16_t *nfdQCYesLimit = data->nfcImpl.decompose(s, limit, nullptr, errorCode);
if(U_FAILURE(errorCode)) { return; }
sink.Append(Collation::LEVEL_SEPARATOR_BYTE);
UChar32 prev = 0;
for(;;) {
UChar32 c = iter->next(iter);
if(c < 0) { break; }
- s.append((UChar)c);
+ s.append((char16_t)c);
}
- const UChar *sArray = s.getBuffer();
+ const char16_t *sArray = s.getBuffer();
writeIdenticalLevel(sArray, sArray + s.length(), sink, errorCode);
if(U_FAILURE(errorCode)) { return 0; }
if(sink.NumberOfBytesAppended() > count) {
RuleBasedCollator::internalGetCEs(const UnicodeString &str, UVector64 &ces,
UErrorCode &errorCode) const {
if(U_FAILURE(errorCode)) { return; }
- const UChar *s = str.getBuffer();
- const UChar *limit = s + str.length();
+ const char16_t *s = str.getBuffer();
+ const char16_t *limit = s + str.length();
UBool numeric = settings->isNumeric();
if(settings->dontCheckFCD()) {
UTF16CollationIterator iter(data, numeric, s, s, limit);
U_NAMESPACE_BEGIN
-static const UChar kSuperscriptDigits[] = {
+static const char16_t kSuperscriptDigits[] = {
0x2070,
0xB9,
0xB2,
0x2078,
0x2079};
-static const UChar kSuperscriptPlusSign = 0x207A;
-static const UChar kSuperscriptMinusSign = 0x207B;
+static const char16_t kSuperscriptPlusSign = 0x207A;
+static const char16_t kSuperscriptMinusSign = 0x207B;
static UBool copyAsSuperscript(
const UnicodeString &s,
UBool firstTime = true;
for (int32_t i = nextSetBit(0); i >= 0; i = nextSetBit(i + 1)) {
if (!firstTime) {
- dest.append((UChar)0x20);
+ dest.append((char16_t)0x20);
}
firstTime = false;
const char *scriptName = uscript_getShortName((UScriptCode(i)));
m_search_->textLength == that.m_search_->textLength &&
getOffset() == that.getOffset() &&
(uprv_memcmp(m_search_->text, that.m_search_->text,
- m_search_->textLength * sizeof(UChar)) == 0));
+ m_search_->textLength * sizeof(char16_t)) == 0));
}
// public methods ----------------------------------------------------
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(SelectFormat)
-static const UChar SELECT_KEYWORD_OTHER[] = {LOW_O, LOW_T, LOW_H, LOW_E, LOW_R, 0};
+static const char16_t SELECT_KEYWORD_OTHER[] = {LOW_O, LOW_T, LOW_H, LOW_E, LOW_R, 0};
SelectFormat::SelectFormat(const UnicodeString& pat,
UErrorCode& status) : msgPattern(status) {
U_NAMESPACE_BEGIN
-#define DOT ((UChar)0x002E)
-#define SINGLE_QUOTE ((UChar)0x0027)
-#define SLASH ((UChar)0x002F)
-#define BACKSLASH ((UChar)0x005C)
-#define SPACE ((UChar)0x0020)
-#define TAB ((UChar)0x0009)
-#define QUOTATION_MARK ((UChar)0x0022)
-#define ASTERISK ((UChar)0x002A)
-#define COMMA ((UChar)0x002C)
-#define HYPHEN ((UChar)0x002D)
-#define U_ZERO ((UChar)0x0030)
-#define U_ONE ((UChar)0x0031)
-#define U_TWO ((UChar)0x0032)
-#define U_THREE ((UChar)0x0033)
-#define U_FOUR ((UChar)0x0034)
-#define U_FIVE ((UChar)0x0035)
-#define U_SIX ((UChar)0x0036)
-#define U_SEVEN ((UChar)0x0037)
-#define U_EIGHT ((UChar)0x0038)
-#define U_NINE ((UChar)0x0039)
-#define COLON ((UChar)0x003A)
-#define SEMI_COLON ((UChar)0x003B)
-#define CAP_A ((UChar)0x0041)
-#define CAP_B ((UChar)0x0042)
-#define CAP_R ((UChar)0x0052)
-#define CAP_Z ((UChar)0x005A)
-#define LOWLINE ((UChar)0x005F)
-#define LEFTBRACE ((UChar)0x007B)
-#define RIGHTBRACE ((UChar)0x007D)
+#define DOT ((char16_t)0x002E)
+#define SINGLE_QUOTE ((char16_t)0x0027)
+#define SLASH ((char16_t)0x002F)
+#define BACKSLASH ((char16_t)0x005C)
+#define SPACE ((char16_t)0x0020)
+#define TAB ((char16_t)0x0009)
+#define QUOTATION_MARK ((char16_t)0x0022)
+#define ASTERISK ((char16_t)0x002A)
+#define COMMA ((char16_t)0x002C)
+#define HYPHEN ((char16_t)0x002D)
+#define U_ZERO ((char16_t)0x0030)
+#define U_ONE ((char16_t)0x0031)
+#define U_TWO ((char16_t)0x0032)
+#define U_THREE ((char16_t)0x0033)
+#define U_FOUR ((char16_t)0x0034)
+#define U_FIVE ((char16_t)0x0035)
+#define U_SIX ((char16_t)0x0036)
+#define U_SEVEN ((char16_t)0x0037)
+#define U_EIGHT ((char16_t)0x0038)
+#define U_NINE ((char16_t)0x0039)
+#define COLON ((char16_t)0x003A)
+#define SEMI_COLON ((char16_t)0x003B)
+#define CAP_A ((char16_t)0x0041)
+#define CAP_B ((char16_t)0x0042)
+#define CAP_R ((char16_t)0x0052)
+#define CAP_Z ((char16_t)0x005A)
+#define LOWLINE ((char16_t)0x005F)
+#define LEFTBRACE ((char16_t)0x007B)
+#define RIGHTBRACE ((char16_t)0x007D)
-#define LOW_A ((UChar)0x0061)
-#define LOW_B ((UChar)0x0062)
-#define LOW_C ((UChar)0x0063)
-#define LOW_D ((UChar)0x0064)
-#define LOW_E ((UChar)0x0065)
-#define LOW_F ((UChar)0x0066)
-#define LOW_G ((UChar)0x0067)
-#define LOW_H ((UChar)0x0068)
-#define LOW_I ((UChar)0x0069)
-#define LOW_J ((UChar)0x006a)
-#define LOW_K ((UChar)0x006B)
-#define LOW_L ((UChar)0x006C)
-#define LOW_M ((UChar)0x006D)
-#define LOW_N ((UChar)0x006E)
-#define LOW_O ((UChar)0x006F)
-#define LOW_P ((UChar)0x0070)
-#define LOW_Q ((UChar)0x0071)
-#define LOW_R ((UChar)0x0072)
-#define LOW_S ((UChar)0x0073)
-#define LOW_T ((UChar)0x0074)
-#define LOW_U ((UChar)0x0075)
-#define LOW_V ((UChar)0x0076)
-#define LOW_W ((UChar)0x0077)
-#define LOW_X ((UChar)0x0078)
-#define LOW_Y ((UChar)0x0079)
-#define LOW_Z ((UChar)0x007A)
+#define LOW_A ((char16_t)0x0061)
+#define LOW_B ((char16_t)0x0062)
+#define LOW_C ((char16_t)0x0063)
+#define LOW_D ((char16_t)0x0064)
+#define LOW_E ((char16_t)0x0065)
+#define LOW_F ((char16_t)0x0066)
+#define LOW_G ((char16_t)0x0067)
+#define LOW_H ((char16_t)0x0068)
+#define LOW_I ((char16_t)0x0069)
+#define LOW_J ((char16_t)0x006a)
+#define LOW_K ((char16_t)0x006B)
+#define LOW_L ((char16_t)0x006C)
+#define LOW_M ((char16_t)0x006D)
+#define LOW_N ((char16_t)0x006E)
+#define LOW_O ((char16_t)0x006F)
+#define LOW_P ((char16_t)0x0070)
+#define LOW_Q ((char16_t)0x0071)
+#define LOW_R ((char16_t)0x0072)
+#define LOW_S ((char16_t)0x0073)
+#define LOW_T ((char16_t)0x0074)
+#define LOW_U ((char16_t)0x0075)
+#define LOW_V ((char16_t)0x0076)
+#define LOW_W ((char16_t)0x0077)
+#define LOW_X ((char16_t)0x0078)
+#define LOW_Y ((char16_t)0x0079)
+#define LOW_Z ((char16_t)0x007A)
class UnicodeSet;
// Gregorian calendar started.
const int8_t SimpleTimeZone::STATICMONTHLENGTH[] = {31,29,31,30,31,30,31,31,30,31,30,31};
-static const UChar DST_STR[] = {0x0028,0x0044,0x0053,0x0054,0x0029,0}; // "(DST)"
-static const UChar STD_STR[] = {0x0028,0x0053,0x0054,0x0044,0x0029,0}; // "(STD)"
+static const char16_t DST_STR[] = {0x0028,0x0044,0x0053,0x0054,0x0029,0}; // "(DST)"
+static const char16_t STD_STR[] = {0x0028,0x0053,0x0054,0x0044,0x0029,0}; // "(STD)"
// *****************************************************************************
// GMT-minutes. For instance, in France the time zone is GMT+60.
// Also accepted are GMT+H:MM or GMT-H:MM.
// Currently not being used
-//static const UChar gGmt[] = {0x0047, 0x004D, 0x0054, 0x0000}; // "GMT"
-//static const UChar gGmtPlus[] = {0x0047, 0x004D, 0x0054, 0x002B, 0x0000}; // "GMT+"
-//static const UChar gGmtMinus[] = {0x0047, 0x004D, 0x0054, 0x002D, 0x0000}; // "GMT-"
-//static const UChar gDefGmtPat[] = {0x0047, 0x004D, 0x0054, 0x007B, 0x0030, 0x007D, 0x0000}; /* GMT{0} */
-//static const UChar gDefGmtNegHmsPat[] = {0x002D, 0x0048, 0x0048, 0x003A, 0x006D, 0x006D, 0x003A, 0x0073, 0x0073, 0x0000}; /* -HH:mm:ss */
-//static const UChar gDefGmtNegHmPat[] = {0x002D, 0x0048, 0x0048, 0x003A, 0x006D, 0x006D, 0x0000}; /* -HH:mm */
-//static const UChar gDefGmtPosHmsPat[] = {0x002B, 0x0048, 0x0048, 0x003A, 0x006D, 0x006D, 0x003A, 0x0073, 0x0073, 0x0000}; /* +HH:mm:ss */
-//static const UChar gDefGmtPosHmPat[] = {0x002B, 0x0048, 0x0048, 0x003A, 0x006D, 0x006D, 0x0000}; /* +HH:mm */
-//static const UChar gUt[] = {0x0055, 0x0054, 0x0000}; // "UT"
-//static const UChar gUtc[] = {0x0055, 0x0054, 0x0043, 0x0000}; // "UT"
+//static const char16_t gGmt[] = {0x0047, 0x004D, 0x0054, 0x0000}; // "GMT"
+//static const char16_t gGmtPlus[] = {0x0047, 0x004D, 0x0054, 0x002B, 0x0000}; // "GMT+"
+//static const char16_t gGmtMinus[] = {0x0047, 0x004D, 0x0054, 0x002D, 0x0000}; // "GMT-"
+//static const char16_t gDefGmtPat[] = {0x0047, 0x004D, 0x0054, 0x007B, 0x0030, 0x007D, 0x0000}; /* GMT{0} */
+//static const char16_t gDefGmtNegHmsPat[] = {0x002D, 0x0048, 0x0048, 0x003A, 0x006D, 0x006D, 0x003A, 0x0073, 0x0073, 0x0000}; /* -HH:mm:ss */
+//static const char16_t gDefGmtNegHmPat[] = {0x002D, 0x0048, 0x0048, 0x003A, 0x006D, 0x006D, 0x0000}; /* -HH:mm */
+//static const char16_t gDefGmtPosHmsPat[] = {0x002B, 0x0048, 0x0048, 0x003A, 0x006D, 0x006D, 0x003A, 0x0073, 0x0073, 0x0000}; /* +HH:mm:ss */
+//static const char16_t gDefGmtPosHmPat[] = {0x002B, 0x0048, 0x0048, 0x003A, 0x006D, 0x006D, 0x0000}; /* +HH:mm */
+//static const char16_t gUt[] = {0x0055, 0x0054, 0x0000}; // "UT"
+//static const char16_t gUtc[] = {0x0055, 0x0054, 0x0043, 0x0000}; // "UT"
typedef enum GmtPatSize {
kGmtLen = 3,
// This is a pattern-of-last-resort used when we can't load a usable pattern out
// of a resource.
-static const UChar gDefaultPattern[] =
+static const char16_t gDefaultPattern[] =
{
0x79, 0x4D, 0x4D, 0x64, 0x64, 0x20, 0x68, 0x68, 0x3A, 0x6D, 0x6D, 0x20, 0x61, 0
}; /* "yMMdd hh:mm a" */
// This prefix is designed to NEVER MATCH real text, in order to
// suppress the parsing of negative numbers. Adjust as needed (if
// this becomes valid Unicode).
-static const UChar SUPPRESS_NEGATIVE_PREFIX[] = {0xAB00, 0};
+static const char16_t SUPPRESS_NEGATIVE_PREFIX[] = {0xAB00, 0};
/**
* These are the tags we expect to see in normal resource bundle files associated
* with a locale.
*/
-static const UChar QUOTE = 0x27; // Single quote
+static const char16_t QUOTE = 0x27; // Single quote
/*
* The field range check bias for each UDateFormatField.
}
//----------------------------------------------------------------------
-static const UChar* timeSkeletons[4] = {
+static const char16_t* timeSkeletons[4] = {
u"jmmsszzzz", // kFull
u"jmmssz", // kLong
u"jmmss", // kMedium
return;
}
- const UChar *resStr,*ovrStr;
+ const char16_t *resStr,*ovrStr;
int32_t resStrLen,ovrStrLen = 0;
fDateOverride.setToBogus();
fTimeOverride.setToBogus();
}
UBool inQuote = false;
- UChar prevCh = 0;
+ char16_t prevCh = 0;
int32_t count = 0;
int32_t fieldNum = 0;
UDisplayContext capitalizationContext = getContext(UDISPCTX_TYPE_CAPITALIZATION, status);
// loop through the pattern string character by character
for (int32_t i = 0; i < fPattern.length() && U_SUCCESS(status); ++i) {
- UChar ch = fPattern[i];
+ char16_t ch = fPattern[i];
// Use subFormat() to format a repeated pattern character
// when a different pattern or non-pattern character is seen
// Consecutive single quotes are a single quote literal,
// either outside of quotes or between quotes
if ((i+1) < fPattern.length() && fPattern[i+1] == QUOTE) {
- appendTo += (UChar)QUOTE;
+ appendTo += (char16_t)QUOTE;
++i;
} else {
inQuote = ! inQuote;
/*A?.*/ 40, 0, 0
};
-int32_t SimpleDateFormat::getLevelFromChar(UChar ch) {
+int32_t SimpleDateFormat::getLevelFromChar(char16_t ch) {
// Map date field LETTER into calendar field level.
// the larger the level, the smaller the field unit.
// NOTE: if new fields adds in, the table needs to update.
return ch < UPRV_LENGTHOF(mapCharToLevel) ? mapCharToLevel[ch] : -1;
}
-UBool SimpleDateFormat::isSyntaxChar(UChar ch) {
+UBool SimpleDateFormat::isSyntaxChar(char16_t ch) {
static const UBool mapCharToIsSyntax[] = {
//
false, false, false, false, false, false, false, false,
NSOverride *overrideList = nullptr;
while (moreToProcess) {
- int32_t delimiterPosition = str.indexOf((UChar)ULOC_KEYWORD_ITEM_SEPARATOR_UNICODE,start);
+ int32_t delimiterPosition = str.indexOf((char16_t)ULOC_KEYWORD_ITEM_SEPARATOR_UNICODE,start);
if (delimiterPosition == -1) {
moreToProcess = false;
len = str.length() - start;
len = delimiterPosition - start;
}
UnicodeString currentString(str,start,len);
- int32_t equalSignPosition = currentString.indexOf((UChar)ULOC_KEYWORD_ASSIGN_UNICODE,0);
+ int32_t equalSignPosition = currentString.indexOf((char16_t)ULOC_KEYWORD_ASSIGN_UNICODE,0);
if (equalSignPosition == -1) { // Simple override string such as "hebrew"
nsName.setTo(currentString);
ovrField.setToBogus();
case UDAT_TIMEZONE_ISO_FIELD: // 'X'
case UDAT_TIMEZONE_ISO_LOCAL_FIELD: // 'x'
{
- UChar zsbuf[ZONE_NAME_U16_MAX];
+ char16_t zsbuf[ZONE_NAME_U16_MAX];
UnicodeString zoneString(zsbuf, 0, UPRV_LENGTHOF(zsbuf));
const TimeZone& tz = cal.getTimeZone();
UDate date = cal.getTime(status);
return;
}
for (int i=0; i<fields.length(); i++) {
- UChar field = fields.charAt(i);
+ char16_t field = fields.charAt(i);
// if the pattern character is unrecognized, signal an error and bail out
UDateFormatField patternCharIndex = DateFormatSymbols::getPatternCharIndex(field);
if (patternCharIndex == UDAT_FIELD_COUNT) {
}
const NumberFormat *
-SimpleDateFormat::getNumberFormatForField(UChar field) const {
+SimpleDateFormat::getNumberFormatForField(char16_t field) const {
UDateFormatField index = DateFormatSymbols::getPatternCharIndex(field);
if (index == UDAT_FIELD_COUNT) {
return nullptr;
* Return true if the given format character, occurring count
* times, represents a numeric field.
*/
-UBool SimpleDateFormat::isNumeric(UChar formatChar, int32_t count) {
+UBool SimpleDateFormat::isNumeric(char16_t formatChar, int32_t count) {
return DateFormatSymbols::isNumericPatternChar(formatChar, count);
}
// not at any field
return false;
}
- UChar ch = pattern.charAt(patternOffset);
+ char16_t ch = pattern.charAt(patternOffset);
UDateFormatField f = DateFormatSymbols::getPatternCharIndex(ch);
if (f == UDAT_FIELD_COUNT) {
// not at any field
// not after any field
return false;
}
- UChar ch = pattern.charAt(--patternOffset);
+ char16_t ch = pattern.charAt(--patternOffset);
UDateFormatField f = DateFormatSymbols::getPatternCharIndex(ch);
if (f == UDAT_FIELD_COUNT) {
// not after any field
}
for (int32_t i=0; i<fPattern.length(); ++i) {
- UChar ch = fPattern.charAt(i);
+ char16_t ch = fPattern.charAt(i);
// Handle alphabetic field characters.
if (!inQuote && isSyntaxChar(ch)) {
if (i+1 < fPattern.length()) {
// move to next pattern character
- UChar c = fPattern.charAt(i+1);
+ char16_t c = fPattern.charAt(i+1);
// check for whitespace
if (PatternProps::isWhiteSpace(c)) {
// scan pattern looking for contiguous literal characters
for ( ; i < pattern.length(); i += 1) {
- UChar ch = pattern.charAt(i);
+ char16_t ch = pattern.charAt(i);
if (!inQuote && isSyntaxChar(ch)) {
break;
int32_t tStart = t;
while (t < text.length()) {
- UChar tch = text.charAt(t);
+ char16_t tch = text.charAt(t);
if (!u_isUWhiteSpace(tch) && !PatternProps::isWhiteSpace(tch)) {
break;
}
// if it is actual whitespace and we're whitespace lenient it's OK
- UChar wsc = text.charAt(t);
+ char16_t wsc = text.charAt(t);
if(PatternProps::isWhiteSpace(wsc)) {
// Lenient mode and it's just whitespace we skip it
++t;
}
for (t = textOffset; t < text.length(); t += 1) {
- UChar ch = text.charAt(t);
+ char16_t ch = text.charAt(t);
if (ignorables == nullptr || !ignorables->contains(ch)) {
break;
* Private member function that converts the parsed date strings into
* timeFields. Returns -start (for ParsePosition) if failed.
*/
-int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UChar ch, int32_t count,
+int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, char16_t ch, int32_t count,
UBool obeyCount, UBool allowNegative, UBool ambiguousYear[], int32_t& saveHebrewMonth, Calendar& cal,
int32_t patLoc, MessageFormat * numericLeapMonthFormatter, UTimeZoneFormatTimeType *tzTimeType,
int32_t *dayPeriod) const
// so we should not get here. Leave support in for future definition.
case UDAT_TIME_SEPARATOR_FIELD:
{
- static const UChar def_sep = DateFormatSymbols::DEFAULT_TIME_SEPARATOR;
- static const UChar alt_sep = DateFormatSymbols::ALTERNATE_TIME_SEPARATOR;
+ static const char16_t def_sep = DateFormatSymbols::DEFAULT_TIME_SEPARATOR;
+ static const char16_t alt_sep = DateFormatSymbols::ALTERNATE_TIME_SEPARATOR;
// Try matching a time separator.
int32_t count_sep = 1;
translatedPattern.remove();
UBool inQuote = false;
for (int32_t i = 0; i < originalPattern.length(); ++i) {
- UChar c = originalPattern[i];
+ char16_t c = originalPattern[i];
if (inQuote) {
if (c == QUOTE) {
inQuote = false;
UCalendarDateFields field) {
int32_t fieldLevel = fgCalendarFieldToLevel[field];
int32_t level;
- UChar ch;
+ char16_t ch;
UBool inQuote = false;
- UChar prevCh = 0;
+ char16_t prevCh = 0;
int32_t count = 0;
for (int32_t i = 0; i < pattern.length(); ++i) {
int32_t
SimpleDateFormat::skipPatternWhiteSpace(const UnicodeString& text, int32_t pos) const {
- const UChar* s = text.getBuffer();
+ const char16_t* s = text.getBuffer();
return (int32_t)(PatternProps::skipWhiteSpace(s + pos, text.length() - pos) - s);
}
int len = fPattern.length();
UBool inQuote = false;
for (int32_t i = 0; i < len; ++i) {
- UChar ch = fPattern[i];
+ char16_t ch = fPattern[i];
if (ch == QUOTE) {
inQuote = !inQuote;
}
return -1;
}
-static const UChar gZero[] = u"zero";
-static const UChar gOne[] = u"one";
-static const UChar gTwo[] = u"two";
-static const UChar gFew[] = u"few";
-static const UChar gMany[] = u"many";
-static const UChar gOther[] = u"other";
-static const UChar gEq0[] = u"=0";
-static const UChar gEq1[] = u"=1";
+static const char16_t gZero[] = u"zero";
+static const char16_t gOne[] = u"one";
+static const char16_t gTwo[] = u"two";
+static const char16_t gFew[] = u"few";
+static const char16_t gMany[] = u"many";
+static const char16_t gOther[] = u"other";
+static const char16_t gEq0[] = u"=0";
+static const char16_t gEq1[] = u"=1";
int32_t StandardPlural::indexOrNegativeFromString(const UnicodeString &keyword) {
switch (keyword.length()) {
if (limit < cursor) {
// Match in the reverse direction
for (i=pattern.length()-1; i>=0; --i) {
- UChar keyChar = pattern.charAt(i);
+ char16_t keyChar = pattern.charAt(i);
UnicodeMatcher* subm = data->lookupMatcher(keyChar);
if (subm == 0) {
if (cursor > limit &&
// without completing our match.
return U_PARTIAL_MATCH;
}
- UChar keyChar = pattern.charAt(i);
+ char16_t keyChar = pattern.charAt(i);
UnicodeMatcher* subm = data->lookupMatcher(keyChar);
if (subm == 0) {
// Don't need the cursor < limit check if
result.truncate(0);
UnicodeString str, quoteBuf;
if (segmentNumber > 0) {
- result.append((UChar)40); /*(*/
+ result.append((char16_t)40); /*(*/
}
for (int32_t i=0; i<pattern.length(); ++i) {
- UChar keyChar = pattern.charAt(i);
+ char16_t keyChar = pattern.charAt(i);
const UnicodeMatcher* m = data->lookupMatcher(keyChar);
if (m == 0) {
ICU_Utility::appendToRule(result, keyChar, false, escapeUnprintable, quoteBuf);
}
}
if (segmentNumber > 0) {
- result.append((UChar)41); /*)*/
+ result.append((char16_t)41); /*)*/
}
// Flush quoteBuf out to result
ICU_Utility::appendToRule(result, -1,
UBool /*escapeUnprintable*/) const {
// assert(segmentNumber > 0);
rule.truncate(0);
- rule.append((UChar)0x0024 /*$*/);
+ rule.append((char16_t)0x0024 /*$*/);
ICU_Utility::appendNumber(rule, segmentNumber, 10, 1);
return rule;
}
text.copy(start-len, start, tempStart);
destStart += len;
} else {
- UnicodeString str((UChar) 0xFFFF);
+ UnicodeString str((char16_t) 0xFFFF);
text.handleReplaceBetween(tempStart, tempStart, str);
destStart++;
}
// Handle a cursor preceding the output
if (hasCursor && cursor < 0) {
while (cursor++ < 0) {
- ICU_Utility::appendToRule(rule, (UChar)0x0040 /*@*/, true, escapeUnprintable, quoteBuf);
+ ICU_Utility::appendToRule(rule, (char16_t)0x0040 /*@*/, true, escapeUnprintable, quoteBuf);
}
// Fall through and append '|' below
}
for (int32_t i=0; i<output.length(); ++i) {
if (hasCursor && i == cursor) {
- ICU_Utility::appendToRule(rule, (UChar)0x007C /*|*/, true, escapeUnprintable, quoteBuf);
+ ICU_Utility::appendToRule(rule, (char16_t)0x007C /*|*/, true, escapeUnprintable, quoteBuf);
}
- UChar c = output.charAt(i); // Ok to use 16-bits here
+ char16_t c = output.charAt(i); // Ok to use 16-bits here
UnicodeReplacer* r = data->lookupReplacer(c);
if (r == nullptr) {
} else {
UnicodeString buf;
r->toReplacerPattern(buf, escapeUnprintable);
- buf.insert(0, (UChar)0x20);
- buf.append((UChar)0x20);
+ buf.insert(0, (char16_t)0x20);
+ buf.append((char16_t)0x20);
ICU_Utility::appendToRule(rule, buf,
true, escapeUnprintable, quoteBuf);
}
if (hasCursor && cursor > output.length()) {
cursor -= output.length();
while (cursor-- > 0) {
- ICU_Utility::appendToRule(rule, (UChar)0x0040 /*@*/, true, escapeUnprintable, quoteBuf);
+ ICU_Utility::appendToRule(rule, (char16_t)0x0040 /*@*/, true, escapeUnprintable, quoteBuf);
}
- ICU_Utility::appendToRule(rule, (UChar)0x007C /*|*/, true, escapeUnprintable, quoteBuf);
+ ICU_Utility::appendToRule(rule, (char16_t)0x007C /*|*/, true, escapeUnprintable, quoteBuf);
}
// Flush quoteBuf out to result
ICU_Utility::appendToRule(rule, -1,
// Static data and constants
-static const UChar WORLD[] = {0x30, 0x30, 0x31, 0x00}; /* "001" */
+static const char16_t WORLD[] = {0x30, 0x30, 0x31, 0x00}; /* "001" */
-static const UChar GMT_ID[] = {0x47, 0x4D, 0x54, 0x00}; /* "GMT" */
-static const UChar UNKNOWN_ZONE_ID[] = {0x45, 0x74, 0x63, 0x2F, 0x55, 0x6E, 0x6B, 0x6E, 0x6F, 0x77, 0x6E, 0x00}; /* "Etc/Unknown" */
+static const char16_t GMT_ID[] = {0x47, 0x4D, 0x54, 0x00}; /* "GMT" */
+static const char16_t UNKNOWN_ZONE_ID[] = {0x45, 0x74, 0x63, 0x2F, 0x55, 0x6E, 0x6B, 0x6E, 0x6F, 0x77, 0x6E, 0x00}; /* "Etc/Unknown" */
static const int32_t GMT_ID_LENGTH = 3;
static const int32_t UNKNOWN_ZONE_ID_LENGTH = 11;
static int32_t findInStringArray(UResourceBundle* array, const UnicodeString& id, UErrorCode &status)
{
UnicodeString copy;
- const UChar *u;
+ const char16_t *u;
int32_t len;
int32_t start = 0;
}
}
if (type == UCAL_ZONE_TYPE_CANONICAL_LOCATION) {
- const UChar *region = TimeZone::getRegion(id, ec);
+ const char16_t *region = TimeZone::getRegion(id, ec);
if (U_FAILURE(ec)) {
break;
}
UBool getID(int32_t i, UErrorCode& ec) {
int32_t idLen = 0;
- const UChar* id = nullptr;
+ const char16_t* id = nullptr;
UResourceBundle *top = ures_openDirect(0, kZONEINFO, &ec);
top = ures_getByKey(top, kNAMES, top, &ec); // dereference Zones section
id = ures_getStringByIndex(top, i, &idLen, &ec);
UResourceBundle *ares = ures_getByKey(top, kNAMES, nullptr, &ec); // dereference Zones section
if (U_SUCCESS(ec)) {
int32_t idLen = 0;
- const UChar* id2 = ures_getStringByIndex(ares, zone, &idLen, &ec);
+ const char16_t* id2 = ures_getStringByIndex(ares, zone, &idLen, &ec);
result.fastCopyFrom(UnicodeString(true, id2, idLen));
U_DEBUG_TZ_MSG(("gei(%d) -> %d, len%d, %s\n", index, zone, result.length(), u_errorName(ec)));
}
// These methods are used by ZoneMeta class only.
-const UChar*
+const char16_t*
TimeZone::findID(const UnicodeString& id) {
- const UChar *result = nullptr;
+ const char16_t *result = nullptr;
UErrorCode ec = U_ZERO_ERROR;
UResourceBundle *rb = ures_openDirect(nullptr, kZONEINFO, &ec);
}
-const UChar*
+const char16_t*
TimeZone::dereferOlsonLink(const UnicodeString& id) {
- const UChar *result = nullptr;
+ const char16_t *result = nullptr;
UErrorCode ec = U_ZERO_ERROR;
UResourceBundle *rb = ures_openDirect(nullptr, kZONEINFO, &ec);
if (ures_getType(rb) == URES_INT) {
// this is a link - dereference the link
int32_t deref = ures_getInt(rb, &ec);
- const UChar* tmp = ures_getStringByIndex(names, deref, nullptr, &ec);
+ const char16_t* tmp = ures_getStringByIndex(names, deref, nullptr, &ec);
if (U_SUCCESS(ec)) {
result = tmp;
}
return result;
}
-const UChar*
+const char16_t*
TimeZone::getRegion(const UnicodeString& id) {
UErrorCode status = U_ZERO_ERROR;
return getRegion(id, status);
}
-const UChar*
+const char16_t*
TimeZone::getRegion(const UnicodeString& id, UErrorCode& status) {
if (U_FAILURE(status)) {
return nullptr;
}
- const UChar *result = nullptr;
+ const char16_t *result = nullptr;
UResourceBundle *rb = ures_openDirect(nullptr, kZONEINFO, &status);
// resolve zone index by name
// get region mapping
ures_getByKey(rb, kREGIONS, res, &status);
- const UChar *tmp = ures_getStringByIndex(res, idx, nullptr, &status);
+ const char16_t *tmp = ures_getStringByIndex(res, idx, nullptr, &status);
if (U_SUCCESS(status)) {
result = tmp;
}
return 0;
}
- const UChar *uregion = nullptr;
+ const char16_t *uregion = nullptr;
// "Etc/Unknown" is not a system zone ID,
// but in the zone data
if (id.compare(UNKNOWN_ZONE_ID, UNKNOWN_ZONE_ID_LENGTH) != 0) {
id.setTo(GMT_ID, GMT_ID_LENGTH);
if (hour | min | sec) {
if (negative) {
- id += (UChar)MINUS;
+ id += (char16_t)MINUS;
} else {
- id += (UChar)PLUS;
+ id += (char16_t)PLUS;
}
if (hour < 10) {
- id += (UChar)ZERO_DIGIT;
+ id += (char16_t)ZERO_DIGIT;
} else {
- id += (UChar)(ZERO_DIGIT + hour/10);
+ id += (char16_t)(ZERO_DIGIT + hour/10);
}
- id += (UChar)(ZERO_DIGIT + hour%10);
- id += (UChar)COLON;
+ id += (char16_t)(ZERO_DIGIT + hour%10);
+ id += (char16_t)COLON;
if (min < 10) {
- id += (UChar)ZERO_DIGIT;
+ id += (char16_t)ZERO_DIGIT;
} else {
- id += (UChar)(ZERO_DIGIT + min/10);
+ id += (char16_t)(ZERO_DIGIT + min/10);
}
- id += (UChar)(ZERO_DIGIT + min%10);
+ id += (char16_t)(ZERO_DIGIT + min%10);
if (sec) {
- id += (UChar)COLON;
+ id += (char16_t)COLON;
if (sec < 10) {
- id += (UChar)ZERO_DIGIT;
+ id += (char16_t)ZERO_DIGIT;
} else {
- id += (UChar)(ZERO_DIGIT + sec/10);
+ id += (char16_t)(ZERO_DIGIT + sec/10);
}
- id += (UChar)(ZERO_DIGIT + sec%10);
+ id += (char16_t)(ZERO_DIGIT + sec%10);
}
}
return id;
int32_t len = 0;
StackUResourceBundle bundle;
ures_openDirectFillIn(bundle.getAlias(), nullptr, kZONEINFO, &status);
- const UChar *tzver = ures_getStringByKey(bundle.getAlias(), kTZVERSION, &len, &status);
+ const char16_t *tzver = ures_getStringByKey(bundle.getAlias(), kTZVERSION, &len, &status);
if (U_SUCCESS(status)) {
if (len >= (int32_t)sizeof(TZDATA_VERSION)) {
continue;
}
int32_t len;
- const UChar *tzids = ures_getString(regionalData, &len, &status);
+ const char16_t *tzids = ures_getString(regionalData, &len, &status);
if (U_FAILURE(status)) {
break;
}
- const UChar *start = tzids;
+ const char16_t *start = tzids;
UBool hasNext = true;
while (hasNext) {
- const UChar *end = u_strchr(start, (UChar)0x20);
+ const char16_t *end = u_strchr(start, (char16_t)0x20);
if (end == nullptr) {
end = tzids + len;
hasNext = false;
return id;
}
- const UChar *tzid = nullptr;
+ const char16_t *tzid = nullptr;
int32_t len = 0;
UBool gotID = false;
if (region) {
- const UChar *tzids = ures_getStringByKey(zones, region, &len, &tmperr); // use tmperr, because
+ const char16_t *tzids = ures_getStringByKey(zones, region, &len, &tmperr); // use tmperr, because
// regional mapping is optional
if (U_SUCCESS(tmperr)) {
// first ID delimited by space is the default one
- const UChar *end = u_strchr(tzids, (UChar)0x20);
+ const char16_t *end = u_strchr(tzids, (char16_t)0x20);
if (end == nullptr) {
id.setTo(tzids, -1);
} else {
csc.limit = offsets.contextLimit;
UnicodeString tmp;
- const UChar *s;
+ const char16_t *s;
int32_t textPos, delta, result;
for(textPos=offsets.start; textPos<offsets.limit;) {
#include "unicode/msgfmt.h"
#include "uassert.h"
-#define LEFT_CURLY_BRACKET ((UChar)0x007B)
-#define RIGHT_CURLY_BRACKET ((UChar)0x007D)
-#define SPACE ((UChar)0x0020)
-#define DIGIT_ZERO ((UChar)0x0030)
-#define LOW_S ((UChar)0x0073)
-#define LOW_M ((UChar)0x006D)
-#define LOW_I ((UChar)0x0069)
-#define LOW_N ((UChar)0x006E)
-#define LOW_H ((UChar)0x0068)
-#define LOW_W ((UChar)0x0077)
-#define LOW_D ((UChar)0x0064)
-#define LOW_Y ((UChar)0x0079)
-#define LOW_Z ((UChar)0x007A)
-#define LOW_E ((UChar)0x0065)
-#define LOW_R ((UChar)0x0072)
-#define LOW_O ((UChar)0x006F)
-#define LOW_N ((UChar)0x006E)
-#define LOW_T ((UChar)0x0074)
+#define LEFT_CURLY_BRACKET ((char16_t)0x007B)
+#define RIGHT_CURLY_BRACKET ((char16_t)0x007D)
+#define SPACE ((char16_t)0x0020)
+#define DIGIT_ZERO ((char16_t)0x0030)
+#define LOW_S ((char16_t)0x0073)
+#define LOW_M ((char16_t)0x006D)
+#define LOW_I ((char16_t)0x0069)
+#define LOW_N ((char16_t)0x006E)
+#define LOW_H ((char16_t)0x0068)
+#define LOW_W ((char16_t)0x0077)
+#define LOW_D ((char16_t)0x0064)
+#define LOW_Y ((char16_t)0x0079)
+#define LOW_Z ((char16_t)0x007A)
+#define LOW_E ((char16_t)0x0065)
+#define LOW_R ((char16_t)0x0072)
+#define LOW_O ((char16_t)0x006F)
+#define LOW_N ((char16_t)0x006E)
+#define LOW_T ((char16_t)0x0074)
//TODO: define in compile time
static const char gTimeUnitSecond[] = "second";
static const char gPluralCountOther[] = "other";
-static const UChar DEFAULT_PATTERN_FOR_SECOND[] = {LEFT_CURLY_BRACKET, DIGIT_ZERO, RIGHT_CURLY_BRACKET, SPACE, LOW_S, 0};
-static const UChar DEFAULT_PATTERN_FOR_MINUTE[] = {LEFT_CURLY_BRACKET, DIGIT_ZERO, RIGHT_CURLY_BRACKET, SPACE, LOW_M, LOW_I, LOW_N, 0};
-static const UChar DEFAULT_PATTERN_FOR_HOUR[] = {LEFT_CURLY_BRACKET, DIGIT_ZERO, RIGHT_CURLY_BRACKET, SPACE, LOW_H, 0};
-static const UChar DEFAULT_PATTERN_FOR_WEEK[] = {LEFT_CURLY_BRACKET, DIGIT_ZERO, RIGHT_CURLY_BRACKET, SPACE, LOW_W, 0};
-static const UChar DEFAULT_PATTERN_FOR_DAY[] = {LEFT_CURLY_BRACKET, DIGIT_ZERO, RIGHT_CURLY_BRACKET, SPACE, LOW_D, 0};
-static const UChar DEFAULT_PATTERN_FOR_MONTH[] = {LEFT_CURLY_BRACKET, DIGIT_ZERO, RIGHT_CURLY_BRACKET, SPACE, LOW_M, 0};
-static const UChar DEFAULT_PATTERN_FOR_YEAR[] = {LEFT_CURLY_BRACKET, DIGIT_ZERO, RIGHT_CURLY_BRACKET, SPACE, LOW_Y, 0};
+static const char16_t DEFAULT_PATTERN_FOR_SECOND[] = {LEFT_CURLY_BRACKET, DIGIT_ZERO, RIGHT_CURLY_BRACKET, SPACE, LOW_S, 0};
+static const char16_t DEFAULT_PATTERN_FOR_MINUTE[] = {LEFT_CURLY_BRACKET, DIGIT_ZERO, RIGHT_CURLY_BRACKET, SPACE, LOW_M, LOW_I, LOW_N, 0};
+static const char16_t DEFAULT_PATTERN_FOR_HOUR[] = {LEFT_CURLY_BRACKET, DIGIT_ZERO, RIGHT_CURLY_BRACKET, SPACE, LOW_H, 0};
+static const char16_t DEFAULT_PATTERN_FOR_WEEK[] = {LEFT_CURLY_BRACKET, DIGIT_ZERO, RIGHT_CURLY_BRACKET, SPACE, LOW_W, 0};
+static const char16_t DEFAULT_PATTERN_FOR_DAY[] = {LEFT_CURLY_BRACKET, DIGIT_ZERO, RIGHT_CURLY_BRACKET, SPACE, LOW_D, 0};
+static const char16_t DEFAULT_PATTERN_FOR_MONTH[] = {LEFT_CURLY_BRACKET, DIGIT_ZERO, RIGHT_CURLY_BRACKET, SPACE, LOW_M, 0};
+static const char16_t DEFAULT_PATTERN_FOR_YEAR[] = {LEFT_CURLY_BRACKET, DIGIT_ZERO, RIGHT_CURLY_BRACKET, SPACE, LOW_Y, 0};
-static const UChar PLURAL_COUNT_ZERO[] = {LOW_Z, LOW_E, LOW_R, LOW_O, 0};
-static const UChar PLURAL_COUNT_ONE[] = {LOW_O, LOW_N, LOW_E, 0};
-static const UChar PLURAL_COUNT_TWO[] = {LOW_T, LOW_W, LOW_O, 0};
+static const char16_t PLURAL_COUNT_ZERO[] = {LOW_Z, LOW_E, LOW_R, LOW_O, 0};
+static const char16_t PLURAL_COUNT_ONE[] = {LOW_O, LOW_N, LOW_E, 0};
+static const char16_t PLURAL_COUNT_TWO[] = {LOW_T, LOW_W, LOW_O, 0};
TimeUnitFormat::TimeUnitFormat(UErrorCode& status) {
initMeasureFormat(Locale::getDefault(), UMEASFMT_WIDTH_WIDE, nullptr, status);
LocalUResourceBundlePointer unitsRes(ures_getByKey(rb.getAlias(), key, nullptr, &status));
const char* timeUnitName = getTimeUnitName(srcTimeUnitField, status);
LocalUResourceBundlePointer countsToPatternRB(ures_getByKey(unitsRes.getAlias(), timeUnitName, nullptr, &status));
- const UChar* pattern;
+ const char16_t* pattern;
int32_t ptLength;
pattern = ures_getStringByKeyWithFallback(countsToPatternRB.getAlias(), searchPluralCount, &ptLength, &status);
if (U_SUCCESS(status)) {
if ( uprv_strcmp(searchPluralCount, gPluralCountOther) == 0 ) {
// set default fall back the same as the resource in root
LocalPointer<MessageFormat> messageFormat;
- const UChar *pattern = nullptr;
+ const char16_t *pattern = nullptr;
if ( srcTimeUnitField == TimeUnit::UTIMEUNIT_SECOND ) {
pattern = DEFAULT_PATTERN_FOR_SECOND;
} else if ( srcTimeUnitField == TimeUnit::UTIMEUNIT_MINUTE ) {
#include "cstring.h"
#include "uinvchar.h"
-static const UChar TARGET_SEP = 0x002D; /*-*/
-static const UChar ID_DELIM = 0x003B; /*;*/
-static const UChar VARIANT_SEP = 0x002F; // '/'
+static const char16_t TARGET_SEP = 0x002D; /*-*/
+static const char16_t ID_DELIM = 0x003B; /*;*/
+static const char16_t VARIANT_SEP = 0x002F; // '/'
/**
* Prefix for resource bundle key for the display name for a
maximumContextLength(0)
{
// NUL-terminate the ID string, which is a non-aliased copy.
- ID.append((UChar)0);
+ ID.append((char16_t)0);
ID.truncate(ID.length()-1);
}
maximumContextLength(other.maximumContextLength)
{
// NUL-terminate the ID string, which is a non-aliased copy.
- ID.append((UChar)0);
+ ID.append((char16_t)0);
ID.truncate(ID.length()-1);
if (other.filter != 0) {
* @deprecated the new architecture provides filtering at the top
* level. This method will be removed Dec 31 2001.
*/
-UChar Transliterator::filteredCharAt(const Replaceable& text, int32_t i) const {
- UChar c;
+char16_t Transliterator::filteredCharAt(const Replaceable& text, int32_t i) const {
+ char16_t c;
const UnicodeFilter* localFilter = getFilter();
return (localFilter == 0) ? text.charAt(i) :
- (localFilter->contains(c = text.charAt(i)) ? c : (UChar)0xFFFE);
+ (localFilter->contains(c = text.charAt(i)) ? c : (char16_t)0xFFFE);
}
#endif
}
UResourceBundle* res = ures_getNextResource(colBund, nullptr, &lstatus);
const char* typeStr = ures_getKey(res);
- UChar type;
+ char16_t type;
u_charsToUChars(typeStr, &type, 1);
if (U_SUCCESS(lstatus)) {
int32_t len = 0;
- const UChar *resString;
+ const char16_t *resString;
switch (type) {
case 0x66: // 'f'
case 0x69: // 'i'
#include <stdio.h>
#endif
-// UChar constants
-static const UChar LOCALE_SEP = 95; // '_'
-//static const UChar ID_SEP = 0x002D; /*-*/
-//static const UChar VARIANT_SEP = 0x002F; // '/'
+// char16_t constants
+static const char16_t LOCALE_SEP = 95; // '_'
+//static const char16_t ID_SEP = 0x002D; /*-*/
+//static const char16_t VARIANT_SEP = 0x002F; // '/'
// String constants
-static const UChar ANY[] = { 0x41, 0x6E, 0x79, 0 }; // Any
-static const UChar LAT[] = { 0x4C, 0x61, 0x74, 0 }; // Lat
+static const char16_t ANY[] = { 0x41, 0x6E, 0x79, 0 }; // Any
+static const char16_t LAT[] = { 0x4C, 0x61, 0x74, 0 }; // Lat
// empty string
#define NO_VARIANT UnicodeString()
// to see whether there really are ID blocks at the beginning and end (by looking for U+FFFF, which
// marks the position where an anonymous transliterator goes) and adjust accordingly
int32_t anonymousRBTs = transes->size();
- UnicodeString noIDBlock((UChar)(0xffff));
- noIDBlock += ((UChar)(0xffff));
+ UnicodeString noIDBlock((char16_t)(0xffff));
+ noIDBlock += ((char16_t)(0xffff));
int32_t pos = aliasesOrRules.indexOf(noIDBlock);
while (pos >= 0) {
pos = aliasesOrRules.indexOf(noIDBlock, pos + 1);
UVector transliterators(uprv_deleteUObject, nullptr, ec);
UnicodeString idBlock;
- int32_t blockSeparatorPos = aliasesOrRules.indexOf((UChar)(0xffff));
+ int32_t blockSeparatorPos = aliasesOrRules.indexOf((char16_t)(0xffff));
while (blockSeparatorPos >= 0) {
aliasesOrRules.extract(0, blockSeparatorPos, idBlock);
aliasesOrRules.remove(0, blockSeparatorPos + 1);
transliterators.adoptElement(Transliterator::createInstance(idBlock, UTRANS_FORWARD, pe, ec), ec);
if (!transes->isEmpty())
transliterators.adoptElement(transes->orphanElementAt(0), ec);
- blockSeparatorPos = aliasesOrRules.indexOf((UChar)(0xffff));
+ blockSeparatorPos = aliasesOrRules.indexOf((char16_t)(0xffff));
}
if (!aliasesOrRules.isEmpty())
transliterators.adoptElement(Transliterator::createInstance(aliasesOrRules, UTRANS_FORWARD, pe, ec), ec);
if (U_FAILURE(status)) {
delete data;
}
- entry->stringArg += (UChar)0xffff; // use U+FFFF to mark position of RBTs in ID block
+ entry->stringArg += (char16_t)0xffff; // use U+FFFF to mark position of RBTs in ID block
}
}
}
}
// As of 2.0, resource bundle keys cannot contain '_'
-static const UChar TRANSLITERATE_TO[] = {84,114,97,110,115,108,105,116,101,114,97,116,101,84,111,0}; // "TransliterateTo"
+static const char16_t TRANSLITERATE_TO[] = {84,114,97,110,115,108,105,116,101,114,97,116,101,84,111,0}; // "TransliterateTo"
-static const UChar TRANSLITERATE_FROM[] = {84,114,97,110,115,108,105,116,101,114,97,116,101,70,114,111,109,0}; // "TransliterateFrom"
+static const char16_t TRANSLITERATE_FROM[] = {84,114,97,110,115,108,105,116,101,114,97,116,101,70,114,111,109,0}; // "TransliterateFrom"
-static const UChar TRANSLITERATE[] = {84,114,97,110,115,108,105,116,101,114,97,116,101,0}; // "Transliterate"
+static const char16_t TRANSLITERATE[] = {84,114,97,110,115,108,105,116,101,114,97,116,101,0}; // "Transliterate"
/**
* Attempt to find an entry in a single resource bundle. This is
U_NAMESPACE_BEGIN
-static const UChar ID_DELIM = 0x003B; // ;
-static const UChar TARGET_SEP = 0x002D; // -
-static const UChar VARIANT_SEP = 0x002F; // /
-static const UChar OPEN_REV = 0x0028; // (
-static const UChar CLOSE_REV = 0x0029; // )
+static const char16_t ID_DELIM = 0x003B; // ;
+static const char16_t TARGET_SEP = 0x002D; // -
+static const char16_t VARIANT_SEP = 0x002F; // /
+static const char16_t OPEN_REV = 0x0028; // (
+static const char16_t CLOSE_REV = 0x0029; // )
-//static const UChar EMPTY[] = {0}; // ""
-static const UChar ANY[] = {65,110,121,0}; // "Any"
-static const UChar ANY_NULL[] = {65,110,121,45,78,117,108,108,0}; // "Any-Null"
+//static const char16_t EMPTY[] = {0}; // ""
+static const char16_t ANY[] = {65,110,121,0}; // "Any"
+static const char16_t ANY_NULL[] = {65,110,121,45,78,117,108,108,0}; // "Any-Null"
static const int32_t FORWARD = UTRANS_FORWARD;
static const int32_t REVERSE = UTRANS_REVERSE;
}
// NUL-terminate the ID string for getTerminatedBuffer.
// This prevents valgrind and Purify warnings.
- id.append((UChar)0);
+ id.append((char16_t)0);
id.truncate(id.length()-1);
}
UnicodeString target;
UnicodeString variant;
UnicodeString filter;
- UChar delimiter = 0;
+ char16_t delimiter = 0;
int32_t specCount = 0;
int32_t start = pos;
}
if (delimiter == 0) {
- UChar c = id.charAt(pos);
+ char16_t c = id.charAt(pos);
if ((c == TARGET_SEP && target.length() == 0) ||
(c == VARIANT_SEP && variant.length() == 0)) {
delimiter = c;
static const char gGmtZeroFormatTag[] = "gmtZeroFormat";
static const char gHourFormatTag[]= "hourFormat";
-static const UChar TZID_GMT[] = {0x0045, 0x0074, 0x0063, 0x002F, 0x0047, 0x004D, 0x0054, 0}; // Etc/GMT
-static const UChar UNKNOWN_ZONE_ID[] = {
+static const char16_t TZID_GMT[] = {0x0045, 0x0074, 0x0063, 0x002F, 0x0047, 0x004D, 0x0054, 0}; // Etc/GMT
+static const char16_t UNKNOWN_ZONE_ID[] = {
0x0045, 0x0074, 0x0063, 0x002F, 0x0055, 0x006E, 0x006B, 0x006E, 0x006F, 0x0077, 0x006E, 0}; // Etc/Unknown
-static const UChar UNKNOWN_SHORT_ZONE_ID[] = {0x0075, 0x006E, 0x006B, 0}; // unk
-static const UChar UNKNOWN_LOCATION[] = {0x0055, 0x006E, 0x006B, 0x006E, 0x006F, 0x0077, 0x006E, 0}; // Unknown
-
-static const UChar DEFAULT_GMT_PATTERN[] = {0x0047, 0x004D, 0x0054, 0x007B, 0x0030, 0x007D, 0}; // GMT{0}
-//static const UChar DEFAULT_GMT_ZERO[] = {0x0047, 0x004D, 0x0054, 0}; // GMT
-static const UChar DEFAULT_GMT_POSITIVE_HM[] = {0x002B, 0x0048, 0x003A, 0x006D, 0x006D, 0}; // +H:mm
-static const UChar DEFAULT_GMT_POSITIVE_HMS[] = {0x002B, 0x0048, 0x003A, 0x006D, 0x006D, 0x003A, 0x0073, 0x0073, 0}; // +H:mm:ss
-static const UChar DEFAULT_GMT_NEGATIVE_HM[] = {0x002D, 0x0048, 0x003A, 0x006D, 0x006D, 0}; // -H:mm
-static const UChar DEFAULT_GMT_NEGATIVE_HMS[] = {0x002D, 0x0048, 0x003A, 0x006D, 0x006D, 0x003A, 0x0073, 0x0073, 0}; // -H:mm:ss
-static const UChar DEFAULT_GMT_POSITIVE_H[] = {0x002B, 0x0048, 0}; // +H
-static const UChar DEFAULT_GMT_NEGATIVE_H[] = {0x002D, 0x0048, 0}; // -H
+static const char16_t UNKNOWN_SHORT_ZONE_ID[] = {0x0075, 0x006E, 0x006B, 0}; // unk
+static const char16_t UNKNOWN_LOCATION[] = {0x0055, 0x006E, 0x006B, 0x006E, 0x006F, 0x0077, 0x006E, 0}; // Unknown
+
+static const char16_t DEFAULT_GMT_PATTERN[] = {0x0047, 0x004D, 0x0054, 0x007B, 0x0030, 0x007D, 0}; // GMT{0}
+//static const char16_t DEFAULT_GMT_ZERO[] = {0x0047, 0x004D, 0x0054, 0}; // GMT
+static const char16_t DEFAULT_GMT_POSITIVE_HM[] = {0x002B, 0x0048, 0x003A, 0x006D, 0x006D, 0}; // +H:mm
+static const char16_t DEFAULT_GMT_POSITIVE_HMS[] = {0x002B, 0x0048, 0x003A, 0x006D, 0x006D, 0x003A, 0x0073, 0x0073, 0}; // +H:mm:ss
+static const char16_t DEFAULT_GMT_NEGATIVE_HM[] = {0x002D, 0x0048, 0x003A, 0x006D, 0x006D, 0}; // -H:mm
+static const char16_t DEFAULT_GMT_NEGATIVE_HMS[] = {0x002D, 0x0048, 0x003A, 0x006D, 0x006D, 0x003A, 0x0073, 0x0073, 0}; // -H:mm:ss
+static const char16_t DEFAULT_GMT_POSITIVE_H[] = {0x002B, 0x0048, 0}; // +H
+static const char16_t DEFAULT_GMT_NEGATIVE_H[] = {0x002D, 0x0048, 0}; // -H
static const UChar32 DEFAULT_GMT_DIGITS[] = {
0x0030, 0x0031, 0x0032, 0x0033, 0x0034,
0x0035, 0x0036, 0x0037, 0x0038, 0x0039
};
-static const UChar DEFAULT_GMT_OFFSET_SEP = 0x003A; // ':'
+static const char16_t DEFAULT_GMT_OFFSET_SEP = 0x003A; // ':'
-static const UChar ARG0[] = {0x007B, 0x0030, 0x007D}; // "{0}"
+static const char16_t ARG0[] = {0x007B, 0x0030, 0x007D}; // "{0}"
static const int32_t ARG0_LEN = 3;
-static const UChar DEFAULT_GMT_OFFSET_MINUTE_PATTERN[] = {0x006D, 0x006D, 0}; // "mm"
-static const UChar DEFAULT_GMT_OFFSET_SECOND_PATTERN[] = {0x0073, 0x0073, 0}; // "ss"
+static const char16_t DEFAULT_GMT_OFFSET_MINUTE_PATTERN[] = {0x006D, 0x006D, 0}; // "mm"
+static const char16_t DEFAULT_GMT_OFFSET_SECOND_PATTERN[] = {0x0073, 0x0073, 0}; // "ss"
-static const UChar ALT_GMT_STRINGS[][4] = {
+static const char16_t ALT_GMT_STRINGS[][4] = {
{0x0047, 0x004D, 0x0054, 0}, // GMT
{0x0055, 0x0054, 0x0043, 0}, // UTC
{0x0055, 0x0054, 0, 0}, // UT
-1
};
-static const UChar SINGLEQUOTE = 0x0027;
-static const UChar PLUS = 0x002B;
-static const UChar MINUS = 0x002D;
-static const UChar ISO8601_UTC = 0x005A; // 'Z'
-static const UChar ISO8601_SEP = 0x003A; // ':'
+static const char16_t SINGLEQUOTE = 0x0027;
+static const char16_t PLUS = 0x002B;
+static const char16_t MINUS = 0x002D;
+static const char16_t ISO8601_UTC = 0x005A; // 'Z'
+static const char16_t ISO8601_SEP = 0x003A; // ':'
static const int32_t MILLIS_PER_HOUR = 60 * 60 * 1000;
static const int32_t MILLIS_PER_MINUTE = 60 * 1000;
static GMTOffsetField* createText(const UnicodeString& text, UErrorCode& status);
static GMTOffsetField* createTimeField(FieldType type, uint8_t width, UErrorCode& status);
static UBool isValid(FieldType type, int32_t width);
- static FieldType getTypeByLetter(UChar ch);
+ static FieldType getTypeByLetter(char16_t ch);
FieldType getType() const;
uint8_t getWidth() const;
- const UChar* getPatternText(void) const;
+ const char16_t* getPatternText(void) const;
private:
- UChar* fText;
+ char16_t* fText;
FieldType fType;
uint8_t fWidth;
}
int32_t len = text.length();
- result->fText = (UChar*)uprv_malloc((len + 1) * sizeof(UChar));
+ result->fText = (char16_t*)uprv_malloc((len + 1) * sizeof(char16_t));
if (result->fText == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
delete result;
}
GMTOffsetField::FieldType
-GMTOffsetField::getTypeByLetter(UChar ch) {
+GMTOffsetField::getTypeByLetter(char16_t ch) {
if (ch == 0x0048 /* H */) {
return HOUR;
} else if (ch == 0x006D /* m */) {
return fWidth;
}
-inline const UChar*
+inline const char16_t*
GMTOffsetField::getPatternText(void) const {
return fText;
}
return;
}
- const UChar* gmtPattern = nullptr;
- const UChar* hourFormats = nullptr;
+ const char16_t* gmtPattern = nullptr;
+ const char16_t* hourFormats = nullptr;
UResourceBundle *zoneBundle = ures_open(U_ICUDATA_ZONE, locale.getName(), &status);
UResourceBundle *zoneStringsArray = ures_getByKeyWithFallback(zoneBundle, gZoneStringsTag, nullptr, &status);
if (U_SUCCESS(status)) {
- const UChar* resStr;
+ const char16_t* resStr;
int32_t len;
resStr = ures_getStringByKeyWithFallback(zoneStringsArray, gGmtFormatTag, &len, &status);
if (len > 0) {
UBool useDefaultOffsetPatterns = true;
if (hourFormats) {
- UChar *sep = u_strchr(hourFormats, (UChar)0x003B /* ';' */);
+ char16_t *sep = u_strchr(hourFormats, (char16_t)0x003B /* ';' */);
if (sep != nullptr) {
UErrorCode tmpStatus = U_ZERO_ERROR;
fGMTOffsetPatterns[UTZFMT_PAT_POSITIVE_HM].setTo(false, hourFormats, (int32_t)(sep - hourFormats));
break;
case UTZFMT_STYLE_ZONE_ID_SHORT:
{
- const UChar* shortID = ZoneMeta::getShortID(tz);
+ const char16_t* shortID = ZoneMeta::getShortID(tz);
if (shortID == nullptr) {
shortID = UNKNOWN_SHORT_ZONE_ID;
}
if (tz != nullptr) {
int32_t rawOffset, dstOffset;
tz->getOffset(date, false, rawOffset, dstOffset, status);
- UChar buf[ZONE_NAME_U16_MAX];
+ char16_t buf[ZONE_NAME_U16_MAX];
UnicodeString result(buf, 0, UPRV_LENGTHOF(buf));
formatOffsetLocalizedGMT(rawOffset + dstOffset, result, status);
if (U_SUCCESS(status)) {
}
UErrorCode status = U_ZERO_ERROR;
- UChar tzIDBuf[32];
+ char16_t tzIDBuf[32];
UnicodeString tzID(tzIDBuf, 0, UPRV_LENGTHOF(tzIDBuf));
UBool parseTZDBAbbrev = ((parseOptions & UTZFMT_PARSE_OPTION_TZ_DATABASE_ABBREVIATIONS) != 0);
// Failed to parse the input text as the time zone format in the specified style.
// Check the longest match among other styles below.
- UChar parsedIDBuf[32];
+ char16_t parsedIDBuf[32];
UnicodeString parsedID(parsedIDBuf, 0, UPRV_LENGTHOF(parsedIDBuf));
UTimeZoneFormatTimeType parsedTimeType = UTZFMT_TIME_TYPE_UNKNOWN;
}
if (genType == UTZGNM_LOCATION) {
- const UChar* canonicalID = ZoneMeta::getCanonicalCLDRID(tz);
+ const char16_t* canonicalID = ZoneMeta::getCanonicalCLDRID(tz);
if (canonicalID == nullptr) {
name.setToBogus();
return name;
UErrorCode status = U_ZERO_ERROR;
UBool isDaylight = tz.inDaylightTime(date, status);
- const UChar* canonicalID = ZoneMeta::getCanonicalCLDRID(tz);
+ const char16_t* canonicalID = ZoneMeta::getCanonicalCLDRID(tz);
if (U_FAILURE(status) || canonicalID == nullptr) {
name.setToBogus();
UnicodeString&
TimeZoneFormat::formatExemplarLocation(const TimeZone& tz, UnicodeString& name) const {
- UChar locationBuf[ZONE_NAME_U16_MAX];
+ char16_t locationBuf[ZONE_NAME_U16_MAX];
UnicodeString location(locationBuf, 0, UPRV_LENGTHOF(locationBuf));
- const UChar* canonicalID = ZoneMeta::getCanonicalCLDRID(tz);
+ const char16_t* canonicalID = ZoneMeta::getCanonicalCLDRID(tz);
if (canonicalID) {
fTimeZoneNames->getExemplarLocationName(UnicodeString(true, canonicalID, -1), location);
OffsetFields minFields = isShort ? FIELDS_H : FIELDS_HM;
OffsetFields maxFields = ignoreSeconds ? FIELDS_HM : FIELDS_HMS;
- UChar sep = isBasic ? 0 : ISO8601_SEP;
+ char16_t sep = isBasic ? 0 : ISO8601_SEP;
// Note: FIELDS_HMS as maxFields is a CLDR/ICU extension. ISO 8601 specification does
// not support seconds field.
lastIdx--;
}
- UChar sign = PLUS;
+ char16_t sign = PLUS;
if (offset < 0) {
// if all output fields are 0s, do not use negative sign
for (int32_t idx = 0; idx <= lastIdx; idx++) {
if (sep && idx != 0) {
result.append(sep);
}
- result.append((UChar)(0x0030 + fields[idx]/10));
- result.append((UChar)(0x0030 + fields[idx]%10));
+ result.append((char16_t)(0x0030 + fields[idx]/10));
+ result.append((char16_t)(0x0030 + fields[idx]%10));
}
return result;
return 0;
}
- UChar firstChar = text.charAt(start);
- if (firstChar == ISO8601_UTC || firstChar == (UChar)(ISO8601_UTC + 0x20)) {
+ char16_t firstChar = text.charAt(start);
+ if (firstChar == ISO8601_UTC || firstChar == (char16_t)(ISO8601_UTC + 0x20)) {
// "Z" (or "z") - indicates UTC
pos.setIndex(start + 1);
return 0;
// Check if this is a default GMT zero format
for (int32_t i = 0; ALT_GMT_STRINGS[i][0] != 0; i++) {
- const UChar* defGMTZero = ALT_GMT_STRINGS[i];
+ const char16_t* defGMTZero = ALT_GMT_STRINGS[i];
int32_t defGMTZeroLen = u_strlen(defGMTZero);
if (text.caseCompare(start, defGMTZeroLen, defGMTZero, 0) == 0) {
pos.setIndex(start + defGMTZeroLen);
const GMTOffsetField* field = (const GMTOffsetField*)patternItems->elementAt(i);
GMTOffsetField::FieldType fieldType = field->getType();
if (fieldType == GMTOffsetField::TEXT) {
- const UChar* patStr = field->getPatternText();
+ const char16_t* patStr = field->getPatternText();
len = u_strlen(patStr);
if (i == 0) {
// When TimeZoneFormat parse() is called from SimpleDateFormat,
int32_t gmtLen = 0;
for (int32_t i = 0; ALT_GMT_STRINGS[i][0] != 0; i++) {
- const UChar* gmt = ALT_GMT_STRINGS[i];
+ const char16_t* gmt = ALT_GMT_STRINGS[i];
int32_t len = u_strlen(gmt);
if (text.caseCompare(start, len, gmt, 0) == 0) {
gmtLen = len;
// parse sign
int32_t sign = 1;
- UChar c = text.charAt(idx);
+ char16_t c = text.charAt(idx);
if (c == PLUS) {
sign = 1;
} else if (c == MINUS) {
}
int32_t
-TimeZoneFormat::parseDefaultOffsetFields(const UnicodeString& text, int32_t start, UChar separator, int32_t& parsedLen) const {
+TimeZoneFormat::parseDefaultOffsetFields(const UnicodeString& text, int32_t start, char16_t separator, int32_t& parsedLen) const {
int32_t max = text.length();
int32_t idx = start;
int32_t len = 0;
}
UnicodeString&
-TimeZoneFormat::formatOffsetWithAsciiDigits(int32_t offset, UChar sep, OffsetFields minFields, OffsetFields maxFields, UnicodeString& result) {
+TimeZoneFormat::formatOffsetWithAsciiDigits(int32_t offset, char16_t sep, OffsetFields minFields, OffsetFields maxFields, UnicodeString& result) {
U_ASSERT(maxFields >= minFields);
U_ASSERT(offset > -MAX_OFFSET && offset < MAX_OFFSET);
- UChar sign = PLUS;
+ char16_t sign = PLUS;
if (offset < 0) {
sign = MINUS;
offset = -offset;
if (sep && idx != 0) {
result.append(sep);
}
- result.append((UChar)(0x0030 + fields[idx]/10));
- result.append((UChar)(0x0030 + fields[idx]%10));
+ result.append((char16_t)(0x0030 + fields[idx]/10));
+ result.append((char16_t)(0x0030 + fields[idx]%10));
}
return result;
int32_t numDigits = 0;
int32_t idx = start;
while (numDigits < maxDigits && idx < text.length()) {
- UChar uch = text.charAt(idx);
+ char16_t uch = text.charAt(idx);
int32_t digit = DIGIT_VAL(uch);
if (digit < 0) {
break;
}
int32_t
-TimeZoneFormat::parseAsciiOffsetFields(const UnicodeString& text, ParsePosition& pos, UChar sep, OffsetFields minFields, OffsetFields maxFields) {
+TimeZoneFormat::parseAsciiOffsetFields(const UnicodeString& text, ParsePosition& pos, char16_t sep, OffsetFields minFields, OffsetFields maxFields) {
int32_t start = pos.getIndex();
int32_t fieldVal[] = {0, 0, 0};
int32_t fieldLen[] = {0, -1, -1};
for (int32_t idx = start, fieldIdx = 0; idx < text.length() && fieldIdx <= maxFields; idx++) {
- UChar c = text.charAt(idx);
+ char16_t c = text.charAt(idx);
if (c == sep) {
if (fieldIdx == 0) {
if (fieldLen[0] == 0) {
UBool isPrevQuote = false;
UBool inQuote = false;
for (int32_t i = 0; i < pattern.length(); i++) {
- UChar c = pattern.charAt(i);
+ char16_t c = pattern.charAt(i);
if (c == SINGLEQUOTE) {
if (isPrevQuote) {
result.append(c);
int32_t checkBits = 0;
UBool isPrevQuote = false;
UBool inQuote = false;
- UChar textBuf[32];
+ char16_t textBuf[32];
UnicodeString text(textBuf, 0, UPRV_LENGTHOF(textBuf));
GMTOffsetField::FieldType itemType = GMTOffsetField::TEXT;
int32_t itemLength = 1;
for (int32_t i = 0; i < pattern.length(); i++) {
- UChar ch = pattern.charAt(i);
+ char16_t ch = pattern.charAt(i);
if (ch == SINGLEQUOTE) {
if (isPrevQuote) {
text.append(SINGLEQUOTE);
}
UnicodeString sep;
- int32_t idx_H = offsetHM.tempSubString(0, idx_mm).lastIndexOf((UChar)0x0048 /* H */);
+ int32_t idx_H = offsetHM.tempSubString(0, idx_mm).lastIndexOf((char16_t)0x0048 /* H */);
if (idx_H >= 0) {
sep = offsetHM.tempSubString(idx_H + 1, idx_mm - (idx_H + 1));
}
status = U_ILLEGAL_ARGUMENT_ERROR;
return result;
}
- UChar HH[] = {0x0048, 0x0048};
+ char16_t HH[] = {0x0048, 0x0048};
int32_t idx_HH = offsetHM.tempSubString(0, idx_mm).lastIndexOf(HH, 2, 0);
if (idx_HH >= 0) {
return result.setTo(offsetHM.tempSubString(0, idx_HH + 2));
}
- int32_t idx_H = offsetHM.tempSubString(0, idx_mm).lastIndexOf((UChar)0x0048, 0);
+ int32_t idx_H = offsetHM.tempSubString(0, idx_mm).lastIndexOf((char16_t)0x0048, 0);
if (idx_H >= 0) {
return result.setTo(offsetHM.tempSubString(0, idx_H + 1));
}
UnicodeString&
TimeZoneFormat::getTimeZoneID(const TimeZoneNames::MatchInfoCollection* matches, int32_t idx, UnicodeString& tzID) const {
if (!matches->getTimeZoneIDAt(idx, tzID)) {
- UChar mzIDBuf[32];
+ char16_t mzIDBuf[32];
UnicodeString mzID(mzIDBuf, 0, UPRV_LENGTHOF(mzIDBuf));
if (matches->getMetaZoneIDAt(idx, mzID)) {
fTimeZoneNames->getReferenceZoneID(mzID, fTargetRegion, tzID);
virtual ~ZoneIdMatchHandler();
UBool handleMatch(int32_t matchLength, const CharacterNode *node, UErrorCode &status) override;
- const UChar* getID();
+ const char16_t* getID();
int32_t getMatchLen();
private:
int32_t fLen;
- const UChar* fID;
+ const char16_t* fID;
};
ZoneIdMatchHandler::ZoneIdMatchHandler()
return false;
}
if (node->hasValues()) {
- const UChar* id = (const UChar*)node->getValue(0);
+ const char16_t* id = (const char16_t*)node->getValue(0);
if (id != nullptr) {
if (fLen < matchLength) {
fID = id;
return true;
}
-const UChar*
+const char16_t*
ZoneIdMatchHandler::getID() {
return fID;
}
if (U_SUCCESS(status)) {
const UnicodeString *id;
while ((id = tzenum->snext(status)) != nullptr) {
- const UChar* uid = ZoneMeta::findTimeZoneID(*id);
+ const char16_t* uid = ZoneMeta::findTimeZoneID(*id);
if (uid) {
- gZoneIdTrie->put(uid, const_cast<UChar *>(uid), status);
+ gZoneIdTrie->put(uid, const_cast<char16_t *>(uid), status);
}
}
delete tzenum;
} else {
const UnicodeString *id;
while ((id = tzenum->snext(status)) != nullptr) {
- const UChar* uID = ZoneMeta::findTimeZoneID(*id);
- const UChar* shortID = ZoneMeta::getShortID(*id);
+ const char16_t* uID = ZoneMeta::findTimeZoneID(*id);
+ const char16_t* shortID = ZoneMeta::getShortID(*id);
if (shortID && uID) {
- gShortZoneIdTrie->put(shortID, const_cast<UChar *>(uID), status);
+ gShortZoneIdTrie->put(shortID, const_cast<char16_t *>(uID), status);
}
}
}
static const char gRegionFormatTag[] = "regionFormat";
static const char gFallbackFormatTag[] = "fallbackFormat";
-static const UChar gEmpty[] = {0x00};
+static const char16_t gEmpty[] = {0x00};
-static const UChar gDefRegionPattern[] = {0x7B, 0x30, 0x7D, 0x00}; // "{0}"
-static const UChar gDefFallbackPattern[] = {0x7B, 0x31, 0x7D, 0x20, 0x28, 0x7B, 0x30, 0x7D, 0x29, 0x00}; // "{1} ({0})"
+static const char16_t gDefRegionPattern[] = {0x7B, 0x30, 0x7D, 0x00}; // "{0}"
+static const char16_t gDefFallbackPattern[] = {0x7B, 0x31, 0x7D, 0x20, 0x28, 0x7B, 0x30, 0x7D, 0x29, 0x00}; // "{1} ({0})"
static const double kDstCheckRange = (double)184*U_MILLIS_PER_DAY;
U_CDECL_BEGIN
typedef struct PartialLocationKey {
- const UChar* tzID;
- const UChar* mzID;
+ const char16_t* tzID;
+ const char16_t* mzID;
UBool isLong;
} PartialLocationKey;
// <tzID>&<mzID>#[L|S]
PartialLocationKey *p = (PartialLocationKey *)key.pointer;
UnicodeString str(p->tzID);
- str.append((UChar)0x26)
+ str.append((char16_t)0x26)
.append(p->mzID, -1)
- .append((UChar)0x23)
- .append((UChar)(p->isLong ? 0x4C : 0x53));
+ .append((char16_t)0x23)
+ .append((char16_t)(p->isLong ? 0x4C : 0x53));
return str.hashCode();
}
*/
typedef struct GNameInfo {
UTimeZoneGenericNameType type;
- const UChar* tzID;
+ const char16_t* tzID;
} ZNameInfo;
/**
void loadStrings(const UnicodeString& tzCanonicalID);
- const UChar* getGenericLocationName(const UnicodeString& tzCanonicalID);
+ const char16_t* getGenericLocationName(const UnicodeString& tzCanonicalID);
UnicodeString& formatGenericNonLocationName(const TimeZone& tz, UTimeZoneGenericNameType type,
UDate date, UnicodeString& name) const;
const UnicodeString& mzID, UBool isLong, const UnicodeString& mzDisplayName,
UnicodeString& name) const;
- const UChar* getPartialLocationName(const UnicodeString& tzCanonicalID,
+ const char16_t* getPartialLocationName(const UnicodeString& tzCanonicalID,
const UnicodeString& mzID, UBool isLong, const UnicodeString& mzDisplayName);
TimeZoneGenericNameMatchInfo* findLocal(const UnicodeString& text, int32_t start, uint32_t types, UErrorCode& status) const;
zoneStrings = ures_getByKeyWithFallback(zoneStrings, gZoneStrings, zoneStrings, &tmpsts);
if (U_SUCCESS(tmpsts)) {
- const UChar *regionPattern = ures_getStringByKeyWithFallback(zoneStrings, gRegionFormatTag, nullptr, &tmpsts);
+ const char16_t *regionPattern = ures_getStringByKeyWithFallback(zoneStrings, gRegionFormatTag, nullptr, &tmpsts);
if (U_SUCCESS(tmpsts) && u_strlen(regionPattern) > 0) {
rpat.setTo(regionPattern, -1);
}
tmpsts = U_ZERO_ERROR;
- const UChar *fallbackPattern = ures_getStringByKeyWithFallback(zoneStrings, gFallbackFormatTag, nullptr, &tmpsts);
+ const char16_t *fallbackPattern = ures_getStringByKeyWithFallback(zoneStrings, gFallbackFormatTag, nullptr, &tmpsts);
if (U_SUCCESS(tmpsts) && u_strlen(fallbackPattern) > 0) {
fpat.setTo(fallbackPattern, -1);
}
// preload generic names for the default zone
TimeZone *tz = TimeZone::createDefault();
- const UChar *tzID = ZoneMeta::getCanonicalCLDRID(*tz);
+ const char16_t *tzID = ZoneMeta::getCanonicalCLDRID(*tz);
if (tzID != nullptr) {
loadStrings(UnicodeString(true, tzID, -1));
}
switch (type) {
case UTZGNM_LOCATION:
{
- const UChar* tzCanonicalID = ZoneMeta::getCanonicalCLDRID(tz);
+ const char16_t* tzCanonicalID = ZoneMeta::getCanonicalCLDRID(tz);
if (tzCanonicalID != nullptr) {
getGenericLocationName(UnicodeString(true, tzCanonicalID, -1), name);
}
case UTZGNM_SHORT:
formatGenericNonLocationName(tz, type, date, name);
if (name.isEmpty()) {
- const UChar* tzCanonicalID = ZoneMeta::getCanonicalCLDRID(tz);
+ const char16_t* tzCanonicalID = ZoneMeta::getCanonicalCLDRID(tz);
if (tzCanonicalID != nullptr) {
getGenericLocationName(UnicodeString(true, tzCanonicalID, -1), name);
}
return name;
}
- const UChar *locname = nullptr;
+ const char16_t *locname = nullptr;
TZGNCore *nonConstThis = const_cast<TZGNCore *>(this);
umtx_lock(&gLock);
{
/*
* This method updates the cache and must be called with a lock
*/
-const UChar*
+const char16_t*
TZGNCore::getGenericLocationName(const UnicodeString& tzCanonicalID) {
U_ASSERT(!tzCanonicalID.isEmpty());
if (tzCanonicalID.length() > ZID_KEY_MAX) {
}
UErrorCode status = U_ZERO_ERROR;
- UChar tzIDKey[ZID_KEY_MAX + 1];
+ char16_t tzIDKey[ZID_KEY_MAX + 1];
int32_t tzIDKeyLen = tzCanonicalID.extract(tzIDKey, ZID_KEY_MAX + 1, status);
U_ASSERT(status == U_ZERO_ERROR); // already checked length above
tzIDKey[tzIDKeyLen] = 0;
- const UChar *locname = (const UChar *)uhash_get(fLocationNamesMap, tzIDKey);
+ const char16_t *locname = (const char16_t *)uhash_get(fLocationNamesMap, tzIDKey);
if (locname != nullptr) {
// gEmpty indicate the name is not available
locname = name.isEmpty() ? nullptr : fStringPool.get(name, status);
if (U_SUCCESS(status)) {
// Cache the result
- const UChar* cacheID = ZoneMeta::findTimeZoneID(tzCanonicalID);
+ const char16_t* cacheID = ZoneMeta::findTimeZoneID(tzCanonicalID);
U_ASSERT(cacheID != nullptr);
if (locname == nullptr) {
// gEmpty to indicate - no location name available
U_ASSERT(type == UTZGNM_LONG || type == UTZGNM_SHORT);
name.setToBogus();
- const UChar* uID = ZoneMeta::getCanonicalCLDRID(tz);
+ const char16_t* uID = ZoneMeta::getCanonicalCLDRID(tz);
if (uID == nullptr) {
return name;
}
}
// Try meta zone
- UChar mzIDBuf[32];
+ char16_t mzIDBuf[32];
UnicodeString mzID(mzIDBuf, 0, UPRV_LENGTHOF(mzIDBuf));
fTimeZoneNames->getMetaZoneID(tzID, date, mzID);
if (!mzID.isEmpty()) {
UErrorCode status = U_ZERO_ERROR;
UBool useStandard = false;
int32_t raw, sav;
- UChar tmpNameBuf[ZONE_NAME_U16_MAX];
+ char16_t tmpNameBuf[ZONE_NAME_U16_MAX];
tz.getOffset(date, false, raw, sav, status);
if (U_FAILURE(status)) {
// for some meta zones in some locales. This looks like a data bugs.
// For now, we check if the standard name is different from its generic
// name below.
- UChar genNameBuf[ZONE_NAME_U16_MAX];
+ char16_t genNameBuf[ZONE_NAME_U16_MAX];
UnicodeString mzGenericName(genNameBuf, 0, UPRV_LENGTHOF(genNameBuf));
fTimeZoneNames->getMetaZoneDisplayName(mzID, nameType, mzGenericName);
if (stdName.caseCompare(mzGenericName, 0) == 0) {
// Check if we need to use a partial location format.
// This check is done by comparing offset with the meta zone's
// golden zone at the given date.
- UChar idBuf[32];
+ char16_t idBuf[32];
UnicodeString goldenID(idBuf, 0, UPRV_LENGTHOF(idBuf));
fTimeZoneNames->getReferenceZoneID(mzID, fTargetRegion, goldenID);
if (!goldenID.isEmpty() && goldenID != tzID) {
return name;
}
- const UChar *uplname = nullptr;
+ const char16_t *uplname = nullptr;
TZGNCore *nonConstThis = const_cast<TZGNCore *>(this);
umtx_lock(&gLock);
{
/*
* This method updates the cache and must be called with a lock
*/
-const UChar*
+const char16_t*
TZGNCore::getPartialLocationName(const UnicodeString& tzCanonicalID,
const UnicodeString& mzID, UBool isLong, const UnicodeString& mzDisplayName) {
U_ASSERT(!tzCanonicalID.isEmpty());
key.isLong = isLong;
U_ASSERT(key.tzID != nullptr && key.mzID != nullptr);
- const UChar* uplname = (const UChar*)uhash_get(fPartialLocationNamesMap, (void *)&key);
+ const char16_t* uplname = (const char16_t*)uhash_get(fPartialLocationNamesMap, (void *)&key);
if (uplname != nullptr) {
return uplname;
}
TimeZoneNames::getDisplayName(const UnicodeString& tzID, UTimeZoneNameType type, UDate date, UnicodeString& name) const {
getTimeZoneDisplayName(tzID, type, name);
if (name.isEmpty()) {
- UChar mzIDBuf[32];
+ char16_t mzIDBuf[32];
UnicodeString mzID(mzIDBuf, 0, UPRV_LENGTHOF(mzIDBuf));
getMetaZoneID(tzID, date, mzID);
getMetaZoneDisplayName(mzID, type, name);
static const char EMPTY[] = "<empty>"; // place holder for empty ZNames
static const char DUMMY_LOADER[] = "<dummy>"; // place holder for dummy ZNamesLoader
-static const UChar NO_NAME[] = { 0 }; // for empty no-fallback time zone names
+static const char16_t NO_NAME[] = { 0 }; // for empty no-fallback time zone names
// stuff for TZDBTimeZoneNames
static const char* TZDBNAMES_KEYS[] = {"ss", "sd"};
UTZNM_INDEX_SHORT_DAYLIGHT,
UTZNM_INDEX_COUNT
};
-static const UChar* const EMPTY_NAMES[UTZNM_INDEX_COUNT] = {0,0,0,0,0,0,0};
+static const char16_t* const EMPTY_NAMES[UTZNM_INDEX_COUNT] = {0,0,0,0,0,0,0};
U_CDECL_BEGIN
static UBool U_CALLCONV tzdbTimeZoneNames_cleanup(void) {
*/
struct ZNameInfo {
UTimeZoneNameType type;
- const UChar* tzID;
- const UChar* mzID;
+ const char16_t* tzID;
+ const char16_t* mzID;
};
/**
//
void
TextTrieMap::put(const UnicodeString &key, void *value, ZNStringPool &sp, UErrorCode &status) {
- const UChar *s = sp.get(key, status);
+ const char16_t *s = sp.get(key, status);
put(s, value, status);
}
// This method is designed for a persistent key, such as string key stored in
// resource bundle.
void
-TextTrieMap::put(const UChar *key, void *value, UErrorCode &status) {
+TextTrieMap::put(const char16_t *key, void *value, UErrorCode &status) {
fIsEmpty = false;
if (fLazyContents == nullptr) {
LocalPointer<UVector> lpLazyContents(new UVector(status), status);
}
U_ASSERT(fLazyContents != nullptr);
- UChar *s = const_cast<UChar *>(key);
+ char16_t *s = const_cast<char16_t *>(key);
fLazyContents->addElement(s, status);
if (U_FAILURE(status)) {
if (fValueDeleter) {
}
UnicodeString foldedKey;
- const UChar *keyBuffer;
+ const char16_t *keyBuffer;
int32_t keyLength;
if (fIgnoreCase) {
// Ok to use fastCopyFrom() because we discard the copy when we return.
}
CharacterNode*
-TextTrieMap::addChildNode(CharacterNode *parent, UChar c, UErrorCode &status) {
+TextTrieMap::addChildNode(CharacterNode *parent, char16_t c, UErrorCode &status) {
if (U_FAILURE(status)) {
return nullptr;
}
uint16_t nodeIndex = parent->fFirstChild;
while (nodeIndex > 0) {
CharacterNode *current = fNodes + nodeIndex;
- UChar childCharacter = current->fCharacter;
+ char16_t childCharacter = current->fCharacter;
if (childCharacter == c) {
return current;
} else if (childCharacter > c) {
}
CharacterNode*
-TextTrieMap::getChildNode(CharacterNode *parent, UChar c) const {
+TextTrieMap::getChildNode(CharacterNode *parent, char16_t c) const {
// Linear search of the sorted list of children.
uint16_t nodeIndex = parent->fFirstChild;
while (nodeIndex > 0) {
CharacterNode *current = fNodes + nodeIndex;
- UChar childCharacter = current->fCharacter;
+ char16_t childCharacter = current->fCharacter;
if (childCharacter == c) {
return current;
} else if (childCharacter > c) {
void TextTrieMap::buildTrie(UErrorCode &status) {
if (fLazyContents != nullptr) {
for (int32_t i=0; i<fLazyContents->size(); i+=2) {
- const UChar *key = (UChar *)fLazyContents->elementAt(i);
+ const char16_t *key = (char16_t *)fLazyContents->elementAt(i);
void *val = fLazyContents->elementAt(i+1);
UnicodeString keyString(true, key, -1); // Aliasing UnicodeString constructor.
putImpl(keyString, val, status);
tmp.foldCase();
int32_t tmpidx = 0;
while (tmpidx < tmp.length()) {
- UChar c = tmp.charAt(tmpidx++);
+ char16_t c = tmp.charAt(tmpidx++);
node = getChildNode(node, c);
if (node == nullptr) {
break;
}
} else {
// here we just get the next UTF16 code unit
- UChar c = text.charAt(index++);
+ char16_t c = text.charAt(index++);
node = getChildNode(node, c);
}
if (node != nullptr) {
struct ZNStringPoolChunk: public UMemory {
ZNStringPoolChunk *fNext; // Ptr to next pool chunk
int32_t fLimit; // Index to start of unused area at end of fStrings
- UChar fStrings[POOL_CHUNK_SIZE]; // Strings array
+ char16_t fStrings[POOL_CHUNK_SIZE]; // Strings array
ZNStringPoolChunk();
};
}
}
-static const UChar EmptyString = 0;
+static const char16_t EmptyString = 0;
-const UChar *ZNStringPool::get(const UChar *s, UErrorCode &status) {
- const UChar *pooledString;
+const char16_t *ZNStringPool::get(const char16_t *s, UErrorCode &status) {
+ const char16_t *pooledString;
if (U_FAILURE(status)) {
return &EmptyString;
}
- pooledString = static_cast<UChar *>(uhash_get(fHash, s));
+ pooledString = static_cast<char16_t *>(uhash_get(fHash, s));
if (pooledString != nullptr) {
return pooledString;
}
fChunks->fNext = oldChunk;
}
- UChar *destString = &fChunks->fStrings[fChunks->fLimit];
+ char16_t *destString = &fChunks->fStrings[fChunks->fLimit];
u_strcpy(destString, s);
fChunks->fLimit += (length + 1);
uhash_put(fHash, destString, destString, &status);
// into the pool's storage. Used for strings from resource bundles,
// which will persist for the life of the zone string formatter, and
// therefore can be used directly without copying.
-const UChar *ZNStringPool::adopt(const UChar * s, UErrorCode &status) {
- const UChar *pooledString;
+const char16_t *ZNStringPool::adopt(const char16_t * s, UErrorCode &status) {
+ const char16_t *pooledString;
if (U_FAILURE(status)) {
return &EmptyString;
}
if (s != nullptr) {
- pooledString = static_cast<UChar *>(uhash_get(fHash, s));
+ pooledString = static_cast<char16_t *>(uhash_get(fHash, s));
if (pooledString == nullptr) {
- UChar *ncs = const_cast<UChar *>(s);
+ char16_t *ncs = const_cast<char16_t *>(s);
uhash_put(fHash, ncs, ncs, &status);
}
}
}
-const UChar *ZNStringPool::get(const UnicodeString &s, UErrorCode &status) {
+const char16_t *ZNStringPool::get(const UnicodeString &s, UErrorCode &status) {
UnicodeString &nonConstStr = const_cast<UnicodeString &>(s);
return this->get(nonConstStr.getTerminatedBuffer(), status);
}
}
}
- const UChar* fNames[UTZNM_INDEX_COUNT];
+ const char16_t* fNames[UTZNM_INDEX_COUNT];
UBool fDidAddIntoTrie;
// Whether we own the location string, if computed rather than loaded from a bundle.
// A meta zone names instance never has an exemplar location string.
UBool fOwnsLocationName;
- ZNames(const UChar* names[], const UChar* locationName)
+ ZNames(const char16_t* names[], const char16_t* locationName)
: fDidAddIntoTrie(false) {
uprv_memcpy(fNames, names, sizeof(fNames));
if (locationName != nullptr) {
public:
~ZNames() {
if (fOwnsLocationName) {
- const UChar* locationName = fNames[UTZNM_INDEX_EXEMPLAR_LOCATION];
+ const char16_t* locationName = fNames[UTZNM_INDEX_EXEMPLAR_LOCATION];
U_ASSERT(locationName != nullptr);
uprv_free((void*) locationName);
}
}
private:
- static void* createMetaZoneAndPutInCache(UHashtable* cache, const UChar* names[],
+ static void* createMetaZoneAndPutInCache(UHashtable* cache, const char16_t* names[],
const UnicodeString& mzID, UErrorCode& status) {
if (U_FAILURE(status)) { return nullptr; }
U_ASSERT(names != nullptr);
return value;
}
- static void* createTimeZoneAndPutInCache(UHashtable* cache, const UChar* names[],
+ static void* createTimeZoneAndPutInCache(UHashtable* cache, const char16_t* names[],
const UnicodeString& tzID, UErrorCode& status) {
if (U_FAILURE(status)) { return nullptr; }
U_ASSERT(names != nullptr);
// If necessary, compute the location name from the time zone name.
- UChar* locationName = nullptr;
+ char16_t* locationName = nullptr;
if (names[UTZNM_INDEX_EXEMPLAR_LOCATION] == nullptr) {
UnicodeString locationNameUniStr;
TimeZoneNamesImpl::getDefaultExemplarLocationName(tzID, locationNameUniStr);
// Copy the computed location name to the heap
if (locationNameUniStr.length() > 0) {
- const UChar* buff = locationNameUniStr.getTerminatedBuffer();
- int32_t len = sizeof(UChar) * (locationNameUniStr.length() + 1);
- locationName = (UChar*) uprv_malloc(len);
+ const char16_t* buff = locationNameUniStr.getTerminatedBuffer();
+ int32_t len = sizeof(char16_t) * (locationNameUniStr.length() + 1);
+ locationName = (char16_t*) uprv_malloc(len);
if (locationName == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return nullptr;
return value;
}
- const UChar* getName(UTimeZoneNameType type) const {
+ const char16_t* getName(UTimeZoneNameType type) const {
UTimeZoneNameTypeIndex index = getTZNameTypeIndex(type);
return index >= 0 ? fNames[index] : nullptr;
}
- void addAsMetaZoneIntoTrie(const UChar* mzID, TextTrieMap& trie, UErrorCode& status) {
+ void addAsMetaZoneIntoTrie(const char16_t* mzID, TextTrieMap& trie, UErrorCode& status) {
addNamesIntoTrie(mzID, nullptr, trie, status);
}
- void addAsTimeZoneIntoTrie(const UChar* tzID, TextTrieMap& trie, UErrorCode& status) {
+ void addAsTimeZoneIntoTrie(const char16_t* tzID, TextTrieMap& trie, UErrorCode& status) {
addNamesIntoTrie(nullptr, tzID, trie, status);
}
- void addNamesIntoTrie(const UChar* mzID, const UChar* tzID, TextTrieMap& trie,
+ void addNamesIntoTrie(const char16_t* mzID, const char16_t* tzID, TextTrieMap& trie,
UErrorCode& status) {
if (U_FAILURE(status)) { return; }
if (fDidAddIntoTrie) { return; }
fDidAddIntoTrie = true;
for (int32_t i = 0; i < UTZNM_INDEX_COUNT; i++) {
- const UChar* name = fNames[i];
+ const char16_t* name = fNames[i];
if (name != nullptr) {
ZNameInfo *nameinfo = (ZNameInfo *)uprv_malloc(sizeof(ZNameInfo));
if (nameinfo == nullptr) {
};
struct ZNames::ZNamesLoader : public ResourceSink {
- const UChar *names[UTZNM_INDEX_COUNT];
+ const char16_t *names[UTZNM_INDEX_COUNT];
ZNamesLoader() {
clear();
// Replace "/" with ":".
UnicodeString uKey(tzID);
for (int32_t i = 0; i < uKey.length(); i++) {
- if (uKey.charAt(i) == (UChar)0x2F) {
- uKey.setCharAt(i, (UChar)0x3A);
+ if (uKey.charAt(i) == (char16_t)0x2F) {
+ uKey.setCharAt(i, (char16_t)0x3A);
}
}
* This is different than Java, where the array will no longer be modified and null
* may be returned.
*/
- const UChar** getNames() {
+ const char16_t** getNames() {
// Remove 'NO_NAME' references in the array and replace with 'nullptr'
for (int32_t i = 0; i < UTZNM_INDEX_COUNT; ++i) {
if (names[i] == NO_NAME) {
const UnicodeString*
MetaZoneIDsEnumeration::snext(UErrorCode& status) {
if (U_SUCCESS(status) && fMetaZoneIDs != nullptr && fPos < fLen) {
- unistr.setTo((const UChar*)fMetaZoneIDs->elementAt(fPos++), -1);
+ unistr.setTo((const char16_t*)fMetaZoneIDs->elementAt(fPos++), -1);
return &unistr;
}
return nullptr;
// preload zone strings for the default zone
TimeZone *tz = TimeZone::createDefault();
- const UChar *tzID = ZoneMeta::getCanonicalCLDRID(*tz);
+ const char16_t *tzID = ZoneMeta::getCanonicalCLDRID(*tz);
if (tzID != nullptr) {
loadStrings(UnicodeString(tzID), status);
}
for (int32_t i = 0; U_SUCCESS(status) && i < mappings->size(); i++) {
OlsonToMetaMappingEntry *map = (OlsonToMetaMappingEntry *)mappings->elementAt(i);
- const UChar *mzID = map->mzid;
+ const char16_t *mzID = map->mzid;
if (!mzIDs->contains((void *)mzID)) {
mzIDs->addElement((void *)mzID, status);
}
}
if (znames != nullptr) {
- const UChar* s = znames->getName(type);
+ const char16_t* s = znames->getName(type);
if (s != nullptr) {
name.setTo(true, s, -1);
}
}
if (tznames != nullptr) {
- const UChar *s = tznames->getName(type);
+ const char16_t *s = tznames->getName(type);
if (s != nullptr) {
name.setTo(true, s, -1);
}
UnicodeString&
TimeZoneNamesImpl::getExemplarLocationName(const UnicodeString& tzID, UnicodeString& name) const {
name.setToBogus(); // cleanup result.
- const UChar* locName = nullptr;
+ const char16_t* locName = nullptr;
ZNames *tznames = nullptr;
TimeZoneNamesImpl *nonConstThis = const_cast<TimeZoneNamesImpl *>(this);
if (U_FAILURE(status)) { return nullptr; }
U_ASSERT(mzID.length() <= ZID_KEY_MAX - MZ_PREFIX_LEN);
- UChar mzIDKey[ZID_KEY_MAX + 1];
+ char16_t mzIDKey[ZID_KEY_MAX + 1];
mzID.extract(mzIDKey, ZID_KEY_MAX + 1, status);
U_ASSERT(U_SUCCESS(status)); // already checked length above
mzIDKey[mzID.length()] = 0;
if (U_FAILURE(status)) { return nullptr; }
U_ASSERT(tzID.length() <= ZID_KEY_MAX);
- UChar tzIDKey[ZID_KEY_MAX + 1];
+ char16_t tzIDKey[ZID_KEY_MAX + 1];
int32_t tzIDKeyLen = tzID.extract(tzIDKey, ZID_KEY_MAX + 1, status);
U_ASSERT(U_SUCCESS(status)); // already checked length above
tzIDKey[tzIDKeyLen] = 0;
pos = UHASH_FIRST;
while ((element = uhash_nextElement(fMZNamesMap, &pos)) != nullptr) {
if (element->value.pointer == EMPTY) { continue; }
- UChar* mzID = (UChar*) element->key.pointer;
+ char16_t* mzID = (char16_t*) element->key.pointer;
ZNames* znames = (ZNames*) element->value.pointer;
znames->addAsMetaZoneIntoTrie(mzID, fNamesTrie, status);
if (U_FAILURE(status)) { return; }
pos = UHASH_FIRST;
while ((element = uhash_nextElement(fTZNamesMap, &pos)) != nullptr) {
if (element->value.pointer == EMPTY) { continue; }
- UChar* tzID = (UChar*) element->key.pointer;
+ char16_t* tzID = (char16_t*) element->key.pointer;
ZNames* znames = (ZNames*) element->value.pointer;
znames->addAsTimeZoneIntoTrie(tzID, fNamesTrie, status);
if (U_FAILURE(status)) { return; }
// Load the values into the dest array
for (int i = 0; i < numTypes; i++) {
UTimeZoneNameType type = types[i];
- const UChar* name = ((ZNames*)tznames)->getName(type);
+ const char16_t* name = ((ZNames*)tznames)->getName(type);
if (name == nullptr) {
if (mznames == nullptr) {
// Load the meta zone name
-static const UChar gEtcPrefix[] = { 0x45, 0x74, 0x63, 0x2F }; // "Etc/"
+static const char16_t gEtcPrefix[] = { 0x45, 0x74, 0x63, 0x2F }; // "Etc/"
static const int32_t gEtcPrefixLen = 4;
-static const UChar gSystemVPrefix[] = { 0x53, 0x79, 0x73, 0x74, 0x65, 0x6D, 0x56, 0x2F }; // "SystemV/
+static const char16_t gSystemVPrefix[] = { 0x53, 0x79, 0x73, 0x74, 0x65, 0x6D, 0x56, 0x2F }; // "SystemV/
static const int32_t gSystemVPrefixLen = 8;
-static const UChar gRiyadh8[] = { 0x52, 0x69, 0x79, 0x61, 0x64, 0x68, 0x38 }; // "Riyadh8"
+static const char16_t gRiyadh8[] = { 0x52, 0x69, 0x79, 0x61, 0x64, 0x68, 0x38 }; // "Riyadh8"
static const int32_t gRiyadh8Len = 7;
UnicodeString& U_EXPORT2
return name;
}
- int32_t sep = tzID.lastIndexOf((UChar)0x2F /* '/' */);
+ int32_t sep = tzID.lastIndexOf((char16_t)0x2F /* '/' */);
if (sep > 0 && sep + 1 < tzID.length()) {
name.setTo(tzID, sep + 1);
- name.findAndReplace(UnicodeString((UChar)0x5f /* _ */),
- UnicodeString((UChar)0x20 /* space */));
+ name.findAndReplace(UnicodeString((char16_t)0x5f /* _ */),
+ UnicodeString((char16_t)0x20 /* space */));
} else {
name.setToBogus();
}
virtual ~TZDBNames();
static TZDBNames* createInstance(UResourceBundle* rb, const char* key);
- const UChar* getName(UTimeZoneNameType type) const;
+ const char16_t* getName(UTimeZoneNameType type) const;
const char** getParseRegions(int32_t& numRegions) const;
protected:
- TZDBNames(const UChar** names, char** regions, int32_t numRegions);
+ TZDBNames(const char16_t** names, char** regions, int32_t numRegions);
private:
- const UChar** fNames;
+ const char16_t** fNames;
char** fRegions;
int32_t fNumRegions;
};
-TZDBNames::TZDBNames(const UChar** names, char** regions, int32_t numRegions)
+TZDBNames::TZDBNames(const char16_t** names, char** regions, int32_t numRegions)
: fNames(names),
fRegions(regions),
fNumRegions(numRegions) {
UErrorCode status = U_ZERO_ERROR;
- const UChar **names = nullptr;
+ const char16_t **names = nullptr;
char** regions = nullptr;
int32_t numRegions = 0;
return nullptr;
}
- names = (const UChar **)uprv_malloc(sizeof(const UChar*) * TZDBNAMES_KEYS_SIZE);
+ names = (const char16_t **)uprv_malloc(sizeof(const char16_t*) * TZDBNAMES_KEYS_SIZE);
UBool isEmpty = true;
if (names != nullptr) {
for (int32_t i = 0; i < TZDBNAMES_KEYS_SIZE; i++) {
status = U_ZERO_ERROR;
- const UChar *value = ures_getStringByKey(rbTable, TZDBNAMES_KEYS[i], &len, &status);
+ const char16_t *value = ures_getStringByKey(rbTable, TZDBNAMES_KEYS[i], &len, &status);
if (U_FAILURE(status) || len == 0) {
names[i] = nullptr;
} else {
pRegion = regions;
for (int32_t i = 0; i < numRegions; i++, pRegion++) {
status = U_ZERO_ERROR;
- const UChar *uregion = ures_getStringByIndex(regionsRes, i, &len, &status);
+ const char16_t *uregion = ures_getStringByIndex(regionsRes, i, &len, &status);
if (U_FAILURE(status)) {
regionError = true;
break;
return new TZDBNames(names, regions, numRegions);
}
-const UChar*
+const char16_t*
TZDBNames::getName(UTimeZoneNameType type) const {
if (fNames == nullptr) {
return nullptr;
}
- const UChar *name = nullptr;
+ const char16_t *name = nullptr;
switch(type) {
case UTZNM_SHORT_STANDARD:
name = fNames[0];
* in the trie
*/
typedef struct TZDBNameInfo {
- const UChar* mzID;
+ const char16_t* mzID;
UTimeZoneNameType type;
UBool ambiguousType;
const char** parseRegions;
if (names == nullptr) {
continue;
}
- const UChar *std = names->getName(UTZNM_SHORT_STANDARD);
- const UChar *dst = names->getName(UTZNM_SHORT_DAYLIGHT);
+ const char16_t *std = names->getName(UTZNM_SHORT_STANDARD);
+ const char16_t *dst = names->getName(UTZNM_SHORT_DAYLIGHT);
if (std == nullptr && dst == nullptr) {
continue;
}
// we need to store the information for later processing.
UBool ambiguousType = (std != nullptr && dst != nullptr && u_strcmp(std, dst) == 0);
- const UChar *uMzID = ZoneMeta::findMetaZoneID(*mzID);
+ const char16_t *uMzID = ZoneMeta::findMetaZoneID(*mzID);
if (std != nullptr) {
TZDBNameInfo *stdInf = (TZDBNameInfo *)uprv_malloc(sizeof(TZDBNameInfo));
if (stdInf == nullptr) {
const TZDBNames *tzdbNames = TZDBTimeZoneNames::getMetaZoneNames(mzID, status);
if (U_SUCCESS(status)) {
if (tzdbNames != nullptr) {
- const UChar *s = tzdbNames->getName(type);
+ const char16_t *s = tzdbNames->getName(type);
if (s != nullptr) {
name.setTo(true, s, -1);
}
TZDBNames* tzdbNames = nullptr;
- UChar mzIDKey[ZID_KEY_MAX + 1];
+ char16_t mzIDKey[ZID_KEY_MAX + 1];
mzID.extract(mzIDKey, ZID_KEY_MAX + 1, status);
U_ASSERT(status == U_ZERO_ERROR); // already checked length above
mzIDKey[mzID.length()] = 0;
U_NAMESPACE_BEGIN
/*
- * ZNStringPool Pool of (UChar *) strings. Provides for sharing of repeated
+ * ZNStringPool Pool of (char16_t *) strings. Provides for sharing of repeated
* zone strings.
*/
struct ZNStringPoolChunk;
*
* Life time of the returned string is that of the pool.
*/
- const UChar *get(const UChar *s, UErrorCode &status);
+ const char16_t *get(const char16_t *s, UErrorCode &status);
/* Get the pooled string that is equal to the supplied string s.
* Copy the string into the pool if it is not already present.
*/
- const UChar *get(const UnicodeString &s, UErrorCode &status);
+ const char16_t *get(const UnicodeString &s, UErrorCode &status);
/* Adopt a string into the pool, without copying it.
* Used for strings from resource bundles, which will persist without copying.
*/
- const UChar *adopt(const UChar *s, UErrorCode &status);
+ const char16_t *adopt(const char16_t *s, UErrorCode &status);
/* Freeze the string pool. Discards the hash table that is used
* for looking up a string. All pointers to pooled strings remain valid.
inline const void *getValue(int32_t index) const;
void *fValues; // Union of one single value vs. UVector of values.
- UChar fCharacter; // UTF-16 code unit.
+ char16_t fCharacter; // UTF-16 code unit.
uint16_t fFirstChild; // 0 if no children.
uint16_t fNextSibling; // 0 terminates the list.
UBool fHasValuesVector;
virtual ~TextTrieMap();
void put(const UnicodeString &key, void *value, ZNStringPool &sp, UErrorCode &status);
- void put(const UChar*, void *value, UErrorCode &status);
+ void put(const char16_t*, void *value, UErrorCode &status);
void search(const UnicodeString &text, int32_t start,
TextTrieMapSearchResultHandler *handler, UErrorCode& status) const;
int32_t isEmpty() const;
UObjectDeleter *fValueDeleter;
UBool growNodes();
- CharacterNode* addChildNode(CharacterNode *parent, UChar c, UErrorCode &status);
- CharacterNode* getChildNode(CharacterNode *parent, UChar c) const;
+ CharacterNode* addChildNode(CharacterNode *parent, char16_t c, UErrorCode &status);
+ CharacterNode* getChildNode(CharacterNode *parent, char16_t c) const;
void putImpl(const UnicodeString &key, void *value, UErrorCode &status);
void buildTrie(UErrorCode &status);
U_NAMESPACE_USE
static TimeZone*
-_createTimeZone(const UChar* zoneID, int32_t len, UErrorCode* ec) {
+_createTimeZone(const char16_t* zoneID, int32_t len, UErrorCode* ec) {
TimeZone* zone = nullptr;
if (ec != nullptr && U_SUCCESS(*ec)) {
// Note that if zoneID is invalid, we get back GMT. This odd
}
U_CAPI int32_t U_EXPORT2
-ucal_getDefaultTimeZone(UChar* result, int32_t resultCapacity, UErrorCode* ec) {
+ucal_getDefaultTimeZone(char16_t* result, int32_t resultCapacity, UErrorCode* ec) {
int32_t len = 0;
if (ec != nullptr && U_SUCCESS(*ec)) {
TimeZone* zone = TimeZone::createDefault();
}
U_CAPI void U_EXPORT2
-ucal_setDefaultTimeZone(const UChar* zoneID, UErrorCode* ec) {
+ucal_setDefaultTimeZone(const char16_t* zoneID, UErrorCode* ec) {
TimeZone* zone = _createTimeZone(zoneID, -1, ec);
if (zone != nullptr) {
TimeZone::adoptDefault(zone);
}
U_CAPI int32_t U_EXPORT2
-ucal_getHostTimeZone(UChar* result, int32_t resultCapacity, UErrorCode* ec) {
+ucal_getHostTimeZone(char16_t* result, int32_t resultCapacity, UErrorCode* ec) {
int32_t len = 0;
if (ec != nullptr && U_SUCCESS(*ec)) {
TimeZone *zone = TimeZone::detectHostTimeZone();
}
U_CAPI int32_t U_EXPORT2
-ucal_getDSTSavings(const UChar* zoneID, UErrorCode* ec) {
+ucal_getDSTSavings(const char16_t* zoneID, UErrorCode* ec) {
int32_t result = 0;
TimeZone* zone = _createTimeZone(zoneID, -1, ec);
if (U_SUCCESS(*ec)) {
#define ULOC_LOCALE_IDENTIFIER_CAPACITY (ULOC_FULLNAME_CAPACITY + 1 + ULOC_KEYWORD_AND_VALUES_CAPACITY)
U_CAPI UCalendar* U_EXPORT2
-ucal_open( const UChar* zoneID,
+ucal_open( const char16_t* zoneID,
int32_t len,
const char* locale,
UCalendarType caltype,
U_CAPI void U_EXPORT2
ucal_setTimeZone( UCalendar* cal,
- const UChar* zoneID,
+ const char16_t* zoneID,
int32_t len,
UErrorCode *status)
{
U_CAPI int32_t U_EXPORT2
ucal_getTimeZoneID(const UCalendar *cal,
- UChar *result,
+ char16_t *result,
int32_t resultLength,
UErrorCode *status)
{
ucal_getTimeZoneDisplayName(const UCalendar* cal,
UCalendarDisplayNameType type,
const char *locale,
- UChar* result,
+ char16_t* result,
int32_t resultLength,
UErrorCode* status)
{
}
U_CAPI int32_t U_EXPORT2
-ucal_getCanonicalTimeZoneID(const UChar* id, int32_t len,
- UChar* result, int32_t resultCapacity, UBool *isSystemID, UErrorCode* status) {
+ucal_getCanonicalTimeZoneID(const char16_t* id, int32_t len,
+ char16_t* result, int32_t resultCapacity, UBool *isSystemID, UErrorCode* status) {
if(status == 0 || U_FAILURE(*status)) {
return 0;
}
if (U_SUCCESS(*status)) {
for (int i = 0; i < ures_getSize(order); i++) {
int32_t len;
- const UChar *type = ures_getStringByIndex(order, i, &len, status);
+ const char16_t *type = ures_getStringByIndex(order, i, &len, status);
char *caltype = (char*)uprv_malloc(len + 1);
if (caltype == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
}
U_CAPI int32_t U_EXPORT2
-ucal_getWindowsTimeZoneID(const UChar* id, int32_t len, UChar* winid, int32_t winidCapacity, UErrorCode* status) {
+ucal_getWindowsTimeZoneID(const char16_t* id, int32_t len, char16_t* winid, int32_t winidCapacity, UErrorCode* status) {
if (U_FAILURE(*status)) {
return 0;
}
}
U_CAPI int32_t U_EXPORT2
-ucal_getTimeZoneIDForWindowsID(const UChar* winid, int32_t len, const char* region, UChar* id, int32_t idCapacity, UErrorCode* status) {
+ucal_getTimeZoneIDForWindowsID(const char16_t* winid, int32_t len, const char* region, char16_t* id, int32_t idCapacity, UErrorCode* status) {
if (U_FAILURE(*status)) {
return 0;
}
U_CAPI int32_t U_EXPORT2
ucol_getSortKey(const UCollator *coll,
- const UChar *source,
+ const char16_t *source,
int32_t sourceLength,
uint8_t *result,
int32_t resultLength)
}
U_CAPI uint32_t U_EXPORT2
-ucol_setVariableTop(UCollator *coll, const UChar *varTop, int32_t len, UErrorCode *status) {
+ucol_setVariableTop(UCollator *coll, const char16_t *varTop, int32_t len, UErrorCode *status) {
if(U_FAILURE(*status) || coll == nullptr) {
return 0;
}
/* */
U_CAPI UCollationResult U_EXPORT2
ucol_strcoll( const UCollator *coll,
- const UChar *source,
+ const char16_t *source,
int32_t sourceLength,
- const UChar *target,
+ const char16_t *target,
int32_t targetLength)
{
UTRACE_ENTRY(UTRACE_UCOL_STRCOLL);
/* convenience function for comparing strings */
U_CAPI UBool U_EXPORT2
ucol_greater( const UCollator *coll,
- const UChar *source,
+ const char16_t *source,
int32_t sourceLength,
- const UChar *target,
+ const char16_t *target,
int32_t targetLength)
{
return (ucol_strcoll(coll, source, sourceLength, target, targetLength)
/* convenience function for comparing strings */
U_CAPI UBool U_EXPORT2
ucol_greaterOrEqual( const UCollator *coll,
- const UChar *source,
+ const char16_t *source,
int32_t sourceLength,
- const UChar *target,
+ const char16_t *target,
int32_t targetLength)
{
return (ucol_strcoll(coll, source, sourceLength, target, targetLength)
/* convenience function for comparing strings */
U_CAPI UBool U_EXPORT2
ucol_equal( const UCollator *coll,
- const UChar *source,
+ const char16_t *source,
int32_t sourceLength,
- const UChar *target,
+ const char16_t *target,
int32_t targetLength)
{
return (ucol_strcoll(coll, source, sourceLength, target, targetLength)
}
}
-U_CAPI const UChar * U_EXPORT2
+U_CAPI const char16_t * U_EXPORT2
ucol_getRules(const UCollator *coll, int32_t *length) {
const RuleBasedCollator *rbc = RuleBasedCollator::rbcFromUCollator(coll);
// OK to crash if coll==nullptr: We do not want to check "this" pointers.
*length = rules.length();
return rules.getBuffer();
}
- static const UChar _NUL = 0;
+ static const char16_t _NUL = 0;
*length = 0;
return &_NUL;
}
U_CAPI int32_t U_EXPORT2
-ucol_getRulesEx(const UCollator *coll, UColRuleOption delta, UChar *buffer, int32_t bufferLen) {
+ucol_getRulesEx(const UCollator *coll, UColRuleOption delta, char16_t *buffer, int32_t bufferLen) {
UnicodeString rules;
const RuleBasedCollator *rbc = RuleBasedCollator::rbcFromUCollator(coll);
if(rbc != nullptr || coll == nullptr) {
namespace {
-static const UChar *rootRules = nullptr;
+static const char16_t *rootRules = nullptr;
static int32_t rootRulesLength = 0;
static UResourceBundle *rootBundle = nullptr;
static UInitOnce gInitOnceUcolRes {};
LocalUResourceBundlePointer data(
ures_getByKeyWithFallback(collations.getAlias(), type, nullptr, &errorCode));
int32_t length;
- const UChar *s = ures_getStringByKey(data.getAlias(), "Sequence", &length, &errorCode);
+ const char16_t *s = ures_getStringByKey(data.getAlias(), "Sequence", &length, &errorCode);
if(U_FAILURE(errorCode)) { return; }
// No string pointer aliasing so that we need not hold onto the resource bundle.
LocalUResourceBundlePointer def(
ures_getByKeyWithFallback(collations, "default", nullptr, &internalErrorCode));
int32_t length;
- const UChar *s = ures_getString(def.getAlias(), &length, &internalErrorCode);
+ const char16_t *s = ures_getString(def.getAlias(), &length, &internalErrorCode);
if(U_SUCCESS(internalErrorCode) && 0 < length && length < UPRV_LENGTHOF(defaultType)) {
u_UCharsToChars(s, defaultType, length + 1);
} else {
{
UErrorCode internalErrorCode = U_ZERO_ERROR;
int32_t len;
- const UChar *s = ures_getStringByKey(data, "Sequence", &len,
+ const char16_t *s = ures_getStringByKey(data, "Sequence", &len,
&internalErrorCode);
if(U_SUCCESS(internalErrorCode)) {
t->rules.setTo(true, s, len);
ures_getByKeyWithFallback(actualBundle.getAlias(), "collations/default", nullptr,
&internalErrorCode));
int32_t len;
- const UChar *s = ures_getString(def.getAlias(), &len, &internalErrorCode);
+ const char16_t *s = ures_getString(def.getAlias(), &len, &internalErrorCode);
if(U_SUCCESS(internalErrorCode) && len < UPRV_LENGTHOF(defaultType)) {
u_UCharsToChars(s, defaultType, len + 1);
} else {
U_CAPI int32_t U_EXPORT2
ucol_getDisplayName( const char *objLoc,
const char *dispLoc,
- UChar *result,
+ char16_t *result,
int32_t resultLength,
UErrorCode *status)
{
CharString locale;
UColAttributeValue options[UCOL_ATTRIBUTE_COUNT];
uint32_t variableTopValue;
- UChar variableTopString[locElementCapacity];
+ char16_t variableTopString[locElementCapacity];
int32_t variableTopStringLen;
UBool variableTopSet;
CharString entries[UCOL_SIT_ITEMS_COUNT];
U_CDECL_END
-static UChar
+static char16_t
readHexCodeUnit(const char **string, UErrorCode *status)
{
- UChar result = 0;
+ char16_t result = 0;
int32_t value = 0;
char c;
int32_t noDigits = 0;
#endif
return 0;
}
- result = (result << 4) | (UChar)value;
+ result = (result << 4) | (char16_t)value;
noDigits++;
(*string)++;
}
UResourceBundle *defaultColl = ures_getByKeyWithFallback(collations, "default", nullptr, status);
if(U_SUCCESS(*status)) {
int32_t defaultKeyLen = 0;
- const UChar *defaultKey = ures_getString(defaultColl, &defaultKeyLen, status);
+ const char16_t *defaultKey = ures_getString(defaultColl, &defaultKeyLen, status);
u_UCharsToChars(defaultKey, keyBuffer, defaultKeyLen);
keyBuffer[defaultKeyLen] = 0;
} else {
U_CAPI UCollationElements* U_EXPORT2
ucol_openElements(const UCollator *coll,
- const UChar *text,
+ const char16_t *text,
int32_t textLength,
UErrorCode *status)
{
U_CAPI void U_EXPORT2
ucol_setText( UCollationElements *elems,
- const UChar *text,
+ const char16_t *text,
int32_t textLength,
UErrorCode *status)
{
U_CAPI int32_t U_EXPORT2
ucsdet_getUChars(const UCharsetMatch *ucsm,
- UChar *buf, int32_t cap, UErrorCode *status)
+ char16_t *buf, int32_t cap, UErrorCode *status)
{
if(U_FAILURE(*status)) {
return 0;
udat_open(UDateFormatStyle timeStyle,
UDateFormatStyle dateStyle,
const char *locale,
- const UChar *tzID,
+ const char16_t *tzID,
int32_t tzIDLength,
- const UChar *pattern,
+ const char16_t *pattern,
int32_t patternLength,
UErrorCode *status)
{
U_CAPI int32_t U_EXPORT2
udat_format( const UDateFormat* format,
UDate dateToFormat,
- UChar* result,
+ char16_t* result,
int32_t resultLength,
UFieldPosition* position,
UErrorCode* status)
U_CAPI int32_t U_EXPORT2
udat_formatCalendar(const UDateFormat* format,
UCalendar* calendar,
- UChar* result,
+ char16_t* result,
int32_t resultLength,
UFieldPosition* position,
UErrorCode* status)
U_CAPI int32_t U_EXPORT2
udat_formatForFields( const UDateFormat* format,
UDate dateToFormat,
- UChar* result,
+ char16_t* result,
int32_t resultLength,
UFieldPositionIterator* fpositer,
UErrorCode* status)
U_CAPI int32_t U_EXPORT2
udat_formatCalendarForFields(const UDateFormat* format,
UCalendar* calendar,
- UChar* result,
+ char16_t* result,
int32_t resultLength,
UFieldPositionIterator* fpositer,
UErrorCode* status)
U_CAPI UDate U_EXPORT2
udat_parse( const UDateFormat* format,
- const UChar* text,
+ const char16_t* text,
int32_t textLength,
int32_t *parsePos,
UErrorCode *status)
U_CAPI void U_EXPORT2
udat_parseCalendar(const UDateFormat* format,
UCalendar* calendar,
- const UChar* text,
+ const char16_t* text,
int32_t textLength,
int32_t *parsePos,
UErrorCode *status)
}
U_CAPI const UNumberFormat* U_EXPORT2
-udat_getNumberFormatForField(const UDateFormat* fmt, UChar field)
+udat_getNumberFormatForField(const UDateFormat* fmt, char16_t field)
{
UErrorCode status = U_ZERO_ERROR;
verifyIsSimpleDateFormat(fmt, &status);
U_CAPI void U_EXPORT2
udat_adoptNumberFormatForFields( UDateFormat* fmt,
- const UChar* fields,
+ const char16_t* fields,
UNumberFormat* numberFormatToSet,
UErrorCode* status)
{
U_CAPI int32_t U_EXPORT2
udat_toPattern( const UDateFormat *fmt,
UBool localized,
- UChar *result,
+ char16_t *result,
int32_t resultLength,
UErrorCode *status)
{
U_CAPI void U_EXPORT2
udat_applyPattern( UDateFormat *format,
UBool localized,
- const UChar *pattern,
+ const char16_t *pattern,
int32_t patternLength)
{
const UnicodeString pat((UBool)(patternLength == -1), pattern, patternLength);
udat_getSymbols(const UDateFormat *fmt,
UDateFormatSymbolType type,
int32_t index,
- UChar *result,
+ char16_t *result,
int32_t resultLength,
UErrorCode *status)
{
public:
static void
setSymbol(UnicodeString *array, int32_t count, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
if(array!=nullptr) {
if(index>=count) {
static void
setEra(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fEras, syms->fErasCount, index, value, valueLength, errorCode);
}
static void
setEraName(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fEraNames, syms->fEraNamesCount, index, value, valueLength, errorCode);
}
static void
setMonth(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fMonths, syms->fMonthsCount, index, value, valueLength, errorCode);
}
static void
setShortMonth(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fShortMonths, syms->fShortMonthsCount, index, value, valueLength, errorCode);
}
static void
setNarrowMonth(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fNarrowMonths, syms->fNarrowMonthsCount, index, value, valueLength, errorCode);
}
static void
setStandaloneMonth(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fStandaloneMonths, syms->fStandaloneMonthsCount, index, value, valueLength, errorCode);
}
static void
setStandaloneShortMonth(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fStandaloneShortMonths, syms->fStandaloneShortMonthsCount, index, value, valueLength, errorCode);
}
static void
setStandaloneNarrowMonth(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fStandaloneNarrowMonths, syms->fStandaloneNarrowMonthsCount, index, value, valueLength, errorCode);
}
static void
setWeekday(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fWeekdays, syms->fWeekdaysCount, index, value, valueLength, errorCode);
}
static void
setShortWeekday(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fShortWeekdays, syms->fShortWeekdaysCount, index, value, valueLength, errorCode);
}
static void
setShorterWeekday(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fShorterWeekdays, syms->fShorterWeekdaysCount, index, value, valueLength, errorCode);
}
static void
setNarrowWeekday(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fNarrowWeekdays, syms->fNarrowWeekdaysCount, index, value, valueLength, errorCode);
}
static void
setStandaloneWeekday(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fStandaloneWeekdays, syms->fStandaloneWeekdaysCount, index, value, valueLength, errorCode);
}
static void
setStandaloneShortWeekday(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fStandaloneShortWeekdays, syms->fStandaloneShortWeekdaysCount, index, value, valueLength, errorCode);
}
static void
setStandaloneShorterWeekday(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fStandaloneShorterWeekdays, syms->fStandaloneShorterWeekdaysCount, index, value, valueLength, errorCode);
}
static void
setStandaloneNarrowWeekday(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fStandaloneNarrowWeekdays, syms->fStandaloneNarrowWeekdaysCount, index, value, valueLength, errorCode);
}
static void
setQuarter(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fQuarters, syms->fQuartersCount, index, value, valueLength, errorCode);
}
static void
setShortQuarter(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fShortQuarters, syms->fShortQuartersCount, index, value, valueLength, errorCode);
}
static void
setNarrowQuarter(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fNarrowQuarters, syms->fNarrowQuartersCount, index, value, valueLength, errorCode);
}
static void
setStandaloneQuarter(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fStandaloneQuarters, syms->fStandaloneQuartersCount, index, value, valueLength, errorCode);
}
static void
setStandaloneShortQuarter(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fStandaloneShortQuarters, syms->fStandaloneShortQuartersCount, index, value, valueLength, errorCode);
}
static void
setStandaloneNarrowQuarter(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fStandaloneNarrowQuarters, syms->fStandaloneNarrowQuartersCount, index, value, valueLength, errorCode);
}
static void
setShortYearNames(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fShortYearNames, syms->fShortYearNamesCount, index, value, valueLength, errorCode);
}
static void
setShortZodiacNames(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fShortZodiacNames, syms->fShortZodiacNamesCount, index, value, valueLength, errorCode);
}
static void
setAmPm(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fAmPms, syms->fAmPmsCount, index, value, valueLength, errorCode);
}
static void
setLocalPatternChars(DateFormatSymbols *syms,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(&syms->fLocalPatternChars, 1, 0, value, valueLength, errorCode);
}
udat_setSymbols( UDateFormat *format,
UDateFormatSymbolType type,
int32_t index,
- UChar *value,
+ char16_t *value,
int32_t valueLength,
UErrorCode *status)
{
U_CAPI int32_t U_EXPORT2
udat_toPatternRelativeDate(const UDateFormat *fmt,
- UChar *result,
+ char16_t *result,
int32_t resultLength,
UErrorCode *status)
{
U_CAPI int32_t U_EXPORT2
udat_toPatternRelativeTime(const UDateFormat *fmt,
- UChar *result,
+ char16_t *result,
int32_t resultLength,
UErrorCode *status)
{
U_CAPI void U_EXPORT2
udat_applyPatternRelative(UDateFormat *format,
- const UChar *datePattern,
+ const char16_t *datePattern,
int32_t datePatternLength,
- const UChar *timePattern,
+ const char16_t *timePattern,
int32_t timePatternLength,
UErrorCode *status)
{
U_CAPI UDateIntervalFormat* U_EXPORT2
udtitvfmt_open(const char* locale,
- const UChar* skeleton,
+ const char16_t* skeleton,
int32_t skeletonLength,
- const UChar* tzID,
+ const char16_t* tzID,
int32_t tzIDLength,
UErrorCode* status)
{
udtitvfmt_format(const UDateIntervalFormat* formatter,
UDate fromDate,
UDate toDate,
- UChar* result,
+ char16_t* result,
int32_t resultCapacity,
UFieldPosition* position,
UErrorCode* status)
U_CAPI int32_t U_EXPORT2
udatpg_getBestPattern(UDateTimePatternGenerator *dtpg,
- const UChar *skeleton, int32_t length,
- UChar *bestPattern, int32_t capacity,
+ const char16_t *skeleton, int32_t length,
+ char16_t *bestPattern, int32_t capacity,
UErrorCode *pErrorCode) {
return udatpg_getBestPatternWithOptions(dtpg, skeleton, length,
UDATPG_MATCH_NO_OPTIONS,
U_CAPI int32_t U_EXPORT2
udatpg_getBestPatternWithOptions(UDateTimePatternGenerator *dtpg,
- const UChar *skeleton, int32_t length,
+ const char16_t *skeleton, int32_t length,
UDateTimePatternMatchOptions options,
- UChar *bestPattern, int32_t capacity,
+ char16_t *bestPattern, int32_t capacity,
UErrorCode *pErrorCode) {
if(U_FAILURE(*pErrorCode)) {
return 0;
U_CAPI int32_t U_EXPORT2
udatpg_getSkeleton(UDateTimePatternGenerator * /* dtpg */,
- const UChar *pattern, int32_t length,
- UChar *skeleton, int32_t capacity,
+ const char16_t *pattern, int32_t length,
+ char16_t *skeleton, int32_t capacity,
UErrorCode *pErrorCode) {
if(U_FAILURE(*pErrorCode)) {
return 0;
U_CAPI int32_t U_EXPORT2
udatpg_getBaseSkeleton(UDateTimePatternGenerator * /* dtpg */,
- const UChar *pattern, int32_t length,
- UChar *skeleton, int32_t capacity,
+ const char16_t *pattern, int32_t length,
+ char16_t *skeleton, int32_t capacity,
UErrorCode *pErrorCode) {
if(U_FAILURE(*pErrorCode)) {
return 0;
U_CAPI UDateTimePatternConflict U_EXPORT2
udatpg_addPattern(UDateTimePatternGenerator *dtpg,
- const UChar *pattern, int32_t patternLength,
+ const char16_t *pattern, int32_t patternLength,
UBool override,
- UChar *conflictingPattern, int32_t capacity, int32_t *pLength,
+ char16_t *conflictingPattern, int32_t capacity, int32_t *pLength,
UErrorCode *pErrorCode) {
if(U_FAILURE(*pErrorCode)) {
return UDATPG_NO_CONFLICT;
U_CAPI void U_EXPORT2
udatpg_setAppendItemFormat(UDateTimePatternGenerator *dtpg,
UDateTimePatternField field,
- const UChar *value, int32_t length) {
+ const char16_t *value, int32_t length) {
UnicodeString valueString((UBool)(length<0), value, length);
((DateTimePatternGenerator *)dtpg)->setAppendItemFormat(field, valueString);
}
-U_CAPI const UChar * U_EXPORT2
+U_CAPI const char16_t * U_EXPORT2
udatpg_getAppendItemFormat(const UDateTimePatternGenerator *dtpg,
UDateTimePatternField field,
int32_t *pLength) {
U_CAPI void U_EXPORT2
udatpg_setAppendItemName(UDateTimePatternGenerator *dtpg,
UDateTimePatternField field,
- const UChar *value, int32_t length) {
+ const char16_t *value, int32_t length) {
UnicodeString valueString((UBool)(length<0), value, length);
((DateTimePatternGenerator *)dtpg)->setAppendItemName(field, valueString);
}
-U_CAPI const UChar * U_EXPORT2
+U_CAPI const char16_t * U_EXPORT2
udatpg_getAppendItemName(const UDateTimePatternGenerator *dtpg,
UDateTimePatternField field,
int32_t *pLength) {
udatpg_getFieldDisplayName(const UDateTimePatternGenerator *dtpg,
UDateTimePatternField field,
UDateTimePGDisplayWidth width,
- UChar *fieldName, int32_t capacity,
+ char16_t *fieldName, int32_t capacity,
UErrorCode *pErrorCode) {
if (U_FAILURE(*pErrorCode))
return -1;
U_CAPI void U_EXPORT2
udatpg_setDateTimeFormat(const UDateTimePatternGenerator *dtpg,
- const UChar *dtFormat, int32_t length) {
+ const char16_t *dtFormat, int32_t length) {
UnicodeString dtFormatString((UBool)(length<0), dtFormat, length);
((DateTimePatternGenerator *)dtpg)->setDateTimeFormat(dtFormatString);
}
-U_CAPI const UChar * U_EXPORT2
+U_CAPI const char16_t * U_EXPORT2
udatpg_getDateTimeFormat(const UDateTimePatternGenerator *dtpg,
int32_t *pLength) {
UErrorCode status = U_ZERO_ERROR;
U_CAPI void U_EXPORT2
udatpg_setDateTimeFormatForStyle(UDateTimePatternGenerator *udtpg,
UDateFormatStyle style,
- const UChar *dateTimeFormat, int32_t length,
+ const char16_t *dateTimeFormat, int32_t length,
UErrorCode *pErrorCode) {
if (U_FAILURE(*pErrorCode)) {
return;
dtpg->setDateTimeFormat(style, dtFormatString, *pErrorCode);
}
-U_CAPI const UChar* U_EXPORT2
+U_CAPI const char16_t* U_EXPORT2
udatpg_getDateTimeFormatForStyle(const UDateTimePatternGenerator *udtpg,
UDateFormatStyle style, int32_t *pLength,
UErrorCode *pErrorCode) {
- static const UChar emptyString[] = { (UChar)0 };
+ static const char16_t emptyString[] = { (char16_t)0 };
if (U_FAILURE(*pErrorCode)) {
if (pLength !=nullptr) {
*pLength = 0;
U_CAPI void U_EXPORT2
udatpg_setDecimal(UDateTimePatternGenerator *dtpg,
- const UChar *decimal, int32_t length) {
+ const char16_t *decimal, int32_t length) {
UnicodeString decimalString((UBool)(length<0), decimal, length);
((DateTimePatternGenerator *)dtpg)->setDecimal(decimalString);
}
-U_CAPI const UChar * U_EXPORT2
+U_CAPI const char16_t * U_EXPORT2
udatpg_getDecimal(const UDateTimePatternGenerator *dtpg,
int32_t *pLength) {
const UnicodeString &result=((const DateTimePatternGenerator *)dtpg)->getDecimal();
U_CAPI int32_t U_EXPORT2
udatpg_replaceFieldTypes(UDateTimePatternGenerator *dtpg,
- const UChar *pattern, int32_t patternLength,
- const UChar *skeleton, int32_t skeletonLength,
- UChar *dest, int32_t destCapacity,
+ const char16_t *pattern, int32_t patternLength,
+ const char16_t *skeleton, int32_t skeletonLength,
+ char16_t *dest, int32_t destCapacity,
UErrorCode *pErrorCode) {
return udatpg_replaceFieldTypesWithOptions(dtpg, pattern, patternLength, skeleton, skeletonLength,
UDATPG_MATCH_NO_OPTIONS,
U_CAPI int32_t U_EXPORT2
udatpg_replaceFieldTypesWithOptions(UDateTimePatternGenerator *dtpg,
- const UChar *pattern, int32_t patternLength,
- const UChar *skeleton, int32_t skeletonLength,
+ const char16_t *pattern, int32_t patternLength,
+ const char16_t *skeleton, int32_t skeletonLength,
UDateTimePatternMatchOptions options,
- UChar *dest, int32_t destCapacity,
+ char16_t *dest, int32_t destCapacity,
UErrorCode *pErrorCode) {
if(U_FAILURE(*pErrorCode)) {
return 0;
pErrorCode);
}
-U_CAPI const UChar * U_EXPORT2
+U_CAPI const char16_t * U_EXPORT2
udatpg_getPatternForSkeleton(const UDateTimePatternGenerator *dtpg,
- const UChar *skeleton, int32_t skeletonLength,
+ const char16_t *skeleton, int32_t skeletonLength,
int32_t *pLength) {
UnicodeString skeletonString((UBool)(skeletonLength<0), skeleton, skeletonLength);
const UnicodeString &result=((const DateTimePatternGenerator *)dtpg)->getPatternForSkeleton(skeletonString);
return UTRIE2_GET32_FROM_U16_SINGLE_LEAD(trie, c);
}
-UChar
+char16_t
UIterCollationIterator::handleGetTrailSurrogate() {
UChar32 trail = iter.next(&iter);
if(!U16_IS_TRAIL(trail) && trail >= 0) { iter.previous(&iter); }
- return (UChar)trail;
+ return (char16_t)trail;
}
UChar32
return UTRIE2_GET32_FROM_U16_SINGLE_LEAD(trie, c);
}
-UChar
+char16_t
FCDUIterCollationIterator::handleGetTrailSurrogate() {
if(state <= ITER_IN_FCD_SEGMENT) {
UChar32 trail = iter.next(&iter);
} else if(trail >= 0) {
iter.previous(&iter);
}
- return (UChar)trail;
+ return (char16_t)trail;
} else {
U_ASSERT(pos < normalized.length());
- UChar trail;
+ char16_t trail;
if(U16_IS_TRAIL(trail = normalized[pos])) { ++pos; }
return trail;
}
protected:
virtual uint32_t handleNextCE32(UChar32 &c, UErrorCode &errorCode) override;
- virtual UChar handleGetTrailSurrogate() override;
+ virtual char16_t handleGetTrailSurrogate() override;
virtual void forwardNumCodePoints(int32_t num, UErrorCode &errorCode) override;
protected:
virtual uint32_t handleNextCE32(UChar32 &c, UErrorCode &errorCode) override;
- virtual UChar handleGetTrailSurrogate() override;
+ virtual char16_t handleGetTrailSurrogate() override;
virtual void forwardNumCodePoints(int32_t num, UErrorCode &errorCode) override;
static UnicodeString* getUnicodeStrings(
- const UChar* const strings[],
+ const char16_t* const strings[],
const int32_t* stringLengths,
int32_t stringCount,
UnicodeString* length4StackBuffer,
U_CAPI int32_t U_EXPORT2
ulistfmt_format(const UListFormatter* listfmt,
- const UChar* const strings[],
+ const char16_t* const strings[],
const int32_t * stringLengths,
int32_t stringCount,
- UChar* result,
+ char16_t* result,
int32_t resultCapacity,
UErrorCode* status)
{
U_CAPI void U_EXPORT2
ulistfmt_formatStringsToResult(
const UListFormatter* listfmt,
- const UChar* const strings[],
+ const char16_t* const strings[],
const int32_t * stringLengths,
int32_t stringCount,
UFormattedList* uresult,
"AuxExemplarCharacters",
"ExemplarCharactersIndex",
"ExemplarCharactersPunctuation"};
- const UChar *exemplarChars = nullptr;
+ const char16_t *exemplarChars = nullptr;
int32_t len = 0;
UErrorCode localStatus = U_ZERO_ERROR;
U_CAPI int32_t U_EXPORT2
ulocdata_getDelimiter(ULocaleData *uld, ULocaleDataDelimiterType type,
- UChar *result, int32_t resultLength, UErrorCode *status){
+ char16_t *result, int32_t resultLength, UErrorCode *status){
static const char* const delimiterKeys[] = {
"quotationStart",
UResourceBundle *delimiterBundle;
int32_t len = 0;
- const UChar *delimiter = nullptr;
+ const char16_t *delimiter = nullptr;
UErrorCode localStatus = U_ZERO_ERROR;
if (U_FAILURE(*status))
U_CAPI int32_t U_EXPORT2
ulocdata_getLocaleDisplayPattern(ULocaleData *uld,
- UChar *result,
+ char16_t *result,
int32_t resultCapacity,
UErrorCode *status) {
UResourceBundle *patternBundle;
int32_t len = 0;
- const UChar *pattern = nullptr;
+ const char16_t *pattern = nullptr;
UErrorCode localStatus = U_ZERO_ERROR;
if (U_FAILURE(*status))
U_CAPI int32_t U_EXPORT2
ulocdata_getLocaleSeparator(ULocaleData *uld,
- UChar *result,
+ char16_t *result,
int32_t resultCapacity,
UErrorCode *status) {
UResourceBundle *separatorBundle;
int32_t len = 0;
- const UChar *separator = nullptr;
+ const char16_t *separator = nullptr;
UErrorCode localStatus = U_ZERO_ERROR;
- UChar *p0, *p1;
- static const UChar sub0[4] = { 0x007b, 0x0030, 0x007d , 0x0000 }; /* {0} */
- static const UChar sub1[4] = { 0x007b, 0x0031, 0x007d , 0x0000 }; /* {1} */
+ char16_t *p0, *p1;
+ static const char16_t sub0[4] = { 0x007b, 0x0030, 0x007d , 0x0000 }; /* {0} */
+ static const char16_t sub1[4] = { 0x007b, 0x0031, 0x007d , 0x0000 }; /* {1} */
static const int32_t subLen = 3;
if (U_FAILURE(*status))
p0=u_strstr(separator, sub0);
p1=u_strstr(separator, sub1);
if (p0!=nullptr && p1!=nullptr && p0<=p1) {
- separator = (const UChar *)p0 + subLen;
+ separator = (const char16_t *)p0 + subLen;
len = static_cast<int32_t>(p1 - separator);
/* Desired separator is no longer zero-terminated; handle that if necessary */
if (len < resultCapacity) {
U_CAPI int32_t
u_formatMessage(const char *locale,
- const UChar *pattern,
+ const char16_t *pattern,
int32_t patternLength,
- UChar *result,
+ char16_t *result,
int32_t resultLength,
UErrorCode *status,
...)
U_CAPI int32_t U_EXPORT2
u_vformatMessage( const char *locale,
- const UChar *pattern,
+ const char16_t *pattern,
int32_t patternLength,
- UChar *result,
+ char16_t *result,
int32_t resultLength,
va_list ap,
UErrorCode *status)
U_CAPI int32_t
u_formatMessageWithError(const char *locale,
- const UChar *pattern,
+ const char16_t *pattern,
int32_t patternLength,
- UChar *result,
+ char16_t *result,
int32_t resultLength,
UParseError *parseError,
UErrorCode *status,
U_CAPI int32_t U_EXPORT2
u_vformatMessageWithError( const char *locale,
- const UChar *pattern,
+ const char16_t *pattern,
int32_t patternLength,
- UChar *result,
+ char16_t *result,
int32_t resultLength,
UParseError *parseError,
va_list ap,
// 3. Iterate through each formattable returned, and assign to the arguments
U_CAPI void
u_parseMessage( const char *locale,
- const UChar *pattern,
+ const char16_t *pattern,
int32_t patternLength,
- const UChar *source,
+ const char16_t *source,
int32_t sourceLength,
UErrorCode *status,
...)
U_CAPI void U_EXPORT2
u_vparseMessage(const char *locale,
- const UChar *pattern,
+ const char16_t *pattern,
int32_t patternLength,
- const UChar *source,
+ const char16_t *source,
int32_t sourceLength,
va_list ap,
UErrorCode *status)
U_CAPI void
u_parseMessageWithError(const char *locale,
- const UChar *pattern,
+ const char16_t *pattern,
int32_t patternLength,
- const UChar *source,
+ const char16_t *source,
int32_t sourceLength,
UParseError *error,
UErrorCode *status,
}
U_CAPI void U_EXPORT2
u_vparseMessageWithError(const char *locale,
- const UChar *pattern,
+ const char16_t *pattern,
int32_t patternLength,
- const UChar *source,
+ const char16_t *source,
int32_t sourceLength,
va_list ap,
UParseError *error,
U_CAPI UMessageFormat* U_EXPORT2
-umsg_open( const UChar *pattern,
+umsg_open( const char16_t *pattern,
int32_t patternLength,
const char *locale,
UParseError *parseError,
U_CAPI void U_EXPORT2
umsg_applyPattern(UMessageFormat *fmt,
- const UChar* pattern,
+ const char16_t* pattern,
int32_t patternLength,
UParseError* parseError,
UErrorCode* status)
U_CAPI int32_t U_EXPORT2
umsg_toPattern(const UMessageFormat *fmt,
- UChar* result,
+ char16_t* result,
int32_t resultLength,
UErrorCode* status)
{
U_CAPI int32_t
umsg_format( const UMessageFormat *fmt,
- UChar *result,
+ char16_t *result,
int32_t resultLength,
UErrorCode *status,
...)
U_CAPI int32_t U_EXPORT2
umsg_vformat( const UMessageFormat *fmt,
- UChar *result,
+ char16_t *result,
int32_t resultLength,
va_list ap,
UErrorCode *status)
// iterate through the vararg list, and get the arguments out
for(int32_t i = 0; i < count; ++i) {
- UChar *stringVal;
+ char16_t *stringVal;
double tDouble=0;
int32_t tInt =0;
int64_t tInt64 = 0;
case Formattable::kString:
// For some reason, a temporary is needed
- stringVal = va_arg(ap, UChar*);
+ stringVal = va_arg(ap, char16_t*);
if(stringVal){
args[i].setString(UnicodeString(stringVal));
}else{
U_CAPI void
umsg_parse( const UMessageFormat *fmt,
- const UChar *source,
+ const char16_t *source,
int32_t sourceLength,
int32_t *count,
UErrorCode *status,
U_CAPI void U_EXPORT2
umsg_vparse(const UMessageFormat *fmt,
- const UChar *source,
+ const char16_t *source,
int32_t sourceLength,
int32_t *count,
va_list ap,
Formattable *args = ((const MessageFormat*)fmt)->parse(srcString,*count,*status);
UDate *aDate;
double *aDouble;
- UChar *aString;
+ char16_t *aString;
int32_t* aInt;
int64_t* aInt64;
UnicodeString temp;
break;
case Formattable::kString:
- aString = va_arg(ap, UChar*);
+ aString = va_arg(ap, char16_t*);
if(aString){
args[i].getString(temp);
len = temp.length();
delete [] args;
}
-#define SINGLE_QUOTE ((UChar)0x0027)
-#define CURLY_BRACE_LEFT ((UChar)0x007B)
-#define CURLY_BRACE_RIGHT ((UChar)0x007D)
+#define SINGLE_QUOTE ((char16_t)0x0027)
+#define CURLY_BRACE_LEFT ((char16_t)0x007B)
+#define CURLY_BRACE_RIGHT ((char16_t)0x007D)
#define STATE_INITIAL 0
#define STATE_SINGLE_QUOTE 1
#define MAppend(c) if (len < destCapacity) dest[len++] = c; else len++
-int32_t umsg_autoQuoteApostrophe(const UChar* pattern,
+int32_t umsg_autoQuoteApostrophe(const char16_t* pattern,
int32_t patternLength,
- UChar* dest,
+ char16_t* dest,
int32_t destCapacity,
UErrorCode* ec)
{
}
for (int i = 0; i < patternLength; ++i) {
- UChar c = pattern[i];
+ char16_t c = pattern[i];
switch (state) {
case STATE_INITIAL:
switch (c) {
/* global variables used by the C and C++ message formatting API. */
-extern const UChar *g_umsgTypeList[];
-extern const UChar *g_umsgModifierList[];
-extern const UChar *g_umsgDateModifierList[];
+extern const char16_t *g_umsgTypeList[];
+extern const char16_t *g_umsgModifierList[];
+extern const char16_t *g_umsgDateModifierList[];
extern const int32_t g_umsgListLength;
-extern const UChar g_umsg_number[];
-extern const UChar g_umsg_date[];
-extern const UChar g_umsg_time[];
-extern const UChar g_umsg_choice[];
+extern const char16_t g_umsg_number[];
+extern const char16_t g_umsg_date[];
+extern const char16_t g_umsg_time[];
+extern const char16_t g_umsg_choice[];
-extern const UChar g_umsg_currency[];
-extern const UChar g_umsg_percent[];
-extern const UChar g_umsg_integer[];
+extern const char16_t g_umsg_currency[];
+extern const char16_t g_umsg_percent[];
+extern const char16_t g_umsg_integer[];
-extern const UChar g_umsg_short[];
-extern const UChar g_umsg_medium[];
-extern const UChar g_umsg_long[];
-extern const UChar g_umsg_full[];
+extern const char16_t g_umsg_short[];
+extern const char16_t g_umsg_medium[];
+extern const char16_t g_umsg_long[];
+extern const char16_t g_umsg_full[];
#endif /* #if !UCONFIG_NO_FORMATTING */
/**
* Special character marking the end of the spec[] array.
*/
-static const UChar END = 0xFFFF;
+static const char16_t END = 0xFFFF;
// Unicode: "U+10FFFF" hex, min=4, max=6
-static const UChar SPEC_Unicode[] = {
+static const char16_t SPEC_Unicode[] = {
2, 0, 16, 4, 6, 85/*U*/, 43/*+*/,
END
};
// Java: "\\uFFFF" hex, min=4, max=4
-static const UChar SPEC_Java[] = {
+static const char16_t SPEC_Java[] = {
2, 0, 16, 4, 4, 92/*\*/, 117/*u*/,
END
};
// C: "\\uFFFF" hex, min=4, max=4; \\U0010FFFF hex, min=8, max=8
-static const UChar SPEC_C[] = {
+static const char16_t SPEC_C[] = {
2, 0, 16, 4, 4, 92/*\*/, 117/*u*/,
2, 0, 16, 8, 8, 92/*\*/, 85/*U*/,
END
};
// XML: "" hex, min=1, max=6
-static const UChar SPEC_XML[] = {
+static const char16_t SPEC_XML[] = {
3, 1, 16, 1, 6, 38/*&*/, 35/*#*/, 120/*x*/, 59/*;*/,
END
};
// XML10: "" dec, min=1, max=7 (not really "Hex-Any")
-static const UChar SPEC_XML10[] = {
+static const char16_t SPEC_XML10[] = {
2, 1, 10, 1, 7, 38/*&*/, 35/*#*/, 59/*;*/,
END
};
// Perl: "\\x{263A}" hex, min=1, max=6
-static const UChar SPEC_Perl[] = {
+static const char16_t SPEC_Perl[] = {
3, 1, 16, 1, 6, 92/*\*/, 120/*x*/, 123/*{*/, 125/*}*/,
END
};
// All: Java, C, Perl, XML, XML10, Unicode
-static const UChar SPEC_Any[] = {
+static const char16_t SPEC_Any[] = {
2, 0, 16, 4, 6, 85/*U*/, 43/*+*/, // Unicode
2, 0, 16, 4, 4, 92/*\*/, 117/*u*/, // Java
2, 0, 16, 8, 8, 92/*\*/, 85/*U*/, // C (surrogates)
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(UnescapeTransliterator)
-static UChar* copySpec(const UChar* spec) {
+static char16_t* copySpec(const char16_t* spec) {
int32_t len = 0;
while (spec[len] != END) {
++len;
}
++len;
- UChar *result = (UChar *)uprv_malloc(len*sizeof(UChar));
+ char16_t *result = (char16_t *)uprv_malloc(len*sizeof(char16_t));
// Check for memory allocation error.
if (result != nullptr) {
uprv_memcpy(result, spec, (size_t)len*sizeof(result[0]));
* Constructor. Takes the encoded spec array.
*/
UnescapeTransliterator::UnescapeTransliterator(const UnicodeString& newID,
- const UChar *newSpec) :
+ const char16_t *newSpec) :
Transliterator(newID, nullptr)
{
this->spec = copySpec(newSpec);
break;
}
}
- UChar c = text.charAt(s++);
+ char16_t c = text.charAt(s++);
if (c != spec[ipat + i]) {
match = false;
break;
match = false;
break;
}
- UChar c = text.charAt(s++);
+ char16_t c = text.charAt(s++);
if (c != spec[ipat + prefixLen + i]) {
match = false;
break;
* and suffix. The end is marked by a header of length one
* consisting of the character END.
*/
- UChar* spec; // owned; may not be nullptr
+ char16_t* spec; // owned; may not be nullptr
public:
* @param spec the encoded spec array
*/
UnescapeTransliterator(const UnicodeString& ID,
- const UChar *spec);
+ const char16_t *spec);
/**
* Copy constructor.
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(UnicodeNameTransliterator)
-static const UChar OPEN_DELIM[] = {92,78,123,0}; // "\N{"
-static const UChar CLOSE_DELIM = 125; // "}"
+static const char16_t OPEN_DELIM[] = {92,78,123,0}; // "\N{"
+static const char16_t CLOSE_DELIM = 125; // "}"
#define OPEN_DELIM_LEN 3
/**
*
* @internal
*/
- void setCurrency(const UChar* currency, UErrorCode& status);
+ void setCurrency(const char16_t* currency, UErrorCode& status);
#endif // U_HIDE_INTERNAL_API
/**
for (int32_t i = 0; unitPref.getKeyAndValue(i, key, value); ++i) {
if (uprv_strcmp(key, "unit") == 0) {
int32_t length;
- const UChar *u = value.getString(length, status);
+ const char16_t *u = value.getString(length, status);
up->unit.appendInvariantChars(u, length, status);
} else if (uprv_strcmp(key, "geq") == 0) {
int32_t length;
- const UChar *g = value.getString(length, status);
+ const char16_t *g = value.getString(length, status);
CharString geq;
geq.appendInvariantChars(g, length, status);
DecimalQuantity dq;
U_CAPI UNumberFormat* U_EXPORT2
unum_open( UNumberFormatStyle style,
- const UChar* pattern,
+ const char16_t* pattern,
int32_t patternLength,
const char* locale,
UParseError* parseErr,
U_CAPI int32_t U_EXPORT2
unum_format( const UNumberFormat* fmt,
int32_t number,
- UChar* result,
+ char16_t* result,
int32_t resultLength,
UFieldPosition *pos,
UErrorCode* status)
U_CAPI int32_t U_EXPORT2
unum_formatInt64(const UNumberFormat* fmt,
int64_t number,
- UChar* result,
+ char16_t* result,
int32_t resultLength,
UFieldPosition *pos,
UErrorCode* status)
U_CAPI int32_t U_EXPORT2
unum_formatDouble( const UNumberFormat* fmt,
double number,
- UChar* result,
+ char16_t* result,
int32_t resultLength,
UFieldPosition *pos, /* 0 if ignore */
UErrorCode* status)
U_CAPI int32_t U_EXPORT2
unum_formatDoubleForFields(const UNumberFormat* format,
double number,
- UChar* result,
+ char16_t* result,
int32_t resultLength,
UFieldPositionIterator* fpositer,
UErrorCode* status)
unum_formatDecimal(const UNumberFormat* fmt,
const char * number,
int32_t length,
- UChar* result,
+ char16_t* result,
int32_t resultLength,
UFieldPosition *pos, /* 0 if ignore */
UErrorCode* status) {
U_CAPI int32_t U_EXPORT2
unum_formatDoubleCurrency(const UNumberFormat* fmt,
double number,
- UChar* currency,
- UChar* result,
+ char16_t* currency,
+ char16_t* result,
int32_t resultLength,
UFieldPosition* pos, /* ignored if 0 */
UErrorCode* status) {
static void
parseRes(Formattable& res,
const UNumberFormat* fmt,
- const UChar* text,
+ const char16_t* text,
int32_t textLength,
int32_t *parsePos /* 0 = start */,
UErrorCode *status)
U_CAPI int32_t U_EXPORT2
unum_parse( const UNumberFormat* fmt,
- const UChar* text,
+ const char16_t* text,
int32_t textLength,
int32_t *parsePos /* 0 = start */,
UErrorCode *status)
U_CAPI int64_t U_EXPORT2
unum_parseInt64( const UNumberFormat* fmt,
- const UChar* text,
+ const char16_t* text,
int32_t textLength,
int32_t *parsePos /* 0 = start */,
UErrorCode *status)
U_CAPI double U_EXPORT2
unum_parseDouble( const UNumberFormat* fmt,
- const UChar* text,
+ const char16_t* text,
int32_t textLength,
int32_t *parsePos /* 0 = start */,
UErrorCode *status)
U_CAPI int32_t U_EXPORT2
unum_parseDecimal(const UNumberFormat* fmt,
- const UChar* text,
+ const char16_t* text,
int32_t textLength,
int32_t *parsePos /* 0 = start */,
char *outBuf,
U_CAPI double U_EXPORT2
unum_parseDoubleCurrency(const UNumberFormat* fmt,
- const UChar* text,
+ const char16_t* text,
int32_t textLength,
int32_t* parsePos, /* 0 = start */
- UChar* currency,
+ char16_t* currency,
UErrorCode* status) {
double doubleVal = 0.0;
currency[0] = 0;
U_CAPI int32_t U_EXPORT2
unum_getTextAttribute(const UNumberFormat* fmt,
UNumberFormatTextAttribute tag,
- UChar* result,
+ char16_t* result,
int32_t resultLength,
UErrorCode* status)
{
int32_t count = rbnf->getNumberOfRuleSetNames();
for (int i = 0; i < count; ++i) {
res += rbnf->getRuleSetName(i);
- res += (UChar)0x003b; // semicolon
+ res += (char16_t)0x003b; // semicolon
}
} else {
*status = U_UNSUPPORTED_ERROR;
U_CAPI void U_EXPORT2
unum_setTextAttribute( UNumberFormat* fmt,
UNumberFormatTextAttribute tag,
- const UChar* newValue,
+ const char16_t* newValue,
int32_t newValueLength,
UErrorCode *status)
{
U_CAPI int32_t U_EXPORT2
unum_toPattern( const UNumberFormat* fmt,
UBool isPatternLocalized,
- UChar* result,
+ char16_t* result,
int32_t resultLength,
UErrorCode* status)
{
U_CAPI int32_t U_EXPORT2
unum_getSymbol(const UNumberFormat *fmt,
UNumberFormatSymbol symbol,
- UChar *buffer,
+ char16_t *buffer,
int32_t size,
UErrorCode *status)
{
U_CAPI void U_EXPORT2
unum_setSymbol(UNumberFormat *fmt,
UNumberFormatSymbol symbol,
- const UChar *value,
+ const char16_t *value,
int32_t length,
UErrorCode *status)
{
U_CAPI void U_EXPORT2
unum_applyPattern( UNumberFormat *fmt,
UBool localized,
- const UChar *pattern,
+ const char16_t *pattern,
int32_t patternLength,
UParseError *parseError,
UErrorCode* status)
}
int32_t len = (patternLength == -1 ? u_strlen(pattern) : patternLength);
- const UnicodeString pat((UChar*)pattern, len, len);
+ const UnicodeString pat((char16_t*)pattern, len, len);
// Verify if the object passed is a DecimalFormat object
NumberFormat* nf = reinterpret_cast<NumberFormat*>(fmt);
U_CAPI UFormattable * U_EXPORT2
unum_parseToUFormattable(const UNumberFormat* fmt,
UFormattable *result,
- const UChar* text,
+ const char16_t* text,
int32_t textLength,
int32_t* parsePos, /* 0 = start */
UErrorCode* status) {
U_CAPI int32_t U_EXPORT2
unum_formatUFormattable(const UNumberFormat* fmt,
const UFormattable *number,
- UChar *result,
+ char16_t *result,
int32_t resultLength,
UFieldPosition *pos, /* ignored if 0 */
UErrorCode *status) {
}
U_CAPI int32_t U_EXPORT2
-unumsys_getDescription(const UNumberingSystem *unumsys, UChar *result,
+unumsys_getDescription(const UNumberingSystem *unumsys, char16_t *result,
int32_t resultLength, UErrorCode *status)
{
if (U_FAILURE(*status)) {
U_CAPI int32_t U_EXPORT2
uplrules_select(const UPluralRules *uplrules,
double number,
- UChar *keyword, int32_t capacity,
+ char16_t *keyword, int32_t capacity,
UErrorCode *status)
{
if (U_FAILURE(*status)) {
U_CAPI int32_t U_EXPORT2
uplrules_selectFormatted(const UPluralRules *uplrules,
const UFormattedNumber* number,
- UChar *keyword, int32_t capacity,
+ char16_t *keyword, int32_t capacity,
UErrorCode *status)
{
if (U_FAILURE(*status)) {
U_CAPI int32_t U_EXPORT2
uplrules_selectForRange(const UPluralRules *uplrules,
const UFormattedNumberRange* urange,
- UChar *keyword, int32_t capacity,
+ char16_t *keyword, int32_t capacity,
UErrorCode *status)
{
if (U_FAILURE(*status)) {
uplrules_selectWithFormat(const UPluralRules *uplrules,
double number,
const UNumberFormat *fmt,
- UChar *keyword, int32_t capacity,
+ char16_t *keyword, int32_t capacity,
UErrorCode *status)
{
if (U_FAILURE(*status)) {
int32_t fMagic;
RegexPattern *fPat;
u_atomic_int32_t *fPatRefCount;
- UChar *fPatString;
+ char16_t *fPatString;
int32_t fPatStringLen;
RegexMatcher *fMatcher;
- const UChar *fText; // Text from setText()
+ const char16_t *fText; // Text from setText()
int32_t fTextLength; // Length provided by user with setText(), which
// may be -1.
UBool fOwnsText;
//
//----------------------------------------------------------------------------------------
U_CAPI URegularExpression * U_EXPORT2
-uregex_open( const UChar *pattern,
+uregex_open( const char16_t *pattern,
int32_t patternLength,
uint32_t flags,
UParseError *pe,
RegularExpression *re = new RegularExpression;
u_atomic_int32_t *refC = (u_atomic_int32_t *)uprv_malloc(sizeof(int32_t));
- UChar *patBuf = (UChar *)uprv_malloc(sizeof(UChar)*(actualPatLen+1));
+ char16_t *patBuf = (char16_t *)uprv_malloc(sizeof(char16_t)*(actualPatLen+1));
if (re == nullptr || refC == nullptr || patBuf == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
delete re;
int32_t pattern16Length = utext_extract(pattern, 0, patternNativeLength, nullptr, 0, &lengthStatus);
u_atomic_int32_t *refC = (u_atomic_int32_t *)uprv_malloc(sizeof(int32_t));
- UChar *patBuf = (UChar *)uprv_malloc(sizeof(UChar)*(pattern16Length+1));
+ char16_t *patBuf = (char16_t *)uprv_malloc(sizeof(char16_t)*(pattern16Length+1));
if (re == nullptr || refC == nullptr || patBuf == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
delete re;
// uregex_pattern
//
//------------------------------------------------------------------------------
-U_CAPI const UChar * U_EXPORT2
+U_CAPI const char16_t * U_EXPORT2
uregex_pattern(const URegularExpression *regexp2,
int32_t *patLength,
UErrorCode *status) {
//------------------------------------------------------------------------------
U_CAPI void U_EXPORT2
uregex_setText(URegularExpression *regexp2,
- const UChar *text,
+ const char16_t *text,
int32_t textLength,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
// uregex_getText
//
//------------------------------------------------------------------------------
-U_CAPI const UChar * U_EXPORT2
+U_CAPI const char16_t * U_EXPORT2
uregex_getText(URegularExpression *regexp2,
int32_t *textLength,
UErrorCode *status) {
} else {
UErrorCode lengthStatus = U_ZERO_ERROR;
regexp->fTextLength = utext_extract(inputText, 0, inputNativeLength, nullptr, 0, &lengthStatus); // buffer overflow error
- UChar *inputChars = (UChar *)uprv_malloc(sizeof(UChar)*(regexp->fTextLength+1));
+ char16_t *inputChars = (char16_t *)uprv_malloc(sizeof(char16_t)*(regexp->fTextLength+1));
utext_extract(inputText, 0, inputNativeLength, inputChars, regexp->fTextLength+1, status);
regexp->fText = inputChars;
//------------------------------------------------------------------------------
int32_t
uregex_groupNumberFromName(URegularExpression *regexp2,
- const UChar *groupName,
+ const char16_t *groupName,
int32_t nameLength,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
U_CAPI int32_t U_EXPORT2
uregex_group(URegularExpression *regexp2,
int32_t groupNum,
- UChar *dest,
+ char16_t *dest,
int32_t destCapacity,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
//------------------------------------------------------------------------------
U_CAPI int32_t U_EXPORT2
uregex_replaceAll(URegularExpression *regexp2,
- const UChar *replacementText,
+ const char16_t *replacementText,
int32_t replacementLength,
- UChar *destBuf,
+ char16_t *destBuf,
int32_t destCapacity,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
//------------------------------------------------------------------------------
U_CAPI int32_t U_EXPORT2
uregex_replaceFirst(URegularExpression *regexp2,
- const UChar *replacementText,
+ const char16_t *replacementText,
int32_t replacementLength,
- UChar *destBuf,
+ char16_t *destBuf,
int32_t destCapacity,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
class RegexCImpl {
public:
inline static int32_t appendReplacement(RegularExpression *regexp,
- const UChar *replacementText,
+ const char16_t *replacementText,
int32_t replacementLength,
- UChar **destBuf,
+ char16_t **destBuf,
int32_t *destCapacity,
UErrorCode *status);
inline static int32_t appendTail(RegularExpression *regexp,
- UChar **destBuf,
+ char16_t **destBuf,
int32_t *destCapacity,
UErrorCode *status);
inline static int32_t split(RegularExpression *regexp,
- UChar *destBuf,
+ char16_t *destBuf,
int32_t destCapacity,
int32_t *requiredCapacity,
- UChar *destFields[],
+ char16_t *destFields[],
int32_t destFieldsCapacity,
UErrorCode *status);
};
-static const UChar BACKSLASH = 0x5c;
-static const UChar DOLLARSIGN = 0x24;
-static const UChar LEFTBRACKET = 0x7b;
-static const UChar RIGHTBRACKET = 0x7d;
+static const char16_t BACKSLASH = 0x5c;
+static const char16_t DOLLARSIGN = 0x24;
+static const char16_t LEFTBRACKET = 0x7b;
+static const char16_t RIGHTBRACKET = 0x7d;
//
// Move a character to an output buffer, with bounds checking on the index.
// Index advances even if capacity is exceeded, for preflight size computations.
// This little sequence is used a LOT.
//
-static inline void appendToBuf(UChar c, int32_t *idx, UChar *buf, int32_t bufCapacity) {
+static inline void appendToBuf(char16_t c, int32_t *idx, char16_t *buf, int32_t bufCapacity) {
if (*idx < bufCapacity) {
buf[*idx] = c;
}
// appendReplacement, the actual implementation.
//
int32_t RegexCImpl::appendReplacement(RegularExpression *regexp,
- const UChar *replacementText,
+ const char16_t *replacementText,
int32_t replacementLength,
- UChar **destBuf,
+ char16_t **destBuf,
int32_t *destCapacity,
UErrorCode *status) {
return 0;
}
- UChar *dest = *destBuf;
+ char16_t *dest = *destBuf;
int32_t capacity = *destCapacity;
int32_t destIdx = 0;
int32_t i;
// scan the replacement text, looking for substitutions ($n) and \escapes.
int32_t replIdx = 0;
while (replIdx < replacementLength && U_SUCCESS(*status)) {
- UChar c = replacementText[replIdx];
+ char16_t c = replacementText[replIdx];
replIdx++;
if (c != DOLLARSIGN && c != BACKSLASH) {
// Common case, no substitution, no escaping,
if (escapedChar != (UChar32)0xFFFFFFFF) {
if (escapedChar <= 0xffff) {
- appendToBuf((UChar)escapedChar, &destIdx, dest, capacity);
+ appendToBuf((char16_t)escapedChar, &destIdx, dest, capacity);
} else {
appendToBuf(U16_LEAD(escapedChar), &destIdx, dest, capacity);
appendToBuf(U16_TRAIL(escapedChar), &destIdx, dest, capacity);
//
U_CAPI int32_t U_EXPORT2
uregex_appendReplacement(URegularExpression *regexp2,
- const UChar *replacementText,
+ const char16_t *replacementText,
int32_t replacementLength,
- UChar **destBuf,
+ char16_t **destBuf,
int32_t *destCapacity,
UErrorCode *status) {
//
//------------------------------------------------------------------------------
int32_t RegexCImpl::appendTail(RegularExpression *regexp,
- UChar **destBuf,
+ char16_t **destBuf,
int32_t *destCapacity,
UErrorCode *status)
{
int32_t destIdx = 0;
int32_t destCap = *destCapacity;
- UChar *dest = *destBuf;
+ char16_t *dest = *destBuf;
if (regexp->fText != nullptr) {
int32_t srcIdx;
if (srcIdx == regexp->fTextLength) {
break;
}
- UChar c = regexp->fText[srcIdx];
+ char16_t c = regexp->fText[srcIdx];
if (c == 0 && regexp->fTextLength == -1) {
regexp->fTextLength = srcIdx;
break;
//
U_CAPI int32_t U_EXPORT2
uregex_appendTail(URegularExpression *regexp2,
- UChar **destBuf,
+ char16_t **destBuf,
int32_t *destCapacity,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
//
//------------------------------------------------------------------------------
#if 0
-static void copyString(UChar *destBuffer, // Destination buffer.
+static void copyString(char16_t *destBuffer, // Destination buffer.
int32_t destCapacity, // Total capacity of dest buffer
int32_t *destIndex, // Index into dest buffer. Updated on return.
// Update not clipped to destCapacity.
- const UChar *srcPtr, // Pointer to source string
+ const char16_t *srcPtr, // Pointer to source string
int32_t srcLen) // Source string len.
{
int32_t si;
int32_t di = *destIndex;
- UChar c;
+ char16_t c;
for (si=0; si<srcLen; si++) {
c = srcPtr[si];
//
//------------------------------------------------------------------------------
int32_t RegexCImpl::split(RegularExpression *regexp,
- UChar *destBuf,
+ char16_t *destBuf,
int32_t destCapacity,
int32_t *requiredCapacity,
- UChar *destFields[],
+ char16_t *destFields[],
int32_t destFieldsCapacity,
UErrorCode *status) {
//
//
U_CAPI int32_t U_EXPORT2
uregex_split(URegularExpression *regexp2,
- UChar *destBuf,
+ char16_t *destBuf,
int32_t destCapacity,
int32_t *requiredCapacity,
- UChar *destFields[],
+ char16_t *destFields[],
int32_t destFieldsCapacity,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
* @return fcd value
*/
static
-uint16_t getFCD(const UChar *str, int32_t *offset,
+uint16_t getFCD(const char16_t *str, int32_t *offset,
int32_t strlength)
{
- const UChar *temp = str + *offset;
+ const char16_t *temp = str + *offset;
uint16_t result = g_nfcImpl->nextFCD16(temp, str + strlength);
*offset = (int32_t)(temp - str);
return result;
if (U_FAILURE(*status)) { return; }
UPattern *pattern = &(strsrch->pattern);
- const UChar *patterntext = pattern->text;
+ const char16_t *patterntext = pattern->text;
int32_t length = pattern->textLength;
int32_t index = 0;
// constructors and destructor -------------------------------------------
-U_CAPI UStringSearch * U_EXPORT2 usearch_open(const UChar *pattern,
+U_CAPI UStringSearch * U_EXPORT2 usearch_open(const char16_t *pattern,
int32_t patternlength,
- const UChar *text,
+ const char16_t *text,
int32_t textlength,
const char *locale,
UBreakIterator *breakiter,
}
U_CAPI UStringSearch * U_EXPORT2 usearch_openFromCollator(
- const UChar *pattern,
+ const char16_t *pattern,
int32_t patternlength,
- const UChar *text,
+ const char16_t *text,
int32_t textlength,
const UCollator *collator,
UBreakIterator *breakiter,
U_CAPI int32_t U_EXPORT2 usearch_getMatchedText(const UStringSearch *strsrch,
- UChar *result,
+ char16_t *result,
int32_t resultCapacity,
UErrorCode *status)
{
}
if (copylength > 0) {
uprv_memcpy(result, strsrch->search->text + copyindex,
- copylength * sizeof(UChar));
+ copylength * sizeof(char16_t));
}
return u_terminateUChars(result, resultCapacity,
strsrch->search->matchedLength, status);
#endif
U_CAPI void U_EXPORT2 usearch_setText( UStringSearch *strsrch,
- const UChar *text,
+ const char16_t *text,
int32_t textlength,
UErrorCode *status)
{
}
}
-U_CAPI const UChar * U_EXPORT2 usearch_getText(const UStringSearch *strsrch,
+U_CAPI const char16_t * U_EXPORT2 usearch_getText(const UStringSearch *strsrch,
int32_t *length)
{
if (strsrch) {
}
U_CAPI void U_EXPORT2 usearch_setPattern( UStringSearch *strsrch,
- const UChar *pattern,
+ const char16_t *pattern,
int32_t patternlength,
UErrorCode *status)
{
}
}
-U_CAPI const UChar* U_EXPORT2
+U_CAPI const char16_t* U_EXPORT2
usearch_getPattern(const UStringSearch *strsrch,
int32_t *length)
{
strSearch = ss;
bufSize = ss->pattern.pcesLength + CEBUFFER_EXTRA;
if (ss->search->elementComparisonType != 0) {
- const UChar * patText = ss->pattern.text;
+ const char16_t * patText = ss->pattern.text;
if (patText) {
- const UChar * patTextLimit = patText + ss->pattern.textLength;
+ const char16_t * patTextLimit = patText + ss->pattern.textLength;
while ( patText < patTextLimit ) {
- UChar c = *patText++;
+ char16_t c = *patText++;
if (MIGHT_BE_JAMO_L(c)) {
bufSize += MAX_TARGET_IGNORABLES_PER_PAT_JAMO_L;
} else {
return startIndex;
}
#if 0
- const UChar *text = strsrch->search->text;
+ const char16_t *text = strsrch->search->text;
int32_t textLen = strsrch->search->textLength;
U_ASSERT(startIndex>=0);
return true;
}
#if 0
- const UChar *text = strsrch->search->text;
+ const char16_t *text = strsrch->search->text;
int32_t textLen = strsrch->search->textLength;
U_ASSERT(index>=0);
U_CAPI int32_t U_EXPORT2
uspoof_check(const USpoofChecker *sc,
- const UChar *id, int32_t length,
+ const char16_t *id, int32_t length,
int32_t *position,
UErrorCode *status) {
U_CAPI int32_t U_EXPORT2
uspoof_check2(const USpoofChecker *sc,
- const UChar* id, int32_t length,
+ const char16_t* id, int32_t length,
USpoofCheckResult* checkResult,
UErrorCode *status) {
U_CAPI int32_t U_EXPORT2
uspoof_areConfusable(const USpoofChecker *sc,
- const UChar *id1, int32_t length1,
- const UChar *id2, int32_t length2,
+ const char16_t *id1, int32_t length1,
+ const char16_t *id2, int32_t length2,
UErrorCode *status) {
SpoofImpl::validateThis(sc, *status);
if (U_FAILURE(*status)) {
U_CAPI int32_t U_EXPORT2
uspoof_getSkeleton(const USpoofChecker *sc,
uint32_t type,
- const UChar *id, int32_t length,
- UChar *dest, int32_t destCapacity,
+ const char16_t *id, int32_t length,
+ char16_t *dest, int32_t destCapacity,
UErrorCode *status) {
SpoofImpl::validateThis(sc, *status);
void ConfusabledataBuilder::build(const char * confusables, int32_t confusablesLen,
UErrorCode &status) {
- // Convert the user input data from UTF-8 to UChar (UTF-16)
+ // Convert the user input data from UTF-8 to char16_t (UTF-16)
int32_t inputLen = 0;
if (U_FAILURE(status)) {
return;
return;
}
status = U_ZERO_ERROR;
- fInput = static_cast<UChar *>(uprv_malloc((inputLen+1) * sizeof(UChar)));
+ fInput = static_cast<char16_t *>(uprv_malloc((inputLen+1) * sizeof(char16_t)));
if (fInput == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
uint32_t stringsLength = fStringTable->length();
// Reserve an extra space so the string will be nul-terminated. This is
// only a convenience, for when debugging; it is not needed otherwise.
- UChar *strings =
- static_cast<UChar *>(fSpoofImpl->fSpoofData->reserveSpace(stringsLength*sizeof(UChar)+2, status));
+ char16_t *strings =
+ static_cast<char16_t *>(fSpoofImpl->fSpoofData->reserveSpace(stringsLength*sizeof(char16_t)+2, status));
if (U_FAILURE(status)) {
return;
}
class ConfusabledataBuilder : public UMemory {
private:
SpoofImpl *fSpoofImpl;
- UChar *fInput;
+ char16_t *fInput;
UHashtable *fTable;
UnicodeSet *fKeySet; // A set of all keys (UChar32s) that go into the four mapping tables.
// Convert a text format hex number. Utility function used by builder code. Static.
-// Input: UChar *string text. Output: a UChar32
+// Input: char16_t *string text. Output: a UChar32
// Input has been pre-checked, and will have no non-hex chars.
// The number must fall in the code point range of 0..0x10ffff
// Static Function.
-UChar32 SpoofImpl::ScanHex(const UChar *s, int32_t start, int32_t limit, UErrorCode &status) {
+UChar32 SpoofImpl::ScanHex(const char16_t *s, int32_t start, int32_t limit, UErrorCode &status) {
if (U_FAILURE(status)) {
return 0;
}
fCFUValues = (uint16_t *)((char *)fRawData + fRawData->fCFUStringIndex);
}
if (fRawData->fCFUStringTable != 0) {
- fCFUStrings = (UChar *)((char *)fRawData + fRawData->fCFUStringTable);
+ fCFUStrings = (char16_t *)((char *)fRawData + fRawData->fCFUStringTable);
}
}
// an index into the string table (for longer strings)
uint16_t value = fCFUValues[index];
if (stringLength == 1) {
- dest.append((UChar)value);
+ dest.append((char16_t)value);
} else {
dest.append(fCFUStrings + value, stringLength);
}
bool isIllegalCombiningDotLeadCharacter(UChar32 cp) const;
/** parse a hex number. Untility used by the builders. */
- static UChar32 ScanHex(const UChar *s, int32_t start, int32_t limit, UErrorCode &status);
+ static UChar32 ScanHex(const char16_t *s, int32_t start, int32_t limit, UErrorCode &status);
static UClassID U_EXPORT2 getStaticClassID(void);
virtual UClassID getDynamicClassID(void) const override;
//
// String Table:
// The strings table contains all of the value strings (those of length two or greater)
-// concatenated together into one long UChar (UTF-16) array.
+// concatenated together into one long char16_t (UTF-16) array.
//
// There is no nul character or other mark between adjacent strings.
//
// Confusable data
int32_t *fCFUKeys;
uint16_t *fCFUValues;
- UChar *fCFUStrings;
+ char16_t *fCFUStrings;
friend class ConfusabledataBuilder;
};
U_NAMESPACE_BEGIN
UTF16CollationIterator::UTF16CollationIterator(const UTF16CollationIterator &other,
- const UChar *newText)
+ const char16_t *newText)
: CollationIterator(other),
start(newText),
pos(newText + (other.pos - other.start)),
return UTRIE2_GET32_FROM_U16_SINGLE_LEAD(trie, c);
}
-UChar
+char16_t
UTF16CollationIterator::handleGetTrailSurrogate() {
if(pos == limit) { return 0; }
- UChar trail;
+ char16_t trail;
if(U16_IS_TRAIL(trail = *pos)) { ++pos; }
return trail;
}
return U_SENTINEL;
}
++pos;
- UChar trail;
+ char16_t trail;
if(U16_IS_LEAD(c) && pos != limit && U16_IS_TRAIL(trail = *pos)) {
++pos;
return U16_GET_SUPPLEMENTARY(c, trail);
return U_SENTINEL;
}
UChar32 c = *--pos;
- UChar lead;
+ char16_t lead;
if(U16_IS_TRAIL(c) && pos != start && U16_IS_LEAD(lead = *(pos - 1))) {
--pos;
return U16_GET_SUPPLEMENTARY(lead, c);
// FCDUTF16CollationIterator ----------------------------------------------- ***
FCDUTF16CollationIterator::FCDUTF16CollationIterator(const FCDUTF16CollationIterator &other,
- const UChar *newText)
+ const char16_t *newText)
: UTF16CollationIterator(other),
rawStart(newText),
segmentStart(newText + (other.segmentStart - other.rawStart)),
switchToForward();
}
}
- UChar trail;
+ char16_t trail;
if(U16_IS_LEAD(c) && pos != limit && U16_IS_TRAIL(trail = *pos)) {
++pos;
return U16_GET_SUPPLEMENTARY(c, trail);
switchToBackward();
}
}
- UChar lead;
+ char16_t lead;
if(U16_IS_TRAIL(c) && pos != start && U16_IS_LEAD(lead = *(pos - 1))) {
--pos;
return U16_GET_SUPPLEMENTARY(lead, c);
if(U_FAILURE(errorCode)) { return false; }
U_ASSERT(checkDir > 0 && pos != limit);
// The input text [segmentStart..pos[ passes the FCD check.
- const UChar *p = pos;
+ const char16_t *p = pos;
uint8_t prevCC = 0;
for(;;) {
// Fetch the next character's fcd16 value.
- const UChar *q = p;
+ const char16_t *q = p;
uint16_t fcd16 = nfcImpl.nextFCD16(p, rawLimit);
uint8_t leadCC = (uint8_t)(fcd16 >> 8);
if(leadCC == 0 && q != pos) {
if(U_FAILURE(errorCode)) { return false; }
U_ASSERT(checkDir < 0 && pos != start);
// The input text [pos..segmentLimit[ passes the FCD check.
- const UChar *p = pos;
+ const char16_t *p = pos;
uint8_t nextCC = 0;
for(;;) {
// Fetch the previous character's fcd16 value.
- const UChar *q = p;
+ const char16_t *q = p;
uint16_t fcd16 = nfcImpl.previousFCD16(rawStart, p);
uint8_t trailCC = (uint8_t)fcd16;
if(trailCC == 0 && q != pos) {
}
UBool
-FCDUTF16CollationIterator::normalize(const UChar *from, const UChar *to, UErrorCode &errorCode) {
+FCDUTF16CollationIterator::normalize(const char16_t *from, const char16_t *to, UErrorCode &errorCode) {
// NFD without argument checking.
U_ASSERT(U_SUCCESS(errorCode));
nfcImpl.decompose(from, to, normalized, (int32_t)(to - from), errorCode);
class U_I18N_API UTF16CollationIterator : public CollationIterator {
public:
UTF16CollationIterator(const CollationData *d, UBool numeric,
- const UChar *s, const UChar *p, const UChar *lim)
+ const char16_t *s, const char16_t *p, const char16_t *lim)
: CollationIterator(d, numeric),
start(s), pos(p), limit(lim) {}
- UTF16CollationIterator(const UTF16CollationIterator &other, const UChar *newText);
+ UTF16CollationIterator(const UTF16CollationIterator &other, const char16_t *newText);
virtual ~UTF16CollationIterator();
virtual int32_t getOffset() const override;
- void setText(const UChar *s, const UChar *lim) {
+ void setText(const char16_t *s, const char16_t *lim) {
reset();
start = pos = s;
limit = lim;
virtual uint32_t handleNextCE32(UChar32 &c, UErrorCode &errorCode) override;
- virtual UChar handleGetTrailSurrogate() override;
+ virtual char16_t handleGetTrailSurrogate() override;
virtual UBool foundNULTerminator() override;
// UTF-16 string pointers.
// limit can be nullptr for NUL-terminated strings.
- const UChar *start, *pos, *limit;
+ const char16_t *start, *pos, *limit;
};
/**
class U_I18N_API FCDUTF16CollationIterator : public UTF16CollationIterator {
public:
FCDUTF16CollationIterator(const CollationData *data, UBool numeric,
- const UChar *s, const UChar *p, const UChar *lim)
+ const char16_t *s, const char16_t *p, const char16_t *lim)
: UTF16CollationIterator(data, numeric, s, p, lim),
rawStart(s), segmentStart(p), segmentLimit(nullptr), rawLimit(lim),
nfcImpl(data->nfcImpl),
checkDir(1) {}
- FCDUTF16CollationIterator(const FCDUTF16CollationIterator &other, const UChar *newText);
+ FCDUTF16CollationIterator(const FCDUTF16CollationIterator &other, const char16_t *newText);
virtual ~FCDUTF16CollationIterator();
*/
UBool previousSegment(UErrorCode &errorCode);
- UBool normalize(const UChar *from, const UChar *to, UErrorCode &errorCode);
+ UBool normalize(const char16_t *from, const char16_t *to, UErrorCode &errorCode);
// Text pointers: The input text is [rawStart, rawLimit[
// where rawLimit can be nullptr for NUL-terminated text.
// or the current segment had to be normalized so that
// [segmentStart..segmentLimit[ turned into the normalized string,
// corresponding to normalized.getBuffer()==start<=pos<=limit==start+normalized.length().
- const UChar *rawStart;
- const UChar *segmentStart;
- const UChar *segmentLimit;
+ const char16_t *rawStart;
+ const char16_t *segmentStart;
+ const char16_t *segmentLimit;
// rawLimit==nullptr for a NUL-terminated string.
- const UChar *rawLimit;
+ const char16_t *rawLimit;
const Normalizer2Impl &nfcImpl;
UnicodeString normalized;
return CollationFCD::hasTccc(c);
}
-UChar
+char16_t
FCDUTF8CollationIterator::handleGetTrailSurrogate() {
if(state != IN_NORMALIZED) { return 0; }
U_ASSERT(pos < normalized.length());
- UChar trail;
+ char16_t trail;
if(U16_IS_TRAIL(trail = normalized[pos])) { ++pos; }
return trail;
}
protected:
virtual uint32_t handleNextCE32(UChar32 &c, UErrorCode &errorCode) override;
- virtual UChar handleGetTrailSurrogate() override;
+ virtual char16_t handleGetTrailSurrogate() override;
virtual UBool foundNULTerminator() override;
virtual int32_t getLength() const override;
- virtual UChar getCharAt(int32_t offset) const override;
+ virtual char16_t getCharAt(int32_t offset) const override;
virtual UChar32 getChar32At(int32_t offset) const override;
};
return (*func->length)(rep);
}
-UChar ReplaceableGlue::getCharAt(int32_t offset) const {
+char16_t ReplaceableGlue::getCharAt(int32_t offset) const {
return (*func->charAt)(rep, offset);
}
U_NAMESPACE_USE
U_CAPI UTransliterator* U_EXPORT2
-utrans_openU(const UChar *id,
+utrans_openU(const char16_t *id,
int32_t idLength,
UTransDirection dir,
- const UChar *rules,
+ const char16_t *rules,
int32_t rulesLength,
UParseError *parseError,
UErrorCode *status) {
U_CAPI UTransliterator* U_EXPORT2
utrans_open(const char* id,
UTransDirection dir,
- const UChar* rules, /* may be Null */
+ const char16_t* rules, /* may be Null */
int32_t rulesLength, /* -1 if null-terminated */
UParseError* parseError, /* may be Null */
UErrorCode* status) {
delete (Transliterator*) trans;
}
-U_CAPI const UChar * U_EXPORT2
+U_CAPI const char16_t * U_EXPORT2
utrans_getUnicodeID(const UTransliterator *trans,
int32_t *resultLength) {
// Transliterator keeps its ID NUL-terminated
}
U_CAPI void U_EXPORT2
-utrans_unregisterID(const UChar* id, int32_t idLength) {
+utrans_unregisterID(const char16_t* id, int32_t idLength) {
UnicodeString ID(idLength<0, id, idLength); // r-o alias
Transliterator::unregister(ID);
}
U_CAPI void U_EXPORT2
utrans_setFilter(UTransliterator* trans,
- const UChar* filterPattern,
+ const char16_t* filterPattern,
int32_t filterPatternLen,
UErrorCode* status) {
return ((UTransEnumeration *)uenum)->count;
}
-static const UChar* U_CALLCONV
+static const char16_t* U_CALLCONV
utrans_enum_unext(UEnumeration *uenum,
int32_t* resultLength,
UErrorCode *pErrorCode) {
U_CAPI void U_EXPORT2
utrans_transUChars(const UTransliterator* trans,
- UChar* text,
+ char16_t* text,
int32_t* textLength,
int32_t textCapacity,
int32_t start,
U_CAPI void U_EXPORT2
utrans_transIncrementalUChars(const UTransliterator* trans,
- UChar* text,
+ char16_t* text,
int32_t* textLength,
int32_t textCapacity,
UTransPosition* pos,
U_CAPI int32_t U_EXPORT2
utrans_toRules( const UTransliterator* trans,
UBool escapeUnprintable,
- UChar* result, int32_t resultLength,
+ char16_t* result, int32_t resultLength,
UErrorCode* status) {
utrans_ENTRY(status) 0;
if ( (result==nullptr)? resultLength!=0: resultLength<0 ) {
U_NAMESPACE_BEGIN
// Smybol characters used by RFC2445 VTIMEZONE
-static const UChar COLON = 0x3A; /* : */
-static const UChar SEMICOLON = 0x3B; /* ; */
-static const UChar EQUALS_SIGN = 0x3D; /* = */
-static const UChar COMMA = 0x2C; /* , */
-static const UChar PLUS = 0x2B; /* + */
-static const UChar MINUS = 0x2D; /* - */
+static const char16_t COLON = 0x3A; /* : */
+static const char16_t SEMICOLON = 0x3B; /* ; */
+static const char16_t EQUALS_SIGN = 0x3D; /* = */
+static const char16_t COMMA = 0x2C; /* , */
+static const char16_t PLUS = 0x2B; /* + */
+static const char16_t MINUS = 0x2D; /* - */
// RFC2445 VTIMEZONE tokens
-static const UChar ICAL_BEGIN_VTIMEZONE[] = {0x42, 0x45, 0x47, 0x49, 0x4E, 0x3A, 0x56, 0x54, 0x49, 0x4D, 0x45, 0x5A, 0x4F, 0x4E, 0x45, 0}; /* "BEGIN:VTIMEZONE" */
-static const UChar ICAL_END_VTIMEZONE[] = {0x45, 0x4E, 0x44, 0x3A, 0x56, 0x54, 0x49, 0x4D, 0x45, 0x5A, 0x4F, 0x4E, 0x45, 0}; /* "END:VTIMEZONE" */
-static const UChar ICAL_BEGIN[] = {0x42, 0x45, 0x47, 0x49, 0x4E, 0}; /* "BEGIN" */
-static const UChar ICAL_END[] = {0x45, 0x4E, 0x44, 0}; /* "END" */
-static const UChar ICAL_VTIMEZONE[] = {0x56, 0x54, 0x49, 0x4D, 0x45, 0x5A, 0x4F, 0x4E, 0x45, 0}; /* "VTIMEZONE" */
-static const UChar ICAL_TZID[] = {0x54, 0x5A, 0x49, 0x44, 0}; /* "TZID" */
-static const UChar ICAL_STANDARD[] = {0x53, 0x54, 0x41, 0x4E, 0x44, 0x41, 0x52, 0x44, 0}; /* "STANDARD" */
-static const UChar ICAL_DAYLIGHT[] = {0x44, 0x41, 0x59, 0x4C, 0x49, 0x47, 0x48, 0x54, 0}; /* "DAYLIGHT" */
-static const UChar ICAL_DTSTART[] = {0x44, 0x54, 0x53, 0x54, 0x41, 0x52, 0x54, 0}; /* "DTSTART" */
-static const UChar ICAL_TZOFFSETFROM[] = {0x54, 0x5A, 0x4F, 0x46, 0x46, 0x53, 0x45, 0x54, 0x46, 0x52, 0x4F, 0x4D, 0}; /* "TZOFFSETFROM" */
-static const UChar ICAL_TZOFFSETTO[] = {0x54, 0x5A, 0x4F, 0x46, 0x46, 0x53, 0x45, 0x54, 0x54, 0x4F, 0}; /* "TZOFFSETTO" */
-static const UChar ICAL_RDATE[] = {0x52, 0x44, 0x41, 0x54, 0x45, 0}; /* "RDATE" */
-static const UChar ICAL_RRULE[] = {0x52, 0x52, 0x55, 0x4C, 0x45, 0}; /* "RRULE" */
-static const UChar ICAL_TZNAME[] = {0x54, 0x5A, 0x4E, 0x41, 0x4D, 0x45, 0}; /* "TZNAME" */
-static const UChar ICAL_TZURL[] = {0x54, 0x5A, 0x55, 0x52, 0x4C, 0}; /* "TZURL" */
-static const UChar ICAL_LASTMOD[] = {0x4C, 0x41, 0x53, 0x54, 0x2D, 0x4D, 0x4F, 0x44, 0x49, 0x46, 0x49, 0x45, 0x44, 0}; /* "LAST-MODIFIED" */
-
-static const UChar ICAL_FREQ[] = {0x46, 0x52, 0x45, 0x51, 0}; /* "FREQ" */
-static const UChar ICAL_UNTIL[] = {0x55, 0x4E, 0x54, 0x49, 0x4C, 0}; /* "UNTIL" */
-static const UChar ICAL_YEARLY[] = {0x59, 0x45, 0x41, 0x52, 0x4C, 0x59, 0}; /* "YEARLY" */
-static const UChar ICAL_BYMONTH[] = {0x42, 0x59, 0x4D, 0x4F, 0x4E, 0x54, 0x48, 0}; /* "BYMONTH" */
-static const UChar ICAL_BYDAY[] = {0x42, 0x59, 0x44, 0x41, 0x59, 0}; /* "BYDAY" */
-static const UChar ICAL_BYMONTHDAY[] = {0x42, 0x59, 0x4D, 0x4F, 0x4E, 0x54, 0x48, 0x44, 0x41, 0x59, 0}; /* "BYMONTHDAY" */
-
-static const UChar ICAL_NEWLINE[] = {0x0D, 0x0A, 0}; /* CRLF */
-
-static const UChar ICAL_DOW_NAMES[7][3] = {
+static const char16_t ICAL_BEGIN_VTIMEZONE[] = {0x42, 0x45, 0x47, 0x49, 0x4E, 0x3A, 0x56, 0x54, 0x49, 0x4D, 0x45, 0x5A, 0x4F, 0x4E, 0x45, 0}; /* "BEGIN:VTIMEZONE" */
+static const char16_t ICAL_END_VTIMEZONE[] = {0x45, 0x4E, 0x44, 0x3A, 0x56, 0x54, 0x49, 0x4D, 0x45, 0x5A, 0x4F, 0x4E, 0x45, 0}; /* "END:VTIMEZONE" */
+static const char16_t ICAL_BEGIN[] = {0x42, 0x45, 0x47, 0x49, 0x4E, 0}; /* "BEGIN" */
+static const char16_t ICAL_END[] = {0x45, 0x4E, 0x44, 0}; /* "END" */
+static const char16_t ICAL_VTIMEZONE[] = {0x56, 0x54, 0x49, 0x4D, 0x45, 0x5A, 0x4F, 0x4E, 0x45, 0}; /* "VTIMEZONE" */
+static const char16_t ICAL_TZID[] = {0x54, 0x5A, 0x49, 0x44, 0}; /* "TZID" */
+static const char16_t ICAL_STANDARD[] = {0x53, 0x54, 0x41, 0x4E, 0x44, 0x41, 0x52, 0x44, 0}; /* "STANDARD" */
+static const char16_t ICAL_DAYLIGHT[] = {0x44, 0x41, 0x59, 0x4C, 0x49, 0x47, 0x48, 0x54, 0}; /* "DAYLIGHT" */
+static const char16_t ICAL_DTSTART[] = {0x44, 0x54, 0x53, 0x54, 0x41, 0x52, 0x54, 0}; /* "DTSTART" */
+static const char16_t ICAL_TZOFFSETFROM[] = {0x54, 0x5A, 0x4F, 0x46, 0x46, 0x53, 0x45, 0x54, 0x46, 0x52, 0x4F, 0x4D, 0}; /* "TZOFFSETFROM" */
+static const char16_t ICAL_TZOFFSETTO[] = {0x54, 0x5A, 0x4F, 0x46, 0x46, 0x53, 0x45, 0x54, 0x54, 0x4F, 0}; /* "TZOFFSETTO" */
+static const char16_t ICAL_RDATE[] = {0x52, 0x44, 0x41, 0x54, 0x45, 0}; /* "RDATE" */
+static const char16_t ICAL_RRULE[] = {0x52, 0x52, 0x55, 0x4C, 0x45, 0}; /* "RRULE" */
+static const char16_t ICAL_TZNAME[] = {0x54, 0x5A, 0x4E, 0x41, 0x4D, 0x45, 0}; /* "TZNAME" */
+static const char16_t ICAL_TZURL[] = {0x54, 0x5A, 0x55, 0x52, 0x4C, 0}; /* "TZURL" */
+static const char16_t ICAL_LASTMOD[] = {0x4C, 0x41, 0x53, 0x54, 0x2D, 0x4D, 0x4F, 0x44, 0x49, 0x46, 0x49, 0x45, 0x44, 0}; /* "LAST-MODIFIED" */
+
+static const char16_t ICAL_FREQ[] = {0x46, 0x52, 0x45, 0x51, 0}; /* "FREQ" */
+static const char16_t ICAL_UNTIL[] = {0x55, 0x4E, 0x54, 0x49, 0x4C, 0}; /* "UNTIL" */
+static const char16_t ICAL_YEARLY[] = {0x59, 0x45, 0x41, 0x52, 0x4C, 0x59, 0}; /* "YEARLY" */
+static const char16_t ICAL_BYMONTH[] = {0x42, 0x59, 0x4D, 0x4F, 0x4E, 0x54, 0x48, 0}; /* "BYMONTH" */
+static const char16_t ICAL_BYDAY[] = {0x42, 0x59, 0x44, 0x41, 0x59, 0}; /* "BYDAY" */
+static const char16_t ICAL_BYMONTHDAY[] = {0x42, 0x59, 0x4D, 0x4F, 0x4E, 0x54, 0x48, 0x44, 0x41, 0x59, 0}; /* "BYMONTHDAY" */
+
+static const char16_t ICAL_NEWLINE[] = {0x0D, 0x0A, 0}; /* CRLF */
+
+static const char16_t ICAL_DOW_NAMES[7][3] = {
{0x53, 0x55, 0}, /* "SU" */
{0x4D, 0x4F, 0}, /* "MO" */
{0x54, 0x55, 0}, /* "TU" */
static const int32_t MONTHLENGTH[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
// ICU custom property
-static const UChar ICU_TZINFO_PROP[] = {0x58, 0x2D, 0x54, 0x5A, 0x49, 0x4E, 0x46, 0x4F, 0x3A, 0}; /* "X-TZINFO:" */
-static const UChar ICU_TZINFO_PARTIAL[] = {0x2F, 0x50, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6C, 0x40, 0}; /* "/Partial@" */
-static const UChar ICU_TZINFO_SIMPLE[] = {0x2F, 0x53, 0x69, 0x6D, 0x70, 0x6C, 0x65, 0x40, 0}; /* "/Simple@" */
+static const char16_t ICU_TZINFO_PROP[] = {0x58, 0x2D, 0x54, 0x5A, 0x49, 0x4E, 0x46, 0x4F, 0x3A, 0}; /* "X-TZINFO:" */
+static const char16_t ICU_TZINFO_PARTIAL[] = {0x2F, 0x50, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6C, 0x40, 0}; /* "/Partial@" */
+static const char16_t ICU_TZINFO_SIMPLE[] = {0x2F, 0x53, 0x69, 0x6D, 0x70, 0x6C, 0x65, 0x40, 0}; /* "/Simple@" */
/*
str.append(MINUS);
}
for (i = length - 1; i >= 0; i--) {
- str.append((UChar)(digits[i] + 0x0030));
+ str.append((char16_t)(digits[i] + 0x0030));
}
return str;
}
}
i--;
while (i >= 0) {
- str.append((UChar)(digits[i--] + 0x0030));
+ str.append((char16_t)(digits[i--] + 0x0030));
}
return str;
}
appendAsciiDigits(year, 4, str);
appendAsciiDigits(month + 1, 2, str);
appendAsciiDigits(dom, 2, str);
- str.append((UChar)0x0054 /*'T'*/);
+ str.append((char16_t)0x0054 /*'T'*/);
int32_t t = mid;
int32_t hour = t / U_MILLIS_PER_HOUR;
*/
static UnicodeString& getUTCDateTimeString(UDate time, UnicodeString& str) {
getDateTimeString(time, str);
- str.append((UChar)0x005A /*'Z'*/);
+ str.append((char16_t)0x005A /*'Z'*/);
return str;
}
break;
}
// sign
- UChar s = str.charAt(0);
+ char16_t s = str.charAt(0);
if (s == PLUS) {
sign = 1;
} else if (s == MINUS) {
~VTZWriter();
void write(const UnicodeString& str);
- void write(UChar ch);
- void write(const UChar* str);
- //void write(const UChar* str, int32_t length);
+ void write(char16_t ch);
+ void write(const char16_t* str);
+ //void write(const char16_t* str, int32_t length);
private:
UnicodeString* out;
};
}
void
-VTZWriter::write(UChar ch) {
+VTZWriter::write(char16_t ch) {
out->append(ch);
}
void
-VTZWriter::write(const UChar* str) {
+VTZWriter::write(const char16_t* str) {
out->append(str, -1);
}
/*
void
-VTZWriter::write(const UChar* str, int32_t length) {
+VTZWriter::write(const char16_t* str, int32_t length) {
out->append(str, length);
}
*/
VTZReader(const UnicodeString& input);
~VTZReader();
- UChar read(void);
+ char16_t read(void);
private:
const UnicodeString* in;
int32_t index;
VTZReader::~VTZReader() {
}
-UChar
+char16_t
VTZReader::read(void) {
- UChar ch = 0xFFFF;
+ char16_t ch = 0xFFFF;
if (index < in->length()) {
ch = in->charAt(index);
}
// Set ICU tzdata version
UErrorCode status = U_ZERO_ERROR;
UResourceBundle *bundle = nullptr;
- const UChar* versionStr = nullptr;
+ const char16_t* versionStr = nullptr;
int32_t len = 0;
bundle = ures_openDirect(nullptr, "zoneinfo64", &status);
versionStr = ures_getStringByKey(bundle, "TZVersion", &len, &status);
// Set ICU tzdata version
UResourceBundle *bundle = nullptr;
- const UChar* versionStr = nullptr;
+ const char16_t* versionStr = nullptr;
int32_t len = 0;
bundle = ures_openDirect(nullptr, "zoneinfo64", &status);
versionStr = ures_getStringByKey(bundle, "TZVersion", &len, &status);
UnicodeString line;
while (true) {
- UChar ch = reader.read();
+ char16_t ch = reader.read();
if (ch == 0xFFFF) {
// end of file
if (start && line.startsWith(ICAL_END_VTIMEZONE, -1)) {
return;
}
icutzprop->append(olsonzid);
- icutzprop->append((UChar)0x005B/*'['*/);
+ icutzprop->append((char16_t)0x005B/*'['*/);
icutzprop->append(icutzver);
icutzprop->append(ICU_TZINFO_PARTIAL, -1);
appendMillis(start, *icutzprop);
- icutzprop->append((UChar)0x005D/*']'*/);
+ icutzprop->append((char16_t)0x005D/*']'*/);
customProps.adoptElement(icutzprop, status);
if (U_FAILURE(status)) {
return;
return;
}
icutzprop->append(olsonzid);
- icutzprop->append((UChar)0x005B/*'['*/);
+ icutzprop->append((char16_t)0x005B/*'['*/);
icutzprop->append(icutzver);
icutzprop->append(ICU_TZINFO_SIMPLE, -1);
appendMillis(time, *icutzprop);
- icutzprop->append((UChar)0x005D/*']'*/);
+ icutzprop->append((char16_t)0x005D/*']'*/);
customProps.adoptElement(icutzprop.orphan(), status);
}
writeZone(writer, rbtz, &customProps, status);
U_NAMESPACE_USE
U_CAPI VZone* U_EXPORT2
-vzone_openID(const UChar* ID, int32_t idLength){
+vzone_openID(const char16_t* ID, int32_t idLength){
UnicodeString s(idLength==-1, ID, idLength);
return (VZone*) (VTimeZone::createVTimeZoneByID(s));
}
U_CAPI VZone* U_EXPORT2
-vzone_openData(const UChar* vtzdata, int32_t vtzdataLength, UErrorCode& status) {
+vzone_openData(const char16_t* vtzdata, int32_t vtzdataLength, UErrorCode& status) {
UnicodeString s(vtzdataLength==-1, vtzdata, vtzdataLength);
return (VZone*) (VTimeZone::createVTimeZone(s,status));
}
}
U_CAPI UBool U_EXPORT2
-vzone_getTZURL(VZone* zone, UChar* & url, int32_t & urlLength) {
+vzone_getTZURL(VZone* zone, char16_t* & url, int32_t & urlLength) {
UnicodeString s;
UBool b = ((VTimeZone*)zone)->VTimeZone::getTZURL(s);
}
U_CAPI void U_EXPORT2
-vzone_setTZURL(VZone* zone, UChar* url, int32_t urlLength) {
+vzone_setTZURL(VZone* zone, char16_t* url, int32_t urlLength) {
UnicodeString s(urlLength==-1, url, urlLength);
((VTimeZone*)zone)->VTimeZone::setTZURL(s);
}
}
U_CAPI void U_EXPORT2
-vzone_write(VZone* zone, UChar* & result, int32_t & resultLength, UErrorCode& status) {
+vzone_write(VZone* zone, char16_t* & result, int32_t & resultLength, UErrorCode& status) {
UnicodeString s;
((VTimeZone*)zone)->VTimeZone::write(s, status);
resultLength = s.length();
- result = (UChar*)uprv_malloc(resultLength);
+ result = (char16_t*)uprv_malloc(resultLength);
memcpy(result,s.getBuffer(),resultLength);
return;
}
U_CAPI void U_EXPORT2
-vzone_writeFromStart(VZone* zone, UDate start, UChar* & result, int32_t & resultLength, UErrorCode& status) {
+vzone_writeFromStart(VZone* zone, UDate start, char16_t* & result, int32_t & resultLength, UErrorCode& status) {
UnicodeString s;
((VTimeZone*)zone)->VTimeZone::write(start, s, status);
resultLength = s.length();
- result = (UChar*)uprv_malloc(resultLength);
+ result = (char16_t*)uprv_malloc(resultLength);
memcpy(result,s.getBuffer(),resultLength);
return;
}
U_CAPI void U_EXPORT2
-vzone_writeSimple(VZone* zone, UDate time, UChar* & result, int32_t & resultLength, UErrorCode& status) {
+vzone_writeSimple(VZone* zone, UDate time, char16_t* & result, int32_t & resultLength, UErrorCode& status) {
UnicodeString s;
((VTimeZone*)zone)->VTimeZone::writeSimple(time, s, status);
resultLength = s.length();
- result = (UChar*)uprv_malloc(resultLength);
+ result = (char16_t*)uprv_malloc(resultLength);
memcpy(result,s.getBuffer(),resultLength);
return;
}
if (U_FAILURE(status)) {
- static const UChar defaultPattern[] = {0x007B, 0x0031, 0x007D, 0x0020, 0x007B, 0x0030, 0x007D, 0x0000}; // "{1} {0}"
+ static const char16_t defaultPattern[] = {0x007B, 0x0031, 0x007D, 0x0020, 0x007B, 0x0030, 0x007D, 0x0000}; // "{1} {0}"
return new UnicodeString(defaultPattern, UPRV_LENGTHOF(defaultPattern));
}
// Get proper date time format
glueIndex = (int32_t)(DateFormat::kDateTimeOffset + (fDateStyle - DateFormat::kDateOffset));
}
- const UChar *resStr = ures_getStringByIndex(patBundle, glueIndex, &resStrLen, &status);
+ const char16_t *resStr = ures_getStringByIndex(patBundle, glueIndex, &resStrLen, &status);
result = new UnicodeString(true, resStr, resStrLen);
}
}
- appendTo.append((const UChar *)buffer, (int32_t) wcslen(buffer));
+ appendTo.append((const char16_t *)buffer, (int32_t) wcslen(buffer));
if (buffer != stackBuffer) {
DELETE_ARRAY(buffer);
}
}
- appendTo.append((const UChar *)buffer, (int32_t) wcslen(buffer));
+ appendTo.append((const char16_t *)buffer, (int32_t) wcslen(buffer));
if (buffer != stackBuffer) {
DELETE_ARRAY(buffer);
newLength = _vscwprintf(fmt, args);
va_end(args);
- nBuffer = NEW_ARRAY(UChar, newLength + 1);
+ nBuffer = NEW_ARRAY(char16_t, newLength + 1);
va_start(args, fmt);
result = _vsnwprintf(nBuffer, newLength + 1, fmt, args);
}
}
- appendTo.append((UChar *)buffer, (int32_t) wcslen(buffer));
+ appendTo.append((char16_t *)buffer, (int32_t) wcslen(buffer));
if (buffer != stackBuffer) {
DELETE_ARRAY(buffer);
return result;
}
-static UBool getWindowsTimeZoneInfo(TIME_ZONE_INFORMATION *zoneInfo, const UChar *icuid, int32_t length) {
+static UBool getWindowsTimeZoneInfo(TIME_ZONE_INFORMATION *zoneInfo, const char16_t *icuid, int32_t length) {
UBool result = false;
UnicodeString id = UnicodeString(icuid, length);
TimeZone *tz = TimeZone::createTimeZone(id);
* information to put into zoneInfo. This includes bias and standard time date and daylight saving date.
*/
U_CAPI UBool U_EXPORT2
-uprv_getWindowsTimeZoneInfo(TIME_ZONE_INFORMATION *zoneInfo, const UChar *icuid, int32_t length)
+uprv_getWindowsTimeZoneInfo(TIME_ZONE_INFORMATION *zoneInfo, const char16_t *icuid, int32_t length)
{
if (getWindowsTimeZoneInfo(zoneInfo, icuid, length)) {
return true;
}
/**
- * Deleter for UChar* string
+ * Deleter for char16_t* string
*/
static void U_CALLCONV
deleteUCharString(void *obj) {
- UChar *entry = (UChar*)obj;
+ char16_t *entry = (char16_t*)obj;
uprv_free(entry);
}
static const char gWorldTag[] = "001";
-static const UChar gWorld[] = {0x30, 0x30, 0x31, 0x00}; // "001"
+static const char16_t gWorld[] = {0x30, 0x30, 0x31, 0x00}; // "001"
-static const UChar gDefaultFrom[] = {0x31, 0x39, 0x37, 0x30, 0x2D, 0x30, 0x31, 0x2D, 0x30, 0x31,
+static const char16_t gDefaultFrom[] = {0x31, 0x39, 0x37, 0x30, 0x2D, 0x30, 0x31, 0x2D, 0x30, 0x31,
0x20, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x00}; // "1970-01-01 00:00"
-static const UChar gDefaultTo[] = {0x39, 0x39, 0x39, 0x39, 0x2D, 0x31, 0x32, 0x2D, 0x33, 0x31,
+static const char16_t gDefaultTo[] = {0x39, 0x39, 0x39, 0x39, 0x2D, 0x31, 0x32, 0x2D, 0x33, 0x31,
0x20, 0x32, 0x33, 0x3A, 0x35, 0x39, 0x00}; // "9999-12-31 23:59"
-static const UChar gCustomTzPrefix[] = {0x47, 0x4D, 0x54, 0}; // "GMT"
+static const char16_t gCustomTzPrefix[] = {0x47, 0x4D, 0x54, 0}; // "GMT"
#define ASCII_DIGIT(c) (((c)>=0x30 && (c)<=0x39) ? (c)-0x30 : -1)
* The format used by CLDR metazone mapping is "yyyy-MM-dd HH:mm".
*/
static UDate
-parseDate (const UChar *text, UErrorCode &status) {
+parseDate (const char16_t *text, UErrorCode &status) {
if (U_FAILURE(status)) {
return 0;
}
}
-const UChar* U_EXPORT2
+const char16_t* U_EXPORT2
ZoneMeta::getCanonicalCLDRID(const UnicodeString &tzid, UErrorCode& status) {
if (U_FAILURE(status)) {
return nullptr;
return nullptr;
}
- const UChar *canonicalID = nullptr;
+ const char16_t *canonicalID = nullptr;
UErrorCode tmpStatus = U_ZERO_ERROR;
- UChar utzid[ZID_KEY_MAX + 1];
+ char16_t utzid[ZID_KEY_MAX + 1];
tzid.extract(utzid, ZID_KEY_MAX + 1, tmpStatus);
U_ASSERT(tmpStatus == U_ZERO_ERROR); // we checked the length of tzid already
// Check if it was already cached
umtx_lock(&gZoneMetaLock);
{
- canonicalID = (const UChar *)uhash_get(gCanonicalIDCache, utzid);
+ canonicalID = (const char16_t *)uhash_get(gCanonicalIDCache, utzid);
}
umtx_unlock(&gZoneMetaLock);
ures_getByKey(rb, id, rb, &tmpStatus);
if (U_SUCCESS(tmpStatus)) {
// type entry (canonical) found
- // the input is the canonical ID. resolve to const UChar*
+ // the input is the canonical ID. resolve to const char16_t*
canonicalID = TimeZone::findID(tzid);
isInputCanonical = true;
}
tmpStatus = U_ZERO_ERROR;
ures_getByKey(top, gTypeAliasTag, rb, &tmpStatus);
ures_getByKey(rb, gTimezoneTag, rb, &tmpStatus);
- const UChar *canonical = ures_getStringByKey(rb,id,nullptr,&tmpStatus);
+ const char16_t *canonical = ures_getStringByKey(rb,id,nullptr,&tmpStatus);
if (U_SUCCESS(tmpStatus)) {
// canonical map found
canonicalID = canonical;
if (canonicalID == nullptr) {
// Dereference the input ID using the tz data
- const UChar *derefer = TimeZone::dereferOlsonLink(tzid);
+ const char16_t *derefer = TimeZone::dereferOlsonLink(tzid);
if (derefer == nullptr) {
status = U_ILLEGAL_ARGUMENT_ERROR;
} else {
// Put the resolved canonical ID to the cache
umtx_lock(&gZoneMetaLock);
{
- const UChar* idInCache = (const UChar *)uhash_get(gCanonicalIDCache, utzid);
+ const char16_t* idInCache = (const char16_t *)uhash_get(gCanonicalIDCache, utzid);
if (idInCache == nullptr) {
- const UChar* key = ZoneMeta::findTimeZoneID(tzid);
+ const char16_t* key = ZoneMeta::findTimeZoneID(tzid);
U_ASSERT(key != nullptr);
if (key != nullptr) {
- idInCache = (const UChar *)uhash_put(gCanonicalIDCache, (void *)key, (void *)canonicalID, &status);
+ idInCache = (const char16_t *)uhash_put(gCanonicalIDCache, (void *)key, (void *)canonicalID, &status);
U_ASSERT(idInCache == nullptr);
}
}
if (U_SUCCESS(status) && isInputCanonical) {
// Also put canonical ID itself into the cache if not exist
- const UChar *canonicalInCache = (const UChar*)uhash_get(gCanonicalIDCache, canonicalID);
+ const char16_t *canonicalInCache = (const char16_t*)uhash_get(gCanonicalIDCache, canonicalID);
if (canonicalInCache == nullptr) {
- canonicalInCache = (const UChar *)uhash_put(gCanonicalIDCache, (void *)canonicalID, (void *)canonicalID, &status);
+ canonicalInCache = (const char16_t *)uhash_put(gCanonicalIDCache, (void *)canonicalID, (void *)canonicalID, &status);
U_ASSERT(canonicalInCache == nullptr);
}
}
UnicodeString& U_EXPORT2
ZoneMeta::getCanonicalCLDRID(const UnicodeString &tzid, UnicodeString &systemID, UErrorCode& status) {
- const UChar *canonicalID = getCanonicalCLDRID(tzid, status);
+ const char16_t *canonicalID = getCanonicalCLDRID(tzid, status);
if (U_FAILURE(status) || canonicalID == nullptr) {
systemID.setToBogus();
return systemID;
return systemID;
}
-const UChar* U_EXPORT2
+const char16_t* U_EXPORT2
ZoneMeta::getCanonicalCLDRID(const TimeZone& tz) {
if (dynamic_cast<const OlsonTimeZone *>(&tz) != nullptr) {
// short cut for OlsonTimeZone
*isPrimary = false;
}
- const UChar *region = TimeZone::getRegion(tzid);
+ const char16_t *region = TimeZone::getRegion(tzid);
if (region != nullptr && u_strcmp(gWorld, region) != 0) {
country.setTo(region, -1);
} else {
UResourceBundle *rb = ures_openDirect(nullptr, gMetaZones, &status);
ures_getByKey(rb, gPrimaryZonesTag, rb, &status);
- const UChar *primaryZone = ures_getStringByKey(rb, regionBuf, &idLen, &status);
+ const char16_t *primaryZone = ures_getStringByKey(rb, regionBuf, &idLen, &status);
if (U_SUCCESS(status)) {
if (tzid.compare(primaryZone, idLen) == 0) {
*isPrimary = true;
const UVector* U_EXPORT2
ZoneMeta::getMetazoneMappings(const UnicodeString &tzid) {
UErrorCode status = U_ZERO_ERROR;
- UChar tzidUChars[ZID_KEY_MAX + 1];
+ char16_t tzidUChars[ZID_KEY_MAX + 1];
tzid.extract(tzidUChars, ZID_KEY_MAX + 1, status);
if (U_FAILURE(status) || status == U_STRING_NOT_TERMINATED_WARNING) {
return nullptr;
if (result == nullptr) {
// add the one just created
int32_t tzidLen = tzid.length() + 1;
- UChar *key = (UChar*)uprv_malloc(tzidLen * sizeof(UChar));
+ char16_t *key = (char16_t*)uprv_malloc(tzidLen * sizeof(char16_t));
if (key == nullptr) {
// memory allocation error.. just return nullptr
result = nullptr;
while (ures_hasNext(rb)) {
mz = ures_getNextResource(rb, mz, &status);
- const UChar *mz_name = ures_getStringByIndex(mz, 0, nullptr, &status);
- const UChar *mz_from = gDefaultFrom;
- const UChar *mz_to = gDefaultTo;
+ const char16_t *mz_name = ures_getStringByIndex(mz, 0, nullptr, &status);
+ const char16_t *mz_from = gDefaultFrom;
+ const char16_t *mz_to = gDefaultTo;
if (ures_getSize(mz) == 3) {
mz_from = ures_getStringByIndex(mz, 1, nullptr, &status);
UnicodeString& U_EXPORT2
ZoneMeta::getZoneIdByMetazone(const UnicodeString &mzid, const UnicodeString ®ion, UnicodeString &result) {
UErrorCode status = U_ZERO_ERROR;
- const UChar *tzid = nullptr;
+ const char16_t *tzid = nullptr;
int32_t tzidLen = 0;
char keyBuf[ZID_KEY_MAX + 1];
int32_t keyLen = 0;
}
const char *mzID = ures_getKey(res.getAlias());
int32_t len = static_cast<int32_t>(uprv_strlen(mzID));
- LocalMemory<UChar> uMzID((UChar*)uprv_malloc(sizeof(UChar) * (len + 1)));
+ LocalMemory<char16_t> uMzID((char16_t*)uprv_malloc(sizeof(char16_t) * (len + 1)));
if (uMzID.isNull()) {
status = U_MEMORY_ALLOCATION_ERROR;
break;
return gMetaZoneIDs;
}
-const UChar*
+const char16_t*
ZoneMeta::findMetaZoneID(const UnicodeString& mzid) {
umtx_initOnce(gMetaZoneIDsInitOnce, &initAvailableMetaZoneIDs);
if (gMetaZoneIDTable == nullptr) {
return nullptr;
}
- return (const UChar*)uhash_get(gMetaZoneIDTable, &mzid);
+ return (const char16_t*)uhash_get(gMetaZoneIDTable, &mzid);
}
-const UChar*
+const char16_t*
ZoneMeta::findTimeZoneID(const UnicodeString& tzid) {
return TimeZone::findID(tzid);
}
id.setTo(gCustomTzPrefix, -1);
if (hour != 0 || min != 0) {
if (negative) {
- id.append((UChar)0x2D); // '-'
+ id.append((char16_t)0x2D); // '-'
} else {
- id.append((UChar)0x2B); // '+'
+ id.append((char16_t)0x2B); // '+'
}
// Always use US-ASCII digits
- id.append((UChar)(0x30 + (hour%100)/10));
- id.append((UChar)(0x30 + (hour%10)));
- id.append((UChar)0x3A); // ':'
- id.append((UChar)(0x30 + (min%100)/10));
- id.append((UChar)(0x30 + (min%10)));
+ id.append((char16_t)(0x30 + (hour%100)/10));
+ id.append((char16_t)(0x30 + (hour%10)));
+ id.append((char16_t)0x3A); // ':'
+ id.append((char16_t)(0x30 + (min%100)/10));
+ id.append((char16_t)(0x30 + (min%10)));
if (sec != 0) {
- id.append((UChar)0x3A); // ':'
- id.append((UChar)(0x30 + (sec%100)/10));
- id.append((UChar)(0x30 + (sec%10)));
+ id.append((char16_t)0x3A); // ':'
+ id.append((char16_t)(0x30 + (sec%100)/10));
+ id.append((char16_t)(0x30 + (sec%10)));
}
}
return id;
}
-const UChar*
+const char16_t*
ZoneMeta::getShortID(const TimeZone& tz) {
- const UChar* canonicalID = nullptr;
+ const char16_t* canonicalID = nullptr;
if (dynamic_cast<const OlsonTimeZone *>(&tz) != nullptr) {
// short cut for OlsonTimeZone
const OlsonTimeZone *otz = (const OlsonTimeZone*)&tz;
return getShortIDFromCanonical(canonicalID);
}
-const UChar*
+const char16_t*
ZoneMeta::getShortID(const UnicodeString& id) {
UErrorCode status = U_ZERO_ERROR;
- const UChar* canonicalID = ZoneMeta::getCanonicalCLDRID(id, status);
+ const char16_t* canonicalID = ZoneMeta::getCanonicalCLDRID(id, status);
if (U_FAILURE(status) || canonicalID == nullptr) {
return nullptr;
}
return ZoneMeta::getShortIDFromCanonical(canonicalID);
}
-const UChar*
-ZoneMeta::getShortIDFromCanonical(const UChar* canonicalID) {
- const UChar* shortID = nullptr;
+const char16_t*
+ZoneMeta::getShortIDFromCanonical(const char16_t* canonicalID) {
+ const char16_t* shortID = nullptr;
int32_t len = u_strlen(canonicalID);
char tzidKey[ZID_KEY_MAX + 1];
U_NAMESPACE_BEGIN
struct OlsonToMetaMappingEntry : public UMemory {
- const UChar *mzid; // const because it's a reference to a resource bundle string.
+ const char16_t *mzid; // const because it's a reference to a resource bundle string.
UDate from;
UDate to;
};
/**
* Return the canonical id for this tzid defined by CLDR, which might be the id itself.
- * This overload method returns a persistent const UChar*, which is guaranteed to persist
+ * This overload method returns a persistent const char16_t*, which is guaranteed to persist
* (a pointer to a resource). If the given system tzid is not known, U_ILLEGAL_ARGUMENT_ERROR
* is set in the status.
* @param tzid Zone ID
* @param status Receives the status
* @return The canonical ID for the input time zone ID
*/
- static const UChar* U_EXPORT2 getCanonicalCLDRID(const UnicodeString &tzid, UErrorCode& status);
+ static const char16_t* U_EXPORT2 getCanonicalCLDRID(const UnicodeString &tzid, UErrorCode& status);
/*
* Convenient method returning CLDR canonical ID for the given time zone
*/
- static const UChar* U_EXPORT2 getCanonicalCLDRID(const TimeZone& tz);
+ static const char16_t* U_EXPORT2 getCanonicalCLDRID(const TimeZone& tz);
/**
* Return the canonical country code for this tzid. If we have none, or if the time zone
* Returns the pointer to the persistent time zone ID string, or nullptr if the given tzid is not in the
* tz database. This method is useful when you maintain persistent zone IDs without duplication.
*/
- static const UChar* U_EXPORT2 findTimeZoneID(const UnicodeString& tzid);
+ static const char16_t* U_EXPORT2 findTimeZoneID(const UnicodeString& tzid);
/**
* Returns the pointer to the persistent meta zone ID string, or nullptr if the given mzid is not available.
* This method is useful when you maintain persistent meta zone IDs without duplication.
*/
- static const UChar* U_EXPORT2 findMetaZoneID(const UnicodeString& mzid);
+ static const char16_t* U_EXPORT2 findMetaZoneID(const UnicodeString& mzid);
/**
* Creates a custom zone for the offset
* @param tz the time zone
* @return the short ID of the time zone, or null if the short ID is not available.
*/
- static const UChar* U_EXPORT2 getShortID(const TimeZone& tz);
+ static const char16_t* U_EXPORT2 getShortID(const TimeZone& tz);
/**
* Returns the time zone's short ID (null terminated) for the zone ID.
* @param tz the time zone ID
* @return the short ID of the time zone ID, or null if the short ID is not available.
*/
- static const UChar* U_EXPORT2 getShortID(const UnicodeString& id);
+ static const char16_t* U_EXPORT2 getShortID(const UnicodeString& id);
private:
ZoneMeta() = delete; // Prevent construction.
static UVector* createMetazoneMappings(const UnicodeString &tzid);
static UnicodeString& formatCustomID(uint8_t hour, uint8_t min, uint8_t sec, UBool negative, UnicodeString& id);
- static const UChar* getShortIDFromCanonical(const UChar* canonicalID);
+ static const char16_t* getShortIDFromCanonical(const char16_t* canonicalID);
};
U_NAMESPACE_END
}
U_CAPI void U_EXPORT2
-zrule_getName(ZRule* rule, UChar* name, int32_t nameLength) {
+zrule_getName(ZRule* rule, char16_t* name, int32_t nameLength) {
UnicodeString s(nameLength==-1, name, nameLength);
s = ((TimeZoneRule*)rule)->TimeZoneRule::getName(s);
nameLength = s.length();
*********************************************************************/
U_CAPI IZRule* U_EXPORT2
-izrule_open(const UChar* name, int32_t nameLength, int32_t rawOffset, int32_t dstSavings) {
+izrule_open(const char16_t* name, int32_t nameLength, int32_t rawOffset, int32_t dstSavings) {
UnicodeString s(nameLength==-1, name, nameLength);
return (IZRule*) new InitialTimeZoneRule(s, rawOffset, dstSavings);
}
}
U_CAPI void U_EXPORT2
-izrule_getName(IZRule* rule, UChar* & name, int32_t & nameLength) {
+izrule_getName(IZRule* rule, char16_t* & name, int32_t & nameLength) {
// UnicodeString s(nameLength==-1, name, nameLength);
UnicodeString s;
((InitialTimeZoneRule*)rule)->InitialTimeZoneRule::getName(s);
nameLength = s.length();
- name = (UChar*)uprv_malloc(nameLength);
+ name = (char16_t*)uprv_malloc(nameLength);
memcpy(name, s.getBuffer(), nameLength);
return;
}
/* u_minstrncpy copies the minimum number of code units of (count or output->available) */
static int32_t
u_sprintf_write(void *context,
- const UChar *str,
+ const char16_t *str,
int32_t count)
{
u_localized_print_string *output = (u_localized_print_string *)context;
static int32_t
u_sprintf_pad_and_justify(void *context,
const u_printf_spec_info *info,
- const UChar *result,
+ const char16_t *result,
int32_t resultLen)
{
u_localized_print_string *output = (u_localized_print_string *)context;
}
U_CAPI int32_t U_EXPORT2
-u_sprintf(UChar *buffer,
+u_sprintf(char16_t *buffer,
const char *patternSpecification,
... )
{
}
U_CAPI int32_t U_EXPORT2
-u_sprintf_u(UChar *buffer,
- const UChar *patternSpecification,
+u_sprintf_u(char16_t *buffer,
+ const char16_t *patternSpecification,
... )
{
va_list ap;
}
U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
-u_vsprintf(UChar *buffer,
+u_vsprintf(char16_t *buffer,
const char *patternSpecification,
va_list ap)
{
}
U_CAPI int32_t U_EXPORT2
-u_snprintf(UChar *buffer,
+u_snprintf(char16_t *buffer,
int32_t count,
const char *patternSpecification,
... )
}
U_CAPI int32_t U_EXPORT2
-u_snprintf_u(UChar *buffer,
+u_snprintf_u(char16_t *buffer,
int32_t count,
- const UChar *patternSpecification,
+ const char16_t *patternSpecification,
... )
{
va_list ap;
}
U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
-u_vsnprintf(UChar *buffer,
+u_vsnprintf(char16_t *buffer,
int32_t count,
const char *patternSpecification,
va_list ap)
{
int32_t written;
- UChar *pattern;
- UChar patBuffer[UFMT_DEFAULT_BUFFER_SIZE];
+ char16_t *pattern;
+ char16_t patBuffer[UFMT_DEFAULT_BUFFER_SIZE];
int32_t size = (int32_t)strlen(patternSpecification) + 1;
/* convert from the default codepage to Unicode */
if (size >= (int32_t)MAX_UCHAR_BUFFER_SIZE(patBuffer)) {
- pattern = (UChar *)uprv_malloc(size * sizeof(UChar));
+ pattern = (char16_t *)uprv_malloc(size * sizeof(char16_t));
if(pattern == 0) {
return 0;
}
}
U_CAPI int32_t U_EXPORT2
-u_vsprintf_u(UChar *buffer,
- const UChar *patternSpecification,
+u_vsprintf_u(char16_t *buffer,
+ const char16_t *patternSpecification,
va_list ap)
{
return u_vsnprintf_u(buffer, INT32_MAX, patternSpecification, ap);
};
U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
-u_vsnprintf_u(UChar *buffer,
+u_vsnprintf_u(char16_t *buffer,
int32_t count,
- const UChar *patternSpecification,
+ const char16_t *patternSpecification,
va_list ap)
{
int32_t written = 0; /* haven't written anything yet */
U_CAPI int32_t U_EXPORT2
-u_sscanf(const UChar *buffer,
+u_sscanf(const char16_t *buffer,
const char *patternSpecification,
... )
{
}
U_CAPI int32_t U_EXPORT2
-u_sscanf_u(const UChar *buffer,
- const UChar *patternSpecification,
+u_sscanf_u(const char16_t *buffer,
+ const char16_t *patternSpecification,
... )
{
va_list ap;
}
U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
-u_vsscanf(const UChar *buffer,
+u_vsscanf(const char16_t *buffer,
const char *patternSpecification,
va_list ap)
{
int32_t converted;
- UChar *pattern;
- UChar patBuffer[UFMT_DEFAULT_BUFFER_SIZE];
+ char16_t *pattern;
+ char16_t patBuffer[UFMT_DEFAULT_BUFFER_SIZE];
int32_t size = (int32_t)uprv_strlen(patternSpecification) + 1;
/* convert from the default codepage to Unicode */
if (size >= (int32_t)MAX_UCHAR_BUFFER_SIZE(patBuffer)) {
- pattern = (UChar *)uprv_malloc(size * sizeof(UChar));
+ pattern = (char16_t *)uprv_malloc(size * sizeof(char16_t));
if(pattern == 0) {
return 0;
}
}
U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
-u_vsscanf_u(const UChar *buffer,
- const UChar *patternSpecification,
+u_vsscanf_u(const char16_t *buffer,
+ const char16_t *patternSpecification,
va_list ap)
{
int32_t converted;
inStr.fTranslit = nullptr;
#endif
inStr.fUCBuffer[0] = 0;
- inStr.str.fBuffer = (UChar *)buffer;
- inStr.str.fPos = (UChar *)buffer;
+ inStr.str.fBuffer = (char16_t *)buffer;
+ inStr.str.fPos = (char16_t *)buffer;
inStr.str.fLimit = buffer + u_strlen(buffer);
if(u_locbund_init(&inStr.str.fBundle, "en_US_POSIX") == 0) {
#endif
U_CAPI UFILE* U_EXPORT2
-u_fopen_u(const UChar *filename,
+u_fopen_u(const char16_t *filename,
const char *perm,
const char *locale,
const char *codepage)
U_CAPI UFILE* U_EXPORT2
-u_fstropen(UChar *stringBuf,
+u_fstropen(char16_t *stringBuf,
int32_t capacity,
const char *locale)
{
#define UPPERCASE_Z 0x005A
int
-ufmt_digitvalue(UChar c)
+ufmt_digitvalue(char16_t c)
{
if( ((c>=DIGIT_0)&&(c<=DIGIT_9)) ||
((c>=LOWERCASE_A)&&(c<=LOWERCASE_Z)) ||
}
UBool
-ufmt_isdigit(UChar c,
+ufmt_isdigit(char16_t c,
int32_t radix)
{
int digitVal = ufmt_digitvalue(c);
#define TO_LC_DIGIT(a) a <= 9 ? (DIGIT_0 + a) : (0x0057 + a)
void
-ufmt_64tou(UChar *buffer,
+ufmt_64tou(char16_t *buffer,
int32_t *len,
uint64_t value,
uint8_t radix,
{
int32_t length = 0;
uint32_t digit;
- UChar *left, *right, temp;
+ char16_t *left, *right, temp;
do {
digit = (uint32_t)(value % radix);
value = value / radix;
- buffer[length++] = (UChar)(uselower ? TO_LC_DIGIT(digit)
+ buffer[length++] = (char16_t)(uselower ? TO_LC_DIGIT(digit)
: TO_UC_DIGIT(digit));
} while(value);
}
void
-ufmt_ptou(UChar *buffer,
+ufmt_ptou(char16_t *buffer,
int32_t *len,
void *value,
UBool uselower)
}
int64_t
-ufmt_uto64(const UChar *buffer,
+ufmt_uto64(const char16_t *buffer,
int32_t *len,
int8_t radix)
{
- const UChar *limit;
+ const char16_t *limit;
int32_t count;
uint64_t result;
#define NIBBLE_PER_BYTE 2
void *
-ufmt_utop(const UChar *buffer,
+ufmt_utop(const char16_t *buffer,
int32_t *len)
{
int32_t count, resultIdx, incVal, offset;
return result.ptr;
}
-UChar*
+char16_t*
ufmt_defaultCPToUnicode(const char *s, int32_t sSize,
- UChar *target, int32_t tSize)
+ char16_t *target, int32_t tSize)
{
- UChar *alias;
+ char16_t *alias;
UErrorCode status = U_ZERO_ERROR;
UConverter *defConverter = u_getDefaultConverter(&status);
static int32_t U_EXPORT2
u_printf_write(void *context,
- const UChar *str,
+ const char16_t *str,
int32_t count)
{
return u_file_write(str, count, (UFILE *)context);
static int32_t
u_printf_pad_and_justify(void *context,
const u_printf_spec_info *info,
- const UChar *result,
+ const char16_t *result,
int32_t resultLen)
{
UFILE *output = (UFILE *)context;
U_CAPI int32_t U_EXPORT2
u_fprintf_u( UFILE *f,
- const UChar *patternSpecification,
+ const char16_t *patternSpecification,
... )
{
va_list ap;
}
U_CAPI int32_t U_EXPORT2
-u_printf_u(const UChar *patternSpecification,
+u_printf_u(const char16_t *patternSpecification,
...)
{
va_list ap;
va_list ap)
{
int32_t count;
- UChar *pattern;
- UChar buffer[UFMT_DEFAULT_BUFFER_SIZE];
+ char16_t *pattern;
+ char16_t buffer[UFMT_DEFAULT_BUFFER_SIZE];
size_t size = strlen(patternSpecification) + 1;
/* convert from the default codepage to Unicode */
if (size >= MAX_UCHAR_BUFFER_SIZE(buffer)) {
- pattern = (UChar *)uprv_malloc(size * sizeof(UChar));
+ pattern = (char16_t *)uprv_malloc(size * sizeof(char16_t));
if(pattern == 0) {
return 0;
}
U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
u_vfprintf_u( UFILE *f,
- const UChar *patternSpecification,
+ const char16_t *patternSpecification,
va_list ap)
{
int32_t written = 0; /* haven't written anything yet */
#define UPRINTF_BUFFER_SIZE 1024
#define UPRINTF_SYMBOL_BUFFER_SIZE 8
-static const UChar gNullStr[] = {0x28, 0x6E, 0x75, 0x6C, 0x6C, 0x29, 0}; /* "(null)" */
-static const UChar gSpaceStr[] = {0x20, 0}; /* " " */
+static const char16_t gNullStr[] = {0x28, 0x6E, 0x75, 0x6C, 0x6C, 0x29, 0}; /* "(null)" */
+static const char16_t gSpaceStr[] = {0x20, 0}; /* " " */
/* Sets the sign of a format based on u_printf_spec_info */
/* TODO: Is setting the prefix symbol to a positive sign a good idea in all locales? */
static void
u_printf_set_sign(UNumberFormat *format,
const u_printf_spec_info *info,
- UChar *prefixBuffer,
+ char16_t *prefixBuffer,
int32_t *prefixBufLen,
UErrorCode *status)
{
unum_setTextAttribute(format, UNUM_POSITIVE_PREFIX, gSpaceStr, 1, status);
}
else {
- UChar plusSymbol[UPRINTF_SYMBOL_BUFFER_SIZE];
+ char16_t plusSymbol[UPRINTF_SYMBOL_BUFFER_SIZE];
int32_t symbolLen;
symbolLen = unum_getSymbol(format,
static void
u_printf_reset_sign(UNumberFormat *format,
const u_printf_spec_info *info,
- UChar *prefixBuffer,
+ char16_t *prefixBuffer,
int32_t *prefixBufLen,
UErrorCode *status)
{
(void)formatBundle;
(void)info;
(void)args;
- static const UChar PERCENT[] = { UP_PERCENT };
+ static const char16_t PERCENT[] = { UP_PERCENT };
/* put a single '%' onto the output */
return handler->write(context, PERCENT, 1);
const ufmt_args *args)
{
(void)formatBundle;
- UChar *s;
- UChar buffer[UFMT_DEFAULT_BUFFER_SIZE];
+ char16_t *s;
+ char16_t buffer[UFMT_DEFAULT_BUFFER_SIZE];
int32_t len, written;
int32_t argSize;
const char *arg = (const char*)(args[0].ptrValue);
argSize = (int32_t)strlen(arg) + 1;
if (argSize >= MAX_UCHAR_BUFFER_SIZE(buffer)) {
s = ufmt_defaultCPToUnicode(arg, argSize,
- (UChar *)uprv_malloc(MAX_UCHAR_BUFFER_NEEDED(argSize)),
+ (char16_t *)uprv_malloc(MAX_UCHAR_BUFFER_NEEDED(argSize)),
MAX_UCHAR_BUFFER_NEEDED(argSize));
if(s == nullptr) {
return 0;
}
}
else {
- s = (UChar *)gNullStr;
+ s = (char16_t *)gNullStr;
}
len = u_strlen(s);
const ufmt_args *args)
{
(void)formatBundle;
- UChar s[U16_MAX_LENGTH+1];
+ char16_t s[U16_MAX_LENGTH+1];
int32_t len = 1, written;
unsigned char arg = (unsigned char)(args[0].int64Value);
{
double num = (double) (args[0].doubleValue);
UNumberFormat *format;
- UChar result[UPRINTF_BUFFER_SIZE];
- UChar prefixBuffer[UPRINTF_BUFFER_SIZE];
+ char16_t result[UPRINTF_BUFFER_SIZE];
+ char16_t prefixBuffer[UPRINTF_BUFFER_SIZE];
int32_t prefixBufferLen = sizeof(prefixBuffer);
int32_t minDecimalDigits;
int32_t maxDecimalDigits;
{
int64_t num = args[0].int64Value;
UNumberFormat *format;
- UChar result[UPRINTF_BUFFER_SIZE];
- UChar prefixBuffer[UPRINTF_BUFFER_SIZE];
+ char16_t result[UPRINTF_BUFFER_SIZE];
+ char16_t prefixBuffer[UPRINTF_BUFFER_SIZE];
int32_t prefixBufferLen = sizeof(prefixBuffer);
int32_t minDigits = -1;
int32_t resultLen;
{
(void)formatBundle;
int64_t num = args[0].int64Value;
- UChar result[UPRINTF_BUFFER_SIZE];
+ char16_t result[UPRINTF_BUFFER_SIZE];
int32_t len = UPRINTF_BUFFER_SIZE;
/* convert to alt form, if desired */
if(num != 0 && info->fAlt && len < UPRINTF_BUFFER_SIZE - 2) {
/* shift the formatted string right by 2 chars */
- memmove(result + 2, result, len * sizeof(UChar));
+ memmove(result + 2, result, len * sizeof(char16_t));
result[0] = 0x0030;
result[1] = info->fSpec;
len += 2;
{
(void)formatBundle;
int64_t num = args[0].int64Value;
- UChar result[UPRINTF_BUFFER_SIZE];
+ char16_t result[UPRINTF_BUFFER_SIZE];
int32_t len = UPRINTF_BUFFER_SIZE;
/* convert to alt form, if desired */
if(info->fAlt && result[0] != 0x0030 && len < UPRINTF_BUFFER_SIZE - 1) {
/* shift the formatted string right by 1 char */
- memmove(result + 1, result, len * sizeof(UChar));
+ memmove(result + 1, result, len * sizeof(char16_t));
result[0] = 0x0030;
len += 1;
}
{
int64_t num = args[0].int64Value;
UNumberFormat *format;
- UChar result[UPRINTF_BUFFER_SIZE];
+ char16_t result[UPRINTF_BUFFER_SIZE];
int32_t minDigits = -1;
int32_t resultLen;
UErrorCode status = U_ZERO_ERROR;
const ufmt_args *args)
{
(void)formatBundle;
- UChar result[UPRINTF_BUFFER_SIZE];
+ char16_t result[UPRINTF_BUFFER_SIZE];
int32_t len = UPRINTF_BUFFER_SIZE;
/* format the pointer in hex */
{
double num = (double) (args[0].doubleValue);
UNumberFormat *format;
- UChar result[UPRINTF_BUFFER_SIZE];
- UChar prefixBuffer[UPRINTF_BUFFER_SIZE];
+ char16_t result[UPRINTF_BUFFER_SIZE];
+ char16_t prefixBuffer[UPRINTF_BUFFER_SIZE];
int32_t prefixBufferLen = sizeof(prefixBuffer);
int32_t minDecimalDigits;
int32_t maxDecimalDigits;
UErrorCode status = U_ZERO_ERROR;
- UChar srcExpBuf[UPRINTF_SYMBOL_BUFFER_SIZE];
+ char16_t srcExpBuf[UPRINTF_SYMBOL_BUFFER_SIZE];
int32_t srcLen, expLen;
int32_t resultLen;
- UChar expBuf[UPRINTF_SYMBOL_BUFFER_SIZE];
+ char16_t expBuf[UPRINTF_SYMBOL_BUFFER_SIZE];
prefixBuffer[0] = 0;
&status);
/* Upper/lower case the e */
- if (info->fSpec == (UChar)0x65 /* e */) {
+ if (info->fSpec == (char16_t)0x65 /* e */) {
expLen = u_strToLower(expBuf, (int32_t)sizeof(expBuf),
srcExpBuf, srcLen,
formatBundle->fLocale,
/* set the appropriate flags and number of decimal digits on the formatter */
if(info->fPrecision != -1) {
/* set the # of decimal digits */
- if (info->fOrigSpec == (UChar)0x65 /* e */ || info->fOrigSpec == (UChar)0x45 /* E */) {
+ if (info->fOrigSpec == (char16_t)0x65 /* e */ || info->fOrigSpec == (char16_t)0x45 /* E */) {
unum_setAttribute(format, UNUM_FRACTION_DIGITS, info->fPrecision);
}
else {
{
double num = (double) (args[0].doubleValue);
UNumberFormat *format;
- UChar result[UPRINTF_BUFFER_SIZE];
- UChar prefixBuffer[UPRINTF_BUFFER_SIZE];
+ char16_t result[UPRINTF_BUFFER_SIZE];
+ char16_t prefixBuffer[UPRINTF_BUFFER_SIZE];
int32_t prefixBufferLen = sizeof(prefixBuffer);
int32_t minDecimalDigits;
int32_t maxDecimalDigits;
{
(void)formatBundle;
int32_t len, written;
- const UChar *arg = (const UChar*)(args[0].ptrValue);
+ const char16_t *arg = (const char16_t*)(args[0].ptrValue);
/* allocate enough space for the buffer */
if (arg == nullptr) {
{
(void)formatBundle;
int32_t written = 0;
- UChar arg = (UChar)(args[0].int64Value);
+ char16_t arg = (char16_t)(args[0].int64Value);
/* width = minimum # of characters to write */
/* precision = maximum # of characters to write */
{
double num = (double) (args[0].doubleValue);
UNumberFormat *format;
- UChar result[UPRINTF_BUFFER_SIZE];
- UChar prefixBuffer[UPRINTF_BUFFER_SIZE];
+ char16_t result[UPRINTF_BUFFER_SIZE];
+ char16_t prefixBuffer[UPRINTF_BUFFER_SIZE];
int32_t prefixBufferLen = sizeof(prefixBuffer);
int32_t minDecimalDigits;
int32_t maxDecimalDigits;
(s) == MOD_LOWERL || \
(s) == MOD_L
/* Returns an array of the parsed argument type given in the format string. */
-static ufmt_args* parseArguments(const UChar *alias, va_list ap, UErrorCode *status) {
+static ufmt_args* parseArguments(const char16_t *alias, va_list ap, UErrorCode *status) {
ufmt_args *arglist = nullptr;
ufmt_type_info *typelist = nullptr;
UBool *islonglong = nullptr;
int32_t size = 0;
int32_t pos = 0;
- UChar type;
+ char16_t type;
uint16_t handlerNum;
- const UChar *aliasStart = alias;
+ const char16_t *aliasStart = alias;
/* get maximum number of arguments */
for(;;) {
/* We parse the argument list in Unicode */
U_CFUNC int32_t
u_printf_parse(const u_printf_stream_handler *streamHandler,
- const UChar *fmt,
+ const char16_t *fmt,
void *context,
u_localized_print_string *locStringContext,
ULocaleBundle *formatBundle,
u_printf_spec spec;
u_printf_spec_info *info = &(spec.fInfo);
- const UChar *alias = fmt;
- const UChar *backup;
- const UChar *lastAlias;
- const UChar *orgAlias = fmt;
+ const char16_t *alias = fmt;
+ const char16_t *backup;
+ const char16_t *lastAlias;
+ const char16_t *orgAlias = fmt;
/* parsed argument list */
ufmt_args *arglist = nullptr; /* initialized it to avoid compiler warnings */
UErrorCode status = U_ZERO_ERROR;
/* TODO test that all four are numbers */
/* first four characters are hex values for pad char */
- info->fPadChar = (UChar)ufmt_digitvalue(*alias++);
- info->fPadChar = (UChar)((info->fPadChar * 16) + ufmt_digitvalue(*alias++));
- info->fPadChar = (UChar)((info->fPadChar * 16) + ufmt_digitvalue(*alias++));
- info->fPadChar = (UChar)((info->fPadChar * 16) + ufmt_digitvalue(*alias++));
+ info->fPadChar = (char16_t)ufmt_digitvalue(*alias++);
+ info->fPadChar = (char16_t)((info->fPadChar * 16) + ufmt_digitvalue(*alias++));
+ info->fPadChar = (char16_t)((info->fPadChar * 16) + ufmt_digitvalue(*alias++));
+ info->fPadChar = (char16_t)((info->fPadChar * 16) + ufmt_digitvalue(*alias++));
/* final character is ignored */
alias++;
U_CAPI int32_t U_EXPORT2
u_fscanf_u(UFILE *f,
- const UChar *patternSpecification,
+ const char16_t *patternSpecification,
... )
{
va_list ap;
va_list ap)
{
int32_t converted;
- UChar *pattern;
- UChar patBuffer[UFMT_DEFAULT_BUFFER_SIZE];
+ char16_t *pattern;
+ char16_t patBuffer[UFMT_DEFAULT_BUFFER_SIZE];
int32_t size = (int32_t)uprv_strlen(patternSpecification) + 1;
/* convert from the default codepage to Unicode */
if (size >= MAX_UCHAR_BUFFER_SIZE(patBuffer)) {
- pattern = (UChar *)uprv_malloc(size * sizeof(UChar));
+ pattern = (char16_t *)uprv_malloc(size * sizeof(char16_t));
if(pattern == 0) {
return 0;
}
U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
u_vfscanf_u(UFILE *f,
- const UChar *patternSpecification,
+ const char16_t *patternSpecification,
va_list ap)
{
return u_scanf_parse(f, patternSpecification, ap);
typedef struct u_scanf_spec_info {
int32_t fWidth; /* Width */
- UChar fSpec; /* Format specification */
+ char16_t fSpec; /* Format specification */
- UChar fPadChar; /* Padding character */
+ char16_t fPadChar; /* Padding character */
UBool fSkipArg; /* true if arg should be skipped */
UBool fIsLongDouble; /* L flag */
* @return The number of characters contained in this specifier.
*/
static int32_t
-u_scanf_parse_spec (const UChar *fmt,
+u_scanf_parse_spec (const char16_t *fmt,
u_scanf_spec *spec)
{
- const UChar *s = fmt;
- const UChar *backup;
+ const char16_t *s = fmt;
+ const char16_t *backup;
u_scanf_spec_info *info = &(spec->fInfo);
/* initialize spec to default values */
case FLAG_PAREN:
/* first four characters are hex values for pad char */
- info->fPadChar = (UChar)ufmt_digitvalue(*s++);
- info->fPadChar = (UChar)((info->fPadChar * 16) + ufmt_digitvalue(*s++));
- info->fPadChar = (UChar)((info->fPadChar * 16) + ufmt_digitvalue(*s++));
- info->fPadChar = (UChar)((info->fPadChar * 16) + ufmt_digitvalue(*s++));
+ info->fPadChar = (char16_t)ufmt_digitvalue(*s++);
+ info->fPadChar = (char16_t)((info->fPadChar * 16) + ufmt_digitvalue(*s++));
+ info->fPadChar = (char16_t)((info->fPadChar * 16) + ufmt_digitvalue(*s++));
+ info->fPadChar = (char16_t)((info->fPadChar * 16) + ufmt_digitvalue(*s++));
/* final character is ignored */
s++;
typedef int32_t (*u_scanf_handler) (UFILE *stream,
u_scanf_spec_info *info,
ufmt_args *args,
- const UChar *fmt,
+ const char16_t *fmt,
int32_t *fmtConsumed,
int32_t *argConverted);
static int32_t
u_scanf_skip_leading_ws(UFILE *input,
- UChar pad)
+ char16_t pad)
{
- UChar c;
+ char16_t c;
int32_t count = 0;
UBool isNotEOF;
UNumberFormat *format,
UErrorCode *status)
{
- UChar c;
+ char16_t c;
int32_t count = 0;
UBool isNotEOF;
- UChar plusSymbol[USCANF_SYMBOL_BUFFER_SIZE];
+ char16_t plusSymbol[USCANF_SYMBOL_BUFFER_SIZE];
int32_t symbolLen;
UErrorCode localStatus = U_ZERO_ERROR;
u_scanf_simple_percent_handler(UFILE *input,
u_scanf_spec_info *info,
ufmt_args *args,
- const UChar *fmt,
+ const char16_t *fmt,
int32_t *fmtConsumed,
int32_t *argConverted)
{
u_scanf_count_handler(UFILE *input,
u_scanf_spec_info *info,
ufmt_args *args,
- const UChar *fmt,
+ const char16_t *fmt,
int32_t *fmtConsumed,
int32_t *argConverted)
{
u_scanf_double_handler(UFILE *input,
u_scanf_spec_info *info,
ufmt_args *args,
- const UChar *fmt,
+ const char16_t *fmt,
int32_t *fmtConsumed,
int32_t *argConverted)
{
u_scanf_scientific_handler(UFILE *input,
u_scanf_spec_info *info,
ufmt_args *args,
- const UChar *fmt,
+ const char16_t *fmt,
int32_t *fmtConsumed,
int32_t *argConverted)
{
int32_t parsePos = 0;
int32_t skipped;
UErrorCode status = U_ZERO_ERROR;
- UChar srcExpBuf[UPRINTF_SYMBOL_BUFFER_SIZE];
+ char16_t srcExpBuf[UPRINTF_SYMBOL_BUFFER_SIZE];
int32_t srcLen, expLen;
- UChar expBuf[UPRINTF_SYMBOL_BUFFER_SIZE];
+ char16_t expBuf[UPRINTF_SYMBOL_BUFFER_SIZE];
/* skip all ws in the input */
&status);
/* Upper/lower case the e */
- if (info->fSpec == (UChar)0x65 /* e */) {
+ if (info->fSpec == (char16_t)0x65 /* e */) {
expLen = u_strToLower(expBuf, (int32_t)sizeof(expBuf),
srcExpBuf, srcLen,
input->str.fBundle.fLocale,
u_scanf_scidbl_handler(UFILE *input,
u_scanf_spec_info *info,
ufmt_args *args,
- const UChar *fmt,
+ const char16_t *fmt,
int32_t *fmtConsumed,
int32_t *argConverted)
{
u_scanf_integer_handler(UFILE *input,
u_scanf_spec_info *info,
ufmt_args *args,
- const UChar *fmt,
+ const char16_t *fmt,
int32_t *fmtConsumed,
int32_t *argConverted)
{
u_scanf_uinteger_handler(UFILE *input,
u_scanf_spec_info *info,
ufmt_args *args,
- const UChar *fmt,
+ const char16_t *fmt,
int32_t *fmtConsumed,
int32_t *argConverted)
{
u_scanf_percent_handler(UFILE *input,
u_scanf_spec_info *info,
ufmt_args *args,
- const UChar *fmt,
+ const char16_t *fmt,
int32_t *fmtConsumed,
int32_t *argConverted)
{
u_scanf_string_handler(UFILE *input,
u_scanf_spec_info *info,
ufmt_args *args,
- const UChar *fmt,
+ const char16_t *fmt,
int32_t *fmtConsumed,
int32_t *argConverted)
{
(void)fmt;
(void)fmtConsumed;
- const UChar *source;
+ const char16_t *source;
UConverter *conv;
char *arg = (char*)(args[0].ptrValue);
char *alias = arg;
UErrorCode status = U_ZERO_ERROR;
int32_t count;
int32_t skipped = 0;
- UChar c;
+ char16_t c;
UBool isNotEOF = false;
/* skip all ws in the input */
u_scanf_char_handler(UFILE *input,
u_scanf_spec_info *info,
ufmt_args *args,
- const UChar *fmt,
+ const char16_t *fmt,
int32_t *fmtConsumed,
int32_t *argConverted)
{
u_scanf_ustring_handler(UFILE *input,
u_scanf_spec_info *info,
ufmt_args *args,
- const UChar *fmt,
+ const char16_t *fmt,
int32_t *fmtConsumed,
int32_t *argConverted)
{
(void)fmt;
(void)fmtConsumed;
- UChar *arg = (UChar*)(args[0].ptrValue);
- UChar *alias = arg;
+ char16_t *arg = (char16_t*)(args[0].ptrValue);
+ char16_t *alias = arg;
int32_t count;
int32_t skipped = 0;
- UChar c;
+ char16_t c;
UBool isNotEOF = false;
/* skip all ws in the input */
u_scanf_uchar_handler(UFILE *input,
u_scanf_spec_info *info,
ufmt_args *args,
- const UChar *fmt,
+ const char16_t *fmt,
int32_t *fmtConsumed,
int32_t *argConverted)
{
u_scanf_spellout_handler(UFILE *input,
u_scanf_spec_info *info,
ufmt_args *args,
- const UChar *fmt,
+ const char16_t *fmt,
int32_t *fmtConsumed,
int32_t *argConverted)
{
u_scanf_hex_handler(UFILE *input,
u_scanf_spec_info *info,
ufmt_args *args,
- const UChar *fmt,
+ const char16_t *fmt,
int32_t *fmtConsumed,
int32_t *argConverted)
{
u_scanf_octal_handler(UFILE *input,
u_scanf_spec_info *info,
ufmt_args *args,
- const UChar *fmt,
+ const char16_t *fmt,
int32_t *fmtConsumed,
int32_t *argConverted)
{
u_scanf_pointer_handler(UFILE *input,
u_scanf_spec_info *info,
ufmt_args *args,
- const UChar *fmt,
+ const char16_t *fmt,
int32_t *fmtConsumed,
int32_t *argConverted)
{
u_scanf_scanset_handler(UFILE *input,
u_scanf_spec_info *info,
ufmt_args *args,
- const UChar *fmt,
+ const char16_t *fmt,
int32_t *fmtConsumed,
int32_t *argConverted)
{
UErrorCode status = U_ZERO_ERROR;
int32_t chLeft = INT32_MAX;
UChar32 c;
- UChar *alias = (UChar*) (args[0].ptrValue);
+ char16_t *alias = (char16_t*) (args[0].ptrValue);
UBool isNotEOF = false;
UBool readCharacter = false;
U_CFUNC int32_t
u_scanf_parse(UFILE *f,
- const UChar *patternSpecification,
+ const char16_t *patternSpecification,
va_list ap)
{
- const UChar *alias;
+ const char16_t *alias;
int32_t count, converted, argConsumed, cpConsumed;
uint16_t handlerNum;
/* TODO: is this correct for all codepages? Should we just use \n and let the converter handle it? */
#if U_PLATFORM_USES_ONLY_WIN32_API
-static const UChar DELIMITERS [] = { DELIM_CR, DELIM_LF, 0x0000 };
+static const char16_t DELIMITERS [] = { DELIM_CR, DELIM_LF, 0x0000 };
static const uint32_t DELIMITERS_LEN = 2;
/* TODO: Default newline writing should be detected based upon the converter being used. */
#else
-static const UChar DELIMITERS [] = { DELIM_LF, 0x0000 };
+static const char16_t DELIMITERS [] = { DELIM_LF, 0x0000 };
static const uint32_t DELIMITERS_LEN = 1;
#endif
return old;
}
-static const UChar * u_file_translit(UFILE *f, const UChar *src, int32_t *count, UBool flush)
+static const char16_t * u_file_translit(UFILE *f, const char16_t *src, int32_t *count, UBool flush)
{
int32_t newlen;
int32_t junkCount = 0;
if(f->fTranslit->length > f->fTranslit->pos)
{
memmove(f->fTranslit->buffer, f->fTranslit->buffer + f->fTranslit->pos,
- (f->fTranslit->length - f->fTranslit->pos)*sizeof(UChar));
+ (f->fTranslit->length - f->fTranslit->pos)*sizeof(char16_t));
}
f->fTranslit->length -= f->fTranslit->pos; /* always */
f->fTranslit->pos = 0;
{
if(f->fTranslit->buffer == nullptr)
{
- f->fTranslit->buffer = (UChar*)uprv_malloc(newlen * sizeof(UChar));
+ f->fTranslit->buffer = (char16_t*)uprv_malloc(newlen * sizeof(char16_t));
}
else
{
- f->fTranslit->buffer = (UChar*)uprv_realloc(f->fTranslit->buffer, newlen * sizeof(UChar));
+ f->fTranslit->buffer = (char16_t*)uprv_realloc(f->fTranslit->buffer, newlen * sizeof(char16_t));
}
/* Check for malloc/realloc failure. */
if (f->fTranslit->buffer == nullptr) {
/* Input/output */
U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
-u_fputs(const UChar *s,
+u_fputs(const char16_t *s,
UFILE *f)
{
int32_t count = u_file_write(s, u_strlen(s), f);
u_fputc(UChar32 uc,
UFILE *f)
{
- UChar buf[2];
+ char16_t buf[2];
int32_t idx = 0;
UBool isError = false;
U_CFUNC int32_t U_EXPORT2
-u_file_write_flush(const UChar *chars,
+u_file_write_flush(const char16_t *chars,
int32_t count,
UFILE *f,
UBool flushIO,
{
/* Set up conversion parameters */
UErrorCode status = U_ZERO_ERROR;
- const UChar *mySource = chars;
- const UChar *mySourceBegin;
- const UChar *mySourceEnd;
+ const char16_t *mySource = chars;
+ const char16_t *mySourceBegin;
+ const char16_t *mySourceEnd;
char charBuffer[UFILE_CHARBUFFER_SIZE];
char *myTarget = charBuffer;
int32_t written = 0;
}
U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
-u_file_write( const UChar *chars,
+u_file_write( const char16_t *chars,
int32_t count,
UFILE *f)
{
UErrorCode status;
const char *mySource;
const char *mySourceEnd;
- UChar *myTarget;
+ char16_t *myTarget;
int32_t bufferSize;
int32_t maxCPBytes;
int32_t bytesRead;
/* record how much buffer space is available */
availLength = UFILE_UCHARBUFFER_SIZE - dataSize;
- /* Determine the # of codepage bytes needed to fill our UChar buffer */
+ /* Determine the # of codepage bytes needed to fill our char16_t buffer */
/* weiv: if converter is nullptr, we use invariant converter with charwidth = 1)*/
maxCPBytes = availLength / (f->fConverter!=nullptr?(2*ucnv_getMinCharSize(f->fConverter)):1);
str->fLimit = myTarget;
}
-U_CAPI UChar* U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
-u_fgets(UChar *s,
+U_CAPI char16_t* U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
+u_fgets(char16_t *s,
int32_t n,
UFILE *f)
{
int32_t dataSize;
int32_t count;
- UChar *alias;
- const UChar *limit;
- UChar *sItr;
- UChar currDelim = 0;
+ char16_t *alias;
+ const char16_t *limit;
+ char16_t *sItr;
+ char16_t currDelim = 0;
u_localized_string *str;
if (n <= 0) {
}
U_CFUNC UBool U_EXPORT2
-ufile_getch(UFILE *f, UChar *ch)
+ufile_getch(UFILE *f, char16_t *ch)
{
UBool isValidChar = false;
return isValidChar;
}
-U_CAPI UChar U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
+U_CAPI char16_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
u_fgetc(UFILE *f)
{
- UChar ch;
+ char16_t ch;
ufile_getch(f, &ch);
return ch;
}
*c32 = *(str->fPos)++;
if (U_IS_LEAD(*c32)) {
if (str->fPos < str->fLimit) {
- UChar c16 = *(str->fPos)++;
+ char16_t c16 = *(str->fPos)++;
*c32 = U16_GET_SUPPLEMENTARY(*c32, c16);
isValidChar = true;
}
}
U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
-u_file_read( UChar *chars,
+u_file_read( char16_t *chars,
int32_t count,
UFILE *f)
{
}
/* copy the current data in the buffer */
- memcpy(chars + read, str->fPos, dataSize * sizeof(UChar));
+ memcpy(chars + read, str->fPos, dataSize * sizeof(char16_t));
/* update number of items read */
read += dataSize;
// use the default converter to convert chunks of text
converter = u_getDefaultConverter(&errorCode);
if(U_SUCCESS(errorCode)) {
- const UChar *us = str.getBuffer();
- const UChar *uLimit = us + str.length();
+ const char16_t *us = str.getBuffer();
+ const char16_t *uLimit = us + str.length();
char *s, *sLimit = buffer + (sizeof(buffer) - 1);
do {
errorCode = U_ZERO_ERROR;
}
/* ipfx should eat whitespace when ios::skipws is set */
- UChar uBuffer[16];
+ char16_t uBuffer[16];
char buffer[16];
int32_t idx = 0;
UConverter *converter;
// use the default converter to convert chunks of text
converter = u_getDefaultConverter(&errorCode);
if(U_SUCCESS(errorCode)) {
- UChar *us = uBuffer;
- const UChar *uLimit = uBuffer + UPRV_LENGTHOF(uBuffer);
+ char16_t *us = uBuffer;
+ const char16_t *uLimit = uBuffer + UPRV_LENGTHOF(uBuffer);
const char *s, *sLimit;
char ch;
- UChar ch32;
+ char16_t ch32;
UBool initialWhitespace = true;
UBool continueReading = true;
UnicodeString string("This is a test");
/* lowercase = "istanbul" */
- UChar lowercase[] = {0x69, 0x73, 0x74, 0x61, 0x6e, 0x62, 0x75, 0x6c, 0};
+ char16_t lowercase[] = {0x69, 0x73, 0x74, 0x61, 0x6e, 0x62, 0x75, 0x6c, 0};
/* uppercase = "LATIN CAPITAL I WITH DOT ABOVE STANBUL" */
- UChar uppercase[] = {0x0130, 0x53, 0x54, 0x41, 0x4e, 0x42, 0x55, 0x4C, 0};
+ char16_t uppercase[] = {0x0130, 0x53, 0x54, 0x41, 0x4e, 0x42, 0x55, 0x4C, 0};
UnicodeString upper(uppercase);
UnicodeString lower(lowercase);
void printUChar(UChar32 ch)
{
if(ch < 127) {
- u_fprintf(out, "%C", (UChar) ch);
+ u_fprintf(out, "%C", (char16_t) ch);
} else if (ch == CharacterIterator::DONE) {
u_fprintf(out, "[CharacterIterator::DONE = 0xFFFF]");
} else {
"to the aid of their country.";
UnicodeString testString(testChars,"");
- const UChar *testText = testString.getTerminatedBuffer();
+ const char16_t *testText = testString.getTerminatedBuffer();
UCharCharacterIterator iter(testText, u_strlen(testText));
UCharCharacterIterator* test2 = iter.clone();
// Demonstrates seeking forward using the iterator.
u_fprintf(out, "Forward = ");
- UChar c = iter.first();
+ char16_t c = iter.first();
printUChar(c); // The first char
int32_t i = 0;
"to the aid of their country.";
UnicodeString testString(testChars,"");
- const UChar *testText = testString.getTerminatedBuffer();
+ const char16_t *testText = testString.getTerminatedBuffer();
StringCharacterIterator iter(testText, u_strlen(testText));
StringCharacterIterator* test2 = iter.clone();
u_fprintf(out, "Backwards: ");
- UChar c = iter.last();
+ char16_t c = iter.last();
int32_t i = iter.endIndex();
printUChar(c);
*/
int strcmp()
{
- UChar source[100];
- UChar target[100];
+ char16_t source[100];
+ char16_t target[100];
u_unescape(opt_source, source, 100);
u_unescape(opt_target, target, 100);
UCollationResult result = ucol_strcoll(collator, source, -1, target, -1);
{
// Set up an ICU collator
UErrorCode status = U_ZERO_ERROR;
- UChar rules[100];
+ char16_t rules[100];
if (opt_rules != 0) {
u_unescape(opt_rules, rules, 100);
UnicodeString target;
target += "\"";
for (i=0; i<source.length(); ++i) {
- UChar ch = source[i];
+ char16_t ch = source[i];
if (ch < 0x09 || (ch > 0x0A && ch < 0x20) || ch > 0x7E) {
target += "\\u";
appendHex(ch, 4, target);
* Read the text from a file. The text must start with a Unicode Byte
* Order Mark (BOM) so that we know what order to read the bytes in.
*/
-const UChar *UnicodeReader::readFile(const char *fileName, GUISupport *guiSupport, int32_t &charCount)
+const char16_t *UnicodeReader::readFile(const char *fileName, GUISupport *guiSupport, int32_t &charCount)
{
FILE *f;
int32_t fileSize;
- UChar *charBuffer;
+ char16_t *charBuffer;
char *byteBuffer;
char startBytes[4] = {'\xA5', '\xA5', '\xA5', '\xA5'};
char errorMessage[128];
delete[] byteBuffer;
charCount = myText.length();
- charBuffer = LE_NEW_ARRAY(UChar, charCount + 1);
+ charBuffer = LE_NEW_ARRAY(char16_t, charCount + 1);
if(charBuffer == 0) {
sprintf(errorMessage,"Couldn't get memory for reading %s: %s \n", fileName, strerror(errno));
guiSupport->postErrorMessage(errorMessage, "Text File Error");
// nothing, too
}
- static const UChar *readFile(const char *fileName, GUISupport *guiSupport, int32_t &charCount);
+ static const char16_t *readFile(const char *fileName, GUISupport *guiSupport, int32_t &charCount);
};
#endif
{
LEErrorCode status = LE_NO_ERROR;
le_int32 charCount;
- const UChar *text = UnicodeReader::readFile(fileName, guiSupport, charCount);
+ const char16_t *text = UnicodeReader::readFile(fileName, guiSupport, charCount);
Paragraph *result = nullptr;
if (text == nullptr) {
U_CDECL_BEGIN
-const UChar *uc_readFile(const char *fileName, gs_guiSupport *guiSupport, int32_t *charCount)
+const char16_t *uc_readFile(const char *fileName, gs_guiSupport *guiSupport, int32_t *charCount)
{
return UnicodeReader::readFile(fileName, (GUISupport *) guiSupport, *charCount);
}
U_CDECL_BEGIN
-const UChar *uc_readFile(const char *fileName, gs_guiSupport *guiSupport, int32_t *charCount);
+const char16_t *uc_readFile(const char *fileName, gs_guiSupport *guiSupport, int32_t *charCount);
U_CDECL_END
#include "unicode/utypes.h"
#include "unicode/ustring.h"
-extern "C" void test_current(UChar data[][5], uint32_t size, uint32_t maxLen, uint8_t keys[][32]);
-extern "C" void test_legacy(UChar data[][5], uint32_t size, uint32_t maxlen, uint8_t keys[][32]);
+extern "C" void test_current(char16_t data[][5], uint32_t size, uint32_t maxLen, uint8_t keys[][32]);
+extern "C" void test_legacy(char16_t data[][5], uint32_t size, uint32_t maxlen, uint8_t keys[][32]);
-void printZTUChar(const UChar *str) {
+void printZTUChar(const char16_t *str) {
while(*str != 0) {
if(*str > 0x1F && *str < 0x80) {
fprintf(stdout, "%c", (*str) & 0xFF);
}
}
-void printArray(const char* const comment, const UChar UArray[][5], int32_t arraySize) {
+void printArray(const char* const comment, const char16_t UArray[][5], int32_t arraySize) {
fprintf (stdout, "%s\n", comment);
int32_t i = 0;
for(i = 0; i<arraySize; i++) {
};
#endif
- static UChar uTest[4][5];
+ static char16_t uTest[4][5];
static uint8_t keys[4][32];
// Very simple example code - sticks a sortkey in the buffer
// Not much error checking
-int32_t getSortKey_current(const char *locale, const UChar *string, int32_t sLen, uint8_t *buffer, int32_t bLen) {
+int32_t getSortKey_current(const char *locale, const char16_t *string, int32_t sLen, uint8_t *buffer, int32_t bLen) {
UErrorCode status = U_ZERO_ERROR;
UCollator *coll = ucol_open(locale, &status);
if(U_FAILURE(status)) {
int compare_current(const void *string1, const void *string2) {
if(compareCollator != nullptr) {
- UCollationResult res = ucol_strcoll(compareCollator, (UChar *) string1, -1, (UChar *) string2, -1);
+ UCollationResult res = ucol_strcoll(compareCollator, (char16_t *) string1, -1, (char16_t *) string2, -1);
if(res == UCOL_LESS) {
return -1;
} else if(res == UCOL_GREATER) {
}
-extern "C" void test_current(UChar data[][5], uint32_t size, uint32_t maxlen, uint8_t keys[][32]) {
+extern "C" void test_current(char16_t data[][5], uint32_t size, uint32_t maxlen, uint8_t keys[][32]) {
uint32_t i = 0;
int32_t keySize = 0;
UVersionInfo uvi;
fprintf(stderr, "Done sortkeys, doing qsort test\n");
initCollator_current("ja");
- qsort(data, size, maxlen*sizeof(UChar), compare_current);
+ qsort(data, size, maxlen*sizeof(char16_t), compare_current);
closeCollator_current();
fprintf(stderr, "Done current!\n");
// Very simple example code - sticks a sortkey in the buffer
// Not much error checking
-int32_t getSortKey_legacy(const char *locale, const UChar *string, int32_t sLen, uint8_t *buffer, int32_t bLen) {
+int32_t getSortKey_legacy(const char *locale, const char16_t *string, int32_t sLen, uint8_t *buffer, int32_t bLen) {
UErrorCode status = U_ZERO_ERROR;
UCollator *coll = ucol_open(locale, &status);
if(U_FAILURE(status)) {
int compare_legacy(const void *string1, const void *string2) {
if(compareCollator != nullptr) {
- UCollationResult res = ucol_strcoll(compareCollator, (UChar *) string1, -1, (UChar *) string2, -1);
+ UCollationResult res = ucol_strcoll(compareCollator, (char16_t *) string1, -1, (char16_t *) string2, -1);
if(res == UCOL_LESS) {
return -1;
} else if(res == UCOL_GREATER) {
}
-extern "C" void test_legacy(UChar data[][5], uint32_t size, uint32_t maxlen, uint8_t keys[4][32]) {
+extern "C" void test_legacy(char16_t data[][5], uint32_t size, uint32_t maxlen, uint8_t keys[4][32]) {
uint32_t i = 0;
int32_t keySize = 0;
fprintf(stderr, "Done sortkeys, doing qsort test\n");
initCollator_legacy("ja");
- qsort(data, size, maxlen*sizeof(UChar), compare_legacy);
+ qsort(data, size, maxlen*sizeof(char16_t), compare_legacy);
closeCollator_legacy();
fprintf(stderr, "Done legacy!\n");
UnicodeString target;
target += "\"";
for (i=0; i<source.length(); ++i) {
- UChar ch = source[i];
+ char16_t ch = source[i];
if (ch < 0x09 || (ch > 0x0A && ch < 0x20) || ch > 0x7E) {
target += "\\u";
appendHex(ch, 4, target);
double roundingIncrement;
// Unicode string with the desired currency display symbol or name
- UChar symbol[16];
+ char16_t symbol[16];
} currencyMap[]={
{ "USD", 2, 0.0, { 0x24, 0 } },
{ "GBP", 2, 0.0, { 0xa3, 0 } },
}
// invariant-character conversion to UChars (see utypes.h and putil.h)
- UChar uCurrency[4];
+ char16_t uCurrency[4];
u_charsToUChars(currency, uCurrency, 4);
// set the currency
// output=formatted currency value
output.remove();
nf->format(12345678.93, output);
- output+=(UChar)0x0a; // '\n'
+ output+=(char16_t)0x0a; // '\n'
uprintf(output);
}
}
uint32_t digit;
while (digits > 0) {
digit = (number >> ((--digits) * 4)) & 0xF;
- target += (UChar)(digit < 10 ? 0x30 + digit : 0x41 - 10 + digit);
+ target += (char16_t)(digit < 10 ? 0x30 + digit : 0x41 - 10 + digit);
}
return target;
}
UnicodeString escape(const UnicodeString &source) {
int32_t i;
UnicodeString target;
- target += (UChar)U_DQUOTE;
+ target += (char16_t)U_DQUOTE;
for (i=0; i<source.length(); ++i) {
- UChar ch = source[i];
+ char16_t ch = source[i];
if (ch < 0x09 || (ch > 0x0D && ch < 0x20) || ch > 0x7E) {
- (target += (UChar)U_BACKSLASH) += (UChar)U_SMALL_U;
+ (target += (char16_t)U_BACKSLASH) += (char16_t)U_SMALL_U;
appendHex(ch, 4, target);
} else {
target += ch;
}
}
- target += (UChar)U_DQUOTE;
+ target += (char16_t)U_DQUOTE;
return target;
}
return UnicodeString(buf, "");
}
case Formattable::kString:
- return UnicodeString((UChar)U_DQUOTE).append(f.getString()).append((UChar)U_DQUOTE);
+ return UnicodeString((char16_t)U_DQUOTE).append(f.getString()).append((char16_t)U_DQUOTE);
case Formattable::kArray:
{
int32_t i, count;
const Formattable* array = f.getArray(count);
- UnicodeString result((UChar)U_LEFT_SQUARE_BRACKET);
+ UnicodeString result((char16_t)U_LEFT_SQUARE_BRACKET);
for (i=0; i<count; ++i) {
if (i > 0) {
- (result += (UChar)U_COMMA) += (UChar)U_SPACE;
+ (result += (char16_t)U_COMMA) += (char16_t)U_SPACE;
}
result += formattableToString(array[i]);
}
- result += (UChar)U_RIGHT_SQUARE_BRACKET;
+ result += (char16_t)U_RIGHT_SQUARE_BRACKET;
return result;
}
default:
char const *opt_pattern = "Unicode";
UCollator * collator = 0;
UStringSearch * search = 0;
-UChar rules[100];
-UChar source[100];
-UChar pattern[100];
+char16_t rules[100];
+char16_t source[100];
+char16_t pattern[100];
/**
* Definitions for the command line options
/**
* Remove accents from a character using Normalizer.
*/
-UChar UnaccentTransliterator::unaccent(UChar c) const {
+char16_t UnaccentTransliterator::unaccent(char16_t c) const {
UnicodeString str(c);
UErrorCode status = U_ZERO_ERROR;
UnaccentTransliterator* t = (UnaccentTransliterator*)this;
if (U_FAILURE(status)) {
return c;
}
- return (UChar) t->normalizer.next();
+ return (char16_t) t->normalizer.next();
}
/**
UBool incremental) const {
UnicodeString str("a");
while (index.start < index.limit) {
- UChar c = text.charAt(index.start);
- UChar d = unaccent(c);
+ char16_t c = text.charAt(index.start);
+ char16_t d = unaccent(c);
if (c != d) {
str.setCharAt(0, d);
text.handleReplaceBetween(index.start, index.start+1, str);
/**
* Unaccent a single character using normalizer.
*/
- UChar unaccent(UChar c) const;
+ char16_t unaccent(char16_t c) const;
Normalizer normalizer;
};
/**
* Remove accents from a character using Normalizer.
*/
-UChar UnaccentTransliterator::unaccent(UChar c) const {
+char16_t UnaccentTransliterator::unaccent(char16_t c) const {
UnicodeString str(c);
UErrorCode status = U_ZERO_ERROR;
UnaccentTransliterator* t = (UnaccentTransliterator*)this;
if (U_FAILURE(status)) {
return c;
}
- return (UChar) t->normalizer.next();
+ return (char16_t) t->normalizer.next();
}
/**
UBool incremental) const {
UnicodeString str("a");
while (index.start < index.limit) {
- UChar c = text.charAt(index.start);
- UChar d = unaccent(c);
+ char16_t c = text.charAt(index.start);
+ char16_t d = unaccent(c);
if (c != d) {
str.setCharAt(0, d);
text.handleReplaceBetween(index.start, index.start+1, str);
/**
* Unaccent a single character using normalizer.
*/
- UChar unaccent(UChar c) const;
+ char16_t unaccent(char16_t c) const;
Normalizer normalizer;
UnicodeString target;
target += "\"";
for (i=0; i<source.length(); ++i) {
- UChar ch = source[i];
+ char16_t ch = source[i];
if (ch < 0x09 || (ch > 0x0A && ch < 0x20) || ch > 0x7E) {
target += "\\u";
appendHex(ch, 4, target);
#define UPRV_LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
#endif
-static const UChar kNone[] = { 0x0000 };
+static const char16_t kNone[] = { 0x0000 };
#define U_ASSERT(x) { if(U_FAILURE(x)) {fflush(stdout);fflush(stderr); fprintf(stderr, #x " == %s\n", u_errorName(x)); assert(U_SUCCESS(x)); }}
-/* Print a UChar if possible, in seven characters. */
-void prettyPrintUChar(UChar c)
+/* Print a char16_t if possible, in seven characters. */
+void prettyPrintUChar(char16_t c)
{
if( (c <= 0x007F) &&
(isgraph(c)) ) {
void printUChars(const char *name = "?",
- const UChar *uch = kNone,
+ const char16_t *uch = kNone,
int32_t len = -1 )
{
int32_t i;
printf("ch: U+%06X\n", ch32);
}
else {
- UChar ch = (UChar)ch32;
+ char16_t ch = (char16_t)ch32;
printUChars("C", &ch, 1);
}
}
Very simple C sample to convert the word 'Moscow' in Russian in Unicode,
followed by an exclamation mark (!) into the KOI8-R Russian code page.
- This example first creates a UChar String out of the Unicode chars.
+ This example first creates a char16_t String out of the Unicode chars.
targetSize must be set to the amount of space available in the target
buffer. After fromUChars is called,
// **************************** START SAMPLE *******************
// "cat<cat>OK"
- UChar source[] = { 0x041C, 0x043E, 0x0441, 0x043A, 0x0432,
+ char16_t source[] = { 0x041C, 0x043E, 0x0441, 0x043A, 0x0432,
0x0430, 0x0021, 0x0000 };
char target[100];
UErrorCode status = U_ZERO_ERROR;
char inBuf[BUFFERSIZE];
const char *source;
const char *sourceLimit;
- UChar *uBuf;
- UChar *target;
- UChar *targetLimit;
- UChar *p;
+ char16_t *uBuf;
+ char16_t *target;
+ char16_t *targetLimit;
+ char16_t *p;
int32_t uBufSize = 0;
UConverter *conv;
UErrorCode status = U_ZERO_ERROR;
uBufSize = (BUFFERSIZE/ucnv_getMinCharSize(conv));
printf("input bytes %d / min chars %d = %d UChars\n",
BUFFERSIZE, ucnv_getMinCharSize(conv), uBufSize);
- uBuf = (UChar*)malloc(uBufSize * sizeof(UChar));
+ uBuf = (char16_t*)malloc(uBufSize * sizeof(char16_t));
assert(uBuf!=nullptr);
// grab another buffer's worth
printf("% 5d U+%06X ", info[p].frequency, p);
if(p <= 0xFFFF)
{
- prettyPrintUChar((UChar)p);
+ prettyPrintUChar((char16_t)p);
}
printf("\n");
}
// **************************** START SAMPLE *******************
char source[] = { 0x63, 0x61, 0x74, (char)0x94, 0x4C, (char)0x82, 0x6E, (char)0x82, 0x6A, 0x00 };
- UChar target[100];
+ char16_t target[100];
UErrorCode status = U_ZERO_ERROR;
UConverter *conv;
int32_t len;
UBool convsample_20_didSubstitute(const char *source)
{
- UChar uchars[100];
+ char16_t uchars[100];
char bytes[100];
UConverter *conv = nullptr;
UErrorCode status = U_ZERO_ERROR;
UBool convsample_21_didSubstitute(const char *source)
{
- UChar uchars[100];
+ char16_t uchars[100];
char bytes[100];
UConverter *conv = nullptr, *cloneCnv = nullptr;
UErrorCode status = U_ZERO_ERROR;
char inBuf[BUFFERSIZE];
const char *source;
const char *sourceLimit;
- UChar *uBuf;
- UChar *target;
- UChar *targetLimit;
+ char16_t *uBuf;
+ char16_t *target;
+ char16_t *targetLimit;
int32_t uBufSize = 0;
UConverter *conv = nullptr;
UErrorCode status = U_ZERO_ERROR;
uBufSize = (BUFFERSIZE/ucnv_getMinCharSize(conv));
printf("input bytes %d / min chars %d = %d UChars\n",
BUFFERSIZE, ucnv_getMinCharSize(conv), uBufSize);
- uBuf = (UChar*)malloc(uBufSize * sizeof(UChar));
+ uBuf = (char16_t*)malloc(uBufSize * sizeof(char16_t));
assert(uBuf!=nullptr);
// grab another buffer's worth
FILE *f;
FILE *out;
int32_t count;
- UChar inBuf[BUFFERSIZE];
- const UChar *source;
- const UChar *sourceLimit;
+ char16_t inBuf[BUFFERSIZE];
+ const char16_t *source;
+ const char16_t *sourceLimit;
char *buf;
char *target;
char *targetLimit;
// grab another buffer's worth
while((!feof(f)) &&
- ((count=static_cast<int32_t>(fread(inBuf, sizeof(UChar), BUFFERSIZE , f))) > 0) )
+ ((count=static_cast<int32_t>(fread(inBuf, sizeof(char16_t), BUFFERSIZE , f))) > 0) )
{
inchars += count;
} while (source < sourceLimit); // while simply out of space
}
- printf("%d Uchars (%d bytes) in, %d chars out.\n", inchars, static_cast<int>(inchars * sizeof(UChar)), total);
+ printf("%d Uchars (%d bytes) in, %d chars out.\n", inchars, static_cast<int>(inchars * sizeof(char16_t)), total);
// ***************************** END SAMPLE ********************
ucnv_close(conv);
int32_t signatureLength = 0;
const char *encoding = ucnv_detectUnicodeSignature(input,sizeof(input),&signatureLength,&err);
UConverter *conv = nullptr;
- UChar output[100];
- UChar *target = output, *out;
+ char16_t output[100];
+ char16_t *target = output, *out;
const char *source = input;
if(encoding!=nullptr && U_SUCCESS(err)){
// should signature be discarded ?
const char *fileName;
int fileLen; // Length, in UTF-16 Code Units.
-UChar *ucharBuf = 0; // Buffer, holds converted file. (Simple minded program, always reads
+char16_t *ucharBuf = 0; // Buffer, holds converted file. (Simple minded program, always reads
// the whole file at once.
char *charBuf = 0; // Buffer, for original, unconverted file data.
}
//
- // Convert the file data to UChar.
+ // Convert the file data to char16_t.
// Preflight first to determine required buffer size.
//
uint32_t destCap = ucnv_toUChars(conv,
};
status = U_ZERO_ERROR;
- ucharBuf = (UChar *)realloc(ucharBuf, (destCap+1) * sizeof(UChar));
+ ucharBuf = (char16_t *)realloc(ucharBuf, (destCap+1) * sizeof(char16_t));
ucnv_toUChars(conv,
ucharBuf, // dest,
destCap+1,
if (lineEnd >= fileLen) {
return;
}
- UChar c = ucharBuf[lineEnd];
+ char16_t c = ucharBuf[lineEnd];
lineEnd++;
if (c == 0x0a || // Line Feed
c == 0x0c || // Form Feed
static UConverter *cnv=nullptr;
static void
-printUString(const char *announce, const UChar *s, int32_t length) {
+printUString(const char *announce, const char16_t *s, int32_t length) {
static char out[200];
UChar32 c;
int32_t i;
static void
demo_utf_h_macros() {
- static UChar input[]={ 0x0061, 0xd800, 0xdc00, 0xdbff, 0xdfff, 0x0062 };
+ static char16_t input[]={ 0x0061, 0xd800, 0xdc00, 0xdbff, 0xdfff, 0x0062 };
UChar32 c;
int32_t i;
UBool isError;
static void demo_C_Unicode_strings() {
printf("\n* demo_C_Unicode_strings() --------- ***\n\n");
- static const UChar text[]={ 0x41, 0x42, 0x43, 0 }; /* "ABC" */
- static const UChar appendText[]={ 0x61, 0x62, 0x63, 0 }; /* "abc" */
- static const UChar cmpText[]={ 0x61, 0x53, 0x73, 0x43, 0 }; /* "aSsC" */
- UChar buffer[32];
+ static const char16_t text[]={ 0x41, 0x42, 0x43, 0 }; /* "ABC" */
+ static const char16_t appendText[]={ 0x61, 0x62, 0x63, 0 }; /* "abc" */
+ static const char16_t cmpText[]={ 0x61, 0x53, 0x73, 0x43, 0 }; /* "aSsC" */
+ char16_t buffer[32];
int32_t compare;
int32_t length=u_strlen(text); /* length=3 */
* "<sharp s> <small lig. ffi>"
* "<small final sigma><small sigma><capital sigma>"
*/
- static const UChar input[]={
+ static const char16_t input[]={
0x61, 0x42, 0x3a3,
0x69, 0x49, 0x131, 0x130, 0x20,
0xdf, 0x20, 0xfb03,
0x3c2, 0x3c3, 0x3a3, 0
};
- UChar buffer[32];
+ char16_t buffer[32];
UErrorCode errorCode;
UChar32 c;
* "<sharp s> <small lig. ffi>"
* "<small final sigma><small sigma><capital sigma>"
*/
- static const UChar input[]={
+ static const char16_t input[]={
0x61, 0x42, 0x3a3,
0x69, 0x49, 0x131, 0x130, 0x20,
0xdf, 0x20, 0xfb03,
// sample code for UnicodeString storage models ----------------------------- ***
-static const UChar readonly[]={
+static const char16_t readonly[]={
0x61, 0x31, 0x20ac
};
-static UChar writeable[]={
+static char16_t writeable[]={
0x62, 0x32, 0xdbc0, 0xdc01 // includes a surrogate pair for a supplementary code point
};
static char out[100];
two=one;
printf("length of longer string copy: %d\n", two.length());
- // * UnicodeString using readonly-alias to a const UChar array
+ // * UnicodeString using readonly-alias to a const char16_t array
// construct a string that aliases a readonly buffer
UnicodeString three(false, readonly, UPRV_LENGTHOF(readonly));
printUnicodeString("readonly-alias string: ", three);
printf("verify that a regular copy of a readonly alias uses a different buffer pointer: %d (should be 0)\n",
one.getBuffer()==two.getBuffer());
- // * UnicodeString using writeable-alias to a non-const UChar array
+ // * UnicodeString using writeable-alias to a non-const char16_t array
UnicodeString four(writeable, UPRV_LENGTHOF(writeable), UPRV_LENGTHOF(writeable));
printUnicodeString("writeable-alias string: ", four);
// a modification writes through to the buffer
one.setTo(writeable, UPRV_LENGTHOF(writeable), UPRV_LENGTHOF(writeable));
// grow the string - it will not fit into the backing buffer any more
// and will get copied before modification
- one.append((UChar)0x40);
+ one.append((char16_t)0x40);
// shrink it back so it would fit
one.truncate(one.length()-1);
// we still operate on the copy
UnicodeString invariantOnly=UNICODE_STRING("such characters are safe 123 %-.", 32);
/*
- * In C, we need two macros: one to declare the UChar[] array, and
+ * In C, we need two macros: one to declare the char16_t[] array, and
* one to populate it; the second one is a noop on platforms where
- * wchar_t is compatible with UChar and ASCII-based.
+ * wchar_t is compatible with char16_t and ASCII-based.
* The length of the string literal must be counted for both macros.
*/
/* declare the invString array for the string */
printf("C and C++ Unicode strings are equal: %d\n", invariantOnly==UnicodeString(true, invString, 32));
/*
- * convert between char * and UChar * strings that
+ * convert between char * and char16_t * strings that
* contain only invariant characters
*/
static const char *cs1="such characters are safe 123 %-.";
- static UChar us1[40];
+ static char16_t us1[40];
static char cs2[40];
u_charsToUChars(cs1, us1, 33); /* include the terminating NUL */
u_UCharsToChars(us1, cs2, 33);
- printf("char * -> UChar * -> char * with only "
+ printf("char * -> char16_t * -> char * with only "
"invariant characters: \"%s\"\n",
cs2);
/*
* C: convert and unescape a char * string with only invariant
- * characters to fill a UChar * string
+ * characters to fill a char16_t * string
*/
- UChar buffer[200];
+ char16_t buffer[200];
int32_t length;
length=u_unescape(
"Sch\\u00f6nes Auto: \\u20ac 11240.\\fPrivates Zeichen: \\U00102345\\n",
#endif
U_CHARSET_FAMILY,
- sizeof(UChar),
+ sizeof(char16_t),
0, /* reserved */
{ /* data format identifier */
0x54, 0x6f, 0x43, 0x50}, /* "ToCP" */
UParseError pe = { 0 };
UErrorCode status = U_ZERO_ERROR;
- URegularExpression* re = uregex_open(reinterpret_cast<const UChar*>(data),
- static_cast<int>(size) / sizeof(UChar),
+ URegularExpression* re = uregex_open(reinterpret_cast<const char16_t*>(data),
+ static_cast<int>(size) / sizeof(char16_t),
0, &pe, &status);
if (re)
// file: alphaindextst.cpp
// Alphabetic Index Tests.
//
-// Note: please... no character literals cast to UChars.. use (UChar)0xZZZZ
+// Note: please... no character literals cast to UChars.. use (char16_t)0xZZZZ
#include <stdio.h> // for snprintf
const AlphabeticIndex::Bucket *bucket;
for (int32_t i = 0; (bucket = index.getBucket(i)) != nullptr; ++i) {
if (dest.length() > oldLength) {
- dest.append((UChar)0x3A); // ':'
+ dest.append((char16_t)0x3A); // ':'
}
dest.append(bucket->getLabel());
}
} else if (i <= 26) {
// Labels A - Z for English locale
TEST_ASSERT(type == U_ALPHAINDEX_NORMAL);
- UnicodeString expectedLabel((UChar)(0x40 + i));
+ UnicodeString expectedLabel((char16_t)(0x40 + i));
TEST_ASSERT(expectedLabel == label);
} else if (i == 27) {
TEST_ASSERT(type == U_ALPHAINDEX_OVERFLOW);
assertEquals("getBucketCount()", 1, index.getBucketCount(status)); // ... (underflow only)
index.addLabels(Locale::getEnglish(), status);
assertEquals("getBucketCount()", 28, index.getBucketCount(status)); // ... A-Z ...
- int32_t bucketIndex = index.getBucketIndex(UnicodeString((UChar)0x897f), status);
+ int32_t bucketIndex = index.getBucketIndex(UnicodeString((char16_t)0x897f), status);
assertEquals("getBucketIndex(U+897F)", 0, bucketIndex); // underflow bucket
bucketIndex = index.getBucketIndex("i", status);
assertEquals("getBucketIndex(i)", 9, bucketIndex);
- bucketIndex = index.getBucketIndex(UnicodeString((UChar)0x03B1), status);
+ bucketIndex = index.getBucketIndex(UnicodeString((char16_t)0x03B1), status);
assertEquals("getBucketIndex(Greek alpha)", 27, bucketIndex);
// U+50005 is an unassigned code point which sorts at the end, independent of the Hani group.
bucketIndex = index.getBucketIndex(UnicodeString((UChar32)0x50005), status);
assertEquals("getBucketIndex(U+50005)", 27, bucketIndex);
- bucketIndex = index.getBucketIndex(UnicodeString((UChar)0xFFFF), status);
+ bucketIndex = index.getBucketIndex(UnicodeString((char16_t)0xFFFF), status);
assertEquals("getBucketIndex(U+FFFF)", 27, bucketIndex);
}
assertEquals("getBucketCount()", 28, index.getBucketCount(status)); // ... A-Z ...
index.addLabels(Locale::getChinese(), status);
assertEquals("getBucketCount()", 28, index.getBucketCount(status)); // ... A-Z ...
- int32_t bucketIndex = index.getBucketIndex(UnicodeString((UChar)0x897f), status);
- assertEquals("getBucketIndex(U+897F)", (int32_t)((UChar)0x0058/*X*/ - (UChar)0x0041/*A*/ + 1), bucketIndex);
+ int32_t bucketIndex = index.getBucketIndex(UnicodeString((char16_t)0x897f), status);
+ assertEquals("getBucketIndex(U+897F)", (int32_t)((char16_t)0x0058/*X*/ - (char16_t)0x0041/*A*/ + 1), bucketIndex);
bucketIndex = index.getBucketIndex("i", status);
assertEquals("getBucketIndex(i)", 9, bucketIndex);
- bucketIndex = index.getBucketIndex(UnicodeString((UChar)0x03B1), status);
+ bucketIndex = index.getBucketIndex(UnicodeString((char16_t)0x03B1), status);
assertEquals("getBucketIndex(Greek alpha)", (int32_t)27, bucketIndex);
// U+50005 is an unassigned code point which sorts at the end, independent of the Hani group.
bucketIndex = index.getBucketIndex(UnicodeString((UChar32)0x50005), status);
assertEquals("getBucketIndex(U+50005)", 27, bucketIndex);
- bucketIndex = index.getBucketIndex(UnicodeString((UChar)0xFFFF), status);
+ bucketIndex = index.getBucketIndex(UnicodeString((char16_t)0xFFFF), status);
assertEquals("getBucketIndex(U+FFFF)", 27, bucketIndex);
}
TEST_CHECK_STATUS;
AlphabeticIndex index(coll.orphan(), status);
TEST_CHECK_STATUS;
- index.addRecord(UnicodeString((UChar)0x897f), nullptr, status);
+ index.addRecord(UnicodeString((char16_t)0x897f), nullptr, status);
index.addRecord("i", nullptr, status);
- index.addRecord(UnicodeString((UChar)0x03B1), nullptr, status);
+ index.addRecord(UnicodeString((char16_t)0x03B1), nullptr, status);
assertEquals("getBucketCount()", 1, index.getBucketCount(status)); // ...
TEST_ASSERT(index.nextBucket(status));
assertEquals("underflow label type", (int32_t)U_ALPHAINDEX_UNDERFLOW, index.getBucketLabelType());
LocalPointer<AlphabeticIndex::ImmutableIndex> immIndex(index.buildImmutableIndex(status));
TEST_CHECK_STATUS;
assertEquals("getBucketCount()", 38, immIndex->getBucketCount());
- assertEquals("label 1", UnicodeString((UChar)0x3105), immIndex->getBucket(1)->getLabel());
- assertEquals("label 2", UnicodeString((UChar)0x3106), immIndex->getBucket(2)->getLabel());
- assertEquals("label 3", UnicodeString((UChar)0x3107), immIndex->getBucket(3)->getLabel());
- assertEquals("label 4", UnicodeString((UChar)0x3108), immIndex->getBucket(4)->getLabel());
- assertEquals("label 5", UnicodeString((UChar)0x3109), immIndex->getBucket(5)->getLabel());
+ assertEquals("label 1", UnicodeString((char16_t)0x3105), immIndex->getBucket(1)->getLabel());
+ assertEquals("label 2", UnicodeString((char16_t)0x3106), immIndex->getBucket(2)->getLabel());
+ assertEquals("label 3", UnicodeString((char16_t)0x3107), immIndex->getBucket(3)->getLabel());
+ assertEquals("label 4", UnicodeString((char16_t)0x3108), immIndex->getBucket(4)->getLabel());
+ assertEquals("label 5", UnicodeString((char16_t)0x3109), immIndex->getBucket(5)->getLabel());
}
void AlphabeticIndexTest::TestJapaneseKanji() {
logln("Chinese/unihan has %d buckets/labels", bucketCount);
}
// bucketIndex = radical number, adjusted for simplified radicals in lower buckets.
- int32_t bucketIndex = index.getBucketIndex(UnicodeString((UChar)0x4e5d), status);
+ int32_t bucketIndex = index.getBucketIndex(UnicodeString((char16_t)0x4e5d), status);
assertEquals("getBucketIndex(U+4E5D)", 5, bucketIndex);
// radical 100, and there is a 90' since Unicode 8
- bucketIndex = index.getBucketIndex(UnicodeString((UChar)0x7527), status);
+ bucketIndex = index.getBucketIndex(UnicodeString((char16_t)0x7527), status);
assertEquals("getBucketIndex(U+7527)", 101, bucketIndex);
}
CollationKey sortkIgnorable;
// Most control codes and CGJ are completely ignorable.
// A string with only completely ignorables must compare equal to an empty string.
- col->getCollationKey(UnicodeString((UChar)1).append((UChar)0x34f), sortkIgnorable, key1Status);
+ col->getCollationKey(UnicodeString((char16_t)1).append((char16_t)0x34f), sortkIgnorable, key1Status);
sortkIgnorable.getByteArray(length);
doAssert(!sortkIgnorable.isBogus() && length == 3,
"Completely ignorable string should return a collation key with empty levels");
doAssert((*col1 == *col3), "Copied object is not equal to the original");
UCollationResult res;
- UnicodeString first((UChar)0x0061);
- UnicodeString second((UChar)0x0062);
+ UnicodeString first((char16_t)0x0061);
+ UnicodeString second((char16_t)0x0062);
UnicodeString copiedEnglishRules(((RuleBasedCollator*)col1)->getRules());
delete col1;
doAssert((col->greaterOrEqual(test1, test2) ), "Result should be \"Abcda\" == \"abcda\"");
// Test different APIs
- const UChar* t1 = test1.getBuffer();
+ const char16_t* t1 = test1.getBuffer();
int32_t t1Len = test1.length();
- const UChar* t2 = test2.getBuffer();
+ const char16_t* t2 = test2.getBuffer();
int32_t t2Len = test2.length();
doAssert((col->compare(test1, test2) == Collator::EQUAL), "Problem");
/* Need to use identical strength */
col->setAttribute(UCOL_STRENGTH, UCOL_IDENTICAL, status);
- UChar test1[6] = {0x41, 0x62, 0x63, 0x64, 0x61, 0},
+ char16_t test1[6] = {0x41, 0x62, 0x63, 0x64, 0x61, 0},
test2[6] = {0x61, 0x62, 0x63, 0x64, 0x61, 0},
test3[6] = {0x61, 0x62, 0x63, 0x64, 0x61, 0};
return;
}
col->setAttribute(UCOL_STRENGTH, UCOL_PRIMARY, errorCode);
- UChar i_and_phi[] = { 0x438, 0x3c6 }; // Cyrillic small i & Greek small phi.
+ char16_t i_and_phi[] = { 0x438, 0x3c6 }; // Cyrillic small i & Greek small phi.
// The sort key should be 6 bytes:
// 2 bytes for the Cyrillic i, 1 byte for the primary-compression terminator,
// 2 bytes for the Greek phi, and 1 byte for the NUL terminator.
}
// Insert an 'a' to match ++prefixLength.
- s.insert(prefixLength, (UChar)0x61);
+ s.insert(prefixLength, (char16_t)0x61);
}
}
void CollationAPITest::TestMaxExpansion()
{
UErrorCode status = U_ZERO_ERROR;
- UChar ch = 0;
+ char16_t ch = 0;
UChar32 unassigned = 0xEFFFD;
uint32_t sorder = 0;
uint32_t temporder = 0;
void CollationAPITest::TestVariableTopSetting() {
UErrorCode status = U_ZERO_ERROR;
- UChar vt[256] = { 0 };
+ char16_t vt[256] = { 0 };
// Use the root collator, not the default collator.
// This test fails with en_US_POSIX which tailors the dollar sign after 'A'.
errln("setVariableTop(dollar sign) != following getVariableTop()");
}
- UnicodeString dollar((UChar)0x24);
- UnicodeString euro((UChar)0x20AC);
+ UnicodeString dollar((char16_t)0x24);
+ UnicodeString euro((char16_t)0x20AC);
uint32_t newVarTop2 = coll->setVariableTop(euro, status);
assertEquals("setVariableTop(Euro sign) == following getVariableTop()",
(int64_t)newVarTop2, (int64_t)coll->getVariableTop(status));
coll->setAttribute(UCOL_ALTERNATE_HANDLING, UCOL_SHIFTED, status);
assertEquals("empty==dollar", (int32_t)UCOL_EQUAL, (int32_t)coll->compare(UnicodeString(), dollar));
assertEquals("empty==euro", (int32_t)UCOL_EQUAL, (int32_t)coll->compare(UnicodeString(), euro));
- assertEquals("dollar<zero", (int32_t)UCOL_LESS, (int32_t)coll->compare(dollar, UnicodeString((UChar)0x30)));
+ assertEquals("dollar<zero", (int32_t)UCOL_LESS, (int32_t)coll->compare(dollar, UnicodeString((char16_t)0x30)));
coll->setVariableTop(oldVarTop, status);
}
coll->setAttribute(UCOL_ALTERNATE_HANDLING, UCOL_SHIFTED, errorCode);
- assertEquals("empty==dollar", (int32_t)UCOL_EQUAL, (int32_t)coll->compare(UnicodeString(), UnicodeString((UChar)0x24)));
- assertEquals("empty==euro", (int32_t)UCOL_EQUAL, (int32_t)coll->compare(UnicodeString(), UnicodeString((UChar)0x20AC)));
- assertEquals("dollar<zero", (int32_t)UCOL_LESS, (int32_t)coll->compare(UnicodeString((UChar)0x24), UnicodeString((UChar)0x30)));
+ assertEquals("empty==dollar", (int32_t)UCOL_EQUAL, (int32_t)coll->compare(UnicodeString(), UnicodeString((char16_t)0x24)));
+ assertEquals("empty==euro", (int32_t)UCOL_EQUAL, (int32_t)coll->compare(UnicodeString(), UnicodeString((char16_t)0x20AC)));
+ assertEquals("dollar<zero", (int32_t)UCOL_LESS, (int32_t)coll->compare(UnicodeString((char16_t)0x24), UnicodeString((char16_t)0x30)));
}
void CollationAPITest::TestGetLocale() {
UErrorCode status = U_ZERO_ERROR;
const char *rules = "&a<x<y<z";
- UChar rlz[256] = {0};
+ char16_t rlz[256] = {0};
Collator *coll = Collator::createInstance("root", status);
if(U_FAILURE(status)) {
}
uint8_t sortkey[512], lower[512], upper[512];
- UChar buffer[512];
+ char16_t buffer[512];
static const char * const test[] = {
"John Smith",
const UnicodeString& target,
int32_t length,
UErrorCode& status) const override;
- virtual UCollationResult compare(const UChar* source,
+ virtual UCollationResult compare(const char16_t* source,
int32_t sourceLength,
- const UChar* target,
+ const char16_t* target,
int32_t targetLength,
UErrorCode& status) const override;
virtual CollationKey& getCollationKey(const UnicodeString& source,
CollationKey& key,
UErrorCode& status) const override;
- virtual CollationKey& getCollationKey(const UChar*source,
+ virtual CollationKey& getCollationKey(const char16_t*source,
int32_t sourceLength,
CollationKey& key,
UErrorCode& status) const override;
UErrorCode &status) override;
virtual UColAttributeValue getAttribute(UColAttribute attr,
UErrorCode &status) const override;
- virtual uint32_t setVariableTop(const UChar *varTop, int32_t len,
+ virtual uint32_t setVariableTop(const char16_t *varTop, int32_t len,
UErrorCode &status) override;
virtual uint32_t setVariableTop(const UnicodeString &varTop,
UErrorCode &status) override;
virtual int32_t getSortKey(const UnicodeString& source,
uint8_t* result,
int32_t resultLength) const override;
- virtual int32_t getSortKey(const UChar*source, int32_t sourceLength,
+ virtual int32_t getSortKey(const char16_t*source, int32_t sourceLength,
uint8_t*result, int32_t resultLength) const override;
virtual UnicodeSet *getTailoredSet(UErrorCode &status) const override;
virtual bool operator==(const Collator& other) const override;
}
}
-UCollationResult TestCollator::compare(const UChar* source,
+UCollationResult TestCollator::compare(const char16_t* source,
int32_t sourceLength,
- const UChar* target,
+ const char16_t* target,
int32_t targetLength,
UErrorCode& status) const
{
return key;
}
-CollationKey& TestCollator::getCollationKey(const UChar*source,
+CollationKey& TestCollator::getCollationKey(const char16_t*source,
int32_t sourceLength,
CollationKey& key,
UErrorCode& status) const
return length;
}
-int32_t TestCollator::getSortKey(const UChar*source, int32_t sourceLength,
+int32_t TestCollator::getSortKey(const char16_t*source, int32_t sourceLength,
uint8_t*result, int32_t resultLength) const
{
UnicodeString str(source, sourceLength);
return UCOL_DEFAULT;
}
-uint32_t TestCollator::setVariableTop(const UChar *varTop, int32_t len,
+uint32_t TestCollator::setVariableTop(const char16_t *varTop, int32_t len,
UErrorCode &status)
{
// api not used, this is to make the compiler happy
void CollationAPITest::TestNullptrCharTailoring()
{
UErrorCode status = U_ZERO_ERROR;
- UChar buf[256] = {0};
+ char16_t buf[256] = {0};
int32_t len = u_unescape("&a < '\\u0000'", buf, 256);
- UnicodeString first((UChar)0x0061);
- UnicodeString second((UChar)0);
+ UnicodeString first((char16_t)0x0061);
+ UnicodeString second((char16_t)0);
RuleBasedCollator *coll = new RuleBasedCollator(UnicodeString(buf, len), status);
if(U_FAILURE(status)) {
delete coll;
return;
}
rbc->setAttribute(UCOL_STRENGTH, UCOL_PRIMARY, errorCode);
- UnicodeString uUmlaut((UChar)0xfc);
+ UnicodeString uUmlaut((char16_t)0xfc);
UnicodeString ue = UNICODE_STRING_SIMPLE("ue");
assertEquals("rbc/primary: u-umlaut==ue", (int32_t)UCOL_EQUAL, rbc->compare(uUmlaut, ue, errorCode));
uint8_t bin[25000];
return true;
}
-static const UChar charFromBiDiClass[U_CHAR_DIRECTION_COUNT]={
+static const char16_t charFromBiDiClass[U_CHAR_DIRECTION_COUNT]={
0x6c, // 'l' for L
0x52, // 'R' for R
0x33, // '3' for EN
continue; // Skip empty and comment-only lines.
}
// Parse the code point string in field 0.
- UChar *buffer=inputString.getBuffer(200);
+ char16_t *buffer=inputString.getBuffer(200);
int32_t length=u_parseString(start, buffer, inputString.getCapacity(), nullptr, errorCode);
if(errorCode.errIfFailureAndReset("Invalid string in field 0")) {
errln("Input line %d: %s", (int)lineNumber, line);
}
}
-static UChar printLevel(UBiDiLevel level) {
+static char16_t printLevel(UBiDiLevel level) {
if(level<UBIDI_DEFAULT_LTR) {
return 0x30+level;
} else {
UnicodeString els("Expected levels: ");
int32_t i;
for(i=0; i<levelsCount; ++i) {
- els.append((UChar)0x20).append(printLevel(levels[i]));
+ els.append((char16_t)0x20).append(printLevel(levels[i]));
}
UnicodeString als("Actual levels: ");
for(i=0; i<actualCount; ++i) {
- als.append((UChar)0x20).append(printLevel(actualLevels[i]));
+ als.append((char16_t)0x20).append(printLevel(actualLevels[i]));
}
errln(els);
errln(als);
printErrorLine();
UnicodeString eord("Expected ordering: ");
for(i=0; i<orderingCount; ++i) {
- eord.append((UChar)0x20).append((UChar)(0x30+ordering[i]));
+ eord.append((char16_t)0x20).append((char16_t)(0x30+ordering[i]));
}
UnicodeString aord("Actual ordering: ");
for(i=0; i<resultLength; ++i) {
int32_t logicalIndex=ubidi_getLogicalIndex(ubidi, i, errorCode);
if(levels[logicalIndex]<UBIDI_DEFAULT_LTR) {
- aord.append((UChar)0x20).append((UChar)(0x30+logicalIndex));
+ aord.append((char16_t)0x20).append((char16_t)(0x30+logicalIndex));
}
}
errln(eord);
c->setLenient(true);
doTestCases(tests, c);
- static const UChar expectedUChars[] = {
+ static const char16_t expectedUChars[] = {
0x0627, 0x0644, 0x062e, 0x0645, 0x064a, 0x0633, 0x060c, 0x0020, 0x0662, 0x0662, 0x0020,
0x0634, 0x0648, 0x0627, 0x0644, 0x0020, 0x0661, 0x0663, 0x0668, 0x0669, 0x0020, 0x0647, 0x0640, 0
};
UnicodeString buf1, buf2;
- const UChar* id;
+ const char16_t* id;
while ((id = tz->unext(nullptr, ec)) != nullptr && U_SUCCESS(ec)) {
if (U_FAILURE(ec)) {
errln("FAIL: StringEnumeration::unext");
values->reset(status);
containsHebrew = false;
UnicodeString hebrew = UNICODE_STRING_SIMPLE("hebrew");
- const UChar *ucharValue;
+ const char16_t *ucharValue;
while ((ucharValue = values->unext(&valueLength, status)) != nullptr) {
UnicodeString value(false, ucharValue, valueLength);
if (value == hebrew) {
uzone.length(), nullptr, 0, &status));
if (df.isNull() || U_FAILURE(status)) return;
- UChar upattern[64];
+ char16_t upattern[64];
u_uastrcpy(upattern, "EEE d MMMM y G, HH:mm:ss");
udat_applyPattern(df.getAlias(), false, upattern, u_strlen(upattern));
- UChar ubuffer[1024];
+ char16_t ubuffer[1024];
UDate ud0 = 1337557623000.0;
status = U_ZERO_ERROR;
{ 0, 0, 0, 0, 0, 0 }, // terminator
};
-static const UChar zoneSA[] = {0x41,0x73,0x69,0x61,0x2F,0x52,0x69,0x79,0x61,0x64,0x68,0}; // "Asia/Riyadh"
+static const char16_t zoneSA[] = {0x41,0x73,0x69,0x61,0x2F,0x52,0x69,0x79,0x61,0x64,0x68,0}; // "Asia/Riyadh"
void CalendarTest::TestIslamicUmAlQura() {
virtual int32_t hashCode(void) const override {
return DONE;
}
- virtual UChar nextPostInc(void) override { return text.charAt(pos++);}
+ virtual char16_t nextPostInc(void) override { return text.charAt(pos++);}
virtual UChar32 next32PostInc(void) override {return text.char32At(pos++);}
virtual UBool hasNext() override { return true;}
- virtual UChar first() override {return DONE;}
+ virtual char16_t first() override {return DONE;}
virtual UChar32 first32() override {return DONE;}
- virtual UChar last() override {return DONE;}
+ virtual char16_t last() override {return DONE;}
virtual UChar32 last32() override {return DONE;}
- virtual UChar setIndex(int32_t /*pos*/) override {return DONE;}
+ virtual char16_t setIndex(int32_t /*pos*/) override {return DONE;}
virtual UChar32 setIndex32(int32_t /*pos*/) override {return DONE;}
- virtual UChar current() const override {return DONE;}
+ virtual char16_t current() const override {return DONE;}
virtual UChar32 current32() const override {return DONE;}
- virtual UChar next() override {return DONE;}
+ virtual char16_t next() override {return DONE;}
virtual UChar32 next32() override {return DONE;}
- virtual UChar previous() override {return DONE;}
+ virtual char16_t previous() override {return DONE;}
virtual UChar32 previous32() override {return DONE;}
virtual int32_t move(int32_t delta,CharacterIterator::EOrigin origin) override {
switch(origin) {
void CharIterTest::TestIteration() {
UnicodeString text("Now is the time for all good men to come to the aid of their country.");
- UChar c;
+ char16_t c;
int32_t i;
{
StringCharacterIterator iter(text, 5);
//Tests for new API for utf-16 support
void CharIterTest::TestIterationUChar32() {
- UChar textChars[]={ 0x0061, 0x0062, 0xd841, 0xdc02, 0x20ac, 0xd7ff, 0xd842, 0xdc06, 0xd801, 0xdc00, 0x0061, 0x0000};
+ char16_t textChars[]={ 0x0061, 0x0062, 0xd841, 0xdc02, 0x20ac, 0xd7ff, 0xd842, 0xdc06, 0xd801, 0xdc00, 0x0061, 0x0000};
UnicodeString text(textChars);
UChar32 c;
int32_t i;
}
// useful stuff, mostly dummy but testing coverage and subclassability
- virtual UChar nextPostInc() override {
+ virtual char16_t nextPostInc() override {
if(pos<UPRV_LENGTHOF(s)) {
return s[pos++];
} else {
return pos<UPRV_LENGTHOF(s);
}
- virtual UChar first() override {
+ virtual char16_t first() override {
pos=0;
return s[0];
}
return c;
}
- virtual UChar setIndex(int32_t position) override {
+ virtual char16_t setIndex(int32_t position) override {
if(0<=position && position<=UPRV_LENGTHOF(s)) {
pos=position;
if(pos<UPRV_LENGTHOF(s)) {
return DONE;
}
- virtual UChar current() const override {
+ virtual char16_t current() const override {
if(pos<UPRV_LENGTHOF(s)) {
return s[pos];
} else {
}
}
- virtual UChar next() override {
+ virtual char16_t next() override {
if(pos<UPRV_LENGTHOF(s) && ++pos<UPRV_LENGTHOF(s)) {
return s[pos];
} else {
return nullptr;
}
- virtual UChar last() override {
+ virtual char16_t last() override {
return 0;
}
return 0;
}
- virtual UChar previous() override {
+ virtual char16_t previous() override {
return 0;
}
private:
// dummy string data
- UChar s[4];
+ char16_t s[4];
static const char fgClassID;
};
}
private:
- static const UChar u[3];
+ static const char16_t u[3];
};
-const UChar SubUCharCharIter::u[3]={ 0x61, 0x62, 0x63 };
+const char16_t SubUCharCharIter::u[3]={ 0x61, 0x62, 0x63 };
void CharIterTest::TestCharIteratorSubClasses() {
SubCharIter *p;
static UnicodeString printCollationKey(const CollationKey &key);
// Helpers & fields for data-driven test.
- static UBool isCROrLF(UChar c) { return c == 0xa || c == 0xd; }
- static UBool isSpace(UChar c) { return c == 9 || c == 0x20 || c == 0x3000; }
- static UBool isSectionStarter(UChar c) { return c == 0x25 || c == 0x2a || c == 0x40; } // %*@
+ static UBool isCROrLF(char16_t c) { return c == 0xa || c == 0xd; }
+ static UBool isSpace(char16_t c) { return c == 9 || c == 0x20 || c == 0x3000; }
+ static UBool isSectionStarter(char16_t c) { return c == 0x25 || c == 0x2a || c == 0x40; } // %*@
int32_t skipSpaces(int32_t i) {
while(isSpace(fileLine[i])) { ++i; }
return i;
UBool needsNormalization(const UnicodeString &s, UErrorCode &errorCode) const;
- UBool getSortKeyParts(const UChar *s, int32_t length,
+ UBool getSortKeyParts(const char16_t *s, int32_t length,
CharString &dest, int32_t partSize,
IcuTestErrorCode &errorCode);
UBool getCollationKey(const char *norm, const UnicodeString &line,
- const UChar *s, int32_t length,
+ const char16_t *s, int32_t length,
CollationKey &key, IcuTestErrorCode &errorCode);
- UBool getMergedCollationKey(const UChar *s, int32_t length,
+ UBool getMergedCollationKey(const char16_t *s, int32_t length,
CollationKey &key, IcuTestErrorCode &errorCode);
UBool checkCompareTwo(const char *norm, const UnicodeString &prevFileLine,
const UnicodeString &prevString, const UnicodeString &s,
return;
}
- static const UChar s[2] = { 0xfffe, 0xffff };
+ static const char16_t s[2] = { 0xfffe, 0xffff };
UVector64 ces(errorCode);
rbc->internalGetCEs(UnicodeString(false, s, 2), ces, errorCode);
errorCode.assertSuccess();
return;
}
- static const UChar s[] = { 0x61, 0x62, 0x61, 0x62, 0 };
+ static const char16_t s[] = { 0x61, 0x62, 0x61, 0x62, 0 };
UTF16CollationIterator ci1(data, false, s, s, s + 2);
UTF16CollationIterator ci2(data, false, s + 2, s + 2, nullptr);
}
// Input string, not FCD, NUL-terminated.
- static const UChar s[] = {
+ static const char16_t s[] = {
0x308, 0xe1, 0x62, 0x301, 0x327, 0x430, 0x62,
U16_LEAD(0x1D15F), U16_TRAIL(0x1D15F), // MUSICAL SYMBOL QUARTER NOTE=1D158 1D165, ccc=0, 216
0x327, 0x308, // ccc=202, 230
UnicodeString CollationTest::printSortKey(const uint8_t *p, int32_t length) {
UnicodeString s;
for(int32_t i = 0; i < length; ++i) {
- if(i > 0) { s.append((UChar)0x20); }
+ if(i > 0) { s.append((char16_t)0x20); }
uint8_t b = p[i];
if(b == 0) {
- s.append((UChar)0x2e); // period
+ s.append((char16_t)0x2e); // period
} else if(b == 1) {
- s.append((UChar)0x7c); // vertical bar
+ s.append((char16_t)0x7c); // vertical bar
} else {
appendHex(b, 2, s);
}
UBool CollationTest::readNonEmptyLine(UCHARBUF *f, IcuTestErrorCode &errorCode) {
for(;;) {
int32_t lineLength;
- const UChar *line = ucbuf_readline(f, &lineLength, errorCode);
+ const char16_t *line = ucbuf_readline(f, &lineLength, errorCode);
if(line == nullptr || errorCode.isFailure()) {
fileLine.remove();
return false;
}
++fileLineNumber;
// Strip trailing CR/LF, comments, and spaces.
- const UChar *comment = u_memchr(line, 0x23, lineLength); // '#'
+ const char16_t *comment = u_memchr(line, 0x23, lineLength); // '#'
if(comment != nullptr) {
lineLength = (int32_t)(comment - line);
} else {
int32_t length = fileLine.length();
int32_t i;
for(i = start; i < length && !isSpace(fileLine[i]); ++i) {}
- int32_t pipeIndex = fileLine.indexOf((UChar)0x7c, start, i - start); // '|'
+ int32_t pipeIndex = fileLine.indexOf((char16_t)0x7c, start, i - start); // '|'
if(pipeIndex >= 0) {
prefix = fileLine.tempSubStringBetween(start, pipeIndex).unescape();
if(prefix.isEmpty()) {
Collation::Level relation;
int32_t start;
if(fileLine[0] == 0x3c) { // <
- UChar second = fileLine[1];
+ char16_t second = fileLine[1];
start = 2;
switch(second) {
case 0x31: // <1
// Parse attributes even if the Collator could not be created,
// in order to report syntax errors.
int32_t start = skipSpaces(1);
- int32_t equalPos = fileLine.indexOf((UChar)0x3d);
+ int32_t equalPos = fileLine.indexOf((char16_t)0x3d);
if(equalPos < 0) {
if(fileLine.compare(start, 7, UNICODE_STRING("reorder", 7)) == 0) {
parseAndSetReorderCodes(start + 7, errorCode);
if(errorCode.isFailure()) { return; }
delete coll;
coll = nullptr;
- int32_t at = fileLine.indexOf((UChar)0x40, 9); // @ is not invariant
+ int32_t at = fileLine.indexOf((char16_t)0x40, 9); // @ is not invariant
if(at >= 0) {
- fileLine.setCharAt(at, (UChar)0x2a); // *
+ fileLine.setCharAt(at, (char16_t)0x2a); // *
}
CharString localeID;
localeID.appendInvariantChars(fileLine.tempSubString(9), errorCode);
// those composites must be decomposed.
// Check if s contains 0F71 immediately followed by 0F73 or 0F75 or 0F81.
int32_t index = 0;
- while((index = s.indexOf((UChar)0xf71, index)) >= 0) {
+ while((index = s.indexOf((char16_t)0xf71, index)) >= 0) {
if(++index < s.length()) {
- UChar c = s[index];
+ char16_t c = s[index];
if(c == 0xf73 || c == 0xf75 || c == 0xf81) { return true; }
}
}
return false;
}
-UBool CollationTest::getSortKeyParts(const UChar *s, int32_t length,
+UBool CollationTest::getSortKeyParts(const char16_t *s, int32_t length,
CharString &dest, int32_t partSize,
IcuTestErrorCode &errorCode) {
if(errorCode.isFailure()) { return false; }
}
UBool CollationTest::getCollationKey(const char *norm, const UnicodeString &line,
- const UChar *s, int32_t length,
+ const char16_t *s, int32_t length,
CollationKey &key, IcuTestErrorCode &errorCode) {
if(errorCode.isFailure()) { return false; }
coll->getCollationKey(s, length, key, errorCode);
* Leaves key unchanged if s does not contain U+FFFE.
* @return true if the key was successfully changed
*/
-UBool CollationTest::getMergedCollationKey(const UChar *s, int32_t length,
+UBool CollationTest::getMergedCollationKey(const char16_t *s, int32_t length,
CollationKey &key, IcuTestErrorCode &errorCode) {
if(errorCode.isFailure()) { return false; }
LocalMemory<uint8_t> mergedKey;
if(buffer.length() < i) {
buffer.append(s, buffer.length(), i - buffer.length());
}
- buffer.append((UChar)0xfffd);
+ buffer.append((char16_t)0xfffd);
}
i += U16_LENGTH(c);
}
return false;
}
// Test NUL-termination if the strings do not contain NUL characters.
- UBool containNUL = prevString.indexOf((UChar)0) >= 0 || s.indexOf((UChar)0) >= 0;
+ UBool containNUL = prevString.indexOf((char16_t)0) >= 0 || s.indexOf((char16_t)0) >= 0;
if(!containNUL) {
order = coll->compare(prevString.getBuffer(), -1, s.getBuffer(), -1, errorCode);
if(order != expectedOrder || errorCode.isFailure()) {
strings[listSize++].append(*string);
}
-void StringList::add(const UChar *chars, int32_t count, UErrorCode &status)
+void StringList::add(const char16_t *chars, int32_t count, UErrorCode &status)
{
const UnicodeString string(chars, count);
itemCount = uset_getItemCount(charsToTest);
for(int32_t item = 0; item < itemCount; item += 1) {
UChar32 start = 0, end = 0;
- UChar buffer[16];
+ char16_t buffer[16];
int32_t len = uset_getItem(charsToTest, item, &start, &end,
buffer, 16, &status);
// and there are also more Jamo T at U+D7CB..U+D7FB.
// Maybe use [:HST=T:] and look for the end of the last range?
// Maybe use script boundary mappings instead of this code??
- UChar jamoRanges[] = {Hangul::JAMO_L_BASE, Hangul::JAMO_V_BASE, Hangul::JAMO_T_BASE + 1, 0x11FF};
+ char16_t jamoRanges[] = {Hangul::JAMO_L_BASE, Hangul::JAMO_V_BASE, Hangul::JAMO_T_BASE + 1, 0x11FF};
UnicodeString jamoString(false, jamoRanges, UPRV_LENGTHOF(jamoRanges));
CEList hanList(coll, hanString, status);
CEList jamoList(coll, jamoString, status);
* @param count - the number of code points in the array
* @param status - will be set if any errors occur.
*/
- void add(const UChar *chars, int32_t count, UErrorCode &status);
+ void add(const char16_t *chars, int32_t count, UErrorCode &status);
/**
* Get a particular string from the list.
void CheckLocale(
const Locale& locale, UNumberCompactStyle style,
const ExpectedResult* expectedResults, int32_t expectedResultLength);
- void CheckLocaleWithCurrency(const Locale& locale, UNumberCompactStyle style, const UChar* currency,
+ void CheckLocaleWithCurrency(const Locale& locale, UNumberCompactStyle style, const char16_t* currency,
const ExpectedResult* expectedResults, int32_t expectedResultLength);
void CheckExpectedResult(
const CompactDecimalFormat* cdf, const ExpectedResult* expectedResult,
}
void CompactDecimalFormatTest::CheckLocaleWithCurrency(const Locale& locale, UNumberCompactStyle style,
- const UChar* currency,
+ const char16_t* currency,
const ExpectedResult* expectedResults,
int32_t expectedResultLength) {
UErrorCode status = U_ZERO_ERROR;
TestDataModule *dataModule;
TestData *testData;
const DataMap *testCase;
- const UChar *p;
+ const char16_t *p;
UErrorCode errorCode;
int32_t i, length;
s=testCase->getString("callback", errorCode);
cc.setSub=0; // default: no subchar
- if((index=s.indexOf((UChar)0))>0) {
+ if((index=s.indexOf((char16_t)0))>0) {
// read NUL-separated subchar first, if any
// copy the subchar from Latin-1 characters
// start after the NUL
// remove the NUL and subchar from s
s.truncate(index);
- } else if((index=s.indexOf((UChar)0x3d))>0) /* '=' */ {
+ } else if((index=s.indexOf((char16_t)0x3d))>0) /* '=' */ {
// read a substitution string, separated by an equal sign
p=s.getBuffer()+index+1;
length=s.length()-(index+1);
}
}
-static const UChar ellipsis[]={ 0x2e, 0x2e, 0x2e };
+static const char16_t ellipsis[]={ 0x2e, 0x2e, 0x2e };
void
ConversionTest::TestGetUnicodeSet() {
static void U_CALLCONV
getUnicodeSetCallback(const void *context,
UConverterFromUnicodeArgs * /*fromUArgs*/,
- const UChar* /*codeUnits*/,
+ const char16_t* /*codeUnits*/,
int32_t /*length*/,
UChar32 codePoint,
UConverterCallbackReason reason,
cpLimit=0x110000;
s0Length=0x10000+0x200000; // BMP + surrogate pairs
}
- UChar *s0=new UChar[s0Length];
+ char16_t *s0=new char16_t[s0Length];
if(s0==nullptr) {
return;
}
- UChar *s=s0;
+ char16_t *s=s0;
UChar32 c;
- UChar c2;
+ char16_t c2;
// low BMP
for(c=0; c<=0xd7ff; ++c) {
- *s++=(UChar)c;
+ *s++=(char16_t)c;
}
// trail surrogates
for(c=0xdc00; c<=0xdfff; ++c) {
- *s++=(UChar)c;
+ *s++=(char16_t)c;
}
// lead surrogates
// (after trails so that there is not even one surrogate pair in between)
for(c=0xd800; c<=0xdbff; ++c) {
- *s++=(UChar)c;
+ *s++=(char16_t)c;
}
// high BMP
for(c=0xe000; c<=0xffff; ++c) {
- *s++=(UChar)c;
+ *s++=(char16_t)c;
}
// supplementary code points = surrogate pairs
if(cpLimit==0x110000) {
for(c=0xd800; c<=0xdbff; ++c) {
for(c2=0xdc00; c2<=0xdfff; ++c2) {
- *s++=(UChar)c;
+ *s++=(char16_t)c;
*s++=c2;
}
}
do {
char *t=buffer;
flush=(UBool)(s==s0+s0Length);
- ucnv_fromUnicode(cnv.getAlias(), &t, buffer+sizeof(buffer), (const UChar **)&s, s0+s0Length, nullptr, flush, &errorCode);
+ ucnv_fromUnicode(cnv.getAlias(), &t, buffer+sizeof(buffer), (const char16_t **)&s, s0+s0Length, nullptr, flush, &errorCode);
if(U_FAILURE(errorCode)) {
if(errorCode==U_BUFFER_OVERFLOW_ERROR) {
errorCode=U_ZERO_ERROR;
char result[20];
char *target = result;
const char *targetLimit = result + sizeof(result);
- UChar buffer16[20];
- UChar *pivotSource = buffer16;
- UChar *pivotTarget = buffer16;
- const UChar *pivotLimit = buffer16 + UPRV_LENGTHOF(buffer16);
+ char16_t buffer16[20];
+ char16_t *pivotSource = buffer16;
+ char16_t *pivotTarget = buffer16;
+ const char16_t *pivotLimit = buffer16 + UPRV_LENGTHOF(buffer16);
int32_t length;
// Convert with insufficient target capacity.
char* target = result;
const char* targetLimit = result + targetLen;
- UChar buffer16[20];
- UChar* pivotSource = buffer16;
- UChar* pivotTarget = buffer16;
- const UChar* pivotLimit = buffer16 + UPRV_LENGTHOF(buffer16);
+ char16_t buffer16[20];
+ char16_t* pivotSource = buffer16;
+ char16_t* pivotTarget = buffer16;
+ const char16_t* pivotLimit = buffer16 + UPRV_LENGTHOF(buffer16);
int32_t length;
ucnv_convertEx(cnv2.getAlias(), cnv1.getAlias(),
}
static char *
-printUnicode(const UChar *unicode, int32_t length, char *out) {
+printUnicode(const char16_t *unicode, int32_t length, char *out) {
UChar32 c;
int32_t i;
static int32_t
stepToUnicode(ConversionCase &cc, UConverter *cnv,
- UChar *result, int32_t resultCapacity,
+ char16_t *result, int32_t resultCapacity,
int32_t *resultOffsets, /* also resultCapacity */
int32_t step,
UErrorCode *pErrorCode) {
const char *source, *sourceLimit, *bytesLimit;
- UChar *target, *targetLimit, *resultLimit;
+ char16_t *target, *targetLimit, *resultLimit;
UBool flush;
source=(const char *)cc.bytes;
break;
}
if(c<=0xffff) {
- *target++=(UChar)c;
+ *target++=(char16_t)c;
} else {
*target++=U16_LEAD(c);
if(target==resultLimit) {
++step;
}
} else /* step is even */ {
- // allow only one UChar output
+ // allow only one char16_t output
targetLimit=target<resultLimit ? target+1 : resultLimit;
// as with ucnv_getNextUChar(), we always flush (if we go to bytesLimit)
}
int32_t resultOffsets[256];
- UChar result[256];
+ char16_t result[256];
int32_t resultLength;
UBool ok;
errln("toUnicode[%d](%s) Conversion wrote too much to offsets at index %d",
cc.caseNr, cc.charset, resultLength);
}
- if (result[resultLength] != (UChar)-1) {
+ if (result[resultLength] != (char16_t)-1) {
errln("toUnicode[%d](%s) Conversion wrote too much to result at index %d",
cc.caseNr, cc.charset, resultLength);
}
UBool
ConversionTest::checkToUnicode(ConversionCase &cc, UConverter *cnv, const char *name,
- const UChar *result, int32_t resultLength,
+ const char16_t *result, int32_t resultLength,
const int32_t *resultOffsets,
UErrorCode resultErrorCode) {
char resultInvalidChars[8];
int32_t step,
UErrorCode *pErrorCode) {
const char *source, *sourceLimit, *utf8Limit;
- UChar pivotBuffer[32];
- UChar *pivotSource, *pivotTarget, *pivotLimit;
+ char16_t pivotBuffer[32];
+ char16_t *pivotSource, *pivotTarget, *pivotLimit;
char *target, *targetLimit, *resultLimit;
UBool flush;
int32_t *resultOffsets, /* also resultCapacity */
int32_t step,
UErrorCode *pErrorCode) {
- const UChar *source, *sourceLimit, *unicodeLimit;
+ const char16_t *source, *sourceLimit, *unicodeLimit;
char *target, *targetLimit, *resultLimit;
UBool flush;
const uint8_t *result, int32_t resultLength,
const int32_t *resultOffsets,
UErrorCode resultErrorCode) {
- UChar resultInvalidUChars[8];
+ char16_t resultInvalidUChars[8];
int8_t resultInvalidLength;
UErrorCode errorCode;
/* setup */
int32_t caseNr;
const char *charset, *cbopt, *name;
- UChar subString[16];
+ char16_t subString[16];
char subchar[8];
int8_t setSub;
/* input and expected output */
const uint8_t *bytes;
int32_t bytesLength;
- const UChar *unicode;
+ const char16_t *unicode;
int32_t unicodeLength;
const int32_t *offsets;
UBool fallbacks;
UErrorCode outErrorCode;
const uint8_t *invalidChars;
- const UChar *invalidUChars;
+ const char16_t *invalidUChars;
int32_t invalidLength;
/* actual output */
uint8_t resultBytes[200];
- UChar resultUnicode[200];
+ char16_t resultUnicode[200];
int32_t resultOffsets[200];
int32_t resultLength;
UBool
checkToUnicode(ConversionCase &cc, UConverter *cnv, const char *name,
- const UChar *result, int32_t resultLength,
+ const char16_t *result, int32_t resultLength,
const int32_t *resultOffsets,
UErrorCode resultErrorCode);
/**
* Splits a UnicodeString
*/
-UnicodeString* CompoundTransliteratorTest::split(const UnicodeString& str, UChar seperator, int32_t& count) {
+UnicodeString* CompoundTransliteratorTest::split(const UnicodeString& str, char16_t seperator, int32_t& count) {
//get the count
int32_t i;
/**
* Splits a UnicodeString
*/
- UnicodeString* split(const UnicodeString& str, UChar seperator, int32_t& count);
+ UnicodeString* split(const UnicodeString& str, char16_t seperator, int32_t& count);
void expect(const CompoundTransliterator& t,
const UnicodeString& source,
}
}
-static UnicodeString *split(const UnicodeString &src, UChar ch, int32_t &splits)
+static UnicodeString *split(const UnicodeString &src, char16_t ch, int32_t &splits)
{
int32_t offset = -1;
UnicodeString name(ucsdet_getName(matches[0], &status));
UnicodeString lang(ucsdet_getLanguage(matches[0], &status));
- UChar *decoded = nullptr;
+ char16_t *decoded = nullptr;
int32_t dLength = 0;
if (matchCount == 0) {
return;
}
- decoded = new UChar[testLength];
+ decoded = new char16_t[testLength];
dLength = ucsdet_getUChars(matches[0], decoded, testLength, &status);
if (testString.compare(decoded, dLength) != 0) {
char *bytes = extractBytes(s, "UTF-8", byteLength);
UCharsetDetector *csd = ucsdet_open(&status);
const UCharsetMatch *match;
- UChar *detected = new UChar[sLength];
+ char16_t *detected = new char16_t[sLength];
ucsdet_setText(csd, bytes, byteLength, &status);
match = ucsdet_detect(csd, &status);
{
UErrorCode status = U_ZERO_ERROR;
/* Notice the BOM on the start of this string */
- UChar chars[] = {
+ char16_t chars[] = {
0xFEFF, 0x0623, 0x0648, 0x0631, 0x0648, 0x0628, 0x0627, 0x002C,
0x0020, 0x0628, 0x0631, 0x0645, 0x062c, 0x064a, 0x0627, 0x062a,
0x0020, 0x0627, 0x0644, 0x062d, 0x0627, 0x0633, 0x0648, 0x0628,
#if !UCONFIG_ONLY_HTML_CONVERSION
UErrorCode status = U_ZERO_ERROR;
- static const UChar chars[] = {
+ static const char16_t chars[] = {
0x05D4, 0x05E4, 0x05E8, 0x05E7, 0x05DC, 0x05D9, 0x05D8, 0x0020, 0x05D4, 0x05E6, 0x05D1, 0x05D0, 0x05D9, 0x0020, 0x05D4, 0x05E8,
0x05D0, 0x05E9, 0x05D9, 0x002C, 0x0020, 0x05EA, 0x05EA, 0x0020, 0x05D0, 0x05DC, 0x05D5, 0x05E3, 0x0020, 0x05D0, 0x05D1, 0x05D9,
0x05D7, 0x05D9, 0x0020, 0x05DE, 0x05E0, 0x05D3, 0x05DC, 0x05D1, 0x05DC, 0x05D9, 0x05D8, 0x002C, 0x0020, 0x05D4, 0x05D5, 0x05E8,
0x05EA, 0x05DE, 0x05DC, 0x05D9, 0x05DC, 0x0020, 0x05D4, 0x05E2, 0x05D3, 0x05D5, 0x05D9, 0x05D5, 0x05EA, 0x0000
};
- static const UChar chars_reverse[] = {
+ static const char16_t chars_reverse[] = {
0x05EA, 0x05D5, 0x05D9, 0x05D5, 0x05D3, 0x05E2, 0x05D4, 0x0020, 0x05DC, 0x05D9, 0x05DC, 0x05DE, 0x05EA,
0x05D1, 0x0020, 0x05DF, 0x05D9, 0x05D9, 0x05E2, 0x05E9, 0x0020, 0x05E8, 0x05D7, 0x05D0, 0x05DC, 0x0020, 0x05D5, 0x05EA, 0x05D8,
0x05DC, 0x05D7, 0x05D4, 0x0020, 0x05EA, 0x05D0, 0x0020, 0x05DC, 0x05D1, 0x05D9, 0x05E7, 0x0020, 0x05D8, 0x05D9, 0x05DC, 0x05D1,
#if !UCONFIG_ONLY_HTML_CONVERSION
UErrorCode status = U_ZERO_ERROR;
- static const UChar chars[] = {
+ static const char16_t chars[] = {
0x0648, 0x064F, 0x0636, 0x0639, 0x062A, 0x0020, 0x0648, 0x0646, 0x064F, 0x0641, 0x0630, 0x062A, 0x0020, 0x0628, 0x0631, 0x0627,
0x0645, 0x062C, 0x0020, 0x062A, 0x0623, 0x0645, 0x064A, 0x0646, 0x0020, 0x0639, 0x062F, 0x064A, 0x062F, 0x0629, 0x0020, 0x0641,
0x064A, 0x0020, 0x0645, 0x0624, 0x0633, 0x0633, 0x0629, 0x0020, 0x0627, 0x0644, 0x062A, 0x0623, 0x0645, 0x064A, 0x0646, 0x0020,
0x062F, 0x064A, 0x0629, 0x0020, 0x0648, 0x0627, 0x0644, 0x0627, 0x062C, 0x062A, 0x0645, 0x0627, 0x0639, 0x064A, 0x0629, 0x002E,
0x0000
};
- static const UChar chars_reverse[] = {
+ static const char16_t chars_reverse[] = {
0x002E, 0x0629, 0x064A, 0x0639, 0x0627, 0x0645, 0x062A, 0x062C, 0x0627, 0x0644, 0x0627, 0x0648, 0x0020, 0x0629, 0x064A, 0x062F,
0x0627, 0x0635, 0x062A, 0x0642, 0x0627, 0x0644, 0x0627, 0x0020, 0x0631, 0x0637, 0x0627, 0x062E, 0x0645, 0x0644, 0x0627, 0x0020,
0x0647, 0x062C, 0x0648, 0x0628, 0x0020, 0x0644, 0x064A, 0x0626, 0x0627, 0x0631, 0x0633, 0x0627, 0x0020, 0x0629, 0x0644, 0x0648,
void CollationCurrencyTest::currencyTest(/*char *par*/)
{
// All the currency symbols, in collation order
- static const UChar currency[][2] =
+ static const char16_t currency[][2] =
{
{ 0x00A4, 0x0000}, /*00A4; L; [14 36, 03, 03] # [082B.0020.0002] # CURRENCY SIGN*/
{ 0x00A2, 0x0000}, /*00A2; L; [14 38, 03, 03] # [082C.0020.0002] # CENT SIGN*/
void DataDrivenCalendarTest::processTest(TestData *testData) {
//Calendar *cal= nullptr;
- //const UChar *arguments= nullptr;
+ //const char16_t *arguments= nullptr;
//int32_t argLen = 0;
char testType[256] = "";
const DataMap *settings= nullptr;
- //const UChar *type= nullptr;
+ //const char16_t *type= nullptr;
UErrorCode status = U_ZERO_ERROR;
UnicodeString testSetting;
int n = 0;
void DataDrivenFormatTest::processTest(TestData *testData) {
//Format *cal= nullptr;
- //const UChar *arguments= nullptr;
+ //const char16_t *arguments= nullptr;
//int32_t argLen = 0;
char testType[256] = "";
const DataMap *settings= nullptr;
- //const UChar *type= nullptr;
+ //const char16_t *type= nullptr;
UErrorCode status = U_ZERO_ERROR;
UnicodeString testSetting;
int n = 0;
#include "unicode/localpointer.h"
#include "ustrfmt.h"
-static UBool isCROrLF(UChar c) { return c == 0xa || c == 0xd; }
-static UBool isSpace(UChar c) { return c == 9 || c == 0x20 || c == 0x3000; }
+static UBool isCROrLF(char16_t c) { return c == 0xa || c == 0xd; }
+static UBool isSpace(char16_t c) { return c == 9 || c == 0x20 || c == 0x3000; }
void DataDrivenNumberFormatTestSuite::run(const char *fileName, UBool runAllTests) {
fFileLineNumber = 0;
}
UBool DataDrivenNumberFormatTestSuite::breaksC() {
- return (NFTT_GET_FIELD(fTuple, breaks, "").toUpper().indexOf((UChar)0x43) != -1);
+ return (NFTT_GET_FIELD(fTuple, breaks, "").toUpper().indexOf((char16_t)0x43) != -1);
}
void DataDrivenNumberFormatTestSuite::setTupleField(UErrorCode &status) {
DataDrivenNumberFormatTestSuite::splitBy(
UnicodeString *columnValues,
int32_t columnValuesCount,
- UChar delimiter) {
+ char16_t delimiter) {
int32_t colIdx = 0;
int32_t colStart = 0;
int32_t len = fFileLine.length();
for (int32_t idx = 0; colIdx < columnValuesCount - 1 && idx < len; ++idx) {
- UChar ch = fFileLine.charAt(idx);
+ char16_t ch = fFileLine.charAt(idx);
if (ch == delimiter) {
columnValues[colIdx++] =
fFileLine.tempSubString(colStart, idx - colStart);
}
void DataDrivenNumberFormatTestSuite::showFailure(const UnicodeString &message) {
- UChar lineStr[20];
+ char16_t lineStr[20];
uprv_itou(
lineStr, UPRV_LENGTHOF(lineStr), (uint32_t) fFileLineNumber, 10, 1);
UnicodeString fullMessage("line ");
UBool DataDrivenNumberFormatTestSuite::readLine(
UCHARBUF *f, UErrorCode &status) {
int32_t lineLength;
- const UChar *line = ucbuf_readline(f, &lineLength, &status);
+ const char16_t *line = ucbuf_readline(f, &lineLength, &status);
if(line == nullptr || U_FAILURE(status)) {
if (U_FAILURE(status)) {
errln("Error reading line from file.");
int32_t splitBy(
UnicodeString *columnValues,
int32_t columnValueCount,
- UChar delimiter);
+ char16_t delimiter);
void showError(const char *message);
void showFailure(const UnicodeString &message);
void showLineInfo();
}
int32_t len;
- UChar *testData = ReadAndConvertFile(srcPath, len, "utf-8", status);
+ char16_t *testData = ReadAndConvertFile(srcPath, len, "utf-8", status);
if (U_FAILURE(status)) {
return; /* something went wrong, error already output */
}
delete myCollation;
}
-const UChar CollationGermanTest::testSourceCases[][CollationGermanTest::MAX_TOKEN_LEN] =
+const char16_t CollationGermanTest::testSourceCases[][CollationGermanTest::MAX_TOKEN_LEN] =
{
{0x47, 0x72, 0x00F6, 0x00DF, 0x65, 0},
{0x61, 0x62, 0x63, 0},
{0x53, 0x74, 0x72, 0x61, 0x00DF, 0x65, 0}
};
-const UChar CollationGermanTest::testTargetCases[][CollationGermanTest::MAX_TOKEN_LEN] =
+const char16_t CollationGermanTest::testTargetCases[][CollationGermanTest::MAX_TOKEN_LEN] =
{
{0x47, 0x72, 0x6f, 0x73, 0x73, 0x69, 0x73, 0x74, 0},
{0x61, 0x0308, 0x62, 0x63, 0},
void TestTertiary(/* char* par */);
private:
- static const UChar testSourceCases[][MAX_TOKEN_LEN];
- static const UChar testTargetCases[][MAX_TOKEN_LEN];
+ static const char16_t testSourceCases[][MAX_TOKEN_LEN];
+ static const char16_t testTargetCases[][MAX_TOKEN_LEN];
static const Collator::EComparisonResult results[][2];
Collator *myCollation;
const char *actualPattern;
const char *expectedPattern;
const char *localeID;
- const UChar *expectedLocalPattern;
+ const char16_t *expectedLocalPattern;
} EXPECTED[] = {
{UDAT_YEAR, "y", "en",u"y"},
// -------------------------------------
-UChar toHexString(int32_t i) { return (UChar)(i + (i < 10 ? 0x30 : (0x41 - 10))); }
+char16_t toHexString(int32_t i) { return (char16_t)(i + (i < 10 ? 0x30 : (0x41 - 10))); }
UnicodeString&
DateFormatTest::escape(UnicodeString& s)
UnicodeString buf;
for (int32_t i=0; i<s.length(); ++i)
{
- UChar c = s[(int32_t)i];
- if (c <= (UChar)0x7F) buf += c;
+ char16_t c = s[(int32_t)i];
+ if (c <= (char16_t)0x7F) buf += c;
else {
- buf += (UChar)0x5c; buf += (UChar)0x55;
+ buf += (char16_t)0x5c; buf += (char16_t)0x55;
buf += toHexString((c & 0xF000) >> 12);
buf += toHexString((c & 0x0F00) >> 8);
buf += toHexString((c & 0x00F0) >> 4);
dateFormats[1] = DateFormat::createDateTimeInstance(DateFormat::kFull, DateFormat::kFull, Locale::getFrance());
// Make the pattern "G y M d..."
buf.remove().append(PATTERN_CHARS);
- for (j=buf.length()-1; j>=0; --j) buf.insert(j, (UChar)32/*' '*/);
+ for (j=buf.length()-1; j>=0; --j) buf.insert(j, (char16_t)32/*' '*/);
dateFormats[2] = new SimpleDateFormat(buf, Locale::getUS(), ec);
// Make the pattern "GGGG yyyy MMMM dddd..."
for (j=buf.length()-1; j>=0; j-=2) {
logln("strm.charAt(10)=%04X wanted 0x20\n", strm.charAt(10));
- if (strm.charAt(10) != UChar(0x0020)) {
+ if (strm.charAt(10) != char16_t(0x0020)) {
errln((UnicodeString)"FAIL: Improper formatted date: " + strm );
}
logln("strs.charAt(10)=%04X wanted 0x20\n", strs.charAt(8));
- if (strs.charAt(10) != UChar(0x0020)) {
+ if (strs.charAt(10) != char16_t(0x0020)) {
errln((UnicodeString)"FAIL: Improper formatted date: " + strs);
}
fmt->adoptNumberFormat(fields, check_nf, status);
assertSuccess("adoptNumberFormat check_nf", status);
- const NumberFormat* get_nf = fmt->getNumberFormatForField((UChar)0x004D /*'M'*/);
+ const NumberFormat* get_nf = fmt->getNumberFormatForField((char16_t)0x004D /*'M'*/);
if (get_nf != check_nf) errln("FAIL: getter and setter do not work");
}
NumberFormat* check_nf = NumberFormat::createInstance(Locale("en_US"), status);
static const struct {
const Locale& locale;
const char* const skeleton;
- const UChar* const pattern;
+ const char16_t* const pattern;
} TESTDATA[] = {
// Ticket #11985
{Locale::getEnglish(), "jjmm", u"h:mm\u202Fa"},
const char * skeleton;
UDisplayContext context;
const UDate deltaDate;
- const UChar* expectResult;
+ const char16_t* expectResult;
} DateIntervalContextItem;
static const DateIntervalContextItem testItems[] = {
{ "cs", "MMMEd", CAP_NONE, 60.0*_DAY, u"po 27. 9. – pá 26. 11." },
dataerrln("ERROR: Could not create DateTimePatternGenerator (Locale::getFrench()) - exiting");
return;
}
- UChar newChar;
+ char16_t newChar;
for (i=0; i<10; ++i) {
UnicodeString randomSkeleton;
int32_t len = rand() % 20;
for (int32_t j=0; j<len; ++j ) {
- while ((newChar = (UChar)(rand()%0x7f))>=(UChar)0x20) {
+ while ((newChar = (char16_t)(rand()%0x7f))>=(char16_t)0x20) {
randomSkeleton += newChar;
}
}
typedef struct DTPtnGenOptionsData {
const char *locale;
const char *skel;
- const UChar *expectedPattern;
+ const char16_t *expectedPattern;
UDateTimePatternMatchOptions options;
} DTPtnGenOptionsData;
void IntlTestDateTimePatternGeneratorAPI::testOptions(/*char *par*/)
int32_t patIndx, patLen = pattern.length();
UBool inQuoted = false;
for (patIndx = 0; patIndx < patLen; patIndx++) {
- UChar c = pattern.charAt(patIndx);
+ char16_t c = pattern.charAt(patIndx);
if (c == 0x27) {
inQuoted = !inQuoted;
} else if (!inQuoted && c <= 0x007A && c >= 0x0041) {
if (U_FAILURE(status)) {
dataerrln("FAIL: DateTimePatternGenerator::createInstance failed for locale %s", testDataPtr->locale);
} else {
- UChar expName[kFieldDisplayNameMax+1];
+ char16_t expName[kFieldDisplayNameMax+1];
u_unescape(testDataPtr->expected, expName, kFieldDisplayNameMax);
expName[kFieldDisplayNameMax] = 0; // ensure 0 termination
UnicodeString getName = dtpg->getFieldDisplayName(testDataPtr->field, testDataPtr->width);
}
}
-static const UChar timeCycleChars[] = { (UChar)0x0048, (UChar)0x0068, (UChar)0x004B, (UChar)0x006B, (UChar)0 };
+static const char16_t timeCycleChars[] = { (char16_t)0x0048, (char16_t)0x0068, (char16_t)0x004B, (char16_t)0x006B, (char16_t)0 };
void IntlTestDateTimePatternGeneratorAPI::testJjMapping() {
UErrorCode status = U_ZERO_ERROR;
errln("FAIL: DateTimePatternGenerator::staticGetSkeleton locale %s: %s", localeID, u_errorName(status));
continue;
}
- const UChar* charPtr = timeCycleChars;
- for (; *charPtr != (UChar)0; charPtr++) {
+ const char16_t* charPtr = timeCycleChars;
+ for (; *charPtr != (char16_t)0; charPtr++) {
if (jPatSkeleton.indexOf(*charPtr) >= 0) {
if (shortPatSkeleton.indexOf(*charPtr) < 0) {
char jcBuf[2], spBuf[32], jpBuf[32];
"xz-ZX", // unknown language with unknown country
"ars", "wuu" // aliased locales
};
- static const UChar* skeleton = u"jm";
+ static const char16_t* skeleton = u"jm";
for (const char* localeID: localeIDs) {
UErrorCode status = U_ZERO_ERROR;
Locale locale(localeID);
const struct TestCase {
const char* localeID;
const char* skeleton;
- const UChar* expectedPattern;
+ const char16_t* expectedPattern;
} testCases[] = {
// ICU-21650: (See the "week day" section of https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
// for a full explanation of why this is the desired behavior)
void IntlTestDateTimePatternGeneratorAPI::testRegionOverride() {
const struct TestCase {
const char* locale;
- const UChar* expectedPattern;
+ const char16_t* expectedPattern;
UDateFormatHourCycle expectedHourCycle;
} testCases[] = {
{ "en_US", u"h:mm\u202fa", UDAT_HOUR_CYCLE_12 },
delete myCollation;
}
-static const UChar testSourceCases[][CollationEnglishTest::MAX_TOKEN_LEN] = {
- {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, 0},
- {(UChar)0x0062 /* 'b' */, (UChar)0x006C /* 'l' */, (UChar)0x0061 /* 'a' */, (UChar)0x0063 /* 'c' */, (UChar)0x006B /* 'k' */, (UChar)0x002D /* '-' */, (UChar)0x0062 /* 'b' */, (UChar)0x0069 /* 'i' */, (UChar)0x0072 /* 'r' */, (UChar)0x0064 /* 'd' */, 0},
- {(UChar)0x0062 /* 'b' */, (UChar)0x006C /* 'l' */, (UChar)0x0061 /* 'a' */, (UChar)0x0063 /* 'c' */, (UChar)0x006B /* 'k' */, (UChar)0x0020 /* ' ' */, (UChar)0x0062 /* 'b' */, (UChar)0x0069 /* 'i' */, (UChar)0x0072 /* 'r' */, (UChar)0x0064 /* 'd' */, 0},
- {(UChar)0x0062 /* 'b' */, (UChar)0x006C /* 'l' */, (UChar)0x0061 /* 'a' */, (UChar)0x0063 /* 'c' */, (UChar)0x006B /* 'k' */, (UChar)0x002D /* '-' */, (UChar)0x0062 /* 'b' */, (UChar)0x0069 /* 'i' */, (UChar)0x0072 /* 'r' */, (UChar)0x0064 /* 'd' */, 0},
- {(UChar)0x0048 /* 'H' */, (UChar)0x0065 /* 'e' */, (UChar)0x006C /* 'l' */, (UChar)0x006C /* 'l' */, (UChar)0x006F /* 'o' */, 0},
- {(UChar)0x0041 /* 'A' */, (UChar)0x0042 /* 'B' */, (UChar)0x0043 /* 'C' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
- {(UChar)0x0062 /* 'b' */, (UChar)0x006C /* 'l' */, (UChar)0x0061 /* 'a' */, (UChar)0x0063 /* 'c' */, (UChar)0x006B /* 'k' */, (UChar)0x0062 /* 'b' */, (UChar)0x0069 /* 'i' */, (UChar)0x0072 /* 'r' */, (UChar)0x0064 /* 'd' */, 0},
- {(UChar)0x0062 /* 'b' */, (UChar)0x006C /* 'l' */, (UChar)0x0061 /* 'a' */, (UChar)0x0063 /* 'c' */, (UChar)0x006B /* 'k' */, (UChar)0x002D /* '-' */, (UChar)0x0062 /* 'b' */, (UChar)0x0069 /* 'i' */, (UChar)0x0072 /* 'r' */, (UChar)0x0064 /* 'd' */, 0},
- {(UChar)0x0062 /* 'b' */, (UChar)0x006C /* 'l' */, (UChar)0x0061 /* 'a' */, (UChar)0x0063 /* 'c' */, (UChar)0x006B /* 'k' */, (UChar)0x002D /* '-' */, (UChar)0x0062 /* 'b' */, (UChar)0x0069 /* 'i' */, (UChar)0x0072 /* 'r' */, (UChar)0x0064 /* 'd' */, 0},
- {(UChar)0x0070 /* 'p' */, 0x00EA, (UChar)0x0063 /* 'c' */, (UChar)0x0068 /* 'h' */, (UChar)0x0065 /* 'e' */, 0},
- {(UChar)0x0070 /* 'p' */, 0x00E9, (UChar)0x0063 /* 'c' */, (UChar)0x0068 /* 'h' */, 0x00E9, 0},
- {0x00C4, (UChar)0x0042 /* 'B' */, 0x0308, (UChar)0x0043 /* 'C' */, 0x0308, 0},
- {(UChar)0x0061 /* 'a' */, 0x0308, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
- {(UChar)0x0070 /* 'p' */, 0x00E9, (UChar)0x0063 /* 'c' */, (UChar)0x0068 /* 'h' */, (UChar)0x0065 /* 'e' */, (UChar)0x0072 /* 'r' */, 0},
- {(UChar)0x0072 /* 'r' */, (UChar)0x006F /* 'o' */, (UChar)0x006C /* 'l' */, (UChar)0x0065 /* 'e' */, (UChar)0x0073 /* 's' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
- {(UChar)0x0041 /* 'A' */, 0},
- {(UChar)0x0041 /* 'A' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, 0},
- {(UChar)0x0074 /* 't' */, (UChar)0x0063 /* 'c' */, (UChar)0x006F /* 'o' */, (UChar)0x006D /* 'm' */, (UChar)0x0070 /* 'p' */, (UChar)0x0061 /* 'a' */, (UChar)0x0072 /* 'r' */, (UChar)0x0065 /* 'e' */, (UChar)0x0070 /* 'p' */, (UChar)0x006C /* 'l' */, (UChar)0x0061 /* 'a' */, (UChar)0x0069 /* 'i' */, (UChar)0x006E /* 'n' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0023 /* '#' */, (UChar)0x0062 /* 'b' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0023 /* '#' */, (UChar)0x0062 /* 'b' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
- {(UChar)0x0041 /* 'A' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, (UChar)0x0064 /* 'd' */, (UChar)0x0061 /* 'a' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, (UChar)0x0064 /* 'd' */, (UChar)0x0061 /* 'a' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, (UChar)0x0064 /* 'd' */, (UChar)0x0061 /* 'a' */, 0},
- {0x00E6, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, (UChar)0x0064 /* 'd' */, (UChar)0x0061 /* 'a' */, 0},
- {0x00E4, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, (UChar)0x0064 /* 'd' */, (UChar)0x0061 /* 'a' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0063 /* 'c' */, (UChar)0x0048 /* 'H' */, (UChar)0x0063 /* 'c' */, 0},
- {(UChar)0x0061 /* 'a' */, 0x0308, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
- {(UChar)0x0074 /* 't' */, (UChar)0x0068 /* 'h' */, (UChar)0x0069 /* 'i' */, 0x0302, (UChar)0x0073 /* 's' */, 0},
- {(UChar)0x0070 /* 'p' */, 0x00EA, (UChar)0x0063 /* 'c' */, (UChar)0x0068 /* 'h' */, (UChar)0x0065 /* 'e' */},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
- {(UChar)0x0061 /* 'a' */, 0x00E6, (UChar)0x0063 /* 'c' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
- {(UChar)0x0061 /* 'a' */, 0x00E6, (UChar)0x0063 /* 'c' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
- {(UChar)0x0070 /* 'p' */, 0x00E9, (UChar)0x0063 /* 'c' */, (UChar)0x0068 /* 'h' */, 0x00E9, 0} // 49
+static const char16_t testSourceCases[][CollationEnglishTest::MAX_TOKEN_LEN] = {
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0062 /* 'b' */, 0},
+ {(char16_t)0x0062 /* 'b' */, (char16_t)0x006C /* 'l' */, (char16_t)0x0061 /* 'a' */, (char16_t)0x0063 /* 'c' */, (char16_t)0x006B /* 'k' */, (char16_t)0x002D /* '-' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0069 /* 'i' */, (char16_t)0x0072 /* 'r' */, (char16_t)0x0064 /* 'd' */, 0},
+ {(char16_t)0x0062 /* 'b' */, (char16_t)0x006C /* 'l' */, (char16_t)0x0061 /* 'a' */, (char16_t)0x0063 /* 'c' */, (char16_t)0x006B /* 'k' */, (char16_t)0x0020 /* ' ' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0069 /* 'i' */, (char16_t)0x0072 /* 'r' */, (char16_t)0x0064 /* 'd' */, 0},
+ {(char16_t)0x0062 /* 'b' */, (char16_t)0x006C /* 'l' */, (char16_t)0x0061 /* 'a' */, (char16_t)0x0063 /* 'c' */, (char16_t)0x006B /* 'k' */, (char16_t)0x002D /* '-' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0069 /* 'i' */, (char16_t)0x0072 /* 'r' */, (char16_t)0x0064 /* 'd' */, 0},
+ {(char16_t)0x0048 /* 'H' */, (char16_t)0x0065 /* 'e' */, (char16_t)0x006C /* 'l' */, (char16_t)0x006C /* 'l' */, (char16_t)0x006F /* 'o' */, 0},
+ {(char16_t)0x0041 /* 'A' */, (char16_t)0x0042 /* 'B' */, (char16_t)0x0043 /* 'C' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, 0},
+ {(char16_t)0x0062 /* 'b' */, (char16_t)0x006C /* 'l' */, (char16_t)0x0061 /* 'a' */, (char16_t)0x0063 /* 'c' */, (char16_t)0x006B /* 'k' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0069 /* 'i' */, (char16_t)0x0072 /* 'r' */, (char16_t)0x0064 /* 'd' */, 0},
+ {(char16_t)0x0062 /* 'b' */, (char16_t)0x006C /* 'l' */, (char16_t)0x0061 /* 'a' */, (char16_t)0x0063 /* 'c' */, (char16_t)0x006B /* 'k' */, (char16_t)0x002D /* '-' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0069 /* 'i' */, (char16_t)0x0072 /* 'r' */, (char16_t)0x0064 /* 'd' */, 0},
+ {(char16_t)0x0062 /* 'b' */, (char16_t)0x006C /* 'l' */, (char16_t)0x0061 /* 'a' */, (char16_t)0x0063 /* 'c' */, (char16_t)0x006B /* 'k' */, (char16_t)0x002D /* '-' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0069 /* 'i' */, (char16_t)0x0072 /* 'r' */, (char16_t)0x0064 /* 'd' */, 0},
+ {(char16_t)0x0070 /* 'p' */, 0x00EA, (char16_t)0x0063 /* 'c' */, (char16_t)0x0068 /* 'h' */, (char16_t)0x0065 /* 'e' */, 0},
+ {(char16_t)0x0070 /* 'p' */, 0x00E9, (char16_t)0x0063 /* 'c' */, (char16_t)0x0068 /* 'h' */, 0x00E9, 0},
+ {0x00C4, (char16_t)0x0042 /* 'B' */, 0x0308, (char16_t)0x0043 /* 'C' */, 0x0308, 0},
+ {(char16_t)0x0061 /* 'a' */, 0x0308, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, 0},
+ {(char16_t)0x0070 /* 'p' */, 0x00E9, (char16_t)0x0063 /* 'c' */, (char16_t)0x0068 /* 'h' */, (char16_t)0x0065 /* 'e' */, (char16_t)0x0072 /* 'r' */, 0},
+ {(char16_t)0x0072 /* 'r' */, (char16_t)0x006F /* 'o' */, (char16_t)0x006C /* 'l' */, (char16_t)0x0065 /* 'e' */, (char16_t)0x0073 /* 's' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, 0},
+ {(char16_t)0x0041 /* 'A' */, 0},
+ {(char16_t)0x0041 /* 'A' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0062 /* 'b' */, 0},
+ {(char16_t)0x0074 /* 't' */, (char16_t)0x0063 /* 'c' */, (char16_t)0x006F /* 'o' */, (char16_t)0x006D /* 'm' */, (char16_t)0x0070 /* 'p' */, (char16_t)0x0061 /* 'a' */, (char16_t)0x0072 /* 'r' */, (char16_t)0x0065 /* 'e' */, (char16_t)0x0070 /* 'p' */, (char16_t)0x006C /* 'l' */, (char16_t)0x0061 /* 'a' */, (char16_t)0x0069 /* 'i' */, (char16_t)0x006E /* 'n' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0062 /* 'b' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0023 /* '#' */, (char16_t)0x0062 /* 'b' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0023 /* '#' */, (char16_t)0x0062 /* 'b' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, 0},
+ {(char16_t)0x0041 /* 'A' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, (char16_t)0x0064 /* 'd' */, (char16_t)0x0061 /* 'a' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, (char16_t)0x0064 /* 'd' */, (char16_t)0x0061 /* 'a' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, (char16_t)0x0064 /* 'd' */, (char16_t)0x0061 /* 'a' */, 0},
+ {0x00E6, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, (char16_t)0x0064 /* 'd' */, (char16_t)0x0061 /* 'a' */, 0},
+ {0x00E4, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, (char16_t)0x0064 /* 'd' */, (char16_t)0x0061 /* 'a' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0063 /* 'c' */, (char16_t)0x0048 /* 'H' */, (char16_t)0x0063 /* 'c' */, 0},
+ {(char16_t)0x0061 /* 'a' */, 0x0308, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, 0},
+ {(char16_t)0x0074 /* 't' */, (char16_t)0x0068 /* 'h' */, (char16_t)0x0069 /* 'i' */, 0x0302, (char16_t)0x0073 /* 's' */, 0},
+ {(char16_t)0x0070 /* 'p' */, 0x00EA, (char16_t)0x0063 /* 'c' */, (char16_t)0x0068 /* 'h' */, (char16_t)0x0065 /* 'e' */},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, 0},
+ {(char16_t)0x0061 /* 'a' */, 0x00E6, (char16_t)0x0063 /* 'c' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, 0},
+ {(char16_t)0x0061 /* 'a' */, 0x00E6, (char16_t)0x0063 /* 'c' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, 0},
+ {(char16_t)0x0070 /* 'p' */, 0x00E9, (char16_t)0x0063 /* 'c' */, (char16_t)0x0068 /* 'h' */, 0x00E9, 0} // 49
};
-static const UChar testTargetCases[][CollationEnglishTest::MAX_TOKEN_LEN] = {
- {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
- {(UChar)0x0062 /* 'b' */, (UChar)0x006C /* 'l' */, (UChar)0x0061 /* 'a' */, (UChar)0x0063 /* 'c' */, (UChar)0x006B /* 'k' */, (UChar)0x0062 /* 'b' */, (UChar)0x0069 /* 'i' */, (UChar)0x0072 /* 'r' */, (UChar)0x0064 /* 'd' */, 0},
- {(UChar)0x0062 /* 'b' */, (UChar)0x006C /* 'l' */, (UChar)0x0061 /* 'a' */, (UChar)0x0063 /* 'c' */, (UChar)0x006B /* 'k' */, (UChar)0x002D /* '-' */, (UChar)0x0062 /* 'b' */, (UChar)0x0069 /* 'i' */, (UChar)0x0072 /* 'r' */, (UChar)0x0064 /* 'd' */, 0},
- {(UChar)0x0062 /* 'b' */, (UChar)0x006C /* 'l' */, (UChar)0x0061 /* 'a' */, (UChar)0x0063 /* 'c' */, (UChar)0x006B /* 'k' */, 0},
- {(UChar)0x0068 /* 'h' */, (UChar)0x0065 /* 'e' */, (UChar)0x006C /* 'l' */, (UChar)0x006C /* 'l' */, (UChar)0x006F /* 'o' */, 0},
- {(UChar)0x0041 /* 'A' */, (UChar)0x0042 /* 'B' */, (UChar)0x0043 /* 'C' */, 0},
- {(UChar)0x0041 /* 'A' */, (UChar)0x0042 /* 'B' */, (UChar)0x0043 /* 'C' */, 0},
- {(UChar)0x0062 /* 'b' */, (UChar)0x006C /* 'l' */, (UChar)0x0061 /* 'a' */, (UChar)0x0063 /* 'c' */, (UChar)0x006B /* 'k' */, (UChar)0x0062 /* 'b' */, (UChar)0x0069 /* 'i' */, (UChar)0x0072 /* 'r' */, (UChar)0x0064 /* 'd' */, (UChar)0x0073 /* 's' */, 0},
- {(UChar)0x0062 /* 'b' */, (UChar)0x006C /* 'l' */, (UChar)0x0061 /* 'a' */, (UChar)0x0063 /* 'c' */, (UChar)0x006B /* 'k' */, (UChar)0x0062 /* 'b' */, (UChar)0x0069 /* 'i' */, (UChar)0x0072 /* 'r' */, (UChar)0x0064 /* 'd' */, (UChar)0x0073 /* 's' */, 0},
- {(UChar)0x0062 /* 'b' */, (UChar)0x006C /* 'l' */, (UChar)0x0061 /* 'a' */, (UChar)0x0063 /* 'c' */, (UChar)0x006B /* 'k' */, (UChar)0x0062 /* 'b' */, (UChar)0x0069 /* 'i' */, (UChar)0x0072 /* 'r' */, (UChar)0x0064 /* 'd' */, 0},
- {(UChar)0x0070 /* 'p' */, 0x00E9, (UChar)0x0063 /* 'c' */, (UChar)0x0068 /* 'h' */, 0x00E9, 0},
- {(UChar)0x0070 /* 'p' */, 0x00E9, (UChar)0x0063 /* 'c' */, (UChar)0x0068 /* 'h' */, (UChar)0x0065 /* 'e' */, (UChar)0x0072 /* 'r' */, 0},
- {0x00C4, (UChar)0x0042 /* 'B' */, 0x0308, (UChar)0x0043 /* 'C' */, 0x0308, 0},
- {(UChar)0x0041 /* 'A' */, 0x0308, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
- {(UChar)0x0070 /* 'p' */, 0x00E9, (UChar)0x0063 /* 'c' */, (UChar)0x0068 /* 'h' */, (UChar)0x0065 /* 'e' */, 0},
- {(UChar)0x0072 /* 'r' */, (UChar)0x006F /* 'o' */, 0x0302, (UChar)0x006C /* 'l' */, (UChar)0x0065 /* 'e' */, 0},
- {(UChar)0x0041 /* 'A' */, 0x00E1, (UChar)0x0063 /* 'c' */, (UChar)0x0064 /* 'd' */, 0},
- {(UChar)0x0041 /* 'A' */, 0x00E1, (UChar)0x0063 /* 'c' */, (UChar)0x0064 /* 'd' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
- {(UChar)0x0054 /* 'T' */, (UChar)0x0043 /* 'C' */, (UChar)0x006F /* 'o' */, (UChar)0x006D /* 'm' */, (UChar)0x0070 /* 'p' */, (UChar)0x0061 /* 'a' */, (UChar)0x0072 /* 'r' */, (UChar)0x0065 /* 'e' */, (UChar)0x0050 /* 'P' */, (UChar)0x006C /* 'l' */, (UChar)0x0061 /* 'a' */, (UChar)0x0069 /* 'i' */, (UChar)0x006E /* 'n' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0042 /* 'B' */, (UChar)0x0063 /* 'c' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0023 /* '#' */, (UChar)0x0042 /* 'B' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0026 /* '&' */, (UChar)0x0062 /* 'b' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0023 /* '#' */, (UChar)0x0063 /* 'c' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, (UChar)0x0064 /* 'd' */, (UChar)0x0061 /* 'a' */, 0},
- {0x00C4, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, (UChar)0x0064 /* 'd' */, (UChar)0x0061 /* 'a' */, 0},
- {0x00E4, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, (UChar)0x0064 /* 'd' */, (UChar)0x0061 /* 'a' */, 0},
- {0x00C4, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, (UChar)0x0064 /* 'd' */, (UChar)0x0061 /* 'a' */, 0},
- {0x00C4, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, (UChar)0x0064 /* 'd' */, (UChar)0x0061 /* 'a' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0023 /* '#' */, (UChar)0x0063 /* 'c' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x003D /* '=' */, (UChar)0x0063 /* 'c' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0064 /* 'd' */, 0},
- {0x00E4, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0043 /* 'C' */, (UChar)0x0048 /* 'H' */, (UChar)0x0063 /* 'c' */, 0},
- {0x00E4, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
- {(UChar)0x0074 /* 't' */, (UChar)0x0068 /* 'h' */, 0x00EE, (UChar)0x0073 /* 's' */, 0},
- {(UChar)0x0070 /* 'p' */, 0x00E9, (UChar)0x0063 /* 'c' */, (UChar)0x0068 /* 'h' */, 0x00E9, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0042 /* 'B' */, (UChar)0x0043 /* 'C' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0064 /* 'd' */, 0},
- {0x00E4, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
- {(UChar)0x0061 /* 'a' */, 0x00C6, (UChar)0x0063 /* 'c' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0042 /* 'B' */, (UChar)0x0064 /* 'd' */, 0},
- {0x00E4, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
- {(UChar)0x0061 /* 'a' */, 0x00C6, (UChar)0x0063 /* 'c' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0042 /* 'B' */, (UChar)0x0064 /* 'd' */, 0},
- {0x00E4, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
- {(UChar)0x0070 /* 'p' */, 0x00EA, (UChar)0x0063 /* 'c' */, (UChar)0x0068 /* 'h' */, (UChar)0x0065 /* 'e' */, 0} // 49
+static const char16_t testTargetCases[][CollationEnglishTest::MAX_TOKEN_LEN] = {
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, 0},
+ {(char16_t)0x0062 /* 'b' */, (char16_t)0x006C /* 'l' */, (char16_t)0x0061 /* 'a' */, (char16_t)0x0063 /* 'c' */, (char16_t)0x006B /* 'k' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0069 /* 'i' */, (char16_t)0x0072 /* 'r' */, (char16_t)0x0064 /* 'd' */, 0},
+ {(char16_t)0x0062 /* 'b' */, (char16_t)0x006C /* 'l' */, (char16_t)0x0061 /* 'a' */, (char16_t)0x0063 /* 'c' */, (char16_t)0x006B /* 'k' */, (char16_t)0x002D /* '-' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0069 /* 'i' */, (char16_t)0x0072 /* 'r' */, (char16_t)0x0064 /* 'd' */, 0},
+ {(char16_t)0x0062 /* 'b' */, (char16_t)0x006C /* 'l' */, (char16_t)0x0061 /* 'a' */, (char16_t)0x0063 /* 'c' */, (char16_t)0x006B /* 'k' */, 0},
+ {(char16_t)0x0068 /* 'h' */, (char16_t)0x0065 /* 'e' */, (char16_t)0x006C /* 'l' */, (char16_t)0x006C /* 'l' */, (char16_t)0x006F /* 'o' */, 0},
+ {(char16_t)0x0041 /* 'A' */, (char16_t)0x0042 /* 'B' */, (char16_t)0x0043 /* 'C' */, 0},
+ {(char16_t)0x0041 /* 'A' */, (char16_t)0x0042 /* 'B' */, (char16_t)0x0043 /* 'C' */, 0},
+ {(char16_t)0x0062 /* 'b' */, (char16_t)0x006C /* 'l' */, (char16_t)0x0061 /* 'a' */, (char16_t)0x0063 /* 'c' */, (char16_t)0x006B /* 'k' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0069 /* 'i' */, (char16_t)0x0072 /* 'r' */, (char16_t)0x0064 /* 'd' */, (char16_t)0x0073 /* 's' */, 0},
+ {(char16_t)0x0062 /* 'b' */, (char16_t)0x006C /* 'l' */, (char16_t)0x0061 /* 'a' */, (char16_t)0x0063 /* 'c' */, (char16_t)0x006B /* 'k' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0069 /* 'i' */, (char16_t)0x0072 /* 'r' */, (char16_t)0x0064 /* 'd' */, (char16_t)0x0073 /* 's' */, 0},
+ {(char16_t)0x0062 /* 'b' */, (char16_t)0x006C /* 'l' */, (char16_t)0x0061 /* 'a' */, (char16_t)0x0063 /* 'c' */, (char16_t)0x006B /* 'k' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0069 /* 'i' */, (char16_t)0x0072 /* 'r' */, (char16_t)0x0064 /* 'd' */, 0},
+ {(char16_t)0x0070 /* 'p' */, 0x00E9, (char16_t)0x0063 /* 'c' */, (char16_t)0x0068 /* 'h' */, 0x00E9, 0},
+ {(char16_t)0x0070 /* 'p' */, 0x00E9, (char16_t)0x0063 /* 'c' */, (char16_t)0x0068 /* 'h' */, (char16_t)0x0065 /* 'e' */, (char16_t)0x0072 /* 'r' */, 0},
+ {0x00C4, (char16_t)0x0042 /* 'B' */, 0x0308, (char16_t)0x0043 /* 'C' */, 0x0308, 0},
+ {(char16_t)0x0041 /* 'A' */, 0x0308, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, 0},
+ {(char16_t)0x0070 /* 'p' */, 0x00E9, (char16_t)0x0063 /* 'c' */, (char16_t)0x0068 /* 'h' */, (char16_t)0x0065 /* 'e' */, 0},
+ {(char16_t)0x0072 /* 'r' */, (char16_t)0x006F /* 'o' */, 0x0302, (char16_t)0x006C /* 'l' */, (char16_t)0x0065 /* 'e' */, 0},
+ {(char16_t)0x0041 /* 'A' */, 0x00E1, (char16_t)0x0063 /* 'c' */, (char16_t)0x0064 /* 'd' */, 0},
+ {(char16_t)0x0041 /* 'A' */, 0x00E1, (char16_t)0x0063 /* 'c' */, (char16_t)0x0064 /* 'd' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, 0},
+ {(char16_t)0x0054 /* 'T' */, (char16_t)0x0043 /* 'C' */, (char16_t)0x006F /* 'o' */, (char16_t)0x006D /* 'm' */, (char16_t)0x0070 /* 'p' */, (char16_t)0x0061 /* 'a' */, (char16_t)0x0072 /* 'r' */, (char16_t)0x0065 /* 'e' */, (char16_t)0x0050 /* 'P' */, (char16_t)0x006C /* 'l' */, (char16_t)0x0061 /* 'a' */, (char16_t)0x0069 /* 'i' */, (char16_t)0x006E /* 'n' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0042 /* 'B' */, (char16_t)0x0063 /* 'c' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0023 /* '#' */, (char16_t)0x0042 /* 'B' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0026 /* '&' */, (char16_t)0x0062 /* 'b' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0023 /* '#' */, (char16_t)0x0063 /* 'c' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, (char16_t)0x0064 /* 'd' */, (char16_t)0x0061 /* 'a' */, 0},
+ {0x00C4, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, (char16_t)0x0064 /* 'd' */, (char16_t)0x0061 /* 'a' */, 0},
+ {0x00E4, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, (char16_t)0x0064 /* 'd' */, (char16_t)0x0061 /* 'a' */, 0},
+ {0x00C4, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, (char16_t)0x0064 /* 'd' */, (char16_t)0x0061 /* 'a' */, 0},
+ {0x00C4, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, (char16_t)0x0064 /* 'd' */, (char16_t)0x0061 /* 'a' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0023 /* '#' */, (char16_t)0x0063 /* 'c' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x003D /* '=' */, (char16_t)0x0063 /* 'c' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0064 /* 'd' */, 0},
+ {0x00E4, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0043 /* 'C' */, (char16_t)0x0048 /* 'H' */, (char16_t)0x0063 /* 'c' */, 0},
+ {0x00E4, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, 0},
+ {(char16_t)0x0074 /* 't' */, (char16_t)0x0068 /* 'h' */, 0x00EE, (char16_t)0x0073 /* 's' */, 0},
+ {(char16_t)0x0070 /* 'p' */, 0x00E9, (char16_t)0x0063 /* 'c' */, (char16_t)0x0068 /* 'h' */, 0x00E9, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0042 /* 'B' */, (char16_t)0x0043 /* 'C' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0062 /* 'b' */, (char16_t)0x0064 /* 'd' */, 0},
+ {0x00E4, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, 0},
+ {(char16_t)0x0061 /* 'a' */, 0x00C6, (char16_t)0x0063 /* 'c' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0042 /* 'B' */, (char16_t)0x0064 /* 'd' */, 0},
+ {0x00E4, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, 0},
+ {(char16_t)0x0061 /* 'a' */, 0x00C6, (char16_t)0x0063 /* 'c' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0042 /* 'B' */, (char16_t)0x0064 /* 'd' */, 0},
+ {0x00E4, (char16_t)0x0062 /* 'b' */, (char16_t)0x0063 /* 'c' */, 0},
+ {(char16_t)0x0070 /* 'p' */, 0x00EA, (char16_t)0x0063 /* 'c' */, (char16_t)0x0068 /* 'h' */, (char16_t)0x0065 /* 'e' */, 0} // 49
};
static const Collator::EComparisonResult results[] = {
Collator::LESS // 49
};
-static const UChar testBugs[][CollationEnglishTest::MAX_TOKEN_LEN] = {
+static const char16_t testBugs[][CollationEnglishTest::MAX_TOKEN_LEN] = {
{0x61, 0},
{0x41, 0},
{0x65, 0},
// 0x0300 is grave, 0x0301 is acute
// the order of elements in this array must be different than the order in CollationFrenchTest
-static const UChar testAcute[][CollationEnglishTest::MAX_TOKEN_LEN] = {
+static const char16_t testAcute[][CollationEnglishTest::MAX_TOKEN_LEN] = {
{0x65, 0x65, 0},
{0x65, 0x65, 0x0301, 0},
{0x65, 0x65, 0x0301, 0x0300, 0},
{0x65, 0x0300, 0x0301, 0x65, 0x0300, 0x0301, 0}
};
-static const UChar testMore[][CollationEnglishTest::MAX_TOKEN_LEN] = {
- {(UChar)0x0061 /* 'a' */, (UChar)0x0065 /* 'e' */, 0},
+static const char16_t testMore[][CollationEnglishTest::MAX_TOKEN_LEN] = {
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0065 /* 'e' */, 0},
{ 0x00E6, 0},
{ 0x00C6, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0066 /* 'f' */, 0},
- {(UChar)0x006F /* 'o' */, (UChar)0x0065 /* 'e' */, 0},
+ {(char16_t)0x0061 /* 'a' */, (char16_t)0x0066 /* 'f' */, 0},
+ {(char16_t)0x006F /* 'o' */, (char16_t)0x0065 /* 'e' */, 0},
{ 0x0153, 0},
{ 0x0152, 0},
- {(UChar)0x006F /* 'o' */, (UChar)0x0066 /* 'f' */, 0},
+ {(char16_t)0x006F /* 'o' */, (char16_t)0x0066 /* 'f' */, 0},
};
void CollationEnglishTest::TestTertiary(/* char* par */)
delete myCollation;
}
-const UChar CollationSpanishTest::testSourceCases[][CollationSpanishTest::MAX_TOKEN_LEN] = {
+const char16_t CollationSpanishTest::testSourceCases[][CollationSpanishTest::MAX_TOKEN_LEN] = {
{0x61, 0x6c, 0x69, 0x61, 0x73, 0},
{0x45, 0x6c, 0x6c, 0x69, 0x6f, 0x74, 0},
{0x48, 0x65, 0x6c, 0x6c, 0x6f, 0},
{0x48, 0x65, 0x6c, 0x6c, 0x6f, 0},
};
-const UChar CollationSpanishTest::testTargetCases[][CollationSpanishTest::MAX_TOKEN_LEN] = {
+const char16_t CollationSpanishTest::testTargetCases[][CollationSpanishTest::MAX_TOKEN_LEN] = {
{0x61, 0x6c, 0x6c, 0x69, 0x61, 0x73, 0},
{0x45, 0x6d, 0x69, 0x6f, 0x74, 0},
{0x68, 0x65, 0x6c, 0x6c, 0x4f, 0},
void TestTertiary(/* char* par */);
private:
- static const UChar testSourceCases[][MAX_TOKEN_LEN];
- static const UChar testTargetCases[][MAX_TOKEN_LEN];
+ static const char16_t testSourceCases[][MAX_TOKEN_LEN];
+ static const char16_t testTargetCases[][MAX_TOKEN_LEN];
static const Collator::EComparisonResult results[];
Collator *myCollation;
delete myCollation;
}
-const UChar CollationFinnishTest::testSourceCases[][CollationFinnishTest::MAX_TOKEN_LEN] = {
+const char16_t CollationFinnishTest::testSourceCases[][CollationFinnishTest::MAX_TOKEN_LEN] = {
{0x77, 0x61, 0x74, 0}, // "wat"
{0x76, 0x61, 0x74, 0}, // "vat"
{0x61, 0x00FC, 0x62, 0x65, 0x63, 0x6b, 0},
{0x77, 0x61, 0x74, 0} // "wat"
};
-const UChar CollationFinnishTest::testTargetCases[][CollationFinnishTest::MAX_TOKEN_LEN] = {
+const char16_t CollationFinnishTest::testTargetCases[][CollationFinnishTest::MAX_TOKEN_LEN] = {
{0x76, 0x61, 0x74, 0}, // "vat"
{0x77, 0x61, 0x79, 0},
{0x61, 0x78, 0x62, 0x65, 0x63, 0x6b, 0},
void TestTertiary(/* char* par */);
private:
- static const UChar testSourceCases[][MAX_TOKEN_LEN];
- static const UChar testTargetCases[][MAX_TOKEN_LEN];
+ static const char16_t testSourceCases[][MAX_TOKEN_LEN];
+ static const char16_t testTargetCases[][MAX_TOKEN_LEN];
static const Collator::EComparisonResult results[];
Collator *myCollation;
return str;
}
-static UnicodeString *split(const UnicodeString &src, UChar ch, int32_t &splits)
+static UnicodeString *split(const UnicodeString &src, char16_t ch, int32_t &splits)
{
int32_t offset = -1;
if(U_FAILURE(status)) {
char ch[256];
- const UChar *u = kv[0].getBuffer();
+ const char16_t *u = kv[0].getBuffer();
int32_t len = kv[0].length();
u_UCharsToChars(u, ch, len);
ch[len] = 0; /* include terminating \0 */
if(U_FAILURE(status)) {
char ch[256];
- const UChar *u = kv[1].getBuffer();
+ const char16_t *u = kv[1].getBuffer();
int32_t len = kv[1].length();
u_UCharsToChars(u, ch, len);
ch[len] = 0; /* include terminating \0 */
delete myCollation;
}
-const UChar CollationFrenchTest::testSourceCases[][CollationFrenchTest::MAX_TOKEN_LEN] =
+const char16_t CollationFrenchTest::testSourceCases[][CollationFrenchTest::MAX_TOKEN_LEN] =
{
{0x0061/*'a'*/, 0x0062/*'b'*/, 0x0063/*'c'*/, 0x0000},
{0x0043/*'C'*/, 0x004f/*'O'*/, 0x0054/*'T'*/, 0x0045/*'E'*/, 0x0000},
{0x0101, 0x0000}
};
-const UChar CollationFrenchTest::testTargetCases[][CollationFrenchTest::MAX_TOKEN_LEN] =
+const char16_t CollationFrenchTest::testTargetCases[][CollationFrenchTest::MAX_TOKEN_LEN] =
{
{0x0041/*'A'*/, 0x0042/*'B'*/, 0x0043/*'C'*/, 0x0000},
{0x0063/*'c'*/, 0x00f4, 0x0074/*'t'*/, 0x0065/*'e'*/, 0x0000},
// 0x0300 is grave, 0x0301 is acute
// the order of elements in this array must be different than the order in CollationEnglishTest
-const UChar CollationFrenchTest::testAcute[][CollationFrenchTest::MAX_TOKEN_LEN] =
+const char16_t CollationFrenchTest::testAcute[][CollationFrenchTest::MAX_TOKEN_LEN] =
{
/*00*/ {0x0065/*'e'*/, 0x0065/*'e'*/, 0x0000},
/*01*/ {0x0065/*'e'*/, 0x0301, 0x0065/*'e'*/, 0x0000},
/*18*/ {0x0065/*'e'*/, 0x0301, 0x0300, 0x0065/*'e'*/, 0x0301, 0x0300, 0x0000}
};
-const UChar CollationFrenchTest::testBugs[][CollationFrenchTest::MAX_TOKEN_LEN] =
+const char16_t CollationFrenchTest::testBugs[][CollationFrenchTest::MAX_TOKEN_LEN] =
{
{0x0061/*'a'*/, 0x000},
{0x0041/*'A'*/, 0x000},
void TestExtra(/* char* par */);
private:
- static const UChar testSourceCases[][MAX_TOKEN_LEN];
- static const UChar testTargetCases[][MAX_TOKEN_LEN];
- static const UChar testBugs[][MAX_TOKEN_LEN];
+ static const char16_t testSourceCases[][MAX_TOKEN_LEN];
+ static const char16_t testTargetCases[][MAX_TOKEN_LEN];
+ static const char16_t testBugs[][MAX_TOKEN_LEN];
static const Collator::EComparisonResult results[];
- static const UChar testAcute[][MAX_TOKEN_LEN];
+ static const char16_t testAcute[][MAX_TOKEN_LEN];
Collator *myCollation;
};
#include "sfwdchit.h"
#include "cmemory.h"
-static const UChar testCases[][G7CollationTest::MAX_TOKEN_LEN] = {
+static const char16_t testCases[][G7CollationTest::MAX_TOKEN_LEN] = {
{ 0x0062 /*'b'*/, 0x006c /*'l'*/, 0x0061 /*'a'*/, 0x0062 /*'c'*/, 0x006b /*'k'*/,
0x0062 /*'b'*/, 0x0069 /*'i'*/, 0x0072 /*'r'*/, 0x0064 /*'d'*/, 0x0073 /*'s'*/, 0x0000}, /* 9 */
{ 0x0050 /*'P'*/, 0x0061 /*'a'*/, 0x0074/*'t'*/, 0x0000}, /* 1 */
#include "idnaconf.h"
#include "charstr.h"
-static const UChar C_TAG[] = {0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0}; // =====
-static const UChar C_NAMEZONE[] = {0x6E, 0x61, 0x6D, 0x65, 0x7A, 0x6F, 0x6E, 0x65, 0}; // namezone
-static const UChar C_NAMEBASE[] = {0x6E, 0x61, 0x6D, 0x65, 0x62, 0x61, 0x73, 0x65, 0}; // namebase
+static const char16_t C_TAG[] = {0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0}; // =====
+static const char16_t C_NAMEZONE[] = {0x6E, 0x61, 0x6D, 0x65, 0x7A, 0x6F, 0x6E, 0x65, 0}; // namezone
+static const char16_t C_NAMEBASE[] = {0x6E, 0x61, 0x6D, 0x65, 0x62, 0x61, 0x73, 0x65, 0}; // namebase
-static const UChar C_TYPE[] = {0x74, 0x79, 0x70, 0x65, 0}; // type
-static const UChar C_TOASCII[] = {0x74, 0x6F, 0x61, 0x73, 0x63, 0x69, 0x69, 0}; // toascii
-static const UChar C_TOUNICODE[] = {0x74, 0x6F, 0x75, 0x6E, 0x69, 0x63, 0x6F, 0x64, 0x65, 0}; // tounicode
+static const char16_t C_TYPE[] = {0x74, 0x79, 0x70, 0x65, 0}; // type
+static const char16_t C_TOASCII[] = {0x74, 0x6F, 0x61, 0x73, 0x63, 0x69, 0x69, 0}; // toascii
+static const char16_t C_TOUNICODE[] = {0x74, 0x6F, 0x75, 0x6E, 0x69, 0x63, 0x6F, 0x64, 0x65, 0}; // tounicode
-static const UChar C_PASSFAIL[] = {0x70, 0x61, 0x73, 0x73, 0x66, 0x61, 0x69, 0x6C, 0}; // passfail
-static const UChar C_PASS[] = {0x70, 0x61, 0x73, 0x73, 0}; // pass
-static const UChar C_FAIL[] = {0x66, 0x61, 0x69, 0x6C, 0}; // fail
+static const char16_t C_PASSFAIL[] = {0x70, 0x61, 0x73, 0x73, 0x66, 0x61, 0x69, 0x6C, 0}; // passfail
+static const char16_t C_PASS[] = {0x70, 0x61, 0x73, 0x73, 0}; // pass
+static const char16_t C_FAIL[] = {0x66, 0x61, 0x69, 0x6C, 0}; // fail
-static const UChar C_DESC[] = {0x64, 0x65, 0x73, 0x63, 0}; // desc
-static const UChar C_USESTD3ASCIIRULES[] = {0x55, 0x73, 0x65, 0x53, 0x54, 0x44,
+static const char16_t C_DESC[] = {0x64, 0x65, 0x73, 0x63, 0}; // desc
+static const char16_t C_USESTD3ASCIIRULES[] = {0x55, 0x73, 0x65, 0x53, 0x54, 0x44,
0x33, 0x41, 0x53, 0x43, 0x49, 0x49, 0x52, 0x75, 0x6C, 0x65, 0x73, 0}; // UseSTD3ASCIIRules
IdnaConfTest::IdnaConfTest(){
#if !UCONFIG_NO_IDNA
int IdnaConfTest::isNewlineMark(){
- static const UChar LF = 0x0a;
- static const UChar CR = 0x0d;
- UChar c = base[curOffset];
+ static const char16_t LF = 0x0a;
+ static const char16_t CR = 0x0d;
+ char16_t c = base[curOffset];
// CR LF
if ( c == CR && curOffset + 1 < len && base[curOffset + 1] == LF){
return 2;
UBool IdnaConfTest::ReadOneLine(UnicodeString& buf){
if ( !(curOffset < len) ) return false; // stream end
- static const UChar BACKSLASH = 0x5c;
+ static const char16_t BACKSLASH = 0x5c;
buf.remove();
int t = 0;
while (curOffset < len){
curOffset += t;
break;
}
- UChar c = base[curOffset];
+ char16_t c = base[curOffset];
if (c == BACKSLASH && curOffset < len -1){ // escaped new line mark
if ((t = isNewlineMark())){
curOffset += 1 + t; // BACKSLAH and NewlineMark
* and, of course, will shift tail elements.
*/
void IdnaConfTest::ExplainCodePointTag(UnicodeString& buf){
- buf.append((UChar)0); // add a terminal NUL
- UChar* bufBase = buf.getBuffer(buf.length());
- UChar* p = bufBase;
+ buf.append((char16_t)0); // add a terminal NUL
+ char16_t* bufBase = buf.getBuffer(buf.length());
+ char16_t* p = bufBase;
while (*p != 0){
if ( *p != 0x3C){ // <
*bufBase++ = *p++;
errln("Incomplete record");
} else {
UErrorCode status = U_ZERO_ERROR;
- UChar result[200] = {0,}; // simple life
- const UChar *p = namebase.getTerminatedBuffer();
+ char16_t result[200] = {0,}; // simple life
+ const char16_t *p = namebase.getTerminatedBuffer();
const int p_len = namebase.length();
if (type == 0 && option == 0){
Call();
} else {
// explain key:value
- int p = s.indexOf((UChar)0x3A); // :
+ int p = s.indexOf((char16_t)0x3A); // :
key.setTo(s,0,p).trim();
value.setTo(s,p+1).trim();
if (key.compare(C_TYPE, -1) == 0){
} else {
option = 0;
}
- id.setTo(value, 0, value.indexOf((UChar)0x20)); // space
+ id.setTo(value, 0, value.indexOf((char16_t)0x20)); // space
} else if (key.compare(C_NAMEZONE, -1) == 0){
ExplainCodePointTag(value);
namezone.setTo(value);
void Test(void);
// for test file handling
- UChar* base;
+ char16_t* base;
int len ;
int curOffset;
#include "unicode/ustring.h"
/* it is official IDNA ACE Prefix is "xn--" */
-static const UChar ACE_PREFIX[] ={ 0x0078,0x006E,0x002d,0x002d } ;
+static const char16_t ACE_PREFIX[] ={ 0x0078,0x006E,0x002d,0x002d } ;
#define ACE_PREFIX_LENGTH 4
#define MAX_LABEL_LENGTH 63
inline static UBool
-startsWithPrefix(const UChar* src , int32_t srcLength){
+startsWithPrefix(const char16_t* src , int32_t srcLength){
UBool startsWithPrefix = true;
if(srcLength < ACE_PREFIX_LENGTH){
return startsWithPrefix;
}
-inline static UChar
-toASCIILower(UChar ch){
+inline static char16_t
+toASCIILower(char16_t ch){
if(CAPITAL_A <= ch && ch <= CAPITAL_Z){
return ch + LOWER_CASE_DELTA;
}
}
inline static int32_t
-compareCaseInsensitiveASCII(const UChar* s1, int32_t s1Len,
- const UChar* s2, int32_t s2Len){
+compareCaseInsensitiveASCII(const char16_t* s1, int32_t s1Len,
+ const char16_t* s2, int32_t s2Len){
if(s1Len != s2Len){
return (s1Len > s2Len) ? s1Len : s2Len;
}
- UChar c1,c2;
+ char16_t c1,c2;
int32_t rc;
for(int32_t i =0;/* no condition */;i++) {
}
}
-static inline int32_t convertASCIIToUChars(const char* src,UChar* dest, int32_t length){
+static inline int32_t convertASCIIToUChars(const char* src,char16_t* dest, int32_t length){
int i;
for(i=0;i<length;i++){
dest[i] = src[i];
}
return i;
}
-static inline int32_t convertUCharsToASCII(const UChar* src,char* dest, int32_t length){
+static inline int32_t convertUCharsToASCII(const char16_t* src,char* dest, int32_t length){
int i;
for(i=0;i<length;i++){
dest[i] = (char)src[i];
return i;
}
// wrapper around the reference Punycode implementation
-static int32_t convertToPuny(const UChar* src, int32_t srcLength,
- UChar* dest, int32_t destCapacity,
+static int32_t convertToPuny(const char16_t* src, int32_t srcLength,
+ char16_t* dest, int32_t destCapacity,
UErrorCode& status){
uint32_t b1Stack[MAX_LABEL_BUFFER_SIZE];
int32_t b1Len = 0, b1Capacity = MAX_LABEL_BUFFER_SIZE;
}
-static int32_t convertFromPuny( const UChar* src, int32_t srcLength,
- UChar* dest, int32_t destCapacity,
+static int32_t convertFromPuny( const char16_t* src, int32_t srcLength,
+ char16_t* dest, int32_t destCapacity,
UErrorCode& status){
char b1Stack[MAX_LABEL_BUFFER_SIZE];
char* b1 = b1Stack;
U_CFUNC int32_t U_EXPORT2
-idnaref_toASCII(const UChar* src, int32_t srcLength,
- UChar* dest, int32_t destCapacity,
+idnaref_toASCII(const char16_t* src, int32_t srcLength,
+ char16_t* dest, int32_t destCapacity,
int32_t options,
UParseError* parseError,
UErrorCode* status){
*status = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
- UChar b1Stack[MAX_LABEL_BUFFER_SIZE], b2Stack[MAX_LABEL_BUFFER_SIZE];
+ char16_t b1Stack[MAX_LABEL_BUFFER_SIZE], b2Stack[MAX_LABEL_BUFFER_SIZE];
//initialize pointers to stack buffers
- UChar *b1 = b1Stack, *b2 = b2Stack;
+ char16_t *b1 = b1Stack, *b2 = b2Stack;
int32_t b1Len=0, b2Len=0,
b1Capacity = MAX_LABEL_BUFFER_SIZE,
b2Capacity = MAX_LABEL_BUFFER_SIZE ,
if(*status == U_BUFFER_OVERFLOW_ERROR){
// redo processing of string
/* we do not have enough room so grow the buffer*/
- b1 = (UChar*) uprv_malloc(b1Len * U_SIZEOF_UCHAR);
+ b1 = (char16_t*) uprv_malloc(b1Len * U_SIZEOF_UCHAR);
if(b1==nullptr){
*status = U_MEMORY_ALLOCATION_ERROR;
goto CLEANUP;
if(*status == U_BUFFER_OVERFLOW_ERROR){
// redo processing of string
/* we do not have enough room so grow the buffer*/
- b2 = (UChar*) uprv_malloc(b2Len * U_SIZEOF_UCHAR);
+ b2 = (char16_t*) uprv_malloc(b2Len * U_SIZEOF_UCHAR);
if(b2 == nullptr){
*status = U_MEMORY_ALLOCATION_ERROR;
goto CLEANUP;
U_CFUNC int32_t U_EXPORT2
-idnaref_toUnicode(const UChar* src, int32_t srcLength,
- UChar* dest, int32_t destCapacity,
+idnaref_toUnicode(const char16_t* src, int32_t srcLength,
+ char16_t* dest, int32_t destCapacity,
int32_t options,
UParseError* parseError,
UErrorCode* status){
- UChar b1Stack[MAX_LABEL_BUFFER_SIZE], b2Stack[MAX_LABEL_BUFFER_SIZE], b3Stack[MAX_LABEL_BUFFER_SIZE];
+ char16_t b1Stack[MAX_LABEL_BUFFER_SIZE], b2Stack[MAX_LABEL_BUFFER_SIZE], b3Stack[MAX_LABEL_BUFFER_SIZE];
//initialize pointers to stack buffers
- UChar *b1 = b1Stack, *b2 = b2Stack, *b1Prime=nullptr, *b3=b3Stack;
+ char16_t *b1 = b1Stack, *b2 = b2Stack, *b1Prime=nullptr, *b3=b3Stack;
int32_t b1Len, b2Len, b1PrimeLen, b3Len,
b1Capacity = MAX_LABEL_BUFFER_SIZE,
b2Capacity = MAX_LABEL_BUFFER_SIZE,
if(*status == U_BUFFER_OVERFLOW_ERROR){
// redo processing of string
/* we do not have enough room so grow the buffer*/
- b1 = (UChar*) uprv_malloc(b1Len * U_SIZEOF_UCHAR);
+ b1 = (char16_t*) uprv_malloc(b1Len * U_SIZEOF_UCHAR);
if(b1==nullptr){
*status = U_MEMORY_ALLOCATION_ERROR;
goto CLEANUP;
u_memmove(b1, src, srcLength);
}else{
/* we do not have enough room so grow the buffer*/
- b1 = (UChar*) uprv_malloc(srcLength * U_SIZEOF_UCHAR);
+ b1 = (char16_t*) uprv_malloc(srcLength * U_SIZEOF_UCHAR);
if(b1==nullptr){
*status = U_MEMORY_ALLOCATION_ERROR;
goto CLEANUP;
if(*status == U_BUFFER_OVERFLOW_ERROR){
// redo processing of string
/* we do not have enough room so grow the buffer*/
- b2 = (UChar*) uprv_malloc(b2Len * U_SIZEOF_UCHAR);
+ b2 = (char16_t*) uprv_malloc(b2Len * U_SIZEOF_UCHAR);
if(b2==nullptr){
*status = U_MEMORY_ALLOCATION_ERROR;
goto CLEANUP;
if(*status == U_BUFFER_OVERFLOW_ERROR){
// redo processing of string
/* we do not have enough room so grow the buffer*/
- b3 = (UChar*) uprv_malloc(b3Len * U_SIZEOF_UCHAR);
+ b3 = (char16_t*) uprv_malloc(b3Len * U_SIZEOF_UCHAR);
if(b3==nullptr){
*status = U_MEMORY_ALLOCATION_ERROR;
goto CLEANUP;
static int32_t
-getNextSeparator(UChar *src,int32_t srcLength,NamePrepTransform* prep,
- UChar **limit,
+getNextSeparator(char16_t *src,int32_t srcLength,NamePrepTransform* prep,
+ char16_t **limit,
UBool *done,
UErrorCode *status){
if(srcLength == -1){
}
U_CFUNC int32_t U_EXPORT2
-idnaref_IDNToASCII( const UChar* src, int32_t srcLength,
- UChar* dest, int32_t destCapacity,
+idnaref_IDNToASCII( const char16_t* src, int32_t srcLength,
+ char16_t* dest, int32_t destCapacity,
int32_t options,
UParseError* parseError,
UErrorCode* status){
NamePrepTransform* prep = getInstance(*status);
//initialize pointers to stack buffers
- UChar b1Stack[MAX_LABEL_BUFFER_SIZE];
- UChar *b1 = b1Stack;
+ char16_t b1Stack[MAX_LABEL_BUFFER_SIZE];
+ char16_t *b1 = b1Stack;
int32_t b1Len, labelLen;
- UChar* delimiter = (UChar*)src;
- UChar* labelStart = (UChar*)src;
+ char16_t* delimiter = (char16_t*)src;
+ char16_t* labelStart = (char16_t*)src;
int32_t remainingLen = srcLength;
int32_t b1Capacity = MAX_LABEL_BUFFER_SIZE;
if(*status == U_BUFFER_OVERFLOW_ERROR){
// redo processing of string
/* we do not have enough room so grow the buffer*/
- b1 = (UChar*) uprv_malloc(b1Len * U_SIZEOF_UCHAR);
+ b1 = (char16_t*) uprv_malloc(b1Len * U_SIZEOF_UCHAR);
if(b1==nullptr){
*status = U_MEMORY_ALLOCATION_ERROR;
goto CLEANUP;
if(*status == U_BUFFER_OVERFLOW_ERROR){
// redo processing of string
/* we do not have enough room so grow the buffer*/
- b1 = (UChar*) uprv_malloc(b1Len * U_SIZEOF_UCHAR);
+ b1 = (char16_t*) uprv_malloc(b1Len * U_SIZEOF_UCHAR);
if(b1==nullptr){
*status = U_MEMORY_ALLOCATION_ERROR;
goto CLEANUP;
}
U_CFUNC int32_t U_EXPORT2
-idnaref_IDNToUnicode( const UChar* src, int32_t srcLength,
- UChar* dest, int32_t destCapacity,
+idnaref_IDNToUnicode( const char16_t* src, int32_t srcLength,
+ char16_t* dest, int32_t destCapacity,
int32_t options,
UParseError* parseError,
UErrorCode* status){
NamePrepTransform* prep = getInstance(*status);
//initialize pointers to stack buffers
- UChar b1Stack[MAX_LABEL_BUFFER_SIZE];
- UChar *b1 = b1Stack;
+ char16_t b1Stack[MAX_LABEL_BUFFER_SIZE];
+ char16_t *b1 = b1Stack;
int32_t b1Len, labelLen;
- UChar* delimiter = (UChar*)src;
- UChar* labelStart = (UChar*)src;
+ char16_t* delimiter = (char16_t*)src;
+ char16_t* labelStart = (char16_t*)src;
int32_t remainingLen = srcLength;
int32_t b1Capacity = MAX_LABEL_BUFFER_SIZE;
if(*status == U_BUFFER_OVERFLOW_ERROR){
// redo processing of string
/* we do not have enough room so grow the buffer*/
- b1 = (UChar*) uprv_malloc(b1Len * U_SIZEOF_UCHAR);
+ b1 = (char16_t*) uprv_malloc(b1Len * U_SIZEOF_UCHAR);
if(b1==nullptr){
*status = U_MEMORY_ALLOCATION_ERROR;
goto CLEANUP;
if(*status == U_BUFFER_OVERFLOW_ERROR){
// redo processing of string
/* we do not have enough room so grow the buffer*/
- b1 = (UChar*) uprv_malloc(b1Len * U_SIZEOF_UCHAR);
+ b1 = (char16_t*) uprv_malloc(b1Len * U_SIZEOF_UCHAR);
if(b1==nullptr){
*status = U_MEMORY_ALLOCATION_ERROR;
goto CLEANUP;
}
U_CFUNC int32_t U_EXPORT2
-idnaref_compare( const UChar *s1, int32_t length1,
- const UChar *s2, int32_t length2,
+idnaref_compare( const char16_t *s1, int32_t length1,
+ const char16_t *s2, int32_t length2,
int32_t options,
UErrorCode* status){
return -1;
}
- UChar b1Stack[MAX_IDN_BUFFER_SIZE], b2Stack[MAX_IDN_BUFFER_SIZE];
- UChar *b1 = b1Stack, *b2 = b2Stack;
+ char16_t b1Stack[MAX_IDN_BUFFER_SIZE], b2Stack[MAX_IDN_BUFFER_SIZE];
+ char16_t *b1 = b1Stack, *b2 = b2Stack;
int32_t b1Len, b2Len, b1Capacity = MAX_IDN_BUFFER_SIZE, b2Capacity = MAX_IDN_BUFFER_SIZE;
int32_t result = -1;
if(*status == U_BUFFER_OVERFLOW_ERROR){
// redo processing of string
/* we do not have enough room so grow the buffer*/
- b1 = (UChar*) uprv_malloc(b1Len * U_SIZEOF_UCHAR);
+ b1 = (char16_t*) uprv_malloc(b1Len * U_SIZEOF_UCHAR);
if(b1==nullptr){
*status = U_MEMORY_ALLOCATION_ERROR;
goto CLEANUP;
if(*status == U_BUFFER_OVERFLOW_ERROR){
// redo processing of string
/* we do not have enough room so grow the buffer*/
- b2 = (UChar*) uprv_malloc(b2Len * U_SIZEOF_UCHAR);
+ b2 = (char16_t*) uprv_malloc(b2Len * U_SIZEOF_UCHAR);
if(b2==nullptr){
*status = U_MEMORY_ALLOCATION_ERROR;
goto CLEANUP;
UnicodeString dst;
dst.remove();
for (int32_t i = 0; i < src.length(); ++i) {
- UChar c = src[i];
+ char16_t c = src[i];
if(c < 0x0080)
dst += c;
else {
// [LIU] Just to get things working
UnicodeString
-UCharToUnicodeString(UChar c)
+UCharToUnicodeString(char16_t c)
{ return UnicodeString(c); }
// [rtg] Just to get things working
* + char* ambiguous. - liu
*/
UnicodeString toString(const Formattable& f) {
- UnicodeString s((UChar)91/*[*/);
+ UnicodeString s((char16_t)91/*[*/);
s.append(_toString(f));
- s.append((UChar)0x5d/*]*/);
+ s.append((char16_t)0x5d/*]*/);
return s;
}
int32_t digits,
UnicodeString& target)
{
- static const UChar digitString[] = {
+ static const char16_t digitString[] = {
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0
}; /* "0123456789ABCDEF" */
// Delete a backslash.
int32_t backslashCount = 0;
for (int32_t j=target.length()-1; j>=0; --j) {
- if (target.charAt(j) == (UChar)92) {
+ if (target.charAt(j) == (char16_t)92) {
++backslashCount;
} else {
break;
// string that starts with a LineFeed character and continues
// with spaces according to the current indentation
- static const UChar indentUChars[] = {
+ static const char16_t indentUChars[] = {
'\n',
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
}
// replace each LineFeed by the indentation string
- message.findAndReplace(UnicodeString((UChar)'\n'), indent);
+ message.findAndReplace(UnicodeString((char16_t)'\n'), indent);
// stream out the message
length = message.extract(0, message.length(), buffer, sizeof(buffer));
-static inline UChar toHex(int32_t i) {
- return (UChar)(i + (i < 10 ? 0x30 : (0x41 - 10)));
+static inline char16_t toHex(int32_t i) {
+ return (char16_t)(i + (i < 10 ? 0x30 : (0x41 - 10)));
}
static UnicodeString& escape(const UnicodeString& s, UnicodeString& result) {
for (int32_t i=0; i<s.length(); ++i) {
- UChar c = s[i];
- if (c <= (UChar)0x7F) {
+ char16_t c = s[i];
+ if (c <= (char16_t)0x7F) {
result += c;
} else {
- result += (UChar)0x5c;
- result += (UChar)0x75;
+ result += (char16_t)0x5c;
+ result += (char16_t)0x75;
result += toHex((c >> 12) & 0xF);
result += toHex((c >> 8) & 0xF);
result += toHex((c >> 4) & 0xF);
//-------------------------------------------------------------------------------
//
// ReadAndConvertFile Read a text data file, convert it to UChars, and
-// return the data in one big UChar * buffer, which the caller must delete.
+// return the data in one big char16_t * buffer, which the caller must delete.
//
// parameters:
// fileName: the name of the file, with no directory part. The test data directory
// Pass nullptr for the system default encoding.
// status
// returns:
-// The file data, converted to UChar.
+// The file data, converted to char16_t.
// The caller must delete this when done with
// delete [] theBuffer;
//
//
//--------------------------------------------------------------------------------
-UChar *IntlTest::ReadAndConvertFile(const char *fileName, int &ulen, const char *encoding, UErrorCode &status) {
- UChar *retPtr = nullptr;
+char16_t *IntlTest::ReadAndConvertFile(const char *fileName, int &ulen, const char *encoding, UErrorCode &status) {
+ char16_t *retPtr = nullptr;
char *fileBuf = nullptr;
UConverter* conv = nullptr;
FILE *f = nullptr;
}
//
- // Convert the rules to UChar.
+ // Convert the rules to char16_t.
// Preflight first to determine required buffer size.
//
ulen = ucnv_toUChars(conv,
// Buffer Overflow is expected from the preflight operation.
status = U_ZERO_ERROR;
- retPtr = new UChar[ulen+1];
+ retPtr = new char16_t[ulen+1];
ucnv_toUChars(conv,
retPtr, // dest,
ulen+1,
//-----------------------------------------------------------------------------
//convenience classes to ease porting code that uses the Java
//string-concatenation operator (moved from findword test by rtg)
-UnicodeString UCharToUnicodeString(UChar c);
+UnicodeString UCharToUnicodeString(char16_t c);
UnicodeString Int64ToUnicodeString(int64_t num);
UnicodeString DoubleToUnicodeString(double num);
//UnicodeString operator+(const UnicodeString& left, int64_t num); // Some compilers don't allow this because of the long type.
virtual const char* getTestDataPath(UErrorCode& err) override;
static const char* getSourceTestData(UErrorCode& err);
static char *getUnidataPath(char path[]);
- UChar *ReadAndConvertFile(const char *fileName, int &ulen, const char *encoding, UErrorCode &status);
+ char16_t *ReadAndConvertFile(const char *fileName, int &ulen, const char *encoding, UErrorCode &status);
// static members
void CollationIteratorTest::TestUnicodeChar()
{
CollationElementIterator *iter;
- UChar codepoint;
+ char16_t codepoint;
UnicodeString source;
for (codepoint = 1; codepoint < 0xFFFE;)
UErrorCode status = U_ZERO_ERROR;
UnicodeString rule("&a < ab < c/aba < d < z < ch");
RuleBasedCollator *coll = new RuleBasedCollator(rule, status);
- UChar ch = 0;
+ char16_t ch = 0;
UnicodeString str(ch);
CollationElementIterator *iter = coll->createCollationElementIterator(str);
struct ExpansionRecord
{
- UChar character;
+ char16_t character;
int32_t count;
};
void IntlTestRBNF::TestHebrewFraction() {
// this is the expected output for 123.45, with no '<' in it.
- UChar text1[] = {
+ char16_t text1[] = {
0x05de, 0x05d0, 0x05d4, 0x0020,
0x05e2, 0x05e9, 0x05e8, 0x05d9, 0x05dd, 0x0020,
0x05d5, 0x05e9, 0x05dc, 0x05d5, 0x05e9, 0x0020,
0x05d0, 0x05e8, 0x05d1, 0x05e2, 0x0020,
0x05d7, 0x05de, 0x05e9, 0x0000,
};
- UChar text2[] = {
+ char16_t text2[] = {
0x05DE, 0x05D0, 0x05D4, 0x0020,
0x05E2, 0x05E9, 0x05E8, 0x05D9, 0x05DD, 0x0020,
0x05D5, 0x05E9, 0x05DC, 0x05D5, 0x05E9, 0x0020,
LocalUResourceBundlePointer ruleSets(ures_getByKey(rbnfRules.getAlias(), "SpelloutRules", nullptr, &status));
UnicodeString desc;
while (ures_hasNext(ruleSets.getAlias())) {
- const UChar* currentString = ures_getNextString(ruleSets.getAlias(), &len, nullptr, &status);
+ const char16_t* currentString = ures_getNextString(ruleSets.getAlias(), &len, nullptr, &status);
ruleLen += len;
desc.append(currentString);
}
- const UChar *spelloutRules = desc.getTerminatedBuffer();
+ const char16_t *spelloutRules = desc.getTerminatedBuffer();
if(U_FAILURE(status) || ruleLen == 0 || spelloutRules == nullptr) {
errln("Unable to access the rules string!");
int len = fracRules.length();
int change = 2;
for (int i = 0; i < len; ++i) {
- UChar ch = fracRules.charAt(i);
+ char16_t ch = fracRules.charAt(i);
if (ch == '\n') {
change = 2; // change ok
} else if (ch == ':') {
change = 1; // change, but once we hit a non-space char, don't change
} else if (ch == ' ') {
if (change != 0) {
- fracRules.setCharAt(i, (UChar)0x200e);
+ fracRules.setCharAt(i, (char16_t)0x200e);
}
} else {
if (change == 1) {
#endif
// u_atoll
- const UChar uempty[] = { 0 };
- const UChar uzero[] = { 0x30, 0 };
- const UChar uneg_one[] = { 0x2d, 0x31, 0 };
- const UChar uneg_12345[] = { 0x2d, 0x31, 0x32, 0x33, 0x34, 0x35, 0 };
- const UChar ubig1[] = { 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x30, 0 };
- const UChar ubig2[] = { 0x66, 0x46, 0x66, 0x46, 0x66, 0x46, 0x66, 0x46, 0x66, 0x46, 0x66, 0x46, 0x66, 0x46, 0x66, 0x46, 0 };
+ const char16_t uempty[] = { 0 };
+ const char16_t uzero[] = { 0x30, 0 };
+ const char16_t uneg_one[] = { 0x2d, 0x31, 0 };
+ const char16_t uneg_12345[] = { 0x2d, 0x31, 0x32, 0x33, 0x34, 0x35, 0 };
+ const char16_t ubig1[] = { 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x30, 0 };
+ const char16_t ubig2[] = { 0x66, 0x46, 0x66, 0x46, 0x66, 0x46, 0x66, 0x46, 0x66, 0x46, 0x66, 0x46, 0x66, 0x46, 0x66, 0x46, 0 };
LLAssert(llong::utoll(uempty) == llong(0, 0));
LLAssert(llong::utoll(uzero) == llong(0, 0));
LLAssert(llong::utoll(uneg_one) == llong(0xffffffff, 0xffffffff));
logln("Testing u_lltoa");
// u_lltoa
{
- UChar buf[64];
+ char16_t buf[64];
LLAssert((llong(0, 0).lltou(buf, (uint32_t)sizeof(buf)) == 1) && (u_strcmp(buf, uzero) == 0));
LLAssert((llong(0xffffffff, 0xffffffff).lltou(buf, (uint32_t)sizeof(buf)) == 2) && (u_strcmp(buf, uneg_one) == 0));
LLAssert(((-llong(0, 12345)).lltou(buf, (uint32_t)sizeof(buf)) == 6) && (u_strcmp(buf, uneg_12345) == 0));
void IntlTestRBNF::TestParseFailure() {
UErrorCode status = U_ZERO_ERROR;
RuleBasedNumberFormat rbnf(URBNF_SPELLOUT, Locale::getJapanese(), status);
- static const UChar* testData[] = {
+ static const char16_t* testData[] = {
u"・・・・・・・・・・・・・・・・・・・・・・・・"
};
if (assertSuccess("", status, true, __FILE__, __LINE__)) {
UnicodeString us;
formatter->format((const Formattable)val, us, status);
if (U_SUCCESS(status)) {
- us.insert(0, (UChar)'"');
- us.append((UChar)'"');
+ us.insert(0, (char16_t)'"');
+ us.append((char16_t)'"');
logln(us);
} else {
logln("error: could not format %g, returned status: %d", val, status);
UnicodeString us;
formatter->format((const Formattable)(int32_t)val, us, status);
if (U_SUCCESS(status)) {
- us.insert(0, (UChar)'"');
- us.append((UChar)'"');
+ us.insert(0, (char16_t)'"');
+ us.append((char16_t)'"');
logln(us);
} else {
logln("error: could not format %d, returned status: %d", val, status);
UnicodeString result;
UChar32 cc = 0;
for (int32_t i=0; i<in.length(); i++) {
- UChar c = in.charAt(i);
+ char16_t c = in.charAt(i);
if (c == 0x20) { // Space
if (cc > 0) {
result.append(cc);
int hexDigit = (c>>bitNum) & 0x0f;
if (hexDigit != 0 || doZeroes) {
doZeroes = true;
- dest.append((UChar)(hexDigit<=9? hexDigit + 0x30: hexDigit -10 + 0x41));
+ dest.append((char16_t)(hexDigit<=9? hexDigit + 0x30: hexDigit -10 + 0x41));
}
}
- dest.append((UChar)0x20);
+ dest.append((char16_t)0x20);
}
U_DEFINE_LOCAL_OPEN_POINTER(LocalStdioFilePointer, FILE, fclose);
errln("LocalPointer access failure");
}
// adoptInstead(), orphan()
- s.adoptInstead(new UnicodeString((UChar)0xfffc));
+ s.adoptInstead(new UnicodeString((char16_t)0xfffc));
if(s->length()!=1) {
errln("LocalPointer adoptInstead(U+FFFC) failure");
}
}
void LocalPointerTest::TestLocalPointerMoveSwap() {
- UnicodeString *p1 = new UnicodeString((UChar)0x61);
- UnicodeString *p2 = new UnicodeString((UChar)0x62);
+ UnicodeString *p1 = new UnicodeString((char16_t)0x61);
+ UnicodeString *p2 = new UnicodeString((char16_t)0x62);
LocalPointer<UnicodeString> s1(p1);
LocalPointer<UnicodeString> s2(p2);
s1.swap(s2);
// constructor
LocalArray<UnicodeString> a(new UnicodeString[2]);
// operator[]()
- a[0].append((UChar)0x61);
+ a[0].append((char16_t)0x61);
a[1].append((UChar32)0x60006);
if(a[0].length()!=1 || a[1].length()!=2) {
errln("LocalArray access failure");
}
// adoptInstead()
a.adoptInstead(new UnicodeString[4]);
- a[3].append((UChar)0x62).append((UChar)0x63).reverse();
+ a[3].append((char16_t)0x62).append((char16_t)0x63).reverse();
if(a[3].length()!=2 || a[3][1]!=0x62) {
errln("LocalArray adoptInstead() failure");
}
delete myCollation;
}
-const UChar CollationKanaTest::testSourceCases[][CollationKanaTest::MAX_TOKEN_LEN] = {
+const char16_t CollationKanaTest::testSourceCases[][CollationKanaTest::MAX_TOKEN_LEN] = {
{0xff9E, 0x0000},
{0x3042, 0x0000},
{0x30A2, 0x0000},
{0x30A2, 0x30FC, 0x30C8, 0x0000} /* 6 */
};
-const UChar CollationKanaTest::testTargetCases[][CollationKanaTest::MAX_TOKEN_LEN] = {
+const char16_t CollationKanaTest::testTargetCases[][CollationKanaTest::MAX_TOKEN_LEN] = {
{0xFF9F, 0x0000},
{0x30A2, 0x0000},
{0x3042, 0x3042, 0x0000},
Collator::LESS, //Collator::GREATER /* Prolonged sound mark sorts BEFORE equivalent vowel (ICU 2.0)*//* 6 */
};
-const UChar CollationKanaTest::testBaseCases[][CollationKanaTest::MAX_TOKEN_LEN] = {
+const char16_t CollationKanaTest::testBaseCases[][CollationKanaTest::MAX_TOKEN_LEN] = {
{0x30AB, 0x0000},
{0x30AB, 0x30AD, 0x0000},
{0x30AD, 0x0000},
{0x30AD, 0x30AD, 0x0000}
};
-const UChar CollationKanaTest::testPlainDakutenHandakutenCases[][CollationKanaTest::MAX_TOKEN_LEN] = {
+const char16_t CollationKanaTest::testPlainDakutenHandakutenCases[][CollationKanaTest::MAX_TOKEN_LEN] = {
{0x30CF, 0x30AB, 0x0000},
{0x30D0, 0x30AB, 0x0000},
{0x30CF, 0x30AD, 0x0000},
{0x30D0, 0x30AD, 0x0000}
};
-const UChar CollationKanaTest::testSmallLargeCases[][CollationKanaTest::MAX_TOKEN_LEN] = {
+const char16_t CollationKanaTest::testSmallLargeCases[][CollationKanaTest::MAX_TOKEN_LEN] = {
{0x30C3, 0x30CF, 0x0000},
{0x30C4, 0x30CF, 0x0000},
{0x30C3, 0x30D0, 0x0000},
{0x30C4, 0x30D0, 0x0000}
};
-const UChar CollationKanaTest::testKatakanaHiraganaCases[][CollationKanaTest::MAX_TOKEN_LEN] = {
+const char16_t CollationKanaTest::testKatakanaHiraganaCases[][CollationKanaTest::MAX_TOKEN_LEN] = {
{0x3042, 0x30C3, 0x0000},
{0x30A2, 0x30C3, 0x0000},
{0x3042, 0x30C4, 0x0000},
{0x30A2, 0x30C4, 0x0000}
};
-const UChar CollationKanaTest::testChooonKigooCases[][CollationKanaTest::MAX_TOKEN_LEN] = {
+const char16_t CollationKanaTest::testChooonKigooCases[][CollationKanaTest::MAX_TOKEN_LEN] = {
/*0*/ {0x30AB, 0x30FC, 0x3042, 0x0000},
/*1*/ {0x30AB, 0x30FC, 0x30A2, 0x0000},
/*2*/ {0x30AB, 0x30A4, 0x3042, 0x0000},
void TestChooonKigoo();
private:
- static const UChar testSourceCases[][MAX_TOKEN_LEN];
- static const UChar testTargetCases[][MAX_TOKEN_LEN];
+ static const char16_t testSourceCases[][MAX_TOKEN_LEN];
+ static const char16_t testTargetCases[][MAX_TOKEN_LEN];
static const Collator::EComparisonResult results[];
- static const UChar testBaseCases[][MAX_TOKEN_LEN];
- static const UChar testPlainDakutenHandakutenCases[][MAX_TOKEN_LEN];
- static const UChar testSmallLargeCases[][MAX_TOKEN_LEN];
- static const UChar testKatakanaHiraganaCases[][MAX_TOKEN_LEN];
- static const UChar testChooonKigooCases[][MAX_TOKEN_LEN];
+ static const char16_t testBaseCases[][MAX_TOKEN_LEN];
+ static const char16_t testPlainDakutenHandakutenCases[][MAX_TOKEN_LEN];
+ static const char16_t testSmallLargeCases[][MAX_TOKEN_LEN];
+ static const char16_t testKatakanaHiraganaCases[][MAX_TOKEN_LEN];
+ static const char16_t testChooonKigooCases[][MAX_TOKEN_LEN];
Collator *myCollation;
};
* latin and back.
*/
void JamoTest::TestPiecemeal(void) {
- UnicodeString hangul; hangul.append((UChar)0xBC0F);
+ UnicodeString hangul; hangul.append((char16_t)0xBC0F);
UnicodeString jamo = nameToJamo("(Mi)(I)(Cf)");
UnicodeString latin("mic");
UnicodeString latin2("mich");
delete myCollation;
}
-const UChar LotusCollationKoreanTest::testSourceCases[][LotusCollationKoreanTest::MAX_TOKEN_LEN] = {
+const char16_t LotusCollationKoreanTest::testSourceCases[][LotusCollationKoreanTest::MAX_TOKEN_LEN] = {
{0xac00, 0}
};
-const UChar LotusCollationKoreanTest::testTargetCases[][LotusCollationKoreanTest::MAX_TOKEN_LEN] = {
+const char16_t LotusCollationKoreanTest::testTargetCases[][LotusCollationKoreanTest::MAX_TOKEN_LEN] = {
{0xac01, 0}
};
void TestTertiary(/* char* par */);
private:
- static const UChar testSourceCases[][MAX_TOKEN_LEN];
- static const UChar testTargetCases[][MAX_TOKEN_LEN];
+ static const char16_t testSourceCases[][MAX_TOKEN_LEN];
+ static const char16_t testTargetCases[][MAX_TOKEN_LEN];
static const Collator::EComparisonResult results[];
Collator *myCollation;
return;
}
int32_t lineLength;
- const UChar *p;
+ const char16_t *p;
UnicodeString line;
TestCase test;
int32_t numPassed = 0;
void LocaleDisplayNamesTest::TestUldnOpen() {
UErrorCode status = U_ZERO_ERROR;
const int32_t kMaxResultSize = 150; // long enough
- UChar result[150];
+ char16_t result[150];
ULocaleDisplayNames *ldn = uldn_open(Locale::getGermany().getName(), ULDN_STANDARD_NAMES, &status);
int32_t len = uldn_localeDisplayName(ldn, "de_DE", result, kMaxResultSize, &status);
uldn_close(ldn);
void LocaleDisplayNamesTest::TestUldnOpenDialect() {
UErrorCode status = U_ZERO_ERROR;
const int32_t kMaxResultSize = 150; // long enough
- UChar result[150];
+ char16_t result[150];
ULocaleDisplayNames *ldn = uldn_open(Locale::getUS().getName(), ULDN_DIALECT_NAMES, &status);
int32_t len = uldn_localeDisplayName(ldn, "en_GB", result, kMaxResultSize, &status);
uldn_close(ldn);
void LocaleDisplayNamesTest::TestUldnWithGarbage() {
UErrorCode status = U_ZERO_ERROR;
const int32_t kMaxResultSize = 150; // long enough
- UChar result[150];
+ char16_t result[150];
ULocaleDisplayNames *ldn = uldn_open(Locale::getUS().getName(), ULDN_DIALECT_NAMES, &status);
int32_t len = uldn_localeDisplayName(ldn, "english (United States) [w", result, kMaxResultSize, &status);
uldn_close(ldn);
void LocaleDisplayNamesTest::TestUldnWithKeywordsAndEverything() {
UErrorCode status = U_ZERO_ERROR;
const int32_t kMaxResultSize = 150; // long enough
- UChar result[150];
+ char16_t result[150];
const char *locname = "en_Hant_US_VALLEY@calendar=gregorian;collation=phonebook";
const char *target = "English (Traditional, United States, VALLEY, "
"Gregorian Calendar, Phonebook Sort Order)";
void LocaleDisplayNamesTest::TestUldnComponents() {
UErrorCode status = U_ZERO_ERROR;
const int32_t kMaxResultSize = 150; // long enough
- UChar result[150];
+ char16_t result[150];
ULocaleDisplayNames *ldn = uldn_open(Locale::getGermany().getName(), ULDN_STANDARD_NAMES, &status);
test_assert(U_SUCCESS(status));
UDisplayContext capitalization;
UDisplayContext displayLength;
const char * localeToBeNamed;
- const UChar * result;
+ const char16_t * result;
} LocNameDispContextItem;
static char en[] = "en";
static char en_GB[] = "en_GB";
static char uz_Latn[] = "uz_Latn";
-static UChar daFor_en[] = {0x65,0x6E,0x67,0x65,0x6C,0x73,0x6B,0}; //"engelsk"
-static UChar daFor_en_cabud[] = {0x65,0x6E,0x67,0x65,0x6C,0x73,0x6B,0x20,0x28,0x62,0x75,0x64,0x64,0x68,0x69,0x73,0x74,0x69,0x73,0x6B,0x20,
+static char16_t daFor_en[] = {0x65,0x6E,0x67,0x65,0x6C,0x73,0x6B,0}; //"engelsk"
+static char16_t daFor_en_cabud[] = {0x65,0x6E,0x67,0x65,0x6C,0x73,0x6B,0x20,0x28,0x62,0x75,0x64,0x64,0x68,0x69,0x73,0x74,0x69,0x73,0x6B,0x20,
0x6B,0x61,0x6C,0x65,0x6E,0x64,0x65,0x72,0x29,0}; //"engelsk (buddhistisk kalender)"
-static UChar daFor_en_GB[] = {0x65,0x6E,0x67,0x65,0x6C,0x73,0x6B,0x20,0x28,0x53,0x74,0x6F,0x72,0x62,0x72,0x69,0x74,0x61,0x6E,0x6E,0x69,0x65,0x6E,0x29,0}; //"engelsk (Storbritannien)"
-static UChar daFor_en_GB_D[] = {0x62,0x72,0x69,0x74,0x69,0x73,0x6B,0x20,0x65,0x6E,0x67,0x65,0x6C,0x73,0x6B,0}; //"britisk engelsk"
-static UChar esFor_en[] = {0x69,0x6E,0x67,0x6C,0xE9,0x73,0}; //"ingles" with acute on the e
-static UChar esFor_en_GB[] = {0x69,0x6E,0x67,0x6C,0xE9,0x73,0x20,0x28,0x52,0x65,0x69,0x6E,0x6F,0x20,0x55,0x6E,0x69,0x64,0x6F,0x29,0}; //"ingles (Reino Unido)" ...
-static UChar esFor_en_GB_S[] = {0x69,0x6E,0x67,0x6C,0xE9,0x73,0x20,0x28,0x52,0x55,0x29,0}; //"ingles (RU)" ...
-static UChar esFor_en_GB_D[] = {0x69,0x6E,0x67,0x6C,0xE9,0x73,0x20,0x62,0x72,0x69,0x74,0xE1,0x6E,0x69,0x63,0x6F,0}; //"ingles britanico" with acute on the e, a
-static UChar ruFor_uz_Latn[] = {0x0443,0x0437,0x0431,0x0435,0x043A,0x0441,0x043A,0x0438,0x0439,0x20,0x28,0x043B,0x0430,0x0442,0x0438,0x043D,0x0438,0x0446,0x0430,0x29,0}; // all lowercase
+static char16_t daFor_en_GB[] = {0x65,0x6E,0x67,0x65,0x6C,0x73,0x6B,0x20,0x28,0x53,0x74,0x6F,0x72,0x62,0x72,0x69,0x74,0x61,0x6E,0x6E,0x69,0x65,0x6E,0x29,0}; //"engelsk (Storbritannien)"
+static char16_t daFor_en_GB_D[] = {0x62,0x72,0x69,0x74,0x69,0x73,0x6B,0x20,0x65,0x6E,0x67,0x65,0x6C,0x73,0x6B,0}; //"britisk engelsk"
+static char16_t esFor_en[] = {0x69,0x6E,0x67,0x6C,0xE9,0x73,0}; //"ingles" with acute on the e
+static char16_t esFor_en_GB[] = {0x69,0x6E,0x67,0x6C,0xE9,0x73,0x20,0x28,0x52,0x65,0x69,0x6E,0x6F,0x20,0x55,0x6E,0x69,0x64,0x6F,0x29,0}; //"ingles (Reino Unido)" ...
+static char16_t esFor_en_GB_S[] = {0x69,0x6E,0x67,0x6C,0xE9,0x73,0x20,0x28,0x52,0x55,0x29,0}; //"ingles (RU)" ...
+static char16_t esFor_en_GB_D[] = {0x69,0x6E,0x67,0x6C,0xE9,0x73,0x20,0x62,0x72,0x69,0x74,0xE1,0x6E,0x69,0x63,0x6F,0}; //"ingles britanico" with acute on the e, a
+static char16_t ruFor_uz_Latn[] = {0x0443,0x0437,0x0431,0x0435,0x043A,0x0441,0x043A,0x0438,0x0439,0x20,0x28,0x043B,0x0430,0x0442,0x0438,0x043D,0x0438,0x0446,0x0430,0x29,0}; // all lowercase
#if !UCONFIG_NO_BREAK_ITERATION
-static UChar daFor_en_T[] = {0x45,0x6E,0x67,0x65,0x6C,0x73,0x6B,0}; //"Engelsk"
-static UChar daFor_en_cabudT[]= {0x45,0x6E,0x67,0x65,0x6C,0x73,0x6B,0x20,0x28,0x62,0x75,0x64,0x64,0x68,0x69,0x73,0x74,0x69,0x73,0x6B,0x20,
+static char16_t daFor_en_T[] = {0x45,0x6E,0x67,0x65,0x6C,0x73,0x6B,0}; //"Engelsk"
+static char16_t daFor_en_cabudT[]= {0x45,0x6E,0x67,0x65,0x6C,0x73,0x6B,0x20,0x28,0x62,0x75,0x64,0x64,0x68,0x69,0x73,0x74,0x69,0x73,0x6B,0x20,
0x6B,0x61,0x6C,0x65,0x6E,0x64,0x65,0x72,0x29,0}; //"Engelsk (buddhistisk kalender)"
-static UChar daFor_en_GB_T[] = {0x45,0x6E,0x67,0x65,0x6C,0x73,0x6B,0x20,0x28,0x53,0x74,0x6F,0x72,0x62,0x72,0x69,0x74,0x61,0x6E,0x6E,0x69,0x65,0x6E,0x29,0}; //"Engelsk (Storbritannien)"
-static UChar daFor_en_GB_DT[] = {0x42,0x72,0x69,0x74,0x69,0x73,0x6B,0x20,0x65,0x6E,0x67,0x65,0x6C,0x73,0x6B,0}; //"Britisk engelsk"
-static UChar esFor_en_T[] = {0x49,0x6E,0x67,0x6C,0xE9,0x73,0}; //"Ingles" with acute on the e
-static UChar esFor_en_GB_T[] = {0x49,0x6E,0x67,0x6C,0xE9,0x73,0x20,0x28,0x52,0x65,0x69,0x6E,0x6F,0x20,0x55,0x6E,0x69,0x64,0x6F,0x29,0}; //"Ingles (Reino Unido)" ...
-static UChar esFor_en_GB_ST[] = {0x49,0x6E,0x67,0x6C,0xE9,0x73,0x20,0x28,0x52,0x55,0x29,0}; //"Ingles (RU)" ...
-static UChar esFor_en_GB_DT[] = {0x49,0x6E,0x67,0x6C,0xE9,0x73,0x20,0x62,0x72,0x69,0x74,0xE1,0x6E,0x69,0x63,0x6F,0}; //"Ingles britanico" with acute on the e, a
-static UChar ruFor_uz_Latn_T[]= {0x0423,0x0437,0x0431,0x0435,0x043A,0x0441,0x043A,0x0438,0x0439,0x20,0x28,0x043B,0x0430,0x0442,0x0438,0x043D,0x0438,0x0446,0x0430,0x29,0}; // first char upper
+static char16_t daFor_en_GB_T[] = {0x45,0x6E,0x67,0x65,0x6C,0x73,0x6B,0x20,0x28,0x53,0x74,0x6F,0x72,0x62,0x72,0x69,0x74,0x61,0x6E,0x6E,0x69,0x65,0x6E,0x29,0}; //"Engelsk (Storbritannien)"
+static char16_t daFor_en_GB_DT[] = {0x42,0x72,0x69,0x74,0x69,0x73,0x6B,0x20,0x65,0x6E,0x67,0x65,0x6C,0x73,0x6B,0}; //"Britisk engelsk"
+static char16_t esFor_en_T[] = {0x49,0x6E,0x67,0x6C,0xE9,0x73,0}; //"Ingles" with acute on the e
+static char16_t esFor_en_GB_T[] = {0x49,0x6E,0x67,0x6C,0xE9,0x73,0x20,0x28,0x52,0x65,0x69,0x6E,0x6F,0x20,0x55,0x6E,0x69,0x64,0x6F,0x29,0}; //"Ingles (Reino Unido)" ...
+static char16_t esFor_en_GB_ST[] = {0x49,0x6E,0x67,0x6C,0xE9,0x73,0x20,0x28,0x52,0x55,0x29,0}; //"Ingles (RU)" ...
+static char16_t esFor_en_GB_DT[] = {0x49,0x6E,0x67,0x6C,0xE9,0x73,0x20,0x62,0x72,0x69,0x74,0xE1,0x6E,0x69,0x63,0x6F,0}; //"Ingles britanico" with acute on the e, a
+static char16_t ruFor_uz_Latn_T[]= {0x0423,0x0437,0x0431,0x0435,0x043A,0x0441,0x043A,0x0438,0x0439,0x20,0x28,0x043B,0x0430,0x0442,0x0438,0x043D,0x0438,0x0446,0x0430,0x29,0}; // first char upper
#endif /* #if !UCONFIG_NO_BREAK_ITERATION */
static const LocNameDispContextItem ctxtItems[] = {
displayLength != ctxtItemPtr->displayLength) {
errln("FAIL: uldn_getContext retrieved incorrect dialectHandling, capitalization, or displayLength");
} else {
- UChar nameBuf[ULOC_FULLNAME_CAPACITY];
+ char16_t nameBuf[ULOC_FULLNAME_CAPACITY];
int32_t len = uldn_localeDisplayName(uldn, ctxtItemPtr->localeToBeNamed, nameBuf, ULOC_FULLNAME_CAPACITY, &status);
if (U_FAILURE(status)) {
dataerrln(UnicodeString("FAIL: uldn_localeDisplayName status: ") + u_errorName(status));
void LocaleDisplayNamesTest::TestNumericRegionID() {
UErrorCode err = U_ZERO_ERROR;
ULocaleDisplayNames* ldn = uldn_open("es_MX", ULDN_STANDARD_NAMES, &err);
- UChar displayName[200];
+ char16_t displayName[200];
uldn_regionDisplayName(ldn, "019", displayName, 200, &err);
test_assert(U_SUCCESS(err));
test_assert_equal(UnicodeString(u"América"), UnicodeString(displayName));
void
LocaleTest::TestEuroSupport()
{
- UChar euro = 0x20ac;
+ char16_t euro = 0x20ac;
const UnicodeString EURO_CURRENCY(&euro, 1, 1); // Look for this UnicodeString in formatted Euro currency
const char* localeArr[] = {
"ca_ES",
delete nf;
}
- UnicodeString dollarStr("USD", ""), euroStr("EUR", ""), genericStr((UChar)0x00a4), resultStr;
- UChar tmp[4];
+ UnicodeString dollarStr("USD", ""), euroStr("EUR", ""), genericStr((char16_t)0x00a4), resultStr;
+ char16_t tmp[4];
status = U_ZERO_ERROR;
ucurr_forLocale("en_US", tmp, 4, &status);
df_full.format(mydate, str, pos);
// Make sure that o circumflex (\u00F4) is NOT there, and
// o double acute (\u0151) IS.
- UChar ocf = 0x00f4;
- UChar oda = 0x0151;
+ char16_t ocf = 0x00f4;
+ char16_t oda = 0x0151;
if (str.indexOf(oda) < 0 || str.indexOf(ocf) >= 0) {
/* If the default locale is "th" this test will fail because of the buddhist calendar. */
if (strcmp(Locale::getDefault().getLanguage(), "th") != 0) {
#if !UCONFIG_NO_FORMATTING
UErrorCode status = U_ZERO_ERROR;
UDate date = uprv_getUTCtime();
- UChar TMP[4] = {0, 0, 0, 0};
+ char16_t TMP[4] = {0, 0, 0, 0};
int32_t index = 0;
int32_t resLen = 0;
UnicodeString tempStr, resultStr;
status = U_ZERO_ERROR; // reset
date = uprv_getUTCtime();
- UChar USD[4];
+ char16_t USD[4];
ucurr_forLocaleAndDate("en_US", date, 1, USD, 4, &status);
- UChar YEN[4];
+ char16_t YEN[4];
ucurr_forLocaleAndDate("ja_JP", date, 1, YEN, 4, &status);
ucurr_forLocaleAndDate("en_US", date, 1, TMP, 4, &status);
// Test will fail once SLE is declared legal.
// CLDR 42: Now check that currency of Sierra Leone is SLE (which is legal tender)
UnicodeString sllStr("SLE", ""), resultStr;
- UChar tmp[4];
+ char16_t tmp[4];
UErrorCode status = U_ZERO_ERROR;
ucurr_forLocale("en_SL", tmp, 4, &status);
testFileName.append(filename, -1, status);
int len;
- UChar *testFile = ReadAndConvertFile(testFileName.data(), len, "UTF-8", status);
+ char16_t *testFile = ReadAndConvertFile(testFileName.data(), len, "UTF-8", status);
if (U_FAILURE(status)) {
errln("%s:%d Error %s opening test file %s", __FILE__, __LINE__, u_errorName(status), filename);
return;
}
void MeasureFormatTest::TestCurrencies() {
- UChar USD[4] = {};
+ char16_t USD[4] = {};
u_uastrcpy(USD, "USD");
UErrorCode status = U_ZERO_ERROR;
CurrencyUnit USD_unit(USD, status);
DateFormatMiscTests::test4117335()
{
//UnicodeString bc = "\u7d00\u5143\u524d";
- UChar bcC [] = {
+ char16_t bcC [] = {
0x7D00,
0x5143,
0x524D
UnicodeString bc(bcC, 3, 3);
//UnicodeString ad = "\u897f\u66a6";
- UChar adC [] = {
+ char16_t adC [] = {
0x897F,
0x66A6
};
UnicodeString ad(adC, 2, 2);
//UnicodeString jstLong = "\u65e5\u672c\u6a19\u6e96\u6642";
- UChar jstLongC [] = {
+ char16_t jstLongC [] = {
0x65e5,
0x672c,
0x6a19,
0x6e96,
0x6642
};
- UChar jdtLongC [] = {0x65E5, 0x672C, 0x590F, 0x6642, 0x9593};
+ char16_t jdtLongC [] = {0x65E5, 0x672C, 0x590F, 0x6642, 0x9593};
UnicodeString jstLong(jstLongC, 5, 5);
}
}
void CollationMonkeyTest::TestRules(/* char* par */){
- UChar testSourceCases[][10] = {
+ char16_t testSourceCases[][10] = {
{0x0061, 0x0062, 0x007a, 0},
{0x0061, 0x0062, 0x007a, 0},
};
- UChar testTargetCases[][10] = {
+ char16_t testTargetCases[][10] = {
{0x0061, 0x0062, 0x00e4, 0},
{0x0061, 0x0062, 0x0061, 0x0308, 0},
};
Collator *col = Collator::createInstance("en_US", status);
const UnicodeString baseRules = ((RuleBasedCollator*)col)->getRules();
UnicodeString newRules(" & z < ");
- newRules.append((UChar)0x00e4);
+ newRules.append((char16_t)0x00e4);
newRules.insert(0, baseRules);
RuleBasedCollator *myCollation = new RuleBasedCollator(newRules, status);
if (U_FAILURE(status)) {
logln("Demo Test 2 : Create a new table collation with rules \"& z < a 0x0308\"");
newRules.remove();
newRules.append(" & z < a");
- newRules.append((UChar)0x0308);
+ newRules.append((char16_t)0x0308);
newRules.insert(0, baseRules);
myCollation = new RuleBasedCollator(newRules, status);
if (U_FAILURE(status)) {
{
UErrorCode status = U_ZERO_ERROR;
UnicodeString pattern("-");
- pattern += (UChar) 0x221E;
+ pattern += (char16_t) 0x221E;
pattern += "<are negative|0<are no or fraction|1#is one|1<is 1+|";
- pattern += (UChar) 0x221E;
+ pattern += (char16_t) 0x221E;
pattern += "<are many.";
ChoiceFormat *fmt = new ChoiceFormat(pattern, status);
} else {
float n = 1234.567f;
UnicodeString res0, res1, res2, res3, res4, res5;
- UChar ures3[50];
- UChar ures4[50];
- UChar ures5[50];
+ char16_t ures3[50];
+ char16_t ures4[50];
+ char16_t ures5[50];
f0->format(n, res0);
f1->format(n, res1);
if(lbundle.isValid() && U_SUCCESS(status)){
// create the mapping transliterator
int32_t ruleLen = 0;
- const UChar* ruleUChar = ures_getStringByKey(lbundle.getAlias(), "MapNFKC",&ruleLen, &status);
+ const char16_t* ruleUChar = ures_getStringByKey(lbundle.getAlias(), "MapNFKC",&ruleLen, &status);
int32_t mapRuleLen = 0;
- const UChar *mapRuleUChar = ures_getStringByKey(lbundle.getAlias(), "MapNoNormalization", &mapRuleLen, &status);
+ const char16_t *mapRuleUChar = ures_getStringByKey(lbundle.getAlias(), "MapNoNormalization", &mapRuleLen, &status);
UnicodeString rule(mapRuleUChar, mapRuleLen);
rule.append(ruleUChar, ruleLen);
//create the unassigned set
int32_t patternLen =0;
- const UChar* pattern = ures_getStringByKey(lbundle.getAlias(),"UnassignedSet",&patternLen, &status);
+ const char16_t* pattern = ures_getStringByKey(lbundle.getAlias(),"UnassignedSet",&patternLen, &status);
unassigned.applyPattern(UnicodeString(pattern, patternLen), status);
//create prohibited set
}
if(U_SUCCESS(status)){
- if(prohibited.contains((UChar) 0x644)){
+ if(prohibited.contains((char16_t) 0x644)){
printf("The string contains 0x644 ... !!\n");
}
UnicodeString temp;
}
-int32_t NamePrepTransform::map(const UChar* src, int32_t srcLength,
- UChar* dest, int32_t destCapacity,
+int32_t NamePrepTransform::map(const char16_t* src, int32_t srcLength,
+ char16_t* dest, int32_t destCapacity,
UBool allowUnassigned,
UParseError* /*parseError*/,
UErrorCode& status ){
// transliteration also performs NFKC
mapping->transliterate(rsource);
- const UChar* buffer = rsource.getBuffer();
+ const char16_t* buffer = rsource.getBuffer();
int32_t bufLen = rsource.length();
// check if unassigned
if(allowUnassigned == false){
#define MAX_BUFFER_SIZE 300
-int32_t NamePrepTransform::process( const UChar* src, int32_t srcLength,
- UChar* dest, int32_t destCapacity,
+int32_t NamePrepTransform::process( const char16_t* src, int32_t srcLength,
+ char16_t* dest, int32_t destCapacity,
UBool allowUnassigned,
UParseError* parseError,
UErrorCode& status ){
}
UnicodeString b1String;
- UChar *b1 = b1String.getBuffer(MAX_BUFFER_SIZE);
+ char16_t *b1 = b1String.getBuffer(MAX_BUFFER_SIZE);
int32_t b1Len;
int32_t b1Index = 0;
* that that a character be mapped to nothing, mapped to one
* other character or to a string of other characters.
*
- * @param src Pointer to UChar buffer containing a single label
+ * @param src Pointer to char16_t buffer containing a single label
* @param srcLength Number of characters in the source label
* @param dest Pointer to the destination buffer to receive the output
* @param destCapacity The capacity of destination array
* Must fulfill U_SUCCESS before the function call.
* @return The number of UChars in the destination buffer
*/
- int32_t map(const UChar* src, int32_t srcLength,
- UChar* dest, int32_t destCapacity,
+ int32_t map(const char16_t* src, int32_t srcLength,
+ char16_t* dest, int32_t destCapacity,
UBool allowUnassigned,
UParseError* parseError,
UErrorCode& status );
* Prepare the input stream with for use. This operation maps, normalizes(NFKC),
* checks for prohited and BiDi characters in the order defined by RFC 3454
*
- * @param src Pointer to UChar buffer containing a single label
+ * @param src Pointer to char16_t buffer containing a single label
* @param srcLength Number of characters in the source label
* @param dest Pointer to the destination buffer to receive the output
* @param destCapacity The capacity of destination array
* Must fulfill U_SUCCESS before the function call.
* @return The number of UChars in the destination buffer
*/
- int32_t process(const UChar* src, int32_t srcLength,
- UChar* dest, int32_t destCapacity,
+ int32_t process(const char16_t* src, int32_t srcLength,
+ char16_t* dest, int32_t destCapacity,
UBool allowUnassigned,
UParseError* parseError,
UErrorCode& status );
}
int64_t value = 0;
for (int32_t i = start; i < len; ++i) {
- UChar ch = str[i];
+ char16_t ch = str[i];
if (ch < 0x30 || ch > 0x39) {
status = U_ILLEGAL_ARGUMENT_ERROR;
return;
static void intToStr(
const void *intPtr, UnicodeString &appendTo) {
- UChar buffer[20];
+ char16_t buffer[20];
// int64_t such that all int32_t values can be negated
int64_t xSigned = *static_cast<const int32_t *>(intPtr);
uint32_t x;
if (xSigned < 0) {
- appendTo.append((UChar)0x2D);
+ appendTo.append((char16_t)0x2D);
x = static_cast<uint32_t>(-xSigned);
} else {
x = static_cast<uint32_t>(xSigned);
const char *locale;
const char *unitDisplayCase;
double value;
- const UChar *expected;
+ const char16_t *expected;
};
void runUnitInflectionsTestCases(UnlocalizedNumberFormatter unf,
continue;
};
UnicodeString skelString = UnicodeString("unit/") + t.unitIdentifier + u" " + skeleton;
- const UChar *skel;
+ const char16_t *skel;
if (t.unitDisplayCase == nullptr || t.unitDisplayCase[0] == 0) {
unf = unf.unit(mu).unitDisplayCase("");
skel = skelString.getTerminatedBuffer();
};
UnicodeString skelString = UnicodeString("unit/") + t.unitIdentifier + u" " + skeleton;
- const UChar *skel;
+ const char16_t *skel;
auto displayOptionsBuilder = DisplayOptions::builder();
if (t.unitDisplayCase == nullptr || t.unitDisplayCase[0] == 0) {
auto displayoptions = displayOptionsBuilder.build();
IcuTestErrorCode status(*this, "unitInflections");
UnlocalizedNumberFormatter unf;
- const UChar *skeleton;
+ const char16_t *skeleton;
{
// Simple inflected form test - test case based on the example in CLDR's
// grammaticalFeatures.xml
int32_t lineNumber = 1;
int32_t lineLength;
for (const auto& actualLine : resultLines) {
- const UChar* lineBuf = ucbuf_readline(f.getAlias(), &lineLength, status);
+ const char16_t* lineBuf = ucbuf_readline(f.getAlias(), &lineLength, status);
if (lineBuf == nullptr) {
errln("More lines generated than are in the data file!");
break;
if (tuple.currencyFlag) {
UErrorCode status = U_ZERO_ERROR;
UnicodeString currency(tuple.currency);
- const UChar* terminatedCurrency = currency.getTerminatedBuffer();
+ const char16_t* terminatedCurrency = currency.getTerminatedBuffer();
fmt.setCurrency(terminatedCurrency, status);
if (U_FAILURE(status)) {
appendErrorMessage.append("Error setting currency.");
#include "unicode/dtfmtsym.h"
#include "uassert.h"
-static const UChar kJPY[] = {0x4A, 0x50, 0x59};
+static const char16_t kJPY[] = {0x4A, 0x50, 0x59};
static void fixNonBreakingSpace(UnicodeString &str) {
for (int32_t i = 0; i < str.length(); ++i) {
//#define NUMFMTST_DEBUG 1
-static const UChar EUR[] = {69,85,82,0}; // "EUR"
-static const UChar ISO_CURRENCY_USD[] = {0x55, 0x53, 0x44, 0}; // "USD"
+static const char16_t EUR[] = {69,85,82,0}; // "EUR"
+static const char16_t ISO_CURRENCY_USD[] = {0x55, 0x53, 0x44, 0}; // "USD"
// *****************************************************************************
return appendTo;
}
virtual UnicodeString& format(int32_t ,UnicodeString& appendTo,FieldPosition& ) const override {
- return appendTo.append((UChar)0x0033);
+ return appendTo.append((char16_t)0x0033);
}
virtual UnicodeString& format(int64_t number,UnicodeString& appendTo,FieldPosition& pos) const override {
return NumberFormat::format(number, appendTo, pos);
UErrorCode status = U_ZERO_ERROR;
DecimalFormatSymbols* sym = new DecimalFormatSymbols(Locale::getUS(), status);
UnicodeString pat;
- UChar currency = 0x00A4;
+ char16_t currency = 0x00A4;
if (U_FAILURE(status)) {
errcheckln(status, "Fail to create DecimalFormatSymbols - %s", u_errorName(status));
delete sym;
// -------------------------------------
-static UChar toHexString(int32_t i) { return (UChar)(i + (i < 10 ? 0x30 : (0x41 - 10))); }
+static char16_t toHexString(int32_t i) { return (char16_t)(i + (i < 10 ? 0x30 : (0x41 - 10))); }
UnicodeString&
NumberFormatTest::escape(UnicodeString& s)
UnicodeString buf;
for (int32_t i=0; i<s.length(); ++i)
{
- UChar c = s[(int32_t)i];
- if (c <= (UChar)0x7F) buf += c;
+ char16_t c = s[(int32_t)i];
+ if (c <= (char16_t)0x7F) buf += c;
else {
- buf += (UChar)0x5c; buf += (UChar)0x55;
+ buf += (char16_t)0x5c; buf += (char16_t)0x55;
buf += toHexString((c & 0xF000) >> 12);
buf += toHexString((c & 0x0F00) >> 8);
buf += toHexString((c & 0x00F0) >> 4);
/* fmt.setPadCharacter((UnicodeString)"^^^");
expectPad(fmt, "*^^^#", DecimalFormat::kPadBeforePrefix, 3, (UnicodeString)"^^^");
padString.remove();
- padString.append((UChar)0x0061);
- padString.append((UChar)0x0302);
+ padString.append((char16_t)0x0061);
+ padString.append((char16_t)0x0302);
fmt.setPadCharacter(padString);
- UChar patternChars[]={0x002a, 0x0061, 0x0302, 0x0061, 0x0302, 0x0023, 0x0000};
+ char16_t patternChars[]={0x002a, 0x0061, 0x0302, 0x0061, 0x0302, 0x0023, 0x0000};
UnicodeString pattern(patternChars);
expectPad(fmt, pattern , DecimalFormat::kPadBeforePrefix, 4, padString);
*/
DecimalFormat fmt("#", US, status);
CHECK(status, "DecimalFormat constructor");
- UChar hat = 0x005E; /*^*/
+ char16_t hat = 0x005E; /*^*/
expectPad(fmt, "*^#", DecimalFormat::kPadBeforePrefix, 1, hat);
expectPad(fmt, "$*^#", DecimalFormat::kPadAfterPrefix, 2, hat);
expectPad(fmt, "$*^$#", ILLEGAL);
expectPad(fmt, "#$*^$", ILLEGAL);
expectPad(fmt, "'pre'#,##0*x'post'", DecimalFormat::kPadBeforeSuffix,
- 12, (UChar)0x0078 /*x*/);
+ 12, (char16_t)0x0078 /*x*/);
expectPad(fmt, "''#0*x", DecimalFormat::kPadBeforeSuffix,
- 3, (UChar)0x0078 /*x*/);
+ 3, (char16_t)0x0078 /*x*/);
expectPad(fmt, "'I''ll'*a###.##", DecimalFormat::kPadAfterPrefix,
- 10, (UChar)0x0061 /*a*/);
+ 10, (char16_t)0x0061 /*a*/);
fmt.applyPattern("AA#,##0.00ZZ", status);
CHECK(status, "applyPattern");
expect2(new DecimalFormat("##0.000", custom, status),
1.25, expStr, status);
- custom.setSymbol(DecimalFormatSymbols::kZeroDigitSymbol, (UChar)0x30);
+ custom.setSymbol(DecimalFormatSymbols::kZeroDigitSymbol, (char16_t)0x30);
custom.setSymbol(DecimalFormatSymbols::kCurrencySymbol, "units of money");
custom.setSymbol(DecimalFormatSymbols::kMonetarySeparatorSymbol, "money separator");
patternStr = UNICODE_STRING_SIMPLE("0.00 \\u00A4' in your bank account'");
void NumberFormatTest::TestRegCurrency(void) {
#if !UCONFIG_NO_SERVICE
UErrorCode status = U_ZERO_ERROR;
- UChar USD[4];
+ char16_t USD[4];
ucurr_forLocale("en_US", USD, 4, &status);
- UChar YEN[4];
+ char16_t YEN[4];
ucurr_forLocale("ja_JP", YEN, 4, &status);
- UChar TMP[4];
+ char16_t TMP[4];
if(U_FAILURE(status)) {
errcheckln(status, "Unable to get currency for locale, error %s", u_errorName(status));
// Do a basic check of getName()
// USD { "US$", "US Dollar" } // 04/04/1792-
UErrorCode ec = U_ZERO_ERROR;
- static const UChar USD[] = {0x55, 0x53, 0x44, 0}; /*USD*/
- static const UChar USX[] = {0x55, 0x53, 0x58, 0}; /*USX*/
- static const UChar CAD[] = {0x43, 0x41, 0x44, 0}; /*CAD*/
- static const UChar ITL[] = {0x49, 0x54, 0x4C, 0}; /*ITL*/
+ static const char16_t USD[] = {0x55, 0x53, 0x44, 0}; /*USD*/
+ static const char16_t USX[] = {0x55, 0x53, 0x58, 0}; /*USX*/
+ static const char16_t CAD[] = {0x43, 0x41, 0x44, 0}; /*CAD*/
+ static const char16_t ITL[] = {0x49, 0x54, 0x4C, 0}; /*ITL*/
UBool isChoiceFormat;
int32_t len;
const UBool possibleDataError = true;
status.setScope(cas.isoCode);
UBool choiceFormatIgnored;
int32_t lengthIgnored;
- const UChar* actualShort = ucurr_getName(
+ const char16_t* actualShort = ucurr_getName(
cas.isoCode,
cas.locale,
UCURR_SYMBOL_NAME,
&choiceFormatIgnored,
&lengthIgnored,
status);
- const UChar* actualFormal = ucurr_getName(
+ const char16_t* actualFormal = ucurr_getName(
cas.isoCode,
cas.locale,
UCURR_FORMAL_SYMBOL_NAME,
&choiceFormatIgnored,
&lengthIgnored,
status);
- const UChar* actualVarant = ucurr_getName(
+ const char16_t* actualVarant = ucurr_getName(
cas.isoCode,
cas.locale,
UCURR_VARIANT_SYMBOL_NAME,
&lengthIgnored,
status);
status.errIfFailureAndReset();
- const UChar* actualNarrow = ucurr_getName(
+ const char16_t* actualNarrow = ucurr_getName(
cas.isoCode,
cas.locale,
UCURR_NARROW_SYMBOL_NAME,
void NumberFormatTest::TestCurrencyUnit(void){
UErrorCode ec = U_ZERO_ERROR;
- static const UChar USD[] = u"USD";
+ static const char16_t USD[] = u"USD";
static const char USD8[] = "USD";
- static const UChar BAD[] = u"???";
- static const UChar BAD2[] = u"??A";
- static const UChar XXX[] = u"XXX";
+ static const char16_t BAD[] = u"???";
+ static const char16_t BAD2[] = u"??A";
+ static const char16_t XXX[] = u"XXX";
static const char XXX8[] = "XXX";
- static const UChar XYZ[] = u"XYZ";
+ static const char16_t XYZ[] = u"XYZ";
static const char XYZ8[] = "XYZ";
- static const UChar INV[] = u"{$%";
+ static const char16_t INV[] = u"{$%";
static const char INV8[] = "{$%";
- static const UChar ZZZ[] = u"zz";
+ static const char16_t ZZZ[] = u"zz";
static const char ZZZ8[] = "zz";
- static const UChar JPY[] = u"JPY";
+ static const char16_t JPY[] = u"JPY";
static const char JPY8[] = "JPY";
- static const UChar jpy[] = u"jpy";
+ static const char16_t jpy[] = u"jpy";
static const char jpy8[] = "jpy";
- UChar* EUR = (UChar*) malloc(6);
+ char16_t* EUR = (char16_t*) malloc(6);
EUR[0] = u'E';
EUR[1] = u'U';
EUR[2] = u'R';
void NumberFormatTest::TestCurrencyAmount(void){
UErrorCode ec = U_ZERO_ERROR;
- static const UChar USD[] = {85, 83, 68, 0}; /*USD*/
+ static const char16_t USD[] = {85, 83, 68, 0}; /*USD*/
CurrencyAmount ca(9, USD, ec);
assertSuccess("CurrencyAmount", ec);
Locale locBad(localeName);
assertTrue(WHERE, !locBad.isBogus());
UErrorCode status = U_ZERO_ERROR;
- UnicodeString intlCurrencySymbol((UChar)0xa4);
+ UnicodeString intlCurrencySymbol((char16_t)0xa4);
- intlCurrencySymbol.append((UChar)0xa4);
+ intlCurrencySymbol.append((char16_t)0xa4);
logln("Current locale is %s", Locale::getDefault().getName());
Locale::setDefault(locBad, status);
return;
}
UnicodeString pat(" #,##0.00");
- pat.insert(0, (UChar)0x00A4);
+ pat.insert(0, (char16_t)0x00A4);
DecimalFormat fmt(pat, sym, ec);
if (U_FAILURE(ec)) {
errln("Fail: DecimalFormat constructor");
*/
static void parseCurrencyAmount(const UnicodeString& str,
const NumberFormat& fmt,
- UChar delim,
+ char16_t delim,
Formattable& result,
UErrorCode& ec) {
UnicodeString num, cur;
// fpc: <loc or '-'> <curr.amt> <exp. string> <exp. curr.amt>
if (!tokens.next(currAmt, ec)) goto error;
if (!tokens.next(str, ec)) goto error;
- parseCurrencyAmount(currAmt, *ref, (UChar)0x2F/*'/'*/, n, ec);
+ parseCurrencyAmount(currAmt, *ref, (char16_t)0x2F/*'/'*/, n, ec);
if (assertSuccess("parseCurrencyAmount", ec)) {
assertEquals(where + "getCurrencyFormat(" + mloc + ").format(" + currAmt + ")",
str, mfmt->format(n, out.remove(), ec));
assertSuccess("format", ec);
}
if (!tokens.next(currAmt, ec)) goto error;
- parseCurrencyAmount(currAmt, *ref, (UChar)0x2F/*'/'*/, n, ec);
+ parseCurrencyAmount(currAmt, *ref, (char16_t)0x2F/*'/'*/, n, ec);
if (assertSuccess("parseCurrencyAmount", ec)) {
Formattable m;
double value, const UnicodeString& string) {
UErrorCode ec = U_ZERO_ERROR;
DecimalFormat& fmt = * (DecimalFormat*) &nf;
- const UChar DEFAULT_CURR[] = {45/*-*/,0};
- UChar curr[4];
+ const char16_t DEFAULT_CURR[] = {45/*-*/,0};
+ char16_t curr[4];
u_strcpy(curr, DEFAULT_CURR);
if (*locale.getLanguage() != 0) {
ucurr_forLocale(locale.getName(), curr, 4, &ec);
expectPad(fmt, pat, pos, 0, (UnicodeString)"");
}
void NumberFormatTest::expectPad(DecimalFormat& fmt, const UnicodeString& pat,
- int32_t pos, int32_t width, UChar pad) {
+ int32_t pos, int32_t width, char16_t pad) {
expectPad(fmt, pat, pos, width, UnicodeString(pad));
}
void NumberFormatTest::expectPad(DecimalFormat& fmt, const UnicodeString& pat,
// This test is flaky b/c the symbols for CNY and JPY are equivalent in this locale - FIXME
void NumberFormatTest::TestCompatibleCurrencies() {
/*
- static const UChar JPY[] = {0x4A, 0x50, 0x59, 0};
- static const UChar CNY[] = {0x43, 0x4E, 0x59, 0};
+ static const char16_t JPY[] = {0x4A, 0x50, 0x59, 0};
+ static const char16_t CNY[] = {0x43, 0x4E, 0x59, 0};
UErrorCode status = U_ZERO_ERROR;
LocalPointer<NumberFormat> fmt(
NumberFormat::createCurrencyInstance(Locale::getUS(), status));
*/
}
-void NumberFormatTest::expectParseCurrency(const NumberFormat &fmt, const UChar* currency, double amount, const char *text) {
+void NumberFormatTest::expectParseCurrency(const NumberFormat &fmt, const char16_t* currency, double amount, const char *text) {
ParsePosition ppos;
UnicodeString utext = ctou(text);
LocalPointer<CurrencyAmount> currencyAmount(fmt.parseCurrency(utext, ppos));
MeasureFormat *cloneObj;
UnicodeString str;
Formattable toFormat, result;
- static const UChar ISO_CODE[4] = {0x0047, 0x0042, 0x0050, 0};
+ static const char16_t ISO_CODE[4] = {0x0047, 0x0042, 0x0050, 0};
Locale saveDefaultLocale = Locale::getDefault();
Locale::setDefault( Locale::getUK(), status );
{"zh_CN", "\\u00A4#,##0.00;(\\u00A4#,##0.00)", "1", "\\u00A51.00", "CNY\\u00A01.00", "\\u4EBA\\u6C11\\u5E01\\u00A01.00"}
};
- const UChar doubleCurrencySign[] = {0xA4, 0xA4, 0};
+ const char16_t doubleCurrencySign[] = {0xA4, 0xA4, 0};
UnicodeString doubleCurrencyStr(doubleCurrencySign);
- const UChar tripleCurrencySign[] = {0xA4, 0xA4, 0xA4, 0};
+ const char16_t tripleCurrencySign[] = {0xA4, 0xA4, 0xA4, 0};
UnicodeString tripleCurrencyStr(tripleCurrencySign);
for (uint32_t i=0; i<UPRV_LENGTHOF(DATA); ++i) {
return;
}
UnicodeString pat;
- UChar currency = 0x00A4;
+ char16_t currency = 0x00A4;
// "\xA4#,##0.00;-\xA4#,##0.00"
pat.append(currency).append(currency).append(currency).append("#,##0.00;-").append(currency).append(currency).append(currency).append("#,##0.00");
DecimalFormat* fmt = new DecimalFormat(pat, sym, status);
dataerrln((UnicodeString)"can not create instance, locale:" + localeString + ", style: " + k + " - " + u_errorName(status));
continue;
}
- UChar currencyCode[4];
+ char16_t currencyCode[4];
u_charsToUChars(currencyISOCode, currencyCode, 4);
numFmt->setCurrency(currencyCode, status);
if (U_FAILURE(status)) {
dataerrln((UnicodeString)"can not create instance, locale:" + localeString + ", style: " + k + " - " + u_errorName(status));
continue;
}
- UChar currencyCode[4];
+ char16_t currencyCode[4];
u_charsToUChars(currencyISOCode, currencyCode, 4);
numFmt->setCurrency(currencyCode, status);
if (U_FAILURE(status)) {
U_STRING_DECL(nanstr,"NAN",3);
U_STRING_INIT(nanstr,"NAN",3);
- UChar outputbuf[50] = {0};
+ char16_t outputbuf[50] = {0};
UErrorCode status = U_ZERO_ERROR;
UNumberFormat* fmt = unum_open(UNUM_PATTERN_DECIMAL,pattern,1,nullptr,nullptr,&status);
if ( U_FAILURE(status) ) {
UnicodeString str;
f.getString(str);
int32_t len;
- const UChar* uch = ufmt_getUChars(u, &len, &valueStatus);
+ const char16_t* uch = ufmt_getUChars(u, &len, &valueStatus);
if(U_SUCCESS(valueStatus)) {
UnicodeString str2(uch, len);
- assertTrue("UChar* NUL-terminated", uch[len]==0);
+ assertTrue("char16_t* NUL-terminated", uch[len]==0);
exactMatch = (str == str2);
}
triedExact = true;
custom.setSymbol(DecimalFormatSymbols::kMonetarySeparatorSymbol, ":");
UnicodeString pat(" #,##0.00");
- pat.insert(0, (UChar)0x00A4);
+ pat.insert(0, (char16_t)0x00A4);
DecimalFormat fmt(pat, custom, status);
CHECK(status, "DecimalFormat constructor");
// Test the currency change
// 1st time for getter/setter, 2nd time for factory method
- const UChar CUR_PKR[] = {0x50, 0x4B, 0x52, 0};
+ const char16_t CUR_PKR[] = {0x50, 0x4B, 0x52, 0};
for(int i=0; i<2; i++){
status = U_ZERO_ERROR;
if(i == 0){
dataerrln("Error creating NumberFormat - %s", u_errorName(status));
return;
}
- UChar JPY[] = {0x4A, 0x50, 0x59, 0x0};
+ char16_t JPY[] = {0x4A, 0x50, 0x59, 0x0};
fmt->setCurrency(JPY, status);
if (!assertSuccess("", status)) {
return;
void NumberFormatTest::Test11376_getAndSetPositivePrefix() {
{
- const UChar USD[] = {0x55, 0x53, 0x44, 0x0};
+ const char16_t USD[] = {0x55, 0x53, 0x44, 0x0};
UErrorCode status = U_ZERO_ERROR;
LocalPointer<NumberFormat> fmt(
NumberFormat::createCurrencyInstance("en", status));
assertSuccess("", status);
}
{
- const UChar USD[] = {0x55, 0x53, 0x44, 0x0};
+ const char16_t USD[] = {0x55, 0x53, 0x44, 0x0};
UErrorCode status = U_ZERO_ERROR;
LocalPointer<NumberFormat> fmt(
NumberFormat::createInstance("en", UNUM_CURRENCY_PLURAL, status));
if (!assertSuccess("", status)) {
return;
}
- static UChar USD[] = {0x55, 0x53, 0x44, 0x0};
+ static char16_t USD[] = {0x55, 0x53, 0x44, 0x0};
fmt.setCurrency(USD);
UnicodeString appendTo;
dataerrln("%s %d Chakma df is null", __FILE__, __LINE__);
return;
}
- const UChar* expected = u"\U00011137\U00011138,\U00011139\U0001113A\U0001113B";
+ const char16_t* expected = u"\U00011137\U00011138,\U00011139\U0001113A\U0001113B";
UnicodeString actual;
df->format(12345, actual, status);
assertSuccess("Should not fail when formatting in ccp", status);
assertSuccess("Should not fail when parsing in ccp", status);
assertEquals("Should parse to 12345 in ccp", 12345, result);
- const UChar* expectedScientific = u"\U00011137.\U00011139E\U00011138";
+ const char16_t* expectedScientific = u"\U00011137.\U00011139E\U00011138";
UnicodeString actualScientific;
df.adoptInstead(static_cast<DecimalFormat*>(
NumberFormat::createScientificInstance(Locale("ccp"), status)));
pattern = pattern.unescape();
DecimalFormat fmt(pattern, status);
if (!assertSuccess("", status, true, __FILE__, __LINE__)) { return; }
- static const UChar USD[] = u"USD";
+ static const char16_t USD[] = u"USD";
fmt.setCurrency(USD);
UnicodeString appendTo;
private:
UBool testFormattableAsUFormattable(const char *file, int line, Formattable &f);
- void expectParseCurrency(const NumberFormat &fmt, const UChar* currency, double amount, const char *text);
+ void expectParseCurrency(const NumberFormat &fmt, const char16_t* currency, double amount, const char *text);
static UBool equalValue(const Formattable& a, const Formattable& b);
double value, const UnicodeString& string);
void expectPad(DecimalFormat& fmt, const UnicodeString& pat,
- int32_t pos, int32_t width, UChar pad);
+ int32_t pos, int32_t width, char16_t pad);
void expectPad(DecimalFormat& fmt, const char *pat,
- int32_t pos, int32_t width, UChar pad) {
+ int32_t pos, int32_t width, char16_t pad) {
expectPad(fmt, UnicodeString(pat, ""), pos, width, pad);
}
void expectPad(DecimalFormat& fmt, const char *pat,
int32_t pos) {
- expectPad(fmt, pat, pos, 0, (UChar)0);
+ expectPad(fmt, pat, pos, 0, (char16_t)0);
}
void expect_rbnf(NumberFormat& fmt, const UnicodeString& str, const Formattable& n);
FieldPosition pos(FieldPosition::DONT_CARE);
logln(UnicodeString("format(") + n + ") = " +
df->format(n, buf1, pos));
- symbols->setSymbol(DecimalFormatSymbols::kDecimalSeparatorSymbol, UnicodeString((UChar)0x70)); // change value of field
+ symbols->setSymbol(DecimalFormatSymbols::kDecimalSeparatorSymbol, UnicodeString((char16_t)0x70)); // change value of field
logln(UnicodeString("format(") + n + ") = " +
df->format(n, buf2, pos));
if(buf1 != buf2)
logln("...applyLocalizedPattern # ###,00;(# ###,00) ");
// nbsp = \u00a0
//nf->applyLocalizedPattern("#\u00a0###,00;(#\u00a0###,00)");
- UChar patChars[] = {
+ char16_t patChars[] = {
0x23, 0x202f, 0x23, 0x23, 0x23, 0x2c, 0x30, 0x30, 0x3b,
0x28, 0x23, 0x202f, 0x23, 0x23, 0x23, 0x2c, 0x30, 0x30, 0x29
};
UnicodeString buffer;
buffer = nf->format((int32_t)1234, buffer, pos);
//if (buffer != UnicodeString("1\u00a0234,00"))
- UChar c[] = {
+ char16_t c[] = {
0x31, 0x202f, 0x32, 0x33, 0x34, 0x2c, 0x30, 0x30
};
UnicodeString cc(c, 8, 8);
buffer.remove();
buffer = nf->format((int32_t)-1234, buffer, pos);
- UChar c1[] = {
+ char16_t c1[] = {
0x28, 0x31, 0x202f, 0x32, 0x33, 0x34, 0x2c, 0x30, 0x30, 0x29
};
UnicodeString cc1(c1, 10, 10);
String expectedCurrency = "5\u202f789,98\u00a0F";
String expectedPercent = "-578\u202f998%";
*/
- UChar chars1 [] = {
+ char16_t chars1 [] = {
0x2d, 0x35, 0x202f, 0x37, 0x38, 0x39, 0x2c, 0x39, 0x38, 0x38
};
- UChar chars2 [] = {
+ char16_t chars2 [] = {
0x35, 0x202f, 0x37, 0x38, 0x39, 0x2c, 0x39, 0x39, 0x00a0, 0x46
};
- UChar chars3 [] = {
+ char16_t chars3 [] = {
0x2d, 0x35, 0x37, 0x38, 0x202f, 0x39, 0x39, 0x39, 0x00a0, 0x25
};
UnicodeString expectedDefault(chars1, 10, 10);
String expectedCurrency = "5\u00a0789,98\u00a0$";
String expectedPercent = "-578\u00a0998%";
*/
- UChar chars1 [] = {
+ char16_t chars1 [] = {
0x2d, 0x35, 0x00a0, 0x37, 0x38, 0x39, 0x2c, 0x39, 0x38, 0x38
};
- UChar chars2 [] = {
+ char16_t chars2 [] = {
0x35, 0x00a0, 0x37, 0x38, 0x39, 0x2c, 0x39, 0x39, 0x00a0, 0x24
};
- UChar chars3 [] = {
+ char16_t chars3 [] = {
0x2d, 0x35, 0x37, 0x38, 0x00a0, 0x39, 0x39, 0x39, 0x00a0, 0x25
};
UnicodeString expectedDefault(chars1, 10, 10);
logln((UnicodeString)"Before set ==> Currency : " + currency +(UnicodeString)" Intl Currency : " + intlCurrency + (UnicodeString)" Monetary Decimal Separator : " + monDecSeparatorStr);
fmt->setSymbol(DecimalFormatSymbols::kCurrencySymbol, UnicodeString("XYZ"));
fmt->setSymbol(DecimalFormatSymbols::kIntlCurrencySymbol, UnicodeString("ABC"));
- fmt->setSymbol(DecimalFormatSymbols::kMonetarySeparatorSymbol, UnicodeString((UChar)0x002A/*'*'*/));
+ fmt->setSymbol(DecimalFormatSymbols::kMonetarySeparatorSymbol, UnicodeString((char16_t)0x002A/*'*'*/));
currency = fmt->getSymbol(DecimalFormatSymbols::kCurrencySymbol);
intlCurrency = fmt->getSymbol(DecimalFormatSymbols::kIntlCurrencySymbol);
monDecSeparator = fmt->getSymbol(DecimalFormatSymbols::kMonetarySeparatorSymbol);
if (currency != UnicodeString("XYZ") ||
intlCurrency != UnicodeString("ABC") ||
- monDecSeparator != UnicodeString((UChar)0x002A/*'*'*/)) {
+ monDecSeparator != UnicodeString((char16_t)0x002A/*'*'*/)) {
errln("setCurrencySymbols failed.");
}
monDecSeparatorStr.remove();
return;
}
failure(status, "new DecimalFormat");
- UChar foo [] = { 0x002B };
+ char16_t foo [] = { 0x002B };
UnicodeString bar(foo, 1, 1);
volatile double d = 0.0; // volatile to prevent code optimization
UnicodeString temp;
UnicodeString pattern = numPat.getString(status);
failure(status, "rb->getString()");
- UChar fo[] = { 0x00A4 };
+ char16_t fo[] = { 0x00A4 };
UnicodeString foo(fo, 1, 1);
//if (pattern.indexOf("\u00A4") == -1 ) {
// pattern. We have to skip locales where the currency symbol
// contains decimal separators, because that confuses things
//
- UChar ba[] = { 0x002E/*'.'*/ };
+ char16_t ba[] = { 0x002E/*'.'*/ };
UnicodeString bar(ba, 1, 1);
if (symbols->getSymbol(DecimalFormatSymbols::kCurrencySymbol).indexOf(bar) == -1) {
failure(status, "new DecimalFormat");
// Get the currency (if there is one) so we can set the rounding and fraction
- const UChar *currency = fmt1->getCurrency();
+ const char16_t *currency = fmt1->getCurrency();
if (*currency != 0) {
double rounding = ucurr_getRoundingIncrement(currency, &status);
int32_t frac = ucurr_getDefaultFractionDigits(currency, &status);
}
DecimalFormatSymbols *sym = (DecimalFormatSymbols*) nf->getDecimalFormatSymbols();
- sym->setSymbol(DecimalFormatSymbols::kDecimalSeparatorSymbol, (UChar)/*'\''*/0x0027);
+ sym->setSymbol(DecimalFormatSymbols::kDecimalSeparatorSymbol, (char16_t)/*'\''*/0x0027);
nf->setDecimalFormatSymbols(*sym);
double pi = 3.14159;
UnicodeString s;
FieldPosition pos;
- sym.setSymbol(DecimalFormatSymbols::kMinusSignSymbol, (UChar)0x5e);
+ sym.setSymbol(DecimalFormatSymbols::kMinusSignSymbol, (char16_t)0x5e);
fmt.setDecimalFormatSymbols(sym);
s.remove();
if (fmt.format((int32_t)-1, s, pos) != UNICODE_STRING("^1", 2)) {
", exp ^1");
}
s.remove();
- if (fmt.getNegativePrefix(s) != UnicodeString((UChar)0x5e)) {
+ if (fmt.getNegativePrefix(s) != UnicodeString((char16_t)0x5e)) {
errln(UnicodeString("FAIL: (minus=^).getNegativePrefix -> ") +
s + ", exp ^");
}
- sym.setSymbol(DecimalFormatSymbols::kMinusSignSymbol, (UChar)0x2d);
+ sym.setSymbol(DecimalFormatSymbols::kMinusSignSymbol, (char16_t)0x2d);
fmt.applyPattern(UnicodeString("#%"), status);
failure(status, "applyPattern percent");
- sym.setSymbol(DecimalFormatSymbols::kPercentSymbol, (UChar)0x5e);
+ sym.setSymbol(DecimalFormatSymbols::kPercentSymbol, (char16_t)0x5e);
fmt.setDecimalFormatSymbols(sym);
s.remove();
if (fmt.format(0.25, s, pos) != UNICODE_STRING("25^", 3)) {
", exp 25^");
}
s.remove();
- if (fmt.getPositiveSuffix(s) != UnicodeString((UChar)0x5e)) {
+ if (fmt.getPositiveSuffix(s) != UnicodeString((char16_t)0x5e)) {
errln(UnicodeString("FAIL: (percent=^).getPositiveSuffix -> ") +
s + ", exp ^");
}
- sym.setSymbol(DecimalFormatSymbols::kPercentSymbol, (UChar)0x25);
+ sym.setSymbol(DecimalFormatSymbols::kPercentSymbol, (char16_t)0x25);
fmt.applyPattern(str("#\\u2030"), status);
failure(status, "applyPattern permill");
- sym.setSymbol(DecimalFormatSymbols::kPerMillSymbol, (UChar)0x5e);
+ sym.setSymbol(DecimalFormatSymbols::kPerMillSymbol, (char16_t)0x5e);
fmt.setDecimalFormatSymbols(sym);
s.remove();
if (fmt.format(0.25, s, pos) != UNICODE_STRING("250^", 4)) {
", exp 250^");
}
s.remove();
- if (fmt.getPositiveSuffix(s) != UnicodeString((UChar)0x5e)) {
+ if (fmt.getPositiveSuffix(s) != UnicodeString((char16_t)0x5e)) {
errln(UnicodeString("FAIL: (permill=^).getPositiveSuffix -> ") +
s + ", exp ^");
}
- sym.setSymbol(DecimalFormatSymbols::kPerMillSymbol, (UChar)0x2030);
+ sym.setSymbol(DecimalFormatSymbols::kPerMillSymbol, (char16_t)0x2030);
fmt.applyPattern(str("\\u00A4#.00"), status);
failure(status, "applyPattern currency");
void NumberFormatRegressionTest::Test9677(void) {
- static const UChar pattern[] = { 0x23,0x23,0x23,0x23,0x2E,0x23,0x23,0x23,0x23,0 }; // "####.####"
- static const UChar positivePrefix[] = { 0x40,0 }; // "@"
- static const UChar negativePrefix[] = { 0x6E,0 }; // "n"
- static const UChar text[] = { 0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0 }; // 123456789
- static const UChar text2[] = { 0x6E, 0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0 }; // n123456789
+ static const char16_t pattern[] = { 0x23,0x23,0x23,0x23,0x2E,0x23,0x23,0x23,0x23,0 }; // "####.####"
+ static const char16_t positivePrefix[] = { 0x40,0 }; // "@"
+ static const char16_t negativePrefix[] = { 0x6E,0 }; // "n"
+ static const char16_t text[] = { 0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0 }; // 123456789
+ static const char16_t text2[] = { 0x6E, 0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0 }; // n123456789
UErrorCode status = U_ZERO_ERROR;
LocalUNumberFormatPointer f(unum_open(UNUM_DEFAULT, nullptr, 0, "en_US", nullptr, &status));
UErrorCode status = U_ZERO_ERROR;
UnicodeString fmtString(fmt, -1, US_INV);
PluralFormat pf(Locale::getEnglish(), fmtString, status);
- MessageFormat mf(UNICODE_STRING_SIMPLE("{0,plural,").append(fmtString).append((UChar)0x7d /* '}' */),
+ MessageFormat mf(UNICODE_STRING_SIMPLE("{0,plural,").append(fmtString).append((char16_t)0x7d /* '}' */),
Locale::getEnglish(), status);
Formattable args;
FieldPosition ignore;
// Test word break rule status constants.
//
void RBBIAPITest::TestRuleStatus() {
- UChar str[30];
+ char16_t str[30];
//no longer test Han or hiragana breaking here: ruleStatusVec would return nothing
// changed UBRK_WORD_KANA to UBRK_WORD_IDEO
u_unescape("plain word 123.45 \\u30a1\\u30a2 ",
* runs BreakIterator::next() repeatedly, moving the text in the middle of the sequence.
* The right set of boundaries should still be found.
*/
- UChar testStr[] = {0x20, 0x41, 0x20, 0x42, 0x20, 0x43, 0x20, 0x44, 0x0}; /* = " A B C D" */
- UChar movedStr[] = {0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0};
+ char16_t testStr[] = {0x20, 0x41, 0x20, 0x42, 0x20, 0x43, 0x20, 0x44, 0x0}; /* = " A B C D" */
+ char16_t movedStr[] = {0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0};
UErrorCode status = U_ZERO_ERROR;
UText ut1 = UTEXT_INITIALIZER;
UText ut2 = UTEXT_INITIALIZER;
#if !UCONFIG_NO_BREAK_ITERATION && !UCONFIG_NO_FILTERED_BREAK_ITERATION
static void prtbrks(BreakIterator* brk, const UnicodeString &ustr, IntlTest &it) {
- static const UChar PILCROW=0x00B6, CHSTR=0x3010, CHEND=0x3011; // lenticular brackets
+ static const char16_t PILCROW=0x00B6, CHSTR=0x3010, CHEND=0x3011; // lenticular brackets
it.logln(UnicodeString("String:'")+ustr+UnicodeString("'"));
int32_t *pos = new int32_t[ustr.length()];
}
}
UnicodeString out;
- out.append((UChar)CHSTR);
+ out.append((char16_t)CHSTR);
int32_t prev = 0;
for(int32_t i=0;i<posCount;i++) {
int32_t n=pos[i];
out.append(ustr.tempSubString(prev,n-prev));
- out.append((UChar)PILCROW);
+ out.append((char16_t)PILCROW);
prev=n;
}
out.append(ustr.tempSubString(prev,ustr.length()-prev));
- out.append((UChar)CHEND);
+ out.append((char16_t)CHEND);
it.logln(out);
out.remove();
// Replace the divide sign (\u00f7) with a regular expression named capture.
// When running the rules, a match that includes this group means we found a break position.
- int32_t dividePos = thisRule->fExpandedRule.indexOf((UChar)0x00f7);
+ int32_t dividePos = thisRule->fExpandedRule.indexOf((char16_t)0x00f7);
if (dividePos >= 0) {
thisRule->fExpandedRule.replace(dividePos, 1, UnicodeString("(?<BreakPosition>)"));
}
- if (thisRule->fExpandedRule.indexOf((UChar)0x00f7) != -1) {
+ if (thisRule->fExpandedRule.indexOf((char16_t)0x00f7) != -1) {
status = U_ILLEGAL_ARGUMENT_ERROR; // TODO: produce a good error message.
}
// Regular expression set expressions don't accept this. Substitute with [^\u0000-\U0010ffff], which
// also matches nothing.
- static const UChar emptySet[] = {(UChar)0x5b, (UChar)0x5d, 0};
+ static const char16_t emptySet[] = {(char16_t)0x5b, (char16_t)0x5d, 0};
int32_t where = 0;
while ((where = thisRule->fExpandedRule.indexOf(emptySet, 2, 0)) >= 0) {
thisRule->fExpandedRule.replace(where, 2, UnicodeString("[^\\u0000-\\U0010ffff]"));
return;
}
int32_t lineLength = 0;
- const UChar *lineBuf = ucbuf_readline(rules, &lineLength, &status);
+ const char16_t *lineBuf = ucbuf_readline(rules, &lineLength, &status);
if (lineBuf == nullptr) {
break;
}
// Apply reference rules to find the expected breaks.
- fExpectedBreaks.setCharAt(0, (UChar)1); // Force an expected break before the start of the text.
+ fExpectedBreaks.setCharAt(0, (char16_t)1); // Force an expected break before the start of the text.
// ICU always reports a break there.
// The reference rules do not have a means to do so.
int32_t strIdx = 0;
// Record which rule matched over the length of the match.
for (int i = matchStart; i < matchEnd; i++) {
if (fRuleForPosition.charAt(i) == 0) {
- fRuleForPosition.setCharAt(i, (UChar)ruleNum);
+ fRuleForPosition.setCharAt(i, (char16_t)ruleNum);
} else {
- f2ndRuleForPos.setCharAt(i, (UChar)ruleNum);
+ f2ndRuleForPos.setCharAt(i, (char16_t)ruleNum);
}
}
status = U_INVALID_FORMAT_ERROR;
break;
}
- fExpectedBreaks.setCharAt(breakPos, (UChar)1);
+ fExpectedBreaks.setCharAt(breakPos, (char16_t)1);
// printf("recording break at %d\n", breakPos);
// For the next iteration, pick up applying rules immediately after the break,
// which may differ from end of the match. The matching rule may have included
// Actual Breaks length is one longer than the data string length, allowing
// for breaks before the first and after the last character in the data.
for (int32_t i=0; i<=fString.length(); i++) {
- fActualBreaks.append((UChar)0);
+ fActualBreaks.append((char16_t)0);
}
}
UErrorCode status = U_ZERO_ERROR;
// Four Thai words...
- static const UChar thaiWordData[] = { 0x0E43,0x0E2B,0x0E0D,0x0E48, 0x0E43,0x0E2B,0x0E0D,0x0E48,
+ static const char16_t thaiWordData[] = { 0x0E43,0x0E2B,0x0E0D,0x0E48, 0x0E43,0x0E2B,0x0E0D,0x0E48,
0x0E43,0x0E2B,0x0E0D,0x0E48, 0x0E43,0x0E2B,0x0E0D,0x0E48, 0 };
UnicodeString thaiStr(thaiWordData);
testFileName.append("rbbitst.txt", -1, status);
int len;
- UChar *testFile = ReadAndConvertFile(testFileName.data(), len, "UTF-8", status);
+ char16_t *testFile = ReadAndConvertFile(testFileName.data(), len, "UTF-8", status);
if (U_FAILURE(status)) {
errln("%s:%d Error %s opening file rbbitst.txt", __FILE__, __LINE__, u_errorName(status));
return;
for (charIdx = 0; charIdx < len; ) {
status = U_ZERO_ERROR;
- UChar c = testString.charAt(charIdx);
+ char16_t c = testString.charAt(charIdx);
charIdx++;
if (c == u'\r' && charIdx<len && testString.charAt(charIdx) == u'\n') {
// treat CRLF as a unit
static struct TestCase {
const char *fTicketNum;
const char *fFileName;
- const UChar *fString;
+ const char16_t *fString;
} badTestCases[] = {
{"10666", "GraphemeBreakTest.txt", u"\u0020\u0020\u0033"}, // Fake example, for illustration.
// The following tests were originally for
logln("Opening data file %s\n", fileName);
int len;
- UChar *testFile = ReadAndConvertFile(testFileName, len, "UTF-8", status);
+ char16_t *testFile = ReadAndConvertFile(testFileName, len, "UTF-8", status);
if (status != U_FILE_ACCESS_ERROR) {
TEST_ASSERT_SUCCESS(status);
TEST_ASSERT(testFile != nullptr);
__FILE__, __LINE__, u_errorName(status));
return;
}
- UChar str[50];
+ char16_t str[50];
static const char *strlist[] =
{
"\\u200e\\U000e0072\\u0a4b\\U000e003f\\ufd2b\\u2027\\u002e\\u002e",
UErrorCode status = U_ZERO_ERROR;
BreakIterator *bi = BreakIterator::createLineInstance(locale, status);
const int32_t STRSIZE = 50;
- UChar str[STRSIZE];
+ char16_t str[STRSIZE];
static const char *strlist[] =
{
"\\u300f\\ufdfc\\ub798\\u2011\\u2011\\u0020\\u0b43\\u002d\\ubeec\\ufffc",
Locale locale("en");
UErrorCode status = U_ZERO_ERROR;
BreakIterator *bi = BreakIterator::createSentenceInstance(locale, status);
- UChar str[200];
+ char16_t str[200];
static const char *strlist[] =
{
"Now\ris\nthe\r\ntime\n\rfor\r\r",
void RBBITest::TestBug12918() {
// This test triggers an assertion failure in dictbe.cpp
- const UChar *crasherString = u"\u3325\u4a16";
+ const char16_t *crasherString = u"\u3325\u4a16";
UErrorCode status = U_ZERO_ERROR;
UBreakIterator* iter = ubrk_open(UBRK_WORD, nullptr, crasherString, -1, &status);
if (U_FAILURE(status)) {
logln("Opening data file %s\n", testFileName.data());
int len;
- UChar *testFile = ReadAndConvertFile(testFileName.data(), len, "UTF-8", status);
+ char16_t *testFile = ReadAndConvertFile(testFileName.data(), len, "UTF-8", status);
if (U_FAILURE(status) || testFile == nullptr) {
errln("%s:%s %s while opening emoji-test.txt", __FILE__, __LINE__, u_errorName(status));
return;
path.appendPathPart("rules", status);
path.appendPathPart("line.txt", status);
int len;
- std::unique_ptr<UChar []> testFile(ReadAndConvertFile(path.data(), len, "UTF-8", status));
+ std::unique_ptr<char16_t []> testFile(ReadAndConvertFile(path.data(), len, "UTF-8", status));
if (!assertSuccess(WHERE, status)) {
return;
}
int32_t expectedStateRowBits = expectedStateRowIn8Bits ? RBBI_8BITS_ROWS : 0;
// Text are duplicate characters from U+4E00 to U+4FFF
UnicodeString text;
- for (UChar c = 0x4e00; c < 0x5000; c++) {
+ for (char16_t c = 0x4e00; c < 0x5000; c++) {
text.append(c).append(c);
}
// Generate rule which will caused length+4 character classes and
// length+3 states
UnicodeString rules(u"!!quoted_literals_only;");
- for (UChar c = 0x4e00; c < 0x4e00 + numChar; c++) {
+ for (char16_t c = 0x4e00; c < 0x4e00 + numChar; c++) {
rules.append(u'\'').append(c).append(c).append(u"';");
}
rules.append(u".;");
// and as test data to check matching behavior. A break rule consisting of the first 120
// characters of testStr will match the first 120 chars of the full-length testStr.
UnicodeString testStr;
- for (UChar c=0x3000; c<0x3200; ++c) {
+ for (char16_t c=0x3000; c<0x3200; ++c) {
testStr.append(c);
}
testFileName.append(filename, -1, status);
int len;
- UChar *testFile = ReadAndConvertFile(testFileName.data(), len, "UTF-8", status);
+ char16_t *testFile = ReadAndConvertFile(testFileName.data(), len, "UTF-8", status);
if (U_FAILURE(status)) {
errln("%s:%d Error %s opening test file %s", __FILE__, __LINE__, u_errorName(status), filename);
return;
rules += "&n < o ";
rules += "& oe ,o";
- rules += (UChar)0x3080;
+ rules += (char16_t)0x3080;
rules += "& oe ,";
- rules += (UChar)0x1530;
+ rules += (char16_t)0x1530;
rules += " ,O";
rules += "& OE ,O";
- rules += (UChar)0x3080;
+ rules += (char16_t)0x3080;
rules += "& OE ,";
- rules += (UChar)0x1520;
+ rules += (char16_t)0x1520;
rules += "< p ,P";
// Build a collator containing expanding characters
//
void CollationRegressionTest::Test4054238(/* char* par */)
{
- const UChar chars3[] = {0x61, 0x00FC, 0x62, 0x65, 0x63, 0x6b, 0x20, 0x47, 0x72, 0x00F6, 0x00DF, 0x65, 0x20, 0x4c, 0x00FC, 0x62, 0x63, 0x6b, 0};
+ const char16_t chars3[] = {0x61, 0x00FC, 0x62, 0x65, 0x63, 0x6b, 0x20, 0x47, 0x72, 0x00F6, 0x00DF, 0x65, 0x20, 0x4c, 0x00FC, 0x62, 0x63, 0x6b, 0};
const UnicodeString test3(chars3);
RuleBasedCollator *c = en_us->clone();
};
*/
- static const UChar decomp[][CollationRegressionTest::MAX_TOKEN_LEN] =
+ static const char16_t decomp[][CollationRegressionTest::MAX_TOKEN_LEN] =
{
{0x0001, 0}, {0x3c, 0}, {0x0002, 0},
{0x0001, 0}, {0x3d, 0}, {0x0001, 0},
c->setStrength(Collator::SECONDARY);
c->setAttribute(UCOL_NORMALIZATION_MODE, UCOL_ON, status);
- static const UChar tests[][CollationRegressionTest::MAX_TOKEN_LEN] =
+ static const char16_t tests[][CollationRegressionTest::MAX_TOKEN_LEN] =
{
{0xFB4F, 0}, {0x3d, 0}, {0x05D0, 0x05DC} // Alef-Lamed vs. Alef, Lamed
};
rules += "&f < g, G < h, H < i, I < j, J";
rules += " & H < ";
- rules += (UChar)0x0131;
+ rules += (char16_t)0x0131;
rules += ", ";
- rules += (UChar)0x0130;
+ rules += (char16_t)0x0130;
rules += ", i, I";
RuleBasedCollator *c = nullptr;
};
*/
- static const UChar tertiary[][CollationRegressionTest::MAX_TOKEN_LEN] =
+ static const char16_t tertiary[][CollationRegressionTest::MAX_TOKEN_LEN] =
{
{0x41, 0}, {0x3c, 0}, {0x42, 0},
{0x48, 0}, {0x3c, 0}, {0x0131, 0},
"\u0131", "=", "\u0130",
};
*/
- static const UChar secondary[][CollationRegressionTest::MAX_TOKEN_LEN] =
+ static const char16_t secondary[][CollationRegressionTest::MAX_TOKEN_LEN] =
{
{0x48, 0}, {0x3c, 0}, {0x49, 0},
{0x0131, 0}, {0x3d, 0}, {0x0130, 0}
"p\u00eache", "<", "p\u00e9ch\u00e9", // Comparing accents from end, p\u00e9ch\u00e9 is greater
};
*/
- static const UChar tests[][CollationRegressionTest::MAX_TOKEN_LEN] =
+ static const char16_t tests[][CollationRegressionTest::MAX_TOKEN_LEN] =
{
{0x70, 0x00EA, 0x63, 0x68, 0x65, 0}, {0x3c, 0}, {0x70, 0x00E9, 0x63, 0x68, 0x00E9, 0}
};
//
void CollationRegressionTest::Test4066189(/* char* par */)
{
- static const UChar chars1[] = {0x1EB1, 0};
- static const UChar chars2[] = {0x61, 0x0306, 0x0300, 0};
+ static const char16_t chars1[] = {0x1EB1, 0};
+ static const char16_t chars2[] = {0x61, 0x0306, 0x0300, 0};
const UnicodeString test1(chars1);
const UnicodeString test2(chars2);
UErrorCode status = U_ZERO_ERROR;
*/
- static const UChar tests[][CollationRegressionTest::MAX_TOKEN_LEN] =
+ static const char16_t tests[][CollationRegressionTest::MAX_TOKEN_LEN] =
{
{0x00E0, 0}, {0x3e, 0}, {0x01FA, 0}
};
{
// These combining characters are all in the same class, so they should not
// be reordered, and they should compare as unequal.
- static const UChar s1[] = {0x41, 0x0301, 0x0302, 0x0300, 0};
- static const UChar s2[] = {0x41, 0x0302, 0x0300, 0x0301, 0};
+ static const char16_t s1[] = {0x41, 0x0301, 0x0302, 0x0300, 0};
+ static const char16_t s2[] = {0x41, 0x0302, 0x0300, 0x0301, 0};
RuleBasedCollator *c = en_us->clone();
c->setStrength(Collator::TERTIARY);
{
// These combining characters are all in different classes,
// so they should be reordered and the strings should compare as equal.
- static const UChar s1[] = {0x41, 0x0300, 0x0316, 0x0327, 0x0315, 0};
- static const UChar s2[] = {0x41, 0x0327, 0x0316, 0x0315, 0x0300, 0};
+ static const char16_t s1[] = {0x41, 0x0300, 0x0316, 0x0327, 0x0315, 0};
+ static const char16_t s2[] = {0x41, 0x0327, 0x0316, 0x0315, 0x0300, 0};
UErrorCode status = U_ZERO_ERROR;
RuleBasedCollator *c = en_us->clone();
c->setStrength(Collator::SECONDARY);
- static const UChar tests[][CollationRegressionTest::MAX_TOKEN_LEN] =
+ static const char16_t tests[][CollationRegressionTest::MAX_TOKEN_LEN] =
{
{0x7a, 0}, {0x3c, 0}, {0x00E6, 0}, // z < ae
{0x61, 0x0308, 0}, {0x3c, 0}, {0x61, 0x030A, 0}, // a-umlaut < a-ring
RuleBasedCollator *c = en_us->clone();
c->setStrength(Collator::TERTIARY);
- static const UChar tests[][CollationRegressionTest::MAX_TOKEN_LEN] =
+ static const char16_t tests[][CollationRegressionTest::MAX_TOKEN_LEN] =
{
{0x31, 0x32, 0x33, 0}, {0x3d, 0}, {0x31, 0x32, 0x33, 0x0001, 0} // 1 2 3 = 1 2 3 ctrl-A
};
// These now have tertiary differences in UCA
c->setAttribute(UCOL_STRENGTH, UCOL_SECONDARY, status);
- static const UChar tests[][CollationRegressionTest::MAX_TOKEN_LEN] =
+ static const char16_t tests[][CollationRegressionTest::MAX_TOKEN_LEN] =
{
{0x00B5, 0}, {0x3d, 0}, {0x03BC, 0}
};
//c->setStrength(Collator::TERTIARY);
c->setAttribute(UCOL_STRENGTH, UCOL_SECONDARY, status);
- static const UChar tests[][CollationRegressionTest::MAX_TOKEN_LEN] =
+ static const char16_t tests[][CollationRegressionTest::MAX_TOKEN_LEN] =
{
{0x03D4, 0}, {0x3d, 0}, {0x03AB, 0}
};
RuleBasedCollator *c = en_us->clone();
c->setStrength(Collator::TERTIARY);
- static const UChar tests[][CollationRegressionTest::MAX_TOKEN_LEN] =
+ static const char16_t tests[][CollationRegressionTest::MAX_TOKEN_LEN] =
{
{0x66, 0x69, 0x6c, 0x65, 0}, {0x3c, 0}, {0x66, 0x69, 0x6c, 0x65, 0x20, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0},
{0x66, 0x69, 0x6c, 0x65, 0}, {0x3c, 0}, {0x66, 0x69, 0x6c, 0x65, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0}
// into Jamo, but Jamo characters should not be decomposed into
// conjoining Jamo
//
- static const UChar test1[][CollationRegressionTest::MAX_TOKEN_LEN] =
+ static const char16_t test1[][CollationRegressionTest::MAX_TOKEN_LEN] =
{
{0xd4db, 0}, {0x3d, 0}, {0x1111, 0x1171, 0x11b6, 0}
};
//obsolete- // With Full decomposition, it should go all the way down to
//obsolete- // conjoining Jamo characters.
//obsolete- //
-//obsolete- static const UChar test2[][CollationRegressionTest::MAX_TOKEN_LEN] =
+//obsolete- static const char16_t test2[][CollationRegressionTest::MAX_TOKEN_LEN] =
//obsolete- {
//obsolete- {0xd4db, 0}, {0x3d, 0}, {0x1111, 0x116e, 0x1175, 0x11af, 0x11c2, 0}
//obsolete- };
return;
}
- static const UChar test[] = {0x41, 0x0308, 0x62, 0x63, 0};
+ static const char16_t test[] = {0x41, 0x0308, 0x62, 0x63, 0};
CollationKey key;
coll->getCollationKey(test, key, status);
return;
}
- static const UChar test1[][CollationRegressionTest::MAX_TOKEN_LEN] =
+ static const char16_t test1[][CollationRegressionTest::MAX_TOKEN_LEN] =
{
{0x65, 0x0300, 0x65, 0x0301, 0}, {0x3c, 0}, {0x65, 0x0301, 0x65, 0x0300, 0},
{0x65, 0x0300, 0x0301, 0}, {0x3c, 0}, {0x65, 0x0301, 0x0300, 0}
//
void CollationRegressionTest::Test4133509(/* char* par */)
{
- static const UChar test1[][CollationRegressionTest::MAX_TOKEN_LEN] =
+ static const char16_t test1[][CollationRegressionTest::MAX_TOKEN_LEN] =
{
{0x45, 0x78, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0}, {0x3c, 0}, {0x45, 0x78, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x49, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x72, 0x45, 0x72, 0x72, 0x6f, 0x72, 0},
{0x47, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0}, {0x3c, 0}, {0x47, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x45, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0},
RuleBasedCollator *c = en_us->clone();
c->setStrength(Collator::TERTIARY);
- static const UChar test1[][CollationRegressionTest::MAX_TOKEN_LEN] =
+ static const char16_t test1[][CollationRegressionTest::MAX_TOKEN_LEN] =
{
{0x00C0, 0}, {0x3d, 0}, {0x41, 0x0300, 0}, // Should be equivalent
{0x70, 0x00ea, 0x63, 0x68, 0x65, 0}, {0x3e, 0}, {0x70, 0x00e9, 0x63, 0x68, 0x00e9, 0},
c->setAttribute(UCOL_NORMALIZATION_MODE, UCOL_OFF, status);
compareArray(*c, test1, UPRV_LENGTHOF(test1));
- static const UChar test2[][CollationRegressionTest::MAX_TOKEN_LEN] =
+ static const char16_t test2[][CollationRegressionTest::MAX_TOKEN_LEN] =
{
{0x41, 0x0300, 0x0316, 0}, {0x3d, 0}, {0x41, 0x0316, 0x0300, 0} // Reordering --> equal
};
// Ticket 7189
//
// nextSortKeyPart incorrect for EO_S1 collation
-static int32_t calcKeyIncremental(UCollator *coll, const UChar* text, int32_t len, uint8_t *keyBuf, int32_t /*keyBufLen*/, UErrorCode& status) {
+static int32_t calcKeyIncremental(UCollator *coll, const char16_t* text, int32_t len, uint8_t *keyBuf, int32_t /*keyBufLen*/, UErrorCode& status) {
UCharIterator uiter;
uint32_t state[2] = { 0, 0 };
int32_t keyLen;
UCollator *coll;
uint32_t i;
- static const UChar text1[][CollationRegressionTest::MAX_TOKEN_LEN] = {
+ static const char16_t text1[][CollationRegressionTest::MAX_TOKEN_LEN] = {
// "Achter De Hoven"
{ 0x41, 0x63, 0x68, 0x74, 0x65, 0x72, 0x20, 0x44, 0x65, 0x20, 0x48, 0x6F, 0x76, 0x65, 0x6E, 0x00 },
// "ABC"
{ 0x48, 0x45, 0x4C, 0x4C, 0x4F, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0x64, 0x21, 0x00 }
};
- static const UChar text2[][CollationRegressionTest::MAX_TOKEN_LEN] = {
+ static const char16_t text2[][CollationRegressionTest::MAX_TOKEN_LEN] = {
// "Achter de Hoven"
{ 0x41, 0x63, 0x68, 0x74, 0x65, 0x72, 0x20, 0x64, 0x65, 0x20, 0x48, 0x6F, 0x76, 0x65, 0x6E, 0x00 },
// "abc"
void CollationRegressionTest::caseFirstCompressionSub(Collator *col, UnicodeString opt) {
const int32_t maxLength = 50;
- UChar str1[maxLength];
- UChar str2[maxLength];
+ char16_t str1[maxLength];
+ char16_t str2[maxLength];
CollationKey key1, key2;
for (int32_t len = 1; len <= maxLength; len++) {
int32_t i = 0;
for (; i < len - 1; i++) {
- str1[i] = str2[i] = (UChar)0x61; // 'a'
+ str1[i] = str2[i] = (char16_t)0x61; // 'a'
}
- str1[i] = (UChar)0x41; // 'A'
- str2[i] = (UChar)0x61; // 'a'
+ str1[i] = (char16_t)0x41; // 'A'
+ str2[i] = (char16_t)0x61; // 'a'
UErrorCode status = U_ZERO_ERROR;
col->getCollationKey(str1, len, key1, status);
// Check that the rule parser handles a comment without terminating end-of-line.
IcuTestErrorCode errorCode(*this, "TestTrailingComment");
RuleBasedCollator coll(UNICODE_STRING_SIMPLE("&c<b#comment1\n<a#comment2"), errorCode);
- UnicodeString a((UChar)0x61), b((UChar)0x62), c((UChar)0x63);
+ UnicodeString a((char16_t)0x61), b((char16_t)0x62), c((char16_t)0x63);
assertTrue("c<b", coll.compare(c, b) < 0);
assertTrue("b<a", coll.compare(b, a) < 0);
}
}
void CollationRegressionTest::compareArray(Collator &c,
- const UChar tests[][CollationRegressionTest::MAX_TOKEN_LEN],
+ const char16_t tests[][CollationRegressionTest::MAX_TOKEN_LEN],
int32_t testCount)
{
int32_t i;
// Internal utilities
//
void compareArray(Collator &c,
- const UChar tests[][CollationRegressionTest::MAX_TOKEN_LEN],
+ const char16_t tests[][CollationRegressionTest::MAX_TOKEN_LEN],
int32_t testCount);
void assertEqual(CollationElementIterator &i1, CollationElementIterator &i2);
if(ASSERT_BUF[0]==0) {
ASSERT_BUF[0]=0;
for(int32_t i=0;i<buf.length();i++) {
- UChar ch = buf[i];
+ char16_t ch = buf[i];
snprintf(ASSERT_BUF+strlen(ASSERT_BUF), sizeof(ASSERT_BUF) - strlen(ASSERT_BUF), "\\u%02x",ch);
}
}
//
- // Compilation error on reset with UChar *
+ // Compilation error on reset with char16_t *
// These were a hazard that people were stumbling over with runtime errors.
// Changed them to compiler errors by adding private methods that more closely
// matched the incorrect use of the functions.
#if 0
{
UErrorCode status = U_ZERO_ERROR;
- UChar ucharString[20];
+ char16_t ucharString[20];
RegexMatcher m(".", 0, status);
m.reset(ucharString); // should not compile.
}
int32_t len;
- UChar *testData = ReadAndConvertFile(srcPath, len, "utf-8", status);
+ char16_t *testData = ReadAndConvertFile(srcPath, len, "utf-8", status);
if (U_FAILURE(status)) {
return; /* something went wrong, error already output */
}
// Compile the caller's pattern
//
uint32_t bflags = 0;
- if (flags.indexOf((UChar)0x69) >= 0) { // 'i' flag
+ if (flags.indexOf((char16_t)0x69) >= 0) { // 'i' flag
bflags |= UREGEX_CASE_INSENSITIVE;
}
- if (flags.indexOf((UChar)0x78) >= 0) { // 'x' flag
+ if (flags.indexOf((char16_t)0x78) >= 0) { // 'x' flag
bflags |= UREGEX_COMMENTS;
}
- if (flags.indexOf((UChar)0x73) >= 0) { // 's' flag
+ if (flags.indexOf((char16_t)0x73) >= 0) { // 's' flag
bflags |= UREGEX_DOTALL;
}
- if (flags.indexOf((UChar)0x6d) >= 0) { // 'm' flag
+ if (flags.indexOf((char16_t)0x6d) >= 0) { // 'm' flag
bflags |= UREGEX_MULTILINE;
}
- if (flags.indexOf((UChar)0x65) >= 0) { // 'e' flag
+ if (flags.indexOf((char16_t)0x65) >= 0) { // 'e' flag
bflags |= UREGEX_ERROR_ON_UNKNOWN_ESCAPES;
}
- if (flags.indexOf((UChar)0x44) >= 0) { // 'D' flag
+ if (flags.indexOf((char16_t)0x44) >= 0) { // 'D' flag
bflags |= UREGEX_UNIX_LINES;
}
- if (flags.indexOf((UChar)0x51) >= 0) { // 'Q' flag
+ if (flags.indexOf((char16_t)0x51) >= 0) { // 'Q' flag
bflags |= UREGEX_LITERAL;
}
#if UCONFIG_NO_BREAK_ITERATION==1
// 'v' test flag means that the test pattern should not compile if ICU was configured
// to not include break iteration. RBBI is needed for Unicode word boundaries.
- if (flags.indexOf((UChar)0x76) >= 0 /*'v'*/ && status == U_UNSUPPORTED_ERROR) {
+ if (flags.indexOf((char16_t)0x76) >= 0 /*'v'*/ && status == U_UNSUPPORTED_ERROR) {
goto cleanupAndReturn;
}
#endif
- if (flags.indexOf((UChar)0x45) >= 0) { // flags contain 'E'
+ if (flags.indexOf((char16_t)0x45) >= 0) { // flags contain 'E'
// Expected pattern compilation error.
- if (flags.indexOf((UChar)0x64) >= 0) { // flags contain 'd'
+ if (flags.indexOf((char16_t)0x64) >= 0) { // flags contain 'd'
logln("Pattern Compile returns \"%s\"", u_errorName(status));
}
goto cleanupAndReturn;
#if UCONFIG_NO_BREAK_ITERATION==1
// 'v' test flag means that the test pattern should not compile if ICU was configured
// to not include break iteration. RBBI is needed for Unicode word boundaries.
- if (flags.indexOf((UChar)0x76) >= 0 /*'v'*/ && status == U_UNSUPPORTED_ERROR) {
+ if (flags.indexOf((char16_t)0x76) >= 0 /*'v'*/ && status == U_UNSUPPORTED_ERROR) {
goto cleanupAndReturn;
}
#endif
- if (flags.indexOf((UChar)0x45) >= 0) { // flags contain 'E'
+ if (flags.indexOf((char16_t)0x45) >= 0) { // flags contain 'E'
// Expected pattern compilation error.
- if (flags.indexOf((UChar)0x64) >= 0) { // flags contain 'd'
+ if (flags.indexOf((char16_t)0x64) >= 0) { // flags contain 'd'
logln("Pattern Compile returns \"%s\" (UTF8)", u_errorName(status));
}
goto cleanupAndReturn;
status = U_ZERO_ERROR;
}
- if (flags.indexOf((UChar)0x64) >= 0) { // 'd' flag
+ if (flags.indexOf((char16_t)0x64) >= 0) { // 'd' flag
callerPattern->dumpPattern();
}
- if (flags.indexOf((UChar)0x45) >= 0) { // 'E' flag
+ if (flags.indexOf((char16_t)0x45) >= 0) { // 'E' flag
errln("%s, Line %d: Expected, but did not get, a pattern compilation error.", srcPath, line);
goto cleanupAndReturn;
}
//
numFinds = 1;
for (i=2; i<=9; i++) {
- if (flags.indexOf((UChar)(0x30 + i)) >= 0) { // digit flag
+ if (flags.indexOf((char16_t)(0x30 + i)) >= 0) { // digit flag
if (numFinds != 1) {
errln("Line %d: more than one digit flag. Scanning %d.", line, i);
goto cleanupAndReturn;
}
// 'M' flag. Use matches() instead of find()
- if (flags.indexOf((UChar)0x4d) >= 0) {
+ if (flags.indexOf((char16_t)0x4d) >= 0) {
useMatchesFunc = true;
}
- if (flags.indexOf((UChar)0x4c) >= 0) {
+ if (flags.indexOf((char16_t)0x4c) >= 0) {
useLookingAtFunc = true;
}
//
matcher = callerPattern->matcher(deTaggedInput, status);
REGEX_CHECK_STATUS_L(line);
- if (flags.indexOf((UChar)0x74) >= 0) { // 't' trace flag
+ if (flags.indexOf((char16_t)0x74) >= 0) { // 't' trace flag
matcher->setTrace(true);
}
// Generate native indices for UTF8 versions of region and capture group info
//
if (UTF8Matcher != nullptr) {
- if (flags.indexOf((UChar)0x74) >= 0) { // 't' trace flag
+ if (flags.indexOf((char16_t)0x74) >= 0) { // 't' trace flag
UTF8Matcher->setTrace(true);
}
if (regionStart>=0) (void) utextOffsetToNative(&inputText, regionStart, regionStartUTF8);
REGEX_CHECK_STATUS_L(line);
}
}
- if (flags.indexOf((UChar)0x61) >= 0) { // 'a' anchoring bounds flag
+ if (flags.indexOf((char16_t)0x61) >= 0) { // 'a' anchoring bounds flag
matcher->useAnchoringBounds(false);
if (UTF8Matcher != nullptr) {
UTF8Matcher->useAnchoringBounds(false);
}
}
- if (flags.indexOf((UChar)0x62) >= 0) { // 'b' transparent bounds flag
+ if (flags.indexOf((char16_t)0x62) >= 0) { // 'b' transparent bounds flag
matcher->useTransparentBounds(true);
if (UTF8Matcher != nullptr) {
UTF8Matcher->useTransparentBounds(true);
failed = true;
}
- if (flags.indexOf((UChar)0x47 /*G*/) >= 0) {
+ if (flags.indexOf((char16_t)0x47 /*G*/) >= 0) {
// Only check for match / no match. Don't check capture groups.
goto cleanupAndReturn;
}
failed = true;
}
- if ((flags.indexOf((UChar)0x59) >= 0) && // 'Y' flag: RequireEnd() == false
+ if ((flags.indexOf((char16_t)0x59) >= 0) && // 'Y' flag: RequireEnd() == false
matcher->requireEnd() == true) {
errln("Error at line %d: requireEnd() returned true. Expected false", line);
failed = true;
- } else if (UTF8Matcher != nullptr && (flags.indexOf((UChar)0x59) >= 0) && // 'Y' flag: RequireEnd() == false
+ } else if (UTF8Matcher != nullptr && (flags.indexOf((char16_t)0x59) >= 0) && // 'Y' flag: RequireEnd() == false
UTF8Matcher->requireEnd() == true) {
errln("Error at line %d: requireEnd() returned true. Expected false (UTF8)", line);
failed = true;
}
- if ((flags.indexOf((UChar)0x79) >= 0) && // 'y' flag: RequireEnd() == true
+ if ((flags.indexOf((char16_t)0x79) >= 0) && // 'y' flag: RequireEnd() == true
matcher->requireEnd() == false) {
errln("Error at line %d: requireEnd() returned false. Expected true", line);
failed = true;
- } else if (UTF8Matcher != nullptr && (flags.indexOf((UChar)0x79) >= 0) && // 'Y' flag: RequireEnd() == false
+ } else if (UTF8Matcher != nullptr && (flags.indexOf((char16_t)0x79) >= 0) && // 'Y' flag: RequireEnd() == false
UTF8Matcher->requireEnd() == false) {
errln("Error at line %d: requireEnd() returned false. Expected true (UTF8)", line);
failed = true;
}
- if ((flags.indexOf((UChar)0x5A) >= 0) && // 'Z' flag: hitEnd() == false
+ if ((flags.indexOf((char16_t)0x5A) >= 0) && // 'Z' flag: hitEnd() == false
matcher->hitEnd() == true) {
errln("Error at line %d: hitEnd() returned true. Expected false", line);
failed = true;
- } else if (UTF8Matcher != nullptr && (flags.indexOf((UChar)0x5A) >= 0) && // 'Z' flag: hitEnd() == false
+ } else if (UTF8Matcher != nullptr && (flags.indexOf((char16_t)0x5A) >= 0) && // 'Z' flag: hitEnd() == false
UTF8Matcher->hitEnd() == true) {
errln("Error at line %d: hitEnd() returned true. Expected false (UTF8)", line);
failed = true;
}
- if ((flags.indexOf((UChar)0x7A) >= 0) && // 'z' flag: hitEnd() == true
+ if ((flags.indexOf((char16_t)0x7A) >= 0) && // 'z' flag: hitEnd() == true
matcher->hitEnd() == false) {
errln("Error at line %d: hitEnd() returned false. Expected true", line);
failed = true;
- } else if (UTF8Matcher != nullptr && (flags.indexOf((UChar)0x7A) >= 0) && // 'z' flag: hitEnd() == true
+ } else if (UTF8Matcher != nullptr && (flags.indexOf((char16_t)0x7A) >= 0) && // 'z' flag: hitEnd() == true
UTF8Matcher->hitEnd() == false) {
errln("Error at line %d: hitEnd() returned false. Expected true (UTF8)", line);
failed = true;
}
int32_t len;
- UChar *testData = ReadAndConvertFile(srcPath, len, "iso-8859-1", status);
+ char16_t *testData = ReadAndConvertFile(srcPath, len, "iso-8859-1", status);
if (U_FAILURE(status)) {
return; /* something went wrong, error already output */
}
return;
}
int32_t flags = 0;
- const UChar UChar_c = 0x63; // Char constants for the flag letters.
- const UChar UChar_i = 0x69; // (Damn the lack of Unicode support in C)
- const UChar UChar_m = 0x6d;
- const UChar UChar_x = 0x78;
- const UChar UChar_y = 0x79;
+ const char16_t UChar_c = 0x63; // Char constants for the flag letters.
+ const char16_t UChar_i = 0x69; // (Damn the lack of Unicode support in C)
+ const char16_t UChar_m = 0x6d;
+ const char16_t UChar_x = 0x78;
+ const char16_t UChar_y = 0x79;
if (flagStr.indexOf(UChar_i) != -1) {
flags |= UREGEX_CASE_INSENSITIVE;
}
if (perlExpr.length() > 1) {
perlExpr.remove(0, 1); // Remove the '\', but only if not last char.
}
- UChar c = perlExpr.charAt(0);
+ char16_t c = perlExpr.charAt(0);
switch (c) {
case 'n': c = '\n'; break;
// add any other escape sequences that show up in the test expected results.
}
int32_t len;
- UChar *testData = ReadAndConvertFile(srcPath, len, "iso-8859-1", status);
+ char16_t *testData = ReadAndConvertFile(srcPath, len, "iso-8859-1", status);
if (U_FAILURE(status)) {
return; /* something went wrong, error already output */
}
return;
}
int32_t flags = 0;
- const UChar UChar_c = 0x63; // Char constants for the flag letters.
- const UChar UChar_i = 0x69; // (Damn the lack of Unicode support in C)
- const UChar UChar_m = 0x6d;
- const UChar UChar_x = 0x78;
- const UChar UChar_y = 0x79;
+ const char16_t UChar_c = 0x63; // Char constants for the flag letters.
+ const char16_t UChar_i = 0x69; // (Damn the lack of Unicode support in C)
+ const char16_t UChar_m = 0x6d;
+ const char16_t UChar_x = 0x78;
+ const char16_t UChar_y = 0x79;
if (flagStr.indexOf(UChar_i) != -1) {
flags |= UREGEX_CASE_INSENSITIVE;
}
if (perlExpr.length() > 1) {
perlExpr.remove(0, 1); // Remove the '\', but only if not last char.
}
- UChar c = perlExpr.charAt(0);
+ char16_t c = perlExpr.charAt(0);
switch (c) {
case 'n': c = '\n'; break;
// add any other escape sequences that show up in the test expected results.
{
UText text1 = UTEXT_INITIALIZER;
UText text2 = UTEXT_INITIALIZER;
- UChar text2Chars[20];
+ char16_t text2Chars[20];
UText *resultText;
status = U_ZERO_ERROR;
utext_setNativeIndex(&text1, 0);
REGEX_ASSERT(testUTextEqual(resultText, &text1));
- /* Then set a UChar * */
+ /* Then set a char16_t * */
uregex_setText(re, text2Chars, 7, &status);
resultText = uregex_getUText(re, &bufferText, &status);
REGEX_CHECK_STATUS;
* group()
*/
{
- UChar text1[80];
+ char16_t text1[80];
UText *actual;
UBool result;
int64_t length = 0;
* replaceFirst()
*/
{
- UChar text1[80];
- UChar text2[80];
+ char16_t text1[80];
+ char16_t text2[80];
UText replText = UTEXT_INITIALIZER;
UText *result;
status = U_ZERO_ERROR;
* replaceAll()
*/
{
- UChar text1[80];
- UChar text2[80];
+ char16_t text1[80];
+ char16_t text2[80];
UText replText = UTEXT_INITIALIZER;
UText *result;
uregex_setText(re, text.getBuffer(), text.length(), &status);
REGEX_CHECK_STATUS;
- UChar resultBuf[100];
+ char16_t resultBuf[100];
int32_t resultLength;
UnicodeString repl;
// was causing a segfault. Only for Regular Expressions created from UText.
// It should set an U_REGEX_INVALID_STATE.
- UChar buf[100];
+ char16_t buf[100];
int32_t len = uregex_group(icu_re, 0, buf, UPRV_LENGTHOF(buf), &status);
REGEX_ASSERT(status == U_REGEX_INVALID_STATE);
REGEX_ASSERT(len == 0);
LocalPointer<RegexPattern> compiledPat(RegexPattern::compile(patternString, 0, status));
UnicodeString dataString = UnicodeString(data).unescape();
- UChar *exactBuffer = new UChar[dataString.length()];
+ char16_t *exactBuffer = new char16_t[dataString.length()];
dataString.extract(exactBuffer, dataString.length(), status);
UText *ut = utext_openUChars(nullptr, exactBuffer, dataString.length(), &status);
uregex_setText(re, text.getBuffer(), text.length(), &status);
REGEX_CHECK_STATUS;
REGEX_ASSERT(uregex_lookingAt(re, 0, &status));
- UChar buf[10] = {(UChar)13, (UChar)13, (UChar)13, (UChar)13};
+ char16_t buf[10] = {(char16_t)13, (char16_t)13, (char16_t)13, (char16_t)13};
int32_t length = uregex_group(re, 2, buf+1, UPRV_LENGTHOF(buf)-1, &status);
REGEX_ASSERT(length == 0);
REGEX_ASSERT(buf[0] == 13);
// The failure is seen when running this test with Clang's Address Sanitizer.
void RegexTest::TestBug13631() {
- const UChar *pats[] = { u"(?<!^)",
+ const char16_t *pats[] = { u"(?<!^)",
u"(?<=^)",
nullptr
};
- for (const UChar **pat=pats; *pat; ++pat) {
+ for (const char16_t **pat=pats; *pat; ++pat) {
UErrorCode status = U_ZERO_ERROR;
UnicodeString upat(*pat);
RegexMatcher matcher(upat, 0, status);
- const UChar s =u'a';
+ const char16_t s =u'a';
UText *ut = utext_openUChars(nullptr, &s, 1, &status);
REGEX_CHECK_STATUS;
matcher.reset(ut);
UnicodeString chars;
UnicodeString styles;
- static const UChar NO_STYLE;
+ static const char16_t NO_STYLE;
- static const UChar NO_STYLE_MARK;
+ static const char16_t NO_STYLE_MARK;
/**
* The address of this static class variable serves as this class's ID
if (text.charAt(i) == NO_STYLE_MARK) {
s.append(NO_STYLE);
} else {
- s.append((UChar)(i + 0x0031));
+ s.append((char16_t)(i + 0x0031));
}
}
}
return chars.length();
}
- virtual UChar getCharAt(int32_t offset) const override {
+ virtual char16_t getCharAt(int32_t offset) const override {
return chars.charAt(offset);
}
}
void fixStyles(int32_t start, int32_t limit, int32_t newLen) {
- UChar newStyle = NO_STYLE;
+ char16_t newStyle = NO_STYLE;
if (start != limit && styles.charAt(start) != NO_STYLE) {
newStyle = styles.charAt(start);
} else if (start > 0 && getCharAt(start-1) != NO_STYLE_MARK) {
const char TestReplaceable::fgClassID=0;
-const UChar TestReplaceable::NO_STYLE = 0x005F;
+const char16_t TestReplaceable::NO_STYLE = 0x005F;
-const UChar TestReplaceable::NO_STYLE_MARK = 0xFFFF;
+const char16_t TestReplaceable::NO_STYLE_MARK = 0xFFFF;
void
ReplaceableTest::runIndexedTest(int32_t index, UBool exec,
return 0;
}
- virtual UChar getCharAt(int32_t /*offset*/) const override {
+ virtual char16_t getCharAt(int32_t /*offset*/) const override {
return 0xffff;
}
const char NoopReplaceable::fgClassID=0;
void ReplaceableTest::TestReplaceableClass(void) {
- UChar rawTestArray[][6] = {
+ char16_t rawTestArray[][6] = {
{0x0041, 0x0042, 0x0043, 0x0044, 0x0000, 0x0000}, // ABCD
{0x0061, 0x0062, 0x0063, 0x0064, 0x00DF, 0x0000}, // abcd\u00DF
{0x0061, 0x0042, 0x0043, 0x0044, 0x0000, 0x0000}, // aBCD
//***************************************************************************************
-static const UChar kErrorUChars[] = { 0x45, 0x52, 0x52, 0x4f, 0x52, 0 };
+static const char16_t kErrorUChars[] = { 0x45, 0x52, 0x52, 0x4f, 0x52, 0 };
static const int32_t kErrorLength = 5;
//***************************************************************************************
UResourceBundle *resb =ures_open(nullptr,locale,&status);
if(U_SUCCESS(status) && status!=U_USING_FALLBACK_WARNING && status!=U_USING_DEFAULT_WARNING){
int32_t len=0;
- const UChar* strSet = ures_getStringByKey(resb,"ExemplarCharacters",&len,&status);
+ const char16_t* strSet = ures_getStringByKey(resb,"ExemplarCharacters",&len,&status);
UnicodeSet set(strSet,status);
if(U_FAILURE(status)){
errln("Could not construct UnicodeSet from pattern for ExemplarCharacters in locale : %s. Error: %s",locale,u_errorName(status));
//***************************************************************************************
-static const UChar kErrorUChars[] = { 0x45, 0x52, 0x52, 0x4f, 0x52, 0 };
+static const char16_t kErrorUChars[] = { 0x45, 0x52, 0x52, 0x4f, 0x52, 0 };
static const int32_t kErrorLength = 5;
static const int32_t kERROR_COUNT = -1234567;
int32_t i = 0;
int32_t intResult = 0;
uint32_t uintResult = 0;
- UChar expected[] = { 'a','b','c','\0','d','e','f' };
+ char16_t expected[] = { 'a','b','c','\0','d','e','f' };
const char* expect ="tab:\t cr:\r ff:\f newline:\n backslash:\\\\ quote=\\\' doubleQuote=\\\" singlequoutes=''";
- UChar uExpect[200];
+ char16_t uExpect[200];
testdatapath=loadTestData(status);
fHashCode = kInvalidHashCode;
fLen = s.length();
- fStart = new UChar[fLen];
+ fStart = new char16_t[fLen];
if(fStart == nullptr) {
fBogus = true;
} else {
}
#endif
-SimpleFwdCharIterator::SimpleFwdCharIterator(UChar *s, int32_t len, UBool adopt) {
+SimpleFwdCharIterator::SimpleFwdCharIterator(char16_t *s, int32_t len, UBool adopt) {
fHashCode = kInvalidHashCode;
fLen = len==-1 ? u_strlen(s) : len;
if(adopt == false) {
- fStart = new UChar[fLen];
+ fStart = new char16_t[fLen];
if(fStart == nullptr) {
fBogus = true;
} else {
return nullptr;
}
-UChar SimpleFwdCharIterator::nextPostInc(void) {
+char16_t SimpleFwdCharIterator::nextPostInc(void) {
if(fCurrent == fEnd) {
return ForwardCharacterIterator::DONE;
} else {
class SimpleFwdCharIterator : public ForwardCharacterIterator {
public:
// not used -- SimpleFwdCharIterator(const UnicodeString& s);
- SimpleFwdCharIterator(UChar *s, int32_t len, UBool adopt = false);
+ SimpleFwdCharIterator(char16_t *s, int32_t len, UBool adopt = false);
virtual ~SimpleFwdCharIterator();
* (toward endIndex()). If there are
* no more code units to return, returns DONE.
*/
- virtual UChar nextPostInc(void) override;
+ virtual char16_t nextPostInc(void) override;
/**
* Gets the current code point for returning and advances to the next code point
static const int32_t kInvalidHashCode;
static const int32_t kEmptyHashCode;
- UChar *fStart, *fEnd, *fCurrent;
+ char16_t *fStart, *fEnd, *fCurrent;
int32_t fLen;
UBool fBogus;
int32_t fHashCode;
UnicodeString rules;
rules.setTo(((RuleBasedCollator *)m_de_)->getRules());
- UChar extrarules[128];
+ char16_t extrarules[128];
u_unescape(EXTRACOLLATIONRULE, extrarules, 128);
rules.append(extrarules, u_strlen(extrarules));
delete m_de_;
int length = text.length();
for (; count < length; count ++) {
- UChar ch = text[count];
+ char16_t ch = text[count];
if (ch >= 0x20 && ch <= 0x7e) {
result[index ++] = (char)ch;
}
Collator *collator = getCollator(search->collator);
BreakIterator *breaker = getBreakIterator(search->breaker);
StringSearch *strsrch, *strsrch2;
- UChar temp[128];
+ char16_t temp[128];
#if UCONFIG_NO_BREAK_ITERATION
if(search->breaker) {
Collator *collator = getCollator(search->collator);
BreakIterator *breaker = getBreakIterator(search->breaker);
StringSearch *strsrch;
- UChar temp[128];
+ char16_t temp[128];
UBool result = true;
#if UCONFIG_NO_BREAK_ITERATION
Collator *collator = getCollator(search->collator);
BreakIterator *breaker = getBreakIterator(search->breaker);
StringSearch *strsrch;
- UChar temp[128];
+ char16_t temp[128];
#if UCONFIG_NO_BREAK_ITERATION
void StringSearchTest::TestBreakIterator()
{
- UChar temp[128];
+ char16_t temp[128];
u_unescape(BREAKITERATOREXACT[0].text, temp, 128);
UnicodeString text;
text.setTo(temp, u_strlen(temp));
count = 0;
while (count < 1) {
const SearchData *search = &(OVERLAP[count]);
- UChar temp[128];
+ char16_t temp[128];
u_unescape(search->text, temp, 128);
UnicodeString text;
text.setTo(temp, u_strlen(temp));
void StringSearchTest::TestCollator()
{
// test collator that thinks "o" and "p" are the same thing
- UChar temp[128];
+ char16_t temp[128];
u_unescape(COLLATOR[0].text, temp, 128);
UnicodeString text;
text.setTo(temp, u_strlen(temp));
void StringSearchTest::TestPattern()
{
- UChar temp[512];
+ char16_t temp[512];
int templength;
u_unescape(PATTERN[0].text, temp, 512);
UnicodeString text;
void StringSearchTest::TestText()
{
- UChar temp[128];
+ char16_t temp[128];
u_unescape(TEXT[0].text, temp, 128);
UnicodeString text;
text.setTo(temp, u_strlen(temp));
while (BASIC[index].text != nullptr) {
UErrorCode status = U_ZERO_ERROR;
SearchData search = BASIC[index ++];
- UChar temp[128];
+ char16_t temp[128];
u_unescape(search.text, temp, 128);
text.setTo(temp, u_strlen(temp));
void StringSearchTest::TestGetMatch()
{
- UChar temp[128];
+ char16_t temp[128];
SearchData search = MATCH[0];
u_unescape(search.text, temp, 128);
UnicodeString text;
int count = 0;
while (MATCH[count].text != nullptr) {
SearchData search = MATCH[count];
- UChar temp[128];
+ char16_t temp[128];
UErrorCode status = U_ZERO_ERROR;
u_unescape(search.text, temp, 128);
UnicodeString text;
void StringSearchTest::TestContraction()
{
- UChar temp[128];
+ char16_t temp[128];
UErrorCode status = U_ZERO_ERROR;
u_unescape(CONTRACTIONRULE, temp, 128);
void StringSearchTest::TestIgnorable()
{
- UChar temp[128];
+ char16_t temp[128];
u_unescape(IGNORABLERULE, temp, 128);
UnicodeString rules;
rules.setTo(temp, u_strlen(temp));
void StringSearchTest::TestDiacriticMatch()
{
- UChar temp[128];
+ char16_t temp[128];
UErrorCode status = U_ZERO_ERROR;
int count = 0;
RuleBasedCollator* coll = nullptr;
while (count < 4) {
// special purposes for tests numbers 0-3
- UChar temp[128];
+ char16_t temp[128];
const SearchData *search = &(BREAKITERATORCANONICAL[count]);
u_unescape(search->text, temp, 128);
count = 0;
while (count < 1) {
- UChar temp[128];
+ char16_t temp[128];
const SearchData *search = &(OVERLAPCANONICAL[count]);
UErrorCode status = U_ZERO_ERROR;
void StringSearchTest::TestCollatorCanonical()
{
/* test collator that thinks "o" and "p" are the same thing */
- UChar temp[128];
+ char16_t temp[128];
u_unescape(COLLATORCANONICAL[0].text, temp, 128);
UnicodeString text;
text.setTo(temp, u_strlen(temp));
void StringSearchTest::TestPatternCanonical()
{
- UChar temp[128];
+ char16_t temp[128];
u_unescape(PATTERNCANONICAL[0].text, temp, 128);
UnicodeString text;
void StringSearchTest::TestTextCanonical()
{
- UChar temp[128];
+ char16_t temp[128];
u_unescape(TEXTCANONICAL[0].text, temp, 128);
UnicodeString text;
text.setTo(temp, u_strlen(temp));
errln("Error expecting set offset error");
}
int index = 0;
- UChar temp[128];
+ char16_t temp[128];
while (BASICCANONICAL[index].text != nullptr) {
SearchData search = BASICCANONICAL[index ++];
if (BASICCANONICAL[index].text == nullptr) {
void StringSearchTest::TestContractionCanonical()
{
- UChar temp[128];
+ char16_t temp[128];
u_unescape(CONTRACTIONRULE, temp, 128);
UnicodeString rules;
int32_t itemCount = uset_getItemCount(set), len = 0;
int32_t index = m_rand() % itemCount;
UChar32 rangeStart = 0, rangeEnd = 0;
- UChar buffer[16];
+ char16_t buffer[16];
UErrorCode err = U_ZERO_ERROR;
len = uset_getItem(set, index, &rangeStart, &rangeEnd, buffer, 16, &err);
void
StringCaseTest::TestCaseConversion()
{
- static const UChar uppercaseGreek[] =
+ static const char16_t uppercaseGreek[] =
{ 0x399, 0x395, 0x3a3, 0x3a5, 0x3a3, 0x20, 0x03a7, 0x3a1, 0x399, 0x3a3, 0x3a4,
0x39f, 0x3a3, 0 };
// "IESUS CHRISTOS"
- static const UChar lowercaseGreek[] =
+ static const char16_t lowercaseGreek[] =
{ 0x3b9, 0x3b5, 0x3c3, 0x3c5, 0x3c2, 0x20, 0x03c7, 0x3c1, 0x3b9, 0x3c3, 0x3c4,
0x3bf, 0x3c2, 0 };
// "iesus christos"
- static const UChar lowercaseTurkish[] =
+ static const char16_t lowercaseTurkish[] =
{ 0x69, 0x73, 0x74, 0x61, 0x6e, 0x62, 0x75, 0x6c, 0x2c, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x63, 0x6f,
0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x0131, 0x6e, 0x6f, 0x70, 0x6c, 0x65, 0x21, 0 };
- static const UChar uppercaseTurkish[] =
+ static const char16_t uppercaseTurkish[] =
{ 0x54, 0x4f, 0x50, 0x4b, 0x41, 0x50, 0x49, 0x20, 0x50, 0x41, 0x4c, 0x41, 0x43, 0x45, 0x2c, 0x20,
0x0130, 0x53, 0x54, 0x41, 0x4e, 0x42, 0x55, 0x4c, 0 };
// more string case mapping tests with the new implementation
{
- static const UChar
+ static const char16_t
beforeLower[]= { 0x61, 0x42, 0x49, 0x3a3, 0xdf, 0x3a3, 0x2f, 0xd93f, 0xdfff },
lowerRoot[]= { 0x61, 0x62, 0x69, 0x3c3, 0xdf, 0x3c2, 0x2f, 0xd93f, 0xdfff },
// UTF-8
char utf8In[100], utf8Out[100];
int32_t utf8InLength, utf8OutLength, resultLength;
- UChar *buffer;
+ char16_t *buffer;
IcuTestErrorCode errorCode(*this, "TestCasingImpl");
LocalUCaseMapPointer csm(ucasemap_open(localeID, options, errorCode));
} else if(type==-2) {
// Open a trivial break iterator that only delivers { 0, length }
// or even just { 0 } as boundaries.
- static const UChar rules[] = { 0x2e, 0x2a, 0x3b }; // ".*;"
+ static const char16_t rules[] = { 0x2e, 0x2a, 0x3b }; // ".*;"
UParseError parseError;
iter.adoptInstead(ubrk_openRules(rules, UPRV_LENGTHOF(rules), nullptr, 0, &parseError, &status));
}
options = 0;
if(whichCase==TEST_TITLE || whichCase==TEST_FOLD) {
optionsString = myCase->getString("Options", status);
- if(optionsString.indexOf((UChar)0x54)>=0) { // T
+ if(optionsString.indexOf((char16_t)0x54)>=0) { // T
options|=U_FOLD_CASE_EXCLUDE_SPECIAL_I;
}
- if(optionsString.indexOf((UChar)0x4c)>=0) { // L
+ if(optionsString.indexOf((char16_t)0x4c)>=0) { // L
options|=U_TITLECASE_NO_LOWERCASE;
}
- if(optionsString.indexOf((UChar)0x41)>=0) { // A
+ if(optionsString.indexOf((char16_t)0x41)>=0) { // A
options|=U_TITLECASE_NO_BREAK_ADJUSTMENT;
}
}
};
for (int32_t i = 0; i < UPRV_LENGTHOF(capacities); ++i) {
int32_t cap = capacities[i];
- UChar *dest16 = result16.getBuffer(expected16.length() + 1);
+ char16_t *dest16 = result16.getBuffer(expected16.length() + 1);
u_memset(dest16, 0x55AA, result16.getCapacity());
UErrorCode errorCode = U_ZERO_ERROR;
length = u_strToUpper(dest16, cap, s16.getBuffer(), s16.length(), "el", &errorCode);
int32_t length = 0x40000004; // more than 1G UChars
UnicodeString s(length, (UChar32)0x390, length);
UnicodeString result;
- UChar *dest = result.getBuffer(length + 1);
+ char16_t *dest = result.getBuffer(length + 1);
if (s.isBogus() || dest == nullptr) {
logln("Out of memory, unable to run this test on this machine.");
return;
void StringCaseTest::TestCaseMapWithEdits() {
IcuTestErrorCode errorCode(*this, "TestCaseMapWithEdits");
- UChar dest[20];
+ char16_t dest[20];
Edits edits;
int32_t length = CaseMap::toLower("tr", U_OMIT_UNCHANGED_TEXT,
// It is a bit of a misnomer until we have CaseMap API that writes to
// a UnicodeString, at which point we should change this code here.
IcuTestErrorCode errorCode(*this, "TestCaseMapToString");
- UChar dest[20];
+ char16_t dest[20];
// Omit unchanged text.
int32_t length = CaseMap::toLower("tr", U_OMIT_UNCHANGED_TEXT,
// Code coverage for UnicodeString case mapping code handling
// long strings or many changes in a string.
UnicodeString s(true,
- (const UChar *)
+ (const char16_t *)
u"aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeF"
u"aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeF"
u"aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeF"
u"aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeF"
u"aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeF", 6 * 51);
UnicodeString expected(true,
- (const UChar *)
+ (const char16_t *)
u"AAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDDEEEEEEEEEEF"
u"AAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDDEEEEEEEEEEF"
u"AAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDDEEEEEEEEEEF"
if(2!=sizeof(uint16_t)) {
errln("2!=sizeof(uint16_t)");
}
- if(2!=sizeof(UChar)) {
- errln("2!=sizeof(UChar)");
+ if(2!=sizeof(char16_t)) {
+ errln("2!=sizeof(char16_t)");
}
if(1!=sizeof(int8_t)) {
errln("1!=sizeof(int8_t)");
UnicodeString displayName;
Collator::getDisplayName(fu_FU, displayName);
/* The locale display pattern for the locale ja, ko, and zh are different. */
- const UChar zh_fuFU_Array[] = { 0x0066, 0x0075, 0xff08, 0x0046, 0x0055, 0xff09, 0 };
+ const char16_t zh_fuFU_Array[] = { 0x0066, 0x0075, 0xff08, 0x0046, 0x0055, 0xff09, 0 };
const UnicodeString zh_fuFU(zh_fuFU_Array);
const Locale& defaultLocale = Locale::getDefault();
if (displayName != "fu (FU)" &&
assertTrue("count verified", i==n);
iter.reset(ec);
for (;; ++idxAfterReset) {
- const UChar *s = iter.unext(nullptr, ec);
+ const char16_t *s = iter.unext(nullptr, ec);
if (!assertSuccess("unext", ec) || s == nullptr)
break;
if (idxAfterReset != 0)
testAllCodepoints(TestIDNA& test){
/*
{
- UChar str[19] = {
+ char16_t str[19] = {
0xC138, 0xACC4, 0xC758, 0xBAA8, 0xB4E0, 0xC0AC, 0xB78C, 0xB4E4, 0xC774,
0x070F,//prohibited
0xD55C, 0xAD6D, 0xC5B4, 0xB97C, 0xC774, 0xD574, 0xD55C, 0xB2E4, 0xBA74
pTestIDNA->errln("Did not get the expected result. Expected: 0x%04X Got: 0x%04X \n", mapping[i], mappingData[index+i]);
}
}else{
- UChar lead = U16_LEAD(mapping[i]);
- UChar trail = U16_TRAIL(mapping[i]);
+ char16_t lead = U16_LEAD(mapping[i]);
+ char16_t trail = U16_TRAIL(mapping[i]);
if(mappingData[index+i] != lead ||
mappingData[index+i+1] != trail){
pTestIDNA->errln( "Did not get the expected result. Expected: 0x%04X 0x%04X Got: 0x%04X 0x%04X", lead, trail, mappingData[index+i], mappingData[index+i+1]);
int32_t value=0;
/*
// supplementary code point
- UChar __lead16=U16_LEAD(0x2323E);
+ char16_t __lead16=U16_LEAD(0x2323E);
int32_t __offset;
// get data for lead surrogate
#include "unicode/putil.h"
#include "idnaconf.h"
-static const UChar unicodeIn[][41] ={
+static const char16_t unicodeIn[][41] ={
{
0x0644, 0x064A, 0x0647, 0x0645, 0x0627, 0x0628, 0x062A, 0x0643, 0x0644,
0x0645, 0x0648, 0x0634, 0x0639, 0x0631, 0x0628, 0x064A, 0x061F, 0x0000
static const struct ErrorCases{
- UChar unicode[100];
+ char16_t unicode[100];
const char *ascii;
UErrorCode expected;
UBool useSTD3ASCIIRules;
#define MAX_DEST_SIZE 300
-void TestIDNA::debug(const UChar* src, int32_t srcLength, int32_t options){
+void TestIDNA::debug(const char16_t* src, int32_t srcLength, int32_t options){
UParseError parseError;
UErrorCode transStatus = U_ZERO_ERROR;
UErrorCode prepStatus = U_ZERO_ERROR;
NamePrepTransform* trans = NamePrepTransform::createInstance(parseError,transStatus);
int32_t prepOptions = (((options & UIDNA_ALLOW_UNASSIGNED) != 0) ? USPREP_ALLOW_UNASSIGNED: 0);
LocalUStringPrepProfilePointer prep(usprep_openByType(USPREP_RFC3491_NAMEPREP,&prepStatus));
- UChar *transOut=nullptr, *prepOut=nullptr;
+ char16_t *transOut=nullptr, *prepOut=nullptr;
int32_t transOutLength=0, prepOutLength=0;
transOutLength = trans->process(src,srcLength,transOut, 0, prepOptions>0, &parseError, transStatus);
if( transStatus == U_BUFFER_OVERFLOW_ERROR){
transStatus = U_ZERO_ERROR;
- transOut = (UChar*) malloc(U_SIZEOF_UCHAR * transOutLength);
+ transOut = (char16_t*) malloc(U_SIZEOF_UCHAR * transOutLength);
transOutLength = trans->process(src,srcLength,transOut, transOutLength, prepOptions>0, &parseError, transStatus);
}
if( prepStatus == U_BUFFER_OVERFLOW_ERROR){
prepStatus = U_ZERO_ERROR;
- prepOut = (UChar*) malloc(U_SIZEOF_UCHAR * prepOutLength);
+ prepOut = (char16_t*) malloc(U_SIZEOF_UCHAR * prepOutLength);
prepOutLength = usprep_prepare(prep.getAlias(), src, srcLength, prepOut, prepOutLength, prepOptions, &parseError, &prepStatus);
}
delete trans;
}
-void TestIDNA::testAPI(const UChar* src, const UChar* expected, const char* testName,
+void TestIDNA::testAPI(const char16_t* src, const char16_t* expected, const char* testName,
UBool useSTD3ASCIIRules,UErrorCode expectedStatus,
UBool doCompare, UBool testUnassigned, TestFunc func, UBool testSTD3ASCIIRules){
UErrorCode status = U_ZERO_ERROR;
- UChar destStack[MAX_DEST_SIZE];
+ char16_t destStack[MAX_DEST_SIZE];
int32_t destLen = 0;
- UChar* dest = nullptr;
+ char16_t* dest = nullptr;
int32_t expectedLen = (expected != nullptr) ? u_strlen(expected) : 0;
int32_t options = (useSTD3ASCIIRules == true) ? UIDNA_USE_STD3_RULES : UIDNA_DEFAULT;
UParseError parseError;
int32_t tSrcLen = 0;
- UChar* tSrc = nullptr;
+ char16_t* tSrc = nullptr;
if(src != nullptr){
tSrcLen = u_strlen(src);
- tSrc =(UChar*) malloc( U_SIZEOF_UCHAR * tSrcLen );
+ tSrc =(char16_t*) malloc( U_SIZEOF_UCHAR * tSrcLen );
memcpy(tSrc,src,tSrcLen * U_SIZEOF_UCHAR);
}
free(tSrc);
}
-void TestIDNA::testCompare(const UChar* s1, int32_t s1Len,
- const UChar* s2, int32_t s2Len,
+void TestIDNA::testCompare(const char16_t* s1, int32_t s1Len,
+ const char16_t* s2, int32_t s2Len,
const char* testName, CompareFunc func,
UBool isEqual){
void TestIDNA::testToASCII(const char* testName, TestFunc func){
int32_t i;
- UChar buf[MAX_DEST_SIZE];
+ char16_t buf[MAX_DEST_SIZE];
for(i=0;i< UPRV_LENGTHOF(unicodeIn); i++){
u_charsToUChars(asciiIn[i],buf, (int32_t)(strlen(asciiIn[i])+1));
void TestIDNA::testToUnicode(const char* testName, TestFunc func){
int32_t i;
- UChar buf[MAX_DEST_SIZE];
+ char16_t buf[MAX_DEST_SIZE];
for(i=0;i< UPRV_LENGTHOF(asciiIn); i++){
u_charsToUChars(asciiIn[i],buf, (int32_t)(strlen(asciiIn[i])+1));
void TestIDNA::testIDNToUnicode(const char* testName, TestFunc func){
int32_t i;
- UChar buf[MAX_DEST_SIZE];
- UChar expected[MAX_DEST_SIZE];
+ char16_t buf[MAX_DEST_SIZE];
+ char16_t expected[MAX_DEST_SIZE];
UErrorCode status = U_ZERO_ERROR;
int32_t bufLen = 0;
UParseError parseError;
void TestIDNA::testIDNToASCII(const char* testName, TestFunc func){
int32_t i;
- UChar buf[MAX_DEST_SIZE];
- UChar expected[MAX_DEST_SIZE];
+ char16_t buf[MAX_DEST_SIZE];
+ char16_t expected[MAX_DEST_SIZE];
UErrorCode status = U_ZERO_ERROR;
int32_t bufLen = 0;
UParseError parseError;
int32_t i;
- UChar www[] = {0x0057, 0x0057, 0x0057, 0x002E, 0x0000};
- UChar com[] = {0x002E, 0x0043, 0x004F, 0x004D, 0x0000};
- UChar buf[MAX_DEST_SIZE]={0x0057, 0x0057, 0x0057, 0x002E, 0x0000};
+ char16_t www[] = {0x0057, 0x0057, 0x0057, 0x002E, 0x0000};
+ char16_t com[] = {0x002E, 0x0043, 0x004F, 0x004D, 0x0000};
+ char16_t buf[MAX_DEST_SIZE]={0x0057, 0x0057, 0x0057, 0x002E, 0x0000};
UnicodeString source(www), uni0(www),uni1(www), ascii0(www), ascii1(www);
uni0.append(unicodeIn[0]);
uni0.append(com);
- uni0.append((UChar)0x0000);
+ uni0.append((char16_t)0x0000);
uni1.append(unicodeIn[1]);
uni1.append(com);
- uni1.append((UChar)0x0000);
+ uni1.append((char16_t)0x0000);
ascii0.append(asciiIn[0]);
ascii0.append(com);
- ascii0.append((UChar)0x0000);
+ ascii0.append((char16_t)0x0000);
ascii1.append(asciiIn[1]);
ascii1.append(com);
- ascii1.append((UChar)0x0000);
+ ascii1.append((char16_t)0x0000);
for(i=0;i< UPRV_LENGTHOF(unicodeIn); i++){
source.truncate(4);
source.append(unicodeIn[i]);
source.append(com);
- source.append((UChar)0x0000);
+ source.append((char16_t)0x0000);
// a) compare it with itself
- const UChar* src = source.getBuffer();
+ const char16_t* src = source.getBuffer();
int32_t srcLen = u_strlen(src); //subtract null
testCompare(src,srcLen,src,srcLen,testName, func, true);
#if 0
static int32_t
-getNextSeperator(UChar *src,int32_t srcLength,
- UChar **limit){
+getNextSeperator(char16_t *src,int32_t srcLength,
+ char16_t **limit){
if(srcLength == -1){
int32_t i;
for(i=0 ; ;i++){
void printPunycodeOutput(){
- UChar dest[MAX_DEST_SIZE];
+ char16_t dest[MAX_DEST_SIZE];
int32_t destCapacity=MAX_DEST_SIZE;
- UChar* start;
- UChar* limit;
+ char16_t* start;
+ char16_t* limit;
int32_t labelLen=0;
UBool caseFlags[MAX_DEST_SIZE];
void TestIDNA::testErrorCases(const char* IDNToASCIIName, TestFunc IDNToASCII,
const char* IDNToUnicodeName, TestFunc IDNToUnicode){
- UChar buf[MAX_DEST_SIZE];
+ char16_t buf[MAX_DEST_SIZE];
int32_t bufLen=0;
for(int32_t i=0;i< UPRV_LENGTHOF(errorCases);i++){
ErrorCases errorCase = errorCases[i];
- UChar* src =nullptr;
+ char16_t* src =nullptr;
if(errorCase.ascii != nullptr){
bufLen = (int32_t)strlen(errorCase.ascii);
u_charsToUChars(errorCase.ascii,buf, bufLen+1);
const char* IDNToASCIIName, TestFunc IDNToASCII,
const char* IDNToUnicodeName, TestFunc IDNToUnicode,
const char* toUnicodeName, TestFunc toUnicode){
- UChar src[MAX_DEST_SIZE];
+ char16_t src[MAX_DEST_SIZE];
int32_t srcLen=0;
- UChar expected[MAX_DEST_SIZE];
+ char16_t expected[MAX_DEST_SIZE];
int32_t expectedLen = 0;
for(int32_t i=0;i< UPRV_LENGTHOF(conformanceTestCases);i++){
const char* utf8Chars1 = conformanceTestCases[i].in;
*/
// test and ascertain
// func(func(func(src))) == func(src)
-void TestIDNA::testChaining(const UChar* src,int32_t numIterations,const char* testName,
+void TestIDNA::testChaining(const char16_t* src,int32_t numIterations,const char* testName,
UBool useSTD3ASCIIRules, UBool caseInsensitive, TestFunc func){
- UChar even[MAX_DEST_SIZE];
- UChar odd[MAX_DEST_SIZE];
- UChar expected[MAX_DEST_SIZE];
+ char16_t even[MAX_DEST_SIZE];
+ char16_t odd[MAX_DEST_SIZE];
+ char16_t expected[MAX_DEST_SIZE];
int32_t i=0,evenLen=0,oddLen=0,expectedLen=0;
UErrorCode status = U_ZERO_ERROR;
int32_t srcLen = u_strlen(src);
void TestIDNA::testChaining(const char* toASCIIName, TestFunc toASCII,
const char* toUnicodeName, TestFunc toUnicode){
int32_t i;
- UChar buf[MAX_DEST_SIZE];
+ char16_t buf[MAX_DEST_SIZE];
for(i=0;i< UPRV_LENGTHOF(asciiIn); i++){
u_charsToUChars(asciiIn[i],buf, (int32_t)(strlen(asciiIn[i])+1));
int32_t i;
- UChar www[] = {0x0057, 0x0057, 0x0057, 0x002E, 0x0000};
- UChar com[] = {0x002E, 0x0043, 0x004F, 0x004D, 0x002E, /* root label separator */0x0000};
- UChar buf[MAX_DEST_SIZE]={0x0057, 0x0057, 0x0057, 0x002E, 0x0000};
+ char16_t www[] = {0x0057, 0x0057, 0x0057, 0x002E, 0x0000};
+ char16_t com[] = {0x002E, 0x0043, 0x004F, 0x004D, 0x002E, /* root label separator */0x0000};
+ char16_t buf[MAX_DEST_SIZE]={0x0057, 0x0057, 0x0057, 0x002E, 0x0000};
UnicodeString source(www), uni0(www),uni1(www), ascii0(www), ascii1(www);
uni0.append(unicodeIn[0]);
uni0.append(com);
- uni0.append((UChar)0x0000);
+ uni0.append((char16_t)0x0000);
uni1.append(unicodeIn[1]);
uni1.append(com);
- uni1.append((UChar)0x0000);
+ uni1.append((char16_t)0x0000);
ascii0.append(asciiIn[0]);
ascii0.append(com);
- ascii0.append((UChar)0x0000);
+ ascii0.append((char16_t)0x0000);
ascii1.append(asciiIn[1]);
ascii1.append(com);
- ascii1.append((UChar)0x0000);
+ ascii1.append((char16_t)0x0000);
for(i=0;i< UPRV_LENGTHOF(unicodeIn); i++){
source.truncate(4);
source.append(unicodeIn[i]);
source.append(com);
- source.append((UChar)0x0000);
+ source.append((char16_t)0x0000);
- const UChar* src = source.getBuffer();
+ const char16_t* src = source.getBuffer();
int32_t srcLen = u_strlen(src); //subtract null
// b) compare it with asciiIn equivalent
TestFunc uIDNA, const char* uIDNAName,
int32_t options){
- const UChar* srcUChars = src.getBuffer();
- UChar exp[MAX_DEST_SIZE]={0};
+ const char16_t* srcUChars = src.getBuffer();
+ char16_t exp[MAX_DEST_SIZE]={0};
int32_t expCap = MAX_DEST_SIZE, expLen=0;
UErrorCode expStatus = U_ZERO_ERROR;
UParseError parseError;
expLen = refIDNA(srcUChars, src.length()-1, exp, expCap,
options, &parseError, &expStatus);
- UChar got[MAX_DEST_SIZE]={0};
+ char16_t got[MAX_DEST_SIZE]={0};
int32_t gotCap = MAX_DEST_SIZE, gotLen=0;
UErrorCode gotStatus = U_ZERO_ERROR;
return UnicodeString("");
}
-void TestIDNA::testCompareReferenceImpl(const UChar* src, int32_t srcLen){
+void TestIDNA::testCompareReferenceImpl(const char16_t* src, int32_t srcLen){
UnicodeString label(src,srcLen);
- label.append((UChar)0x0000);
+ label.append((char16_t)0x0000);
//test idnaref_toASCII and idnare
UnicodeString asciiLabel = testCompareReferenceImpl(label,
UIDNA_USE_STD3_RULES | UIDNA_ALLOW_UNASSIGNED);
if(asciiLabel.length()!=0){
- asciiLabel.append((UChar)0x0000);
+ asciiLabel.append((char16_t)0x0000);
// test toUnciode
testCompareReferenceImpl(asciiLabel,
for(i=0; i<loopCount; i++){
source.truncate(0);
getTestSource(source);
- source.append((UChar)0x0000);
- const UChar* src = source.getBuffer();
+ source.append((char16_t)0x0000);
+ const char16_t* src = source.getBuffer();
testCompareReferenceImpl(src,source.length()-1);
testCompareReferenceImpl(src,source.length()-1);
}
source.truncate(0);
source.append( UnicodeString(failures[i], -1, US_INV) );
source = source.unescape();
- source.append((UChar)0x0000);
- const UChar *src = source.getBuffer();
+ source.append((char16_t)0x0000);
+ const char16_t *src = source.getBuffer();
testCompareReferenceImpl(src,source.length()-1);
//debug(source.getBuffer(),source.length(),UIDNA_ALLOW_UNASSIGNED);
}
UnicodeString expected("\\u043f\\u043e\\u0447\\u0435\\u043c\\u0443\\u0436\\u0435\\u043e\\u043d\\u0438\\u043d\\u0435\\u0433\\u043e\\u0432\\u043e\\u0440\\u044f\\u0442\\u043f\\u043e\\u0440\\u0443\\u0441\\u0441\\u043a\\u0438\\u0000", -1, US_INV);
expected = expected.unescape();
UnicodeString ascii("xn--b1abfaaepdrnnbgefbadotcwatmq2g4l");
- ascii.append((UChar)0x0000);
+ ascii.append((char16_t)0x0000);
testAPI(source.getBuffer(),ascii.getBuffer(), "uidna_toASCII", false, U_ZERO_ERROR, true, true, uidna_toASCII);
testAPI(source.getBuffer(),ascii.getBuffer(), "idnaref_toASCII", false, U_ZERO_ERROR, true, true, idnaref_toASCII);
void TestIDNA::TestCompareReferenceImpl(){
- UChar src [2] = {0,0};
+ char16_t src [2] = {0,0};
int32_t srcLen = 0;
// data even OK?
src[1] = U16_TRAIL(i);
srcLen =2;
} else {
- src[0] = (UChar)i;
+ src[0] = (char16_t)i;
src[1] = 0;
srcLen = 1;
}
U_CDECL_BEGIN
typedef int32_t
-(U_EXPORT2 *TestFunc) ( const UChar *src, int32_t srcLength,
- UChar *dest, int32_t destCapacity,
+(U_EXPORT2 *TestFunc) ( const char16_t *src, int32_t srcLength,
+ char16_t *dest, int32_t destCapacity,
int32_t options, UParseError *parseError,
UErrorCode *status);
typedef int32_t
-(U_EXPORT2 *CompareFunc) (const UChar *s1, int32_t s1Len,
- const UChar *s2, int32_t s2Len,
+(U_EXPORT2 *CompareFunc) (const char16_t *s1, int32_t s1Len,
+ const char16_t *s2, int32_t s2Len,
int32_t options,
UErrorCode *status);
void testCompare(const char* testName, CompareFunc func);
void testChaining(const char* toASCIIName, TestFunc toASCII,
const char* toUnicodeName, TestFunc toUnicode);
- void debug(const UChar* src, int32_t srcLength, int32_t options);
+ void debug(const char16_t* src, int32_t srcLength, int32_t options);
// main testing functions
- void testAPI(const UChar *src, const UChar *expected, const char *testName,
+ void testAPI(const char16_t *src, const char16_t *expected, const char *testName,
UBool useSTD3ASCIIRules, UErrorCode expectedStatus,
UBool doCompare, UBool testUnassigned, TestFunc func, UBool testSTD3ASCIIRules=true);
- void testCompare(const UChar* s1, int32_t s1Len,
- const UChar* s2, int32_t s2Len,
+ void testCompare(const char16_t* s1, int32_t s1Len,
+ const char16_t* s2, int32_t s2Len,
const char* testName, CompareFunc func,
UBool isEqual);
void testErrorCases(const char* IDNToASCIIName, TestFunc IDNToASCII,
const char* IDNToUnicodeName, TestFunc IDNToUnicode);
- void testChaining(const UChar* src,int32_t numIterations,const char* testName,
+ void testChaining(const char16_t* src,int32_t numIterations,const char* testName,
UBool useSTD3ASCIIRules, UBool caseInsensitive, TestFunc func);
void testRootLabelSeparator(const char* testName, CompareFunc func,
const char* IDNToASCIIName, TestFunc IDNToASCII,
const char* IDNToUnicodeName, TestFunc IDNToUnicode);
- void testCompareReferenceImpl(const UChar* src, int32_t srcLen);
+ void testCompareReferenceImpl(const char16_t* src, int32_t srcLen);
UnicodeString testCompareReferenceImpl(UnicodeString& src,
TestFunc refIDNA, const char* refIDNAName,
#include "testutil.h"
#include "intltest.h"
-static const UChar HEX[] = u"0123456789ABCDEF";
+static const char16_t HEX[] = u"0123456789ABCDEF";
UnicodeString &TestUtility::appendHex(UnicodeString &buf, UChar32 ch) {
if (ch >= 0x10000) {
return hex(s, u',');
}
-UnicodeString TestUtility::hex(const UnicodeString& s, UChar sep) {
+UnicodeString TestUtility::hex(const UnicodeString& s, char16_t sep) {
UnicodeString result;
if (s.isEmpty()) return result;
UChar32 c;
static UnicodeString hex(const UnicodeString& s);
- static UnicodeString hex(const UnicodeString& s, UChar sep);
+ static UnicodeString hex(const UnicodeString& s, char16_t sep);
static UnicodeString hex(const uint8_t* bytes, int32_t len);
U_CDECL_BEGIN
static int U_CALLCONV
StrCmp(const void *p1, const void *p2) {
- return ucol_strcoll(thaiColl, *(UChar **) p1, -1, *(UChar **)p2, -1);
+ return ucol_strcoll(thaiColl, *(char16_t **) p1, -1, *(char16_t **)p2, -1);
}
U_CDECL_END
"\\u0E01\\u0E44\\u0E44\\u0E01",
};
- UChar strings[LINES][20];
+ char16_t strings[LINES][20];
- UChar *toSort[LINES];
+ char16_t *toSort[LINES];
int32_t i = 0, j = 0, len = 0;
toSort[i] = strings[i];
}
- qsort (toSort, LINES, sizeof (UChar *), StrCmp);
+ qsort (toSort, LINES, sizeof (char16_t *), StrCmp);
for (i=0; i < LINES; i++)
{
// Just use unlocalized currency symbol.
//UnicodeString compareStrEng = "At <time> on Aug 8, 1997, you made a deposit of $456.83.";
UnicodeString compareStrEng = "At <time> on Aug 8, 1997, you made a deposit of ";
- compareStrEng += (UChar) 0x00a4;
+ compareStrEng += (char16_t) 0x00a4;
compareStrEng += "456.83.";
// {sfb} to get DM, would need Locale::GERMANY, not Locale::GERMAN
// Just use unlocalized currency symbol.
//UnicodeString compareStrGer = "At <time> on 08.08.1997, you made a deposit of 456,83 DM.";
UnicodeString compareStrGer = "At <time> on 08.08.1997, you made a deposit of ";
compareStrGer += "456,83";
- compareStrGer += (UChar) 0x00a0;
+ compareStrGer += (char16_t) 0x00a0;
compareStrGer += "XXX.";
MessageFormat msg( formatStr, err);
if (pos == line.length()) {
return false;
}
- UChar c = line.charAt(pos++);
- UChar quote = 0;
+ char16_t c = line.charAt(pos++);
+ char16_t quote = 0;
switch (c) {
case 34/*'"'*/:
case 39/*'\\'*/:
s="";
status=U_ZERO_ERROR;
index.contextStart = index.contextLimit = index.start = index.limit = 0;
- logln("Testing transliterate(Replaceable, int32_t, UChar, UErrorCode)");
+ logln("Testing transliterate(Replaceable, int32_t, char16_t, UErrorCode)");
for(i=10; i<UPRV_LENGTHOF(Data); i=i+2){
UnicodeString log;
if (Data[i+0] != "") {
log = s + " + " + Data[i+0] + " -> ";
- UChar c=Data[i+0].charAt(0);
+ char16_t c=Data[i+0].charAt(0);
t->transliterate(s, index, c, status);
if(U_FAILURE(status)) {
- errln("FAIL: " + t->getID()+ ".transliterate(Replaceable, int32_t[], UChar, UErrorCode)-->" + (UnicodeString)u_errorName(status));
+ errln("FAIL: " + t->getID()+ ".transliterate(Replaceable, int32_t[], char16_t, UErrorCode)-->" + (UnicodeString)u_errorName(status));
continue;
}
} else {
got.extractBetween(index.limit, index.contextLimit, d);
got.extractBetween(index.contextLimit, got.length(), e);
log.append(a).
- append((UChar)0x7b/*{*/).
+ append((char16_t)0x7b/*{*/).
append(b).
- append((UChar)0x7c/*|*/).
+ append((char16_t)0x7c/*|*/).
append(c).
- append((UChar)0x7c).
+ append((char16_t)0x7c).
append(d).
- append((UChar)0x7d/*}*/).
+ append((char16_t)0x7d/*}*/).
append(e);
if (got == expected)
logln("OK:" + prettify(log));
LegalJamo() {}
virtual ~LegalJamo() {}
virtual UBool is(const UnicodeString& sourceString) const override;
- int getType(UChar c) const;
+ int getType(char16_t c) const;
};
UBool LegalJamo::is(const UnicodeString& sourceString) const {
return true;
}
-int LegalJamo::getType(UChar c) const {
+int LegalJamo::getType(char16_t c) const {
if (0x1100 <= c && c <= 0x1112)
return 0;
else if (0x1161 <= c && c <= 0x1175)
virtual UBool is(const UnicodeString& sourceString) const override;
- static UBool isVowel(UChar c);
+ static UBool isVowel(char16_t c);
- static UBool isRho(UChar c);
+ static UBool isRho(char16_t c);
};
UBool LegalGreek::is(const UnicodeString& sourceString) const {
// return false;
// }
for (int32_t i = 0; i < decomp.length(); ++i) {
- UChar c = decomp.charAt(i);
+ char16_t c = decomp.charAt(i);
// exclude all the accents
if (c == 0x0313 || c == 0x0314 || c == 0x0300 || c == 0x0302
|| c == 0x0342 || c == 0x0345
int32_t breathingCount = 0;
int32_t letterCount = 0;
for (int32_t i = 0; i < decomp.length(); ++i) {
- UChar c = decomp.charAt(i);
+ char16_t c = decomp.charAt(i);
if (u_isalpha(c)) {
++letterCount;
if (noLetterYet) {
return breathingCount == 0;
}
-UBool LegalGreek::isVowel(UChar c) {
+UBool LegalGreek::isVowel(char16_t c) {
switch (c) {
case 0x03B1:
case 0x03B5:
return false;
}
-UBool LegalGreek::isRho(UChar c) {
+UBool LegalGreek::isRho(char16_t c) {
switch (c) {
case 0x03C1:
case 0x03A1:
UBool RTTest::checkIrrelevants(Transliterator *t,
const UnicodeString& irrelevants) {
for (int i = 0; i < irrelevants.length(); ++i) {
- UChar c = irrelevants.charAt(i);
+ char16_t c = irrelevants.charAt(i);
UnicodeString srcStr(c);
UnicodeString targ = srcStr;
t->transliterate(targ);
if (sourceString.length() == 0) return true;
// don't worry about surrogates.
for (int i = 0; i < sourceString.length(); ++i) {
- UChar ch = sourceString.charAt(i);
- UChar next = i+1 == sourceString.length() ? 0x0000 : sourceString.charAt(i);
+ char16_t ch = sourceString.charAt(i);
+ char16_t next = i+1 == sourceString.length() ? 0x0000 : sourceString.charAt(i);
if (FINAL.contains(ch)) {
if (LETTER.contains(next)) return false;
} else if (NON_FINAL.contains(ch)) {
// Define character constants thusly to be EBCDIC-friendly
enum {
- LEFT_BRACE=((UChar)0x007B), /*{*/
- PIPE =((UChar)0x007C), /*|*/
- ZERO =((UChar)0x0030), /*0*/
- UPPER_A =((UChar)0x0041) /*A*/
+ LEFT_BRACE=((char16_t)0x007B), /*{*/
+ PIPE =((char16_t)0x007C), /*|*/
+ ZERO =((char16_t)0x0030), /*0*/
+ UPPER_A =((char16_t)0x0041) /*A*/
};
TransliteratorTest::TransliteratorTest()
UParseError parseError;
Transliterator *t = Transliterator::createFromRules(
"<ID>",
- UnicodeString("$dummy=").append((UChar)0xE100) +
+ UnicodeString("$dummy=").append((char16_t)0xE100) +
UnicodeString(";"
"$vowel=[aeiouAEIOU];"
"$lu=[:Lu:];"
s.extractBetween(index.contextStart, index.start, b);
s.extractBetween(index.start, s.length(), c);
log.append(a).
- append((UChar)LEFT_BRACE).
+ append((char16_t)LEFT_BRACE).
append(b).
- append((UChar)PIPE).
+ append((char16_t)PIPE).
append(c);
if (s == DATA[i+1] && U_SUCCESS(status)) {
logln(log);
// };
// */
//
-// UChar ar_raw[] = {
+// char16_t ar_raw[] = {
// 0x062a, 0x062a, 0x0645, 0x062a, 0x0639, 0x0020, 0x0627,
// 0x0644, 0x0644, 0x063a, 0x0629, 0x0020, 0x0627, 0x0644,
// 0x0639, 0x0631, 0x0628, 0x0628, 0x064a, 0x0629, 0x0020,
return new TestFilter(*this);
}
virtual UBool contains(UChar32 c) const override {
- return c != (UChar)0x0063 /*c*/;
+ return c != (char16_t)0x0063 /*c*/;
}
// Stubs
virtual UnicodeString& toPattern(UnicodeString& result,
// Array of 3n items
// Each item is <rules>, <input>, <expected output>
const UnicodeString DATA[] = {
- UnicodeString(UChar(0x4E01)) + ">'[male adult]'",
- UnicodeString(UChar(0x4E01)),
+ UnicodeString(char16_t(0x4E01)) + ">'[male adult]'",
+ UnicodeString(char16_t(0x4E01)),
"[male adult]"
};
return;
}
- UChar sigma = 0x3C3;
- UChar upsilon = 0x3C5;
- UChar nu = 0x3BD;
-// UChar PHI = 0x3A6;
- UChar alpha = 0x3B1;
-// UChar omega = 0x3C9;
-// UChar omicron = 0x3BF;
-// UChar epsilon = 0x3B5;
+ char16_t sigma = 0x3C3;
+ char16_t upsilon = 0x3C5;
+ char16_t nu = 0x3BD;
+// char16_t PHI = 0x3A6;
+ char16_t alpha = 0x3B1;
+// char16_t omega = 0x3C9;
+// char16_t omicron = 0x3BF;
+// char16_t epsilon = 0x3B5;
// sigma upsilon nu -> syn
UnicodeString syn;
expected= expected.unescape();
while(vIter.next()){
- src.setCharAt(0,(UChar) vIter.getCodepoint());
- expected.setCharAt(0,(UChar) (vIter.getCodepoint()+0x0100));
+ src.setCharAt(0,(char16_t) vIter.getCodepoint());
+ expected.setCharAt(0,(char16_t) (vIter.getCodepoint()+0x0100));
expect(*trans,src,expected);
}
expected.setCharAt(1,0x0A70);
while(nvIter.next()){
//src.setCharAt(0,(char) nvIter.codepoint);
- src.setCharAt(0,(UChar)nvIter.getCodepoint());
- expected.setCharAt(0,(UChar) (nvIter.getCodepoint()+0x0100));
+ src.setCharAt(0,(char16_t)nvIter.getCodepoint());
+ expected.setCharAt(0,(char16_t) (nvIter.getCodepoint()+0x0100));
expect(*trans,src,expected);
}
delete trans;
delete t;
if (U_FAILURE(ec)) {
UnicodeString err(pe.preContext);
- err.append((UChar)124/*|*/).append(pe.postContext);
+ err.append((char16_t)124/*|*/).append(pe.postContext);
if (err.indexOf("d << b") >= 0) {
logln("Ok: " + err);
} else {
delete t;
if (U_FAILURE(ec)) {
UnicodeString err(pe.preContext);
- err.append((UChar)124/*|*/).append(pe.postContext);
+ err.append((char16_t)124/*|*/).append(pe.postContext);
logln("Ok: " + err);
return;
}
delete t;
if (U_FAILURE(ec)) {
UnicodeString err(pe.preContext);
- err.append((UChar)124/*|*/).append(pe.postContext);
+ err.append((char16_t)124/*|*/).append(pe.postContext);
logln("Ok: " + err);
return;
}
delete t;
if (U_FAILURE(ec)) {
UnicodeString err(pe.preContext);
- err.append((UChar)124/*|*/).append(pe.postContext);
+ err.append((char16_t)124/*|*/).append(pe.postContext);
if (err.indexOf("a}b{c") >= 0) {
logln("Ok: " + err);
} else {
}
}
-static const UChar SPACE[] = {32,0};
-static const UChar NEWLINE[] = {10,0};
-static const UChar RETURN[] = {13,0};
-static const UChar EMPTY[] = {0};
+static const char16_t SPACE[] = {32,0};
+static const char16_t NEWLINE[] = {10,0};
+static const char16_t RETURN[] = {13,0};
+static const char16_t EMPTY[] = {0};
void TransliteratorTest::checkRules(const UnicodeString& label, Transliterator& t2,
const UnicodeString& testRulesForward) {
// check that casing handles surrogates
// titlecase is currently defective
char buffer[20];
- UChar buffer2[20];
+ char16_t buffer2[20];
UChar32 dee;
U16_GET(DESERET_dee,0, 0, DESERET_dee.length(), dee);
UnicodeString DEE(u_totitle(dee));
#
\uE001>\u0C01; # SIGN
*/
- static const UChar rule[] = {
+ static const char16_t rule[] = {
0x0023,0x0020,0x000D,0x000A,
0xE001,0x003E,0x0C01,0x003B,0x0020,0x0023,0x0020,0x0053,0x0049,0x0047,0x004E,0
};
- static const UChar expectedRule[] = {
+ static const char16_t expectedRule[] = {
0xE001,0x003E,0x0C01,0x003B,0
};
- UChar result[UPRV_LENGTHOF(rule)];
+ char16_t result[UPRV_LENGTHOF(rule)];
UErrorCode status = U_ZERO_ERROR;
int32_t len = utrans_stripRules(rule, UPRV_LENGTHOF(rule), result, &status);
if (len != u_strlen(expectedRule)) {
input.extractBetween(pos.start, pos.limit, c);
input.extractBetween(pos.limit, pos.contextLimit, d);
input.extractBetween(pos.contextLimit, input.length(), e);
- appendTo.append(a).append((UChar)123/*{*/).append(b).
- append((UChar)PIPE).append(c).append((UChar)PIPE).append(d).
- append((UChar)125/*}*/).append(e);
+ appendTo.append(a).append((char16_t)123/*{*/).append(b).
+ append((char16_t)PIPE).append(c).append((char16_t)PIPE).append(d).
+ append((char16_t)125/*}*/).append(e);
} else {
appendTo.append((UnicodeString)"INVALID UTransPosition {cs=" +
pos.contextStart + ", s=" + pos.start + ", l=" +
delete myCollation;
}
-const UChar CollationTurkishTest::testSourceCases[][CollationTurkishTest::MAX_TOKEN_LEN] = {
+const char16_t CollationTurkishTest::testSourceCases[][CollationTurkishTest::MAX_TOKEN_LEN] = {
{0x73, 0x0327, 0},
{0x76, 0x00E4, 0x74, 0},
{0x6f, 0x6c, 0x64, 0},
{0x69, 0x64, 0x65, 0x61, 0}
};
-const UChar CollationTurkishTest::testTargetCases[][CollationTurkishTest::MAX_TOKEN_LEN] = {
+const char16_t CollationTurkishTest::testTargetCases[][CollationTurkishTest::MAX_TOKEN_LEN] = {
{0x75, 0x0308, 0},
{0x76, 0x62, 0x74, 0},
{0x00D6, 0x61, 0x79, 0},
private:
// static constants
- static const UChar testSourceCases[][MAX_TOKEN_LEN];
- static const UChar testTargetCases[][MAX_TOKEN_LEN];
+ static const char16_t testSourceCases[][MAX_TOKEN_LEN];
+ static const char16_t testTargetCases[][MAX_TOKEN_LEN];
static const Collator::EComparisonResult results[];
Collator *myCollation;
}
UCollationResult
-IntlTestCollator::compareUsingPartials(UCollator *coll, const UChar source[], int32_t sLen, const UChar target[], int32_t tLen, int32_t pieceSize, UErrorCode &status) {
+IntlTestCollator::compareUsingPartials(UCollator *coll, const char16_t source[], int32_t sLen, const char16_t target[], int32_t tLen, int32_t pieceSize, UErrorCode &status) {
int32_t partialSKResult = 0;
uint8_t sBuf[512], tBuf[512];
UCharIterator sIter, tIter;
UColAttributeValue norm = ucol_getAttribute(myCollation, UCOL_NORMALIZATION_MODE, &status);
int32_t sLen = source.length(), tLen = target.length();
- const UChar* src = source.getBuffer();
- const UChar* trg = target.getBuffer();
+ const char16_t* src = source.getBuffer();
+ const char16_t* trg = target.getBuffer();
UCollationResult compareResultIter = (UCollationResult)result;
{
}
void
-IntlTestCollator::doTest(Collator* col, const UChar *source, const UChar *target, Collator::EComparisonResult result) {
+IntlTestCollator::doTest(Collator* col, const char16_t *source, const char16_t *target, Collator::EComparisonResult result) {
doTest(col, UnicodeString(source), UnicodeString(target), result);
}
};
// These two should probably go down in IntlTest
- void doTest(Collator* col, const UChar *source, const UChar *target, Collator::EComparisonResult result);
+ void doTest(Collator* col, const char16_t *source, const char16_t *target, Collator::EComparisonResult result);
void doTest(Collator* col, const UnicodeString &source, const UnicodeString &target, Collator::EComparisonResult result);
void doTestVariant(Collator* col, const UnicodeString &source, const UnicodeString &target, Collator::EComparisonResult result);
* returned by calls to next on the specified iterator
*/
Order *getOrders(CollationElementIterator &iter, int32_t &orderLength);
- UCollationResult compareUsingPartials(UCollator *coll, const UChar source[], int32_t sLen, const UChar target[], int32_t tLen, int32_t pieceSize, UErrorCode &status);
+ UCollationResult compareUsingPartials(UCollator *coll, const char16_t source[], int32_t sLen, const char16_t target[], int32_t tLen, int32_t pieceSize, UErrorCode &status);
};
"", lastResort->getSymbol(DecimalFormatSymbols::kMonetaryGroupingSeparatorSymbol));
lastResort->setSymbol(DecimalFormatSymbols::kMonetaryGroupingSeparatorSymbol, ",");
assertEquals("last-resort NaN",
- UnicodeString((UChar)0xfffd), lastResort->getSymbol(DecimalFormatSymbols::kNaNSymbol));
+ UnicodeString((char16_t)0xfffd), lastResort->getSymbol(DecimalFormatSymbols::kNaNSymbol));
lastResort->setSymbol(DecimalFormatSymbols::kNaNSymbol, "NaN");
// Check that now all of the symbols match root.
for(int32_t i = 0; i < DecimalFormatSymbols::kFormatSymbolCount; ++i) {
void IntlTestDecimalFormatSymbols::testDigitSymbols() {
// This test does more in ICU4J than in ICU4C right now.
// In ICU4C, it is basically just a test for codePointZero and getConstDigitSymbol.
- UChar defZero = u'0';
+ char16_t defZero = u'0';
UChar32 osmanyaZero = U'\U000104A0';
- static const UChar* osmanyaDigitStrings[] = {
+ static const char16_t* osmanyaDigitStrings[] = {
u"\U000104A0", u"\U000104A1", u"\U000104A2", u"\U000104A3", u"\U000104A4",
u"\U000104A5", u"\U000104A6", u"\U000104A7", u"\U000104A8", u"\U000104A9"
};
void TestArabicShapeThreads::doTailTest(void) {
- static const UChar src[] = { 0x0020, 0x0633, 0 };
- static const UChar dst_old[] = { 0xFEB1, 0x200B,0 };
- static const UChar dst_new[] = { 0xFEB1, 0xFE73,0 };
- UChar dst[3] = { 0x0000, 0x0000,0 };
+ static const char16_t src[] = { 0x0020, 0x0633, 0 };
+ static const char16_t dst_old[] = { 0xFEB1, 0x200B,0 };
+ static const char16_t dst_new[] = { 0xFEB1, 0xFE73,0 };
+ char16_t dst[3] = { 0x0000, 0x0000,0 };
int32_t length;
UErrorCode status;
ThreadSafeFormatSharedData::ThreadSafeFormatSharedData(UErrorCode &status) {
fFormat.adoptInstead(NumberFormat::createCurrencyInstance(Locale::getUS(), status));
- static const UChar *kYDD = u"YDD";
- static const UChar *kBBD = u"BBD";
+ static const char16_t *kYDD = u"YDD";
+ static const char16_t *kBBD = u"BBD";
fYDDThing.adoptObject(new CurrencyAmount(123.456, kYDD, status));
fBBDThing.adoptObject(new CurrencyAmount(987.654, kBBD, status));
if (U_FAILURE(status)) {
fFormat.adoptInstead(NumberFormat::createCurrencyInstance(Locale::getUS(), status));
}
-static const UChar *kUSD = u"USD";
+static const char16_t *kUSD = u"USD";
UBool ThreadSafeFormat::doStuff(int32_t offset, UnicodeString &appendErr, UErrorCode &status) const {
UBool okay = true;
#define kCollatorThreadPatience kCollatorThreadThreads*30
struct Line {
- UChar buff[25];
+ char16_t buff[25];
int32_t buflen;
} ;
memset(lines.getAlias(), 0, sizeof(Line)*200000);
int32_t lineNum = 0;
- UChar bufferU[1024];
+ char16_t bufferU[1024];
uint32_t first = 0;
while (fgets(buffer, 1024, testFile) != nullptr) {
// Internal utilities
//
-UnicodeString BasicNormalizerTest::hex(UChar ch) {
+UnicodeString BasicNormalizerTest::hex(char16_t ch) {
UnicodeString result;
return appendHex(ch, 4, result);
}
UnicodeString BasicNormalizerTest::hex(const UnicodeString& s) {
UnicodeString result;
for (int i = 0; i < s.length(); ++i) {
- if (i != 0) result += (UChar)0x2c/*,*/;
+ if (i != 0) result += (char16_t)0x2c/*,*/;
appendHex(s[i], 4, result);
}
return result;
};
void
-BasicNormalizerTest::TestPreviousNext(const UChar *src, int32_t srcLength,
+BasicNormalizerTest::TestPreviousNext(const char16_t *src, int32_t srcLength,
const UChar32 *expect, int32_t expectLength,
const int32_t *expectIndex, // its length=expectLength+1
int32_t srcMiddle, int32_t expectMiddle,
void
BasicNormalizerTest::TestPreviousNext() {
// src and expect strings
- static const UChar src[]={
+ static const char16_t src[]={
U16_LEAD(0x2f999), U16_TRAIL(0x2f999),
U16_LEAD(0x1d15f), U16_TRAIL(0x1d15f),
0xc4,
};
// src and expect strings for regression test for j2911
- static const UChar src_j2911[]={
+ static const char16_t src_j2911[]={
U16_LEAD(0x2f999), U16_TRAIL(0x2f999),
0xdd00, 0xd900, // unpaired surrogates - regression test for j2911
0xc4,
}
// test cases with i and I to make sure Turkic works
- static const UChar iI[]={ 0x49, 0x69, 0x130, 0x131 };
+ static const char16_t iI[]={ 0x49, 0x69, 0x130, 0x131 };
UnicodeSet iSet, set;
UnicodeString s1, s2;
UnicodeString hangulCanon[2][3];
void
- TestPreviousNext(const UChar *src, int32_t srcLength,
+ TestPreviousNext(const char16_t *src, int32_t srcLength,
const UChar32 *expext, int32_t expectLength,
const int32_t *expectIndex, // its length=expectLength+1
int32_t srcMiddle, int32_t expectMiddle,
Normalizer* result,
const UnicodeString& errPrefix);
- static UnicodeString hex(UChar ch);
+ static UnicodeString hex(char16_t ch);
static UnicodeString hex(const UnicodeString& str);
void checkLowMappingToEmpty(const Normalizer2 &n2);
// test compose() and decompose()
UnicodeString tel, nfkc, nfkd;
tel=UnicodeString(1, (UChar32)0x2121, 10);
- tel.insert(1, (UChar)0x301);
+ tel.insert(1, (char16_t)0x301);
UErrorCode errorCode=U_ZERO_ERROR;
Normalizer::compose(tel, true, 0, nfkc, errorCode);
}
}
- // test setText(UChar *), getUMode() and setMode()
+ // test setText(char16_t *), getUMode() and setMode()
errorCode=U_ZERO_ERROR;
copy.setText(s.getBuffer()+1, s.length()-1, errorCode);
copy.setMode(UNORM_NFD);
errln("error in Normalizer::setMode() or Normalizer::getUMode()");
}
if(copy.next()!=0x308 || copy.next()!=0x1100) {
- dataerrln("error in Normalizer::setText(UChar *) or Normalizer::setMode()");
+ dataerrln("error in Normalizer::setText(char16_t *) or Normalizer::setMode()");
}
- // test setText(UChar *, length=-1)
+ // test setText(char16_t *, length=-1)
errorCode=U_ZERO_ERROR;
// NUL-terminate s
- s.append((UChar)0); // append NUL
+ s.append((char16_t)0); // append NUL
s.truncate(s.length()-1); // undo length change
copy.setText(s.getBuffer()+1, -1, errorCode);
if(copy.endIndex()!=s.length()-1) {
- errln("error in Normalizer::setText(UChar *, -1)");
+ errln("error in Normalizer::setText(char16_t *, -1)");
}
// test setOption() and getOption()
}
// test that the same string can be used as source and destination
- s.setTo((UChar)0xe4);
+ s.setTo((char16_t)0xe4);
Normalizer::normalize(s, UNORM_NFD, 0, s, status);
if(s.charAt(1)!=0x308) {
dataerrln("error in Normalizer::normalize(UNORM_NFD, self)");
UTimeUnitFormatStyle styles[] = {UTMUTFMT_FULL_STYLE, UTMUTFMT_ABBREVIATED_STYLE};
const int numbers[] = {1, 7};
- const UChar oneSecond[] = {0x0031, 0x0020, 0x03b4, 0x03b5, 0x03c5, 0x03c4, 0x03b5, 0x03c1, 0x03cc, 0x03bb, 0x03b5, 0x03c0, 0x03c4, 0x03bf, 0};
- const UChar oneSecondShort[] = {0x0031, 0x0020, 0x03b4, 0x03b5, 0x03c5, 0x03c4, 0x002e, 0};
- const UChar oneMinute[] = {0x0031, 0x0020, 0x03bb, 0x03b5, 0x03c0, 0x03c4, 0x03cc, 0};
- const UChar oneMinuteShort[] = {0x0031, 0x0020, 0x03bb, 0x002e, 0};
- const UChar oneHour[] = {0x0031, 0x0020, 0x03ce, 0x03c1, 0x03b1, 0};
- const UChar oneHourShort[] = {0x0031, 0x0020, 0x03ce, 0x002e, 0};
- const UChar oneDay[] = {0x0031, 0x0020, 0x03b7, 0x03bc, 0x03ad, 0x03c1, 0x03b1, 0};
- const UChar oneMonth[] = {0x0031, 0x0020, 0x03bc, 0x03ae, 0x03bd, 0x03b1, 0x03c2, 0};
- const UChar oneMonthShort[] = {0x0031, 0x0020, 0x03bc, 0x03ae, 0x03bd, 0x002e, 0};
- const UChar oneYear[] = {0x0031, 0x0020, 0x03ad, 0x03c4, 0x03bf, 0x03c2, 0};
- const UChar oneYearShort[] = {0x0031, 0x0020, 0x03ad, 0x03c4, 0x002e, 0};
- const UChar sevenSeconds[] = {0x0037, 0x0020, 0x03b4, 0x03b5, 0x03c5, 0x03c4, 0x03b5, 0x03c1, 0x03cc, 0x03bb, 0x03b5, 0x03c0, 0x03c4, 0x03b1, 0};
- const UChar sevenSecondsShort[] = {0x0037, 0x0020, 0x03b4, 0x03b5, 0x03c5, 0x03c4, 0x002e, 0};
- const UChar sevenMinutes[] = {0x0037, 0x0020, 0x03bb, 0x03b5, 0x03c0, 0x03c4, 0x03ac, 0};
- const UChar sevenMinutesShort[] = {0x0037, 0x0020, 0x03bb, 0x002e, 0};
- const UChar sevenHours[] = {0x0037, 0x0020, 0x03ce, 0x03c1, 0x03b5, 0x03c2, 0};
- const UChar sevenHoursShort[] = {0x0037, 0x0020, 0x03ce, 0x002e, 0};
- const UChar sevenDays[] = {0x0037, 0x0020, 0x03b7, 0x03bc, 0x03ad, 0x03c1, 0x03b5, 0x03c2, 0};
- const UChar sevenMonths[] = {0x0037, 0x0020, 0x03bc, 0x03ae, 0x03bd, 0x03b5, 0x3c2, 0};
- const UChar sevenMonthsShort[] = {0x0037, 0x0020, 0x03bc, 0x03ae, 0x03bd, 0x002e, 0};
- const UChar sevenYears[] = {0x0037, 0x0020, 0x03ad, 0x03c4, 0x03b7, 0};
- const UChar sevenYearsShort[] = {0x0037, 0x0020, 0x03ad, 0x03c4, 0x002e, 0};
+ const char16_t oneSecond[] = {0x0031, 0x0020, 0x03b4, 0x03b5, 0x03c5, 0x03c4, 0x03b5, 0x03c1, 0x03cc, 0x03bb, 0x03b5, 0x03c0, 0x03c4, 0x03bf, 0};
+ const char16_t oneSecondShort[] = {0x0031, 0x0020, 0x03b4, 0x03b5, 0x03c5, 0x03c4, 0x002e, 0};
+ const char16_t oneMinute[] = {0x0031, 0x0020, 0x03bb, 0x03b5, 0x03c0, 0x03c4, 0x03cc, 0};
+ const char16_t oneMinuteShort[] = {0x0031, 0x0020, 0x03bb, 0x002e, 0};
+ const char16_t oneHour[] = {0x0031, 0x0020, 0x03ce, 0x03c1, 0x03b1, 0};
+ const char16_t oneHourShort[] = {0x0031, 0x0020, 0x03ce, 0x002e, 0};
+ const char16_t oneDay[] = {0x0031, 0x0020, 0x03b7, 0x03bc, 0x03ad, 0x03c1, 0x03b1, 0};
+ const char16_t oneMonth[] = {0x0031, 0x0020, 0x03bc, 0x03ae, 0x03bd, 0x03b1, 0x03c2, 0};
+ const char16_t oneMonthShort[] = {0x0031, 0x0020, 0x03bc, 0x03ae, 0x03bd, 0x002e, 0};
+ const char16_t oneYear[] = {0x0031, 0x0020, 0x03ad, 0x03c4, 0x03bf, 0x03c2, 0};
+ const char16_t oneYearShort[] = {0x0031, 0x0020, 0x03ad, 0x03c4, 0x002e, 0};
+ const char16_t sevenSeconds[] = {0x0037, 0x0020, 0x03b4, 0x03b5, 0x03c5, 0x03c4, 0x03b5, 0x03c1, 0x03cc, 0x03bb, 0x03b5, 0x03c0, 0x03c4, 0x03b1, 0};
+ const char16_t sevenSecondsShort[] = {0x0037, 0x0020, 0x03b4, 0x03b5, 0x03c5, 0x03c4, 0x002e, 0};
+ const char16_t sevenMinutes[] = {0x0037, 0x0020, 0x03bb, 0x03b5, 0x03c0, 0x03c4, 0x03ac, 0};
+ const char16_t sevenMinutesShort[] = {0x0037, 0x0020, 0x03bb, 0x002e, 0};
+ const char16_t sevenHours[] = {0x0037, 0x0020, 0x03ce, 0x03c1, 0x03b5, 0x03c2, 0};
+ const char16_t sevenHoursShort[] = {0x0037, 0x0020, 0x03ce, 0x002e, 0};
+ const char16_t sevenDays[] = {0x0037, 0x0020, 0x03b7, 0x03bc, 0x03ad, 0x03c1, 0x03b5, 0x03c2, 0};
+ const char16_t sevenMonths[] = {0x0037, 0x0020, 0x03bc, 0x03ae, 0x03bd, 0x03b5, 0x3c2, 0};
+ const char16_t sevenMonthsShort[] = {0x0037, 0x0020, 0x03bc, 0x03ae, 0x03bd, 0x002e, 0};
+ const char16_t sevenYears[] = {0x0037, 0x0020, 0x03ad, 0x03c4, 0x03b7, 0};
+ const char16_t sevenYearsShort[] = {0x0037, 0x0020, 0x03ad, 0x03c4, 0x002e, 0};
const UnicodeString oneSecondStr(oneSecond);
const UnicodeString oneSecondShortStr(oneSecondShort);
"VVVV"
};
-static const UChar ETC_UNKNOWN[] = {0x45, 0x74, 0x63, 0x2F, 0x55, 0x6E, 0x6B, 0x6E, 0x6F, 0x77, 0x6E, 0};
+static const char16_t ETC_UNKNOWN[] = {0x45, 0x74, 0x63, 0x2F, 0x55, 0x6E, 0x6B, 0x6E, 0x6F, 0x77, 0x6E, 0};
-static const UChar ETC_SLASH[] = { 0x45, 0x74, 0x63, 0x2F, 0 }; // "Etc/"
-static const UChar SYSTEMV_SLASH[] = { 0x53, 0x79, 0x73, 0x74, 0x65, 0x6D, 0x56, 0x2F, 0 }; // "SystemV/
-static const UChar RIYADH8[] = { 0x52, 0x69, 0x79, 0x61, 0x64, 0x68, 0x38, 0 }; // "Riyadh8"
+static const char16_t ETC_SLASH[] = { 0x45, 0x74, 0x63, 0x2F, 0 }; // "Etc/"
+static const char16_t SYSTEMV_SLASH[] = { 0x53, 0x79, 0x73, 0x74, 0x65, 0x6D, 0x56, 0x2F, 0 }; // "SystemV/
+static const char16_t RIYADH8[] = { 0x52, 0x69, 0x79, 0x61, 0x64, 0x68, 0x38, 0 }; // "Riyadh8"
static UBool contains(const char** list, const char* str) {
for (int32_t i = 0; list[i]; i++) {
} else if (outtzid != canonical) {
// Canonical ID did not match - check the rules
if (!((BasicTimeZone*)&outtz)->hasEquivalentTransitions((BasicTimeZone&)*tz, low, high, true, status)) {
- if (canonical.indexOf((UChar)0x27 /*'/'*/) == -1) {
+ if (canonical.indexOf((char16_t)0x27 /*'/'*/) == -1) {
// Exceptional cases, such as CET, EET, MET and WET
logln((UnicodeString)"Canonical round trip failed (as expected); tz=" + *tzid
+ ", locale=" + LOCALES[locidx].getName() + ", pattern=" + PATTERNS[patidx]
// Some zones do not have short ID assigned, such as Asia/Riyadh87.
// The time roundtrip will fail for such zones with pattern "V" (short zone ID).
// This is expected behavior.
- const UChar* shortZoneID = ZoneMeta::getShortID(*tzid);
+ const char16_t* shortZoneID = ZoneMeta::getShortID(*tzid);
if (shortZoneID == nullptr) {
continue;
}
// Some zones are not associated with any region, such as Etc/GMT+8.
// The time roundtrip will fail for such zone with pattern "VVV" (exemplar location).
// This is expected behavior.
- if (tzid->indexOf((UChar)0x2F) < 0 || tzid->indexOf(ETC_SLASH, -1, 0) >= 0
+ if (tzid->indexOf((char16_t)0x2F) < 0 || tzid->indexOf(ETC_SLASH, -1, 0) >= 0
|| tzid->indexOf(SYSTEMV_SLASH, -1, 0) >= 0 || tzid->indexOf(RIYADH8, -1, 0) >= 0) {
continue;
}
// Create VTimeZone for Asia/Tokyo
UnicodeString asiaTokyoID("Asia/Tokyo");
- static const UChar asiaTokyo[] = {
+ static const char16_t asiaTokyo[] = {
/* "BEGIN:VTIMEZONE\x0D\x0A" */
0x42,0x45,0x47,0x49,0x4E,0x3A,0x56,0x54,0x49,0x4D,0x45,0x5A,0x4F,0x4E,0x45,0x0D,0x0A,
/* "TZID:Asia\x0D\x0A" */
delete tokyo;
// Create VTimeZone from VTIMEZONE data
- static const UChar fooData[] = {
+ static const char16_t fooData[] = {
/* "BEGIN:VCALENDAR\x0D\x0A" */
0x42,0x45,0x47,0x49,0x4E,0x3A,0x56,0x43,0x41,0x4C,0x45,0x4E,0x44,0x41,0x52,0x0D,0x0A,
/* "BEGIN:VTIMEZONE\x0D\x0A" */
void
TimeZoneRuleTest::TestT6216(void) {
// Test case in #6216
- static const UChar tokyoTZ[] = {
+ static const char16_t tokyoTZ[] = {
/* "BEGIN:VCALENDAR\r\n" */
0x42,0x45,0x47,0x49,0x4e,0x3a,0x56,0x43,0x41,0x4c,0x45,0x4e,0x44,0x41,0x52,0x0d,0x0a,
/* "VERSION:2.0\r\n" */
0
};
// Single final rule, overlapping with another
- static const UChar finalOverlap[] = {
+ static const char16_t finalOverlap[] = {
/* "BEGIN:VCALENDAR\r\n" */
0x42,0x45,0x47,0x49,0x4e,0x3a,0x56,0x43,0x41,0x4c,0x45,0x4e,0x44,0x41,0x52,0x0d,0x0a,
/* "BEGIN:VTIMEZONE\r\n" */
0
};
// Single final rule, no overlapping with another
- static const UChar finalNonOverlap[] = {
+ static const char16_t finalNonOverlap[] = {
/* "BEGIN:VCALENDAR\r\n" */
0x42,0x45,0x47,0x49,0x4e,0x3a,0x56,0x43,0x41,0x4c,0x45,0x4e,0x44,0x41,0x52,0x0d,0x0a,
/* "BEGIN:VTIMEZONE\r\n" */
#if 0
// local variables
UBool b;
- UChar * data = nullptr;
+ char16_t * data = nullptr;
int32_t length = 0;
int32_t i;
UDate result;
UErrorCode status;
const char *name = "Test Initial";
- UChar uname[20];
+ char16_t uname[20];
UClassID cid1;
UClassID cid2;
cid2 = ztrans_getDynamicClassID(zt2);
// test vzone
- v1 = vzone_openID((UChar*)"America/Chicago", sizeof("America/Chicago"));
+ v1 = vzone_openID((char16_t*)"America/Chicago", sizeof("America/Chicago"));
v2 = vzone_clone(v1);
- //v2 = vzone_openData(const UChar* vtzdata, int32_t vtzdataLength, UErrorCode& status);
+ //v2 = vzone_openData(const char16_t* vtzdata, int32_t vtzdataLength, UErrorCode& status);
// test equality
b = vzone_equals(v1, v2);
*/
UnicodeString& TimeZoneTest::formatOffset(int32_t offset, UnicodeString &rv) {
rv.remove();
- UChar sign = 0x002B;
+ char16_t sign = 0x002B;
if (offset < 0) {
sign = 0x002D;
offset = -offset;
int32_t m = offset % 60;
int32_t h = offset / 60;
- rv += (UChar)(sign);
+ rv += (char16_t)(sign);
if (h >= 10) {
- rv += (UChar)(0x0030 + (h/10));
+ rv += (char16_t)(0x0030 + (h/10));
} else {
- rv += (UChar)0x0030;
+ rv += (char16_t)0x0030;
}
- rv += (UChar)(0x0030 + (h%10));
+ rv += (char16_t)(0x0030 + (h%10));
- rv += (UChar)0x003A; /* ':' */
+ rv += (char16_t)0x003A; /* ':' */
if (m >= 10) {
- rv += (UChar)(0x0030 + (m/10));
+ rv += (char16_t)(0x0030 + (m/10));
} else {
- rv += (UChar)0x0030;
+ rv += (char16_t)0x0030;
}
- rv += (UChar)(0x0030 + (m%10));
+ rv += (char16_t)(0x0030 + (m%10));
if (s) {
- rv += (UChar)0x003A; /* ':' */
+ rv += (char16_t)0x003A; /* ':' */
if (s >= 10) {
- rv += (UChar)(0x0030 + (s/10));
+ rv += (char16_t)(0x0030 + (s/10));
} else {
- rv += (UChar)0x0030;
+ rv += (char16_t)0x0030;
}
- rv += (UChar)(0x0030 + (s%10));
+ rv += (char16_t)(0x0030 + (s%10));
}
return rv;
}
*/
UnicodeString& TimeZoneTest::formatTZID(int32_t offset, UnicodeString &rv) {
rv.remove();
- UChar sign = 0x002B;
+ char16_t sign = 0x002B;
if (offset < 0) {
sign = 0x002D;
offset = -offset;
int32_t h = offset / 60;
rv += "GMT";
- rv += (UChar)(sign);
+ rv += (char16_t)(sign);
if (h >= 10) {
- rv += (UChar)(0x0030 + (h/10));
+ rv += (char16_t)(0x0030 + (h/10));
} else {
- rv += (UChar)0x0030;
+ rv += (char16_t)0x0030;
}
- rv += (UChar)(0x0030 + (h%10));
- rv += (UChar)0x003A;
+ rv += (char16_t)(0x0030 + (h%10));
+ rv += (char16_t)0x003A;
if (m >= 10) {
- rv += (UChar)(0x0030 + (m/10));
+ rv += (char16_t)(0x0030 + (m/10));
} else {
- rv += (UChar)0x0030;
+ rv += (char16_t)0x0030;
}
- rv += (UChar)(0x0030 + (m%10));
+ rv += (char16_t)(0x0030 + (m%10));
if (s) {
- rv += (UChar)0x003A;
+ rv += (char16_t)0x003A;
if (s >= 10) {
- rv += (UChar)(0x0030 + (s/10));
+ rv += (char16_t)(0x0030 + (s/10));
} else {
- rv += (UChar)0x0030;
+ rv += (char16_t)0x0030;
}
- rv += (UChar)(0x0030 + (s%10));
+ rv += (char16_t)(0x0030 + (s%10));
}
return rv;
}
static const uint32_t FROM_RULES = 2;
static UBool
-skipLineBecauseOfBug(const UChar *s, int32_t length, uint32_t flags) {
+skipLineBecauseOfBug(const char16_t *s, int32_t length, uint32_t flags) {
// Add temporary exceptions here if there are ICU bugs, until we can fix them.
// For examples see the ICU 52 version of this file.
(void)s;
int32_t line = 0;
- UChar b1[1024], b2[1024];
- UChar *buffer = b1, *oldB = nullptr;
+ char16_t b1[1024], b2[1024];
+ char16_t *buffer = b1, *oldB = nullptr;
char lineB1[1024], lineB2[1024];
char *lineB = lineB1, *oldLineB = lineB2;
UnicodeSet set1, set2;
if (nfcImpl->getCanonStartSet(0x49, set1)) {
/* enumerate all characters that are plausible to be latin letters */
- for(UChar start=0xa0; start<0x2000; ++start) {
+ for(char16_t start=0xa0; start<0x2000; ++start) {
UnicodeString decomp=nfd->normalize(UnicodeString(start), errorCode);
if(decomp.length()>1 && decomp[0]==0x49) {
set2.add(start);
namespace {
-UBool hbp(const UChar *s, int32_t length, UProperty which) {
+UBool hbp(const char16_t *s, int32_t length, UProperty which) {
return u_stringHasBinaryProperty(s, length, which);
}
-UBool hbp(const UChar *s, UProperty which) {
+UBool hbp(const char16_t *s, UProperty which) {
return u_stringHasBinaryProperty(s, -1, which);
}
public:
Generator() : value(4711), num(0) {}
void next() {
- UChar c;
+ char16_t c;
s.truncate(0);
- s.append(c=(UChar)(value>>16));
- s.append((UChar)(value>>4));
+ s.append(c=(char16_t)(value>>16));
+ s.append((char16_t)(value>>4));
if(value&1) {
- s.append((UChar)value);
+ s.append((char16_t)value);
}
set.add(c);
value+=((value>>5)&0x7ff)*3+1;
}
if((result==USTRINGTRIE_INTERMEDIATE_VALUE)!=nextContinues) {
errln("(trie.current()==USTRINGTRIE_INTERMEDIATE_VALUE) contradicts "
- "(trie.next(some UChar)!=USTRINGTRIE_NO_MATCH) after end of %s", data[i].s);
+ "(trie.next(some char16_t)!=USTRINGTRIE_NO_MATCH) after end of %s", data[i].s);
}
trie.reset();
}
// Appendable is abstract; we define a subclass to verify that there is no "poor man's RTTI".
class DummyAppendable : public Appendable {
public:
- virtual UBool appendCodeUnit(UChar /*c*/) override { return true; }
+ virtual UBool appendCodeUnit(char16_t /*c*/) override { return true; }
};
void UObjectTest::testIDs()
TESTCLASSID_FACTORY(MeasureUnit, MeasureUnit::createMeter(status));
TESTCLASSID_FACTORY(TimeUnit, TimeUnit::createInstance(TimeUnit::UTIMEUNIT_YEAR, status));
- static const UChar SMALL_STR[] = u"QQQ";
+ static const char16_t SMALL_STR[] = u"QQQ";
TESTCLASSID_CTOR(CurrencyAmount, (1.0, SMALL_STR, status));
TESTCLASSID_CTOR(CurrencyUnit, (SMALL_STR, status));
#if U_HAVE_DEBUG_LOCATION_NEW
/* Make sure that it compiles with MFC's debuggable new usage. */
UnicodeString *str = new(__FILE__, __LINE__) UnicodeString();
- str->append((UChar)0x0040); // Is it usable?
+ str->append((char16_t)0x0040); // Is it usable?
if(str->charAt(0) != 0x0040) {
errln("debug new doesn't work.");
}
// Throw in a test of complement
set.complement();
UnicodeString exp;
- exp.append((UChar)0x0000).append("aeeoouu").append((UChar)(u'z'+1)).append((UChar)0xFFFF);
+ exp.append((char16_t)0x0000).append("aeeoouu").append((char16_t)(u'z'+1)).append((char16_t)0xFFFF);
expectPairs(set, exp);
}
set.applyPattern("[:L:]", status);
if (U_FAILURE(status)) { errln("FAIL"); return; }
for (i=0; i<0x200; ++i) {
- UBool l = u_isalpha((UChar)i);
+ UBool l = u_isalpha((char16_t)i);
if (l != set.contains(i)) {
errln((UnicodeString)"FAIL: L contains " + (unsigned short)i + " = " +
set.contains(i));
set.applyPattern("[:Lu:]", status);
if (U_FAILURE(status)) { errln("FAIL"); return; }
for (i=0; i<0x200; ++i) {
- UBool lu = (u_charType((UChar)i) == U_UPPERCASE_LETTER);
+ UBool lu = (u_charType((char16_t)i) == U_UPPERCASE_LETTER);
if (lu != set.contains(i)) {
errln((UnicodeString)"FAIL: Lu contains " + (unsigned short)i + " = " +
set.contains(i));
for (int32_t i=0; i<set.getRangeCount(); ++i) {
UnicodeString str("Range ");
- str.append((UChar)(u'0' + i))
+ str.append((char16_t)(u'0' + i))
.append(": ")
.append((UChar32)set.getRangeStart(i))
.append(" - ")
int32_t i = start;
UnicodeString result;
while (i < limit) {
- UChar c = text.charAt(i);
+ char16_t c = text.charAt(i);
if ((i==start && !u_isIDStart(c)) || !u_isIDPart(c)) {
break;
}
end = 0xFFFF;
i = set.getRangeCount(); // Should be unnecessary
}
- pairs.append((UChar)start).append((UChar)end);
+ pairs.append((char16_t)start).append((char16_t)end);
}
return pairs;
}
}
}
-static UChar toHexString(int32_t i) { return (UChar)(i + (i < 10 ? u'0' : (u'A' - 10))); }
+static char16_t toHexString(int32_t i) { return (char16_t)(i + (i < 10 ? u'0' : (u'A' - 10))); }
void
UnicodeSetTest::doAssert(UBool condition, const char *message)
// Append the UTF-8 version of the string to t and return the appended UTF-8 length.
static int32_t
-appendUTF8(const UChar *s, int32_t length, char *t, int32_t capacity) {
+appendUTF8(const char16_t *s, int32_t length, char *t, int32_t capacity) {
UErrorCode errorCode=U_ZERO_ERROR;
int32_t length8=0;
u_strToUTF8(t, capacity, &length8, s, length, &errorCode);
// at code point boundaries.
// That is, each edge of a match must not be in the middle of a surrogate pair.
static inline UBool
-matches16CPB(const UChar *s, int32_t start, int32_t limit, const UnicodeString &t) {
+matches16CPB(const char16_t *s, int32_t start, int32_t limit, const UnicodeString &t) {
s+=start;
limit-=start;
int32_t length=t.length();
}
// Implement span() with contains() for comparison.
-static int32_t containsSpanUTF16(const UnicodeSetWithStrings &set, const UChar *s, int32_t length,
+static int32_t containsSpanUTF16(const UnicodeSetWithStrings &set, const char16_t *s, int32_t length,
USetSpanCondition spanCondition) {
const UnicodeSet &realSet(set.getSet());
if(!set.hasStrings()) {
}
}
-static int32_t containsSpanBackUTF16(const UnicodeSetWithStrings &set, const UChar *s, int32_t length,
+static int32_t containsSpanBackUTF16(const UnicodeSetWithStrings &set, const char16_t *s, int32_t length,
USetSpanCondition spanCondition) {
if(length==0) {
return 0;
}
static inline int32_t slen(const void *s, UBool isUTF16) {
- return isUTF16 ? u_strlen((const UChar *)s) : static_cast<int32_t>(strlen((const char *)s));
+ return isUTF16 ? u_strlen((const char16_t *)s) : static_cast<int32_t>(strlen((const char *)s));
}
/*
length=slen(s, isUTF16);
}
for(;;) {
- start+= isUTF16 ? containsSpanUTF16(set, (const UChar *)s+start, length-start, spanCondition) :
+ start+= isUTF16 ? containsSpanUTF16(set, (const char16_t *)s+start, length-start, spanCondition) :
containsSpanUTF8(set, (const char *)s+start, length-start, spanCondition);
if(count<limitsCapacity) {
limits[count]=start;
case 3:
start=0;
for(;;) {
- start+= isUTF16 ? realSet.span((const UChar *)s+start, length>=0 ? length-start : length, spanCondition) :
+ start+= isUTF16 ? realSet.span((const char16_t *)s+start, length>=0 ? length-start : length, spanCondition) :
realSet.spanUTF8((const char *)s+start, length>=0 ? length-start : length, spanCondition);
if(count<limitsCapacity) {
limits[count]=start;
}
++count;
if(length>=0 ? start>=length :
- isUTF16 ? ((const UChar *)s)[start]==0 :
+ isUTF16 ? ((const char16_t *)s)[start]==0 :
((const char *)s)[start]==0
) {
break;
if(count<=limitsCapacity) {
limits[limitsCapacity-count]=length;
}
- length= isUTF16 ? containsSpanBackUTF16(set, (const UChar *)s, length, spanCondition) :
+ length= isUTF16 ? containsSpanBackUTF16(set, (const char16_t *)s, length, spanCondition) :
containsSpanBackUTF8(set, (const char *)s, length, spanCondition);
if(length==0 && spanCondition==firstSpanCondition) {
break;
// Note: Length<0 is tested only for the first spanBack().
// If we wanted to keep length<0 for all spanBack()s, we would have to
// temporarily modify the string by placing a NUL where the previous spanBack() stopped.
- length= isUTF16 ? realSet.spanBack((const UChar *)s, length, spanCondition) :
+ length= isUTF16 ? realSet.spanBack((const char16_t *)s, length, spanCondition) :
realSet.spanBackUTF8((const char *)s, length, spanCondition);
if(length==0 && spanCondition==firstSpanCondition) {
break;
// Compare span() with containsAll()/containsNone(),
// but only if we have expectLimits[] from the uncomplemented set.
if(isUTF16 && (whichSpans&SPAN_SET)!=0) {
- const UChar *s16=(const UChar *)s;
+ const char16_t *s16=(const char16_t *)s;
UnicodeString string;
int32_t prev=0, limit, length;
for(i=0; i<expectCount; ++i) {
testSpan(sets, s, length, isUTF16, whichSpans, expectLimits, expectCount, testName, index);
}
-UBool stringContainsUnpairedSurrogate(const UChar *s, int32_t length) {
- UChar c, c2;
+UBool stringContainsUnpairedSurrogate(const char16_t *s, int32_t length) {
+ char16_t c, c2;
if(length>=0) {
while(length>0) {
// Testing UTF-16 and UTF-8 together requires that surrogate code points
// have the same contains(c) value as U+FFFD.
void UnicodeSetTest::testSpanBothUTFs(const UnicodeSetWithStrings *sets[4],
- const UChar *s16, int32_t length16,
+ const char16_t *s16, int32_t length16,
uint32_t whichSpans,
const char *testName, int32_t index) {
int32_t expectLimits[500];
uint8_t s8[3000];
int32_t offsets[3000];
- const UChar *s16Limit=s16+length16;
+ const char16_t *s16Limit=s16+length16;
char *t=(char *)s8;
char *tLimit=t+sizeof(s8);
int32_t *o=offsets;
sets[0]->getSet().containsNone(0xd800, 0xdfff)) ||
sets[0]->hasStringsWithSurrogates());
- UChar s[1000];
+ char16_t s[1000];
int32_t length=0;
uint32_t localWhichSpans;
// Test with a particular, interesting string.
// Specify length and try NUL-termination.
void UnicodeSetTest::testSpanUTF16String(const UnicodeSetWithStrings *sets[4], uint32_t whichSpans, const char *testName) {
- static const UChar s[]={
+ static const char16_t s[]={
0x61, 0x62, 0x20, // Latin, space
0x3b1, 0x3b2, 0x3b3, // Greek
0xd900, // lead surrogate
}
string16=u"byayaxya";
- const UChar *s16=string16.getBuffer();
+ const char16_t *s16=string16.getBuffer();
int32_t length16=string16.length();
(void)length16; // Suppress set but not used warning.
if( set.span(s16, 8, USET_SPAN_NOT_CONTAINED)!=4 ||
uint32_t whichSpans,
const char *testName, int32_t index);
void testSpanBothUTFs(const UnicodeSetWithStrings *sets[4],
- const UChar *s16, int32_t length16,
+ const char16_t *s16, int32_t length16,
uint32_t whichSpans,
const char *testName, int32_t index);
void testSpanContents(const UnicodeSetWithStrings *sets[4], uint32_t whichSpans, const char *testName);
if (test1 != expectedValue)
errln("replace() failed: expected \"" + expectedValue + "\"\n,got \"" + test1 + "\"");
- UChar temp[80];
+ char16_t temp[80];
test1.extract(0, 15, temp);
UnicodeString test2(temp, 15);
errln("UnicodeString(codepageData, dataLength, codepage) does not work with dataLength==-1");
}
- UChar buffer[10]={ 0x61, 0x62, 0x20ac, 0xd900, 0xdc05, 0, 0x62, 0xffff, 0xdbff, 0xdfff };
+ char16_t buffer[10]={ 0x61, 0x62, 0x20ac, 0xd900, 0xdc05, 0, 0x62, 0xffff, 0xdbff, 0xdfff };
UnicodeString s, t(buffer, -1, UPRV_LENGTHOF(buffer));
if(s.setTo(buffer, -1, UPRV_LENGTHOF(buffer)).length()!=u_strlen(buffer)) {
}
if(0!=s.caseCompare(buffer, -1, U_FOLD_CASE_DEFAULT)) {
- errln("UnicodeString.caseCompare(const UChar *, length, options) does not work with length==-1");
+ errln("UnicodeString.caseCompare(const char16_t *, length, options) does not work with length==-1");
}
if(0!=s.caseCompare(0, s.length(), buffer, U_FOLD_CASE_DEFAULT)) {
- errln("UnicodeString.caseCompare(start, _length, const UChar *, options) does not work");
+ errln("UnicodeString.caseCompare(start, _length, const char16_t *, options) does not work");
}
buffer[u_strlen(buffer)]=0xe4;
{
// Test the hardcoded-UTF-8 UnicodeString optimizations.
static const uint8_t utf8[]={ 0x61, 0xC3, 0xA4, 0xC3, 0x9F, 0xE4, 0xB8, 0x80, 0 };
- static const UChar utf16[]={ 0x61, 0xE4, 0xDF, 0x4E00 };
+ static const char16_t utf16[]={ 0x61, 0xE4, 0xDF, 0x4E00 };
UnicodeString from8a = UnicodeString((const char *)utf8);
UnicodeString from8b = UnicodeString((const char *)utf8, (int32_t)sizeof(utf8)-1);
UnicodeString from16(false, utf16, UPRV_LENGTHOF(utf16));
UnicodeString test3("this is a test of the emergency broadcast system");
UnicodeString test4("never say, \"this is a test\"!!");
- UnicodeString test5((UChar)0x5000);
- UnicodeString test6((UChar)0x5100);
+ UnicodeString test5((char16_t)0x5000);
+ UnicodeString test6((char16_t)0x5100);
- UChar uniChars[] = { 0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73,
+ char16_t uniChars[] = { 0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73,
0x20, 0x61, 0x20, 0x74, 0x65, 0x73, 0x74, 0 };
char chars[] = "this is a test";
test3.compare(0, 18, test1) <=0 )
errln("compare(offset, length, UnicodeString) fails");
- // test compare(UChar*)
+ // test compare(char16_t*)
if (test2.compare(uniChars) != 0 || test3.compare(uniChars) <= 0 || test4.compare(uniChars) >= 0)
- errln("compare(UChar*) failed");
+ errln("compare(char16_t*) failed");
// test compare(char*)
if (test2.compare(chars) != 0 || test3.compare(chars) <= 0 || test4.compare(chars) >= 0)
errln("compare(char*) failed");
- // test compare(UChar*, length)
+ // test compare(char16_t*, length)
if (test1.compare(uniChars, 4) <= 0 || test1.compare(uniChars, 4) <= 0)
- errln("compare(UChar*, length) failed");
+ errln("compare(char16_t*, length) failed");
// test compare(thisOffset, thisLength, that, thatOffset, thatLength)
if (test1.compare(0, 14, test2, 0, 14) != 0
/* test compareCodePointOrder() */
{
/* these strings are in ascending order */
- static const UChar strings[][4]={
+ static const char16_t strings[][4]={
{ 0x61, 0 }, /* U+0061 */
{ 0x20ac, 0xd801, 0 }, /* U+20ac U+d801 */
{ 0x20ac, 0xd800, 0xdc00, 0 }, /* U+20ac U+10000 */
/* test caseCompare() */
{
- static const UChar
+ static const char16_t
_mixed[]= { 0x61, 0x42, 0x131, 0x3a3, 0xdf, 0x130, 0x49, 0xfb03, 0xd93f, 0xdfff, 0 },
_otherDefault[]= { 0x41, 0x62, 0x131, 0x3c3, 0x73, 0x53, 0x69, 0x307, 0x69, 0x46, 0x66, 0x49, 0xd93f, 0xdfff, 0 },
_otherExcludeSpecialI[]={ 0x41, 0x62, 0x131, 0x3c3, 0x53, 0x73, 0x69, 0x131, 0x66, 0x46, 0x69, 0xd93f, 0xdfff, 0 },
}
// test that srcLength=-1 is handled in functions that
- // take input const UChar */int32_t srcLength (j785)
+ // take input const char16_t */int32_t srcLength (j785)
{
- static const UChar u[]={ 0x61, 0x308, 0x62, 0 };
+ static const char16_t u[]={ 0x61, 0x308, 0x62, 0 };
UnicodeString s=UNICODE_STRING("a\\u0308b", 8).unescape();
if(s.compare(u, -1)!=0 || s.compare(0, 999, u, 0, -1)!=0) {
- errln("error UnicodeString::compare(..., const UChar *, srcLength=-1) does not work");
+ errln("error UnicodeString::compare(..., const char16_t *, srcLength=-1) does not work");
}
if(s.compareCodePointOrder(u, -1)!=0 || s.compareCodePointOrder(0, 999, u, 0, -1)!=0) {
- errln("error UnicodeString::compareCodePointOrder(..., const UChar *, srcLength=-1, ...) does not work");
+ errln("error UnicodeString::compareCodePointOrder(..., const char16_t *, srcLength=-1, ...) does not work");
}
if(s.caseCompare(u, -1, U_FOLD_CASE_DEFAULT)!=0 || s.caseCompare(0, 999, u, 0, -1, U_FOLD_CASE_DEFAULT)!=0) {
- errln("error UnicodeString::caseCompare(..., const UChar *, srcLength=-1, ...) does not work");
+ errln("error UnicodeString::caseCompare(..., const char16_t *, srcLength=-1, ...) does not work");
}
if(s.indexOf(u, 1, -1, 0, 999)!=1 || s.indexOf(u+1, -1, 0, 999)!=1 || s.indexOf(u+1, -1, 0)!=1) {
- errln("error UnicodeString::indexOf(const UChar *, srcLength=-1, ...) does not work");
+ errln("error UnicodeString::indexOf(const char16_t *, srcLength=-1, ...) does not work");
}
if(s.lastIndexOf(u, 1, -1, 0, 999)!=1 || s.lastIndexOf(u+1, -1, 0, 999)!=1 || s.lastIndexOf(u+1, -1, 0)!=1) {
- errln("error UnicodeString::lastIndexOf(const UChar *, srcLength=-1, ...) does not work");
+ errln("error UnicodeString::lastIndexOf(const char16_t *, srcLength=-1, ...) does not work");
}
UnicodeString s2, s3;
s2.replace(0, 0, u+1, -1);
s3.replace(0, 0, u, 1, -1);
if(s.compare(1, 999, s2)!=0 || s2!=s3) {
- errln("error UnicodeString::replace(..., const UChar *, srcLength=-1, ...) does not work");
+ errln("error UnicodeString::replace(..., const char16_t *, srcLength=-1, ...) does not work");
}
}
}
{
UnicodeString test1("Now is the time for all good men to come to the aid of their country.", "");
UnicodeString test2;
- UChar test3[13] = {1, 2, 3, 4, 5, 6, 7, 8, 8, 10, 11, 12, 13};
+ char16_t test3[13] = {1, 2, 3, 4, 5, 6, 7, 8, 8, 10, 11, 12, 13};
char test4[13] = {1, 2, 3, 4, 5, 6, 7, 8, 8, 10, 11, 12, 13};
UnicodeString test5;
char test6[13] = {1, 2, 3, 4, 5, 6, 7, 8, 8, 10, 11, 12, 13};
break;
}
if (test1.charAt((int32_t)(11 + i)) != test3[i]) {
- errln(UnicodeString("extracting into an array of UChar failed at position ") + i);
+ errln(UnicodeString("extracting into an array of char16_t failed at position ") + i);
break;
}
if (((char)test1.charAt((int32_t)(11 + i))) != test4b.charAt(i)) {
{
// test new, NUL-terminating extract() function
UnicodeString s("terminate", "");
- UChar dest[20]={
+ char16_t dest[20]={
0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5,
0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5
};
int32_t length;
errorCode=U_ZERO_ERROR;
- length=s.extract((UChar *)nullptr, 0, errorCode);
+ length=s.extract((char16_t *)nullptr, 0, errorCode);
if(errorCode!=U_BUFFER_OVERFLOW_ERROR || length!=s.length()) {
errln("UnicodeString.extract(nullptr, 0)==%d (%s) expected %d (U_BUFFER_OVERFLOW_ERROR)", length, s.length(), u_errorName(errorCode));
}
{
UnicodeString test1("The rain in Spain stays mainly on the plain");
UnicodeString test2("eat SPAMburgers!");
- UChar test3[] = { 0x53, 0x50, 0x41, 0x4d, 0x4d, 0 };
+ char16_t test3[] = { 0x53, 0x50, 0x41, 0x4d, 0x4d, 0 };
char test4[] = "SPAM";
UnicodeString& test5 = test1;
{
UnicodeString test1("test test ttest tetest testesteststt");
UnicodeString test2("test");
- UChar testChar = 0x74;
+ char16_t testChar = 0x74;
UChar32 testChar32 = 0x20402;
- UChar testData[]={
+ char16_t testData[]={
// 0 1 2 3 4 5 6 7
0xd841, 0xdc02, 0x0071, 0xdc02, 0xd841, 0x0071, 0xd841, 0xdc02,
if(test3.indexOf((UChar32)0xd841) != 4 || test3.indexOf((UChar32)0xdc02) != 3) {
errln("error: UnicodeString::indexOf(UChar32 surrogate) finds a partial supplementary code point");
}
- if( UnicodeString(test3, 0, 17).lastIndexOf((UChar)0xd841, 0) != 4 ||
+ if( UnicodeString(test3, 0, 17).lastIndexOf((char16_t)0xd841, 0) != 4 ||
UnicodeString(test3, 0, 17).lastIndexOf((UChar32)0xd841, 2) != 4 ||
test3.lastIndexOf((UChar32)0xd841, 0, 17) != 4 || test3.lastIndexOf((UChar32)0xdc02, 0, 17) != 16
) {
void
UnicodeStringTest::TestStartsWithAndEndsWithNulTerminated() {
UnicodeString test("abcde");
- const UChar ab[] = { 0x61, 0x62, 0 };
- const UChar de[] = { 0x64, 0x65, 0 };
+ const char16_t ab[] = { 0x61, 0x62, 0 };
+ const char16_t de[] = { 0x64, 0x65, 0 };
assertTrue("abcde.startsWith(ab, -1)", test.startsWith(ab, -1));
assertTrue("abcde.startsWith(ab, 0, -1)", test.startsWith(ab, 0, -1));
assertTrue("abcde.endsWith(de, -1)", test.endsWith(de, -1));
// test getBuffer(minCapacity) and releaseBuffer()
test1=UnicodeString(); // make sure that it starts with its stackBuffer
- UChar *p=test1.getBuffer(20);
+ char16_t *p=test1.getBuffer(20);
if(test1.getCapacity()<20) {
errln("UnicodeString::getBuffer(20).getCapacity()<20");
}
- test1.append((UChar)7); // must not be able to modify the string here
+ test1.append((char16_t)7); // must not be able to modify the string here
test1.setCharAt(3, 7);
test1.reverse();
if( test1.length()!=0 ||
p[1]=2;
p[2]=3;
test1.releaseBuffer(3);
- test1.append((UChar)4);
+ test1.append((char16_t)4);
if(test1.length()!=4 || test1.charAt(0)!=1 || test1.charAt(1)!=2 || test1.charAt(2)!=3 || test1.charAt(3)!=4) {
errln("UnicodeString::releaseBuffer(newLength) does not properly reallow access to the UnicodeString");
}
// test getBuffer(const)
- const UChar *q=test1.getBuffer(), *r=test1.getBuffer();
+ const char16_t *q=test1.getBuffer(), *r=test1.getBuffer();
if( test1.length()!=4 ||
q[0]!=1 || q[1]!=2 || q[2]!=3 || q[3]!=4 ||
r[0]!=1 || r[1]!=2 || r[2]!=3 || r[3]!=4
// test releaseBuffer() with a non-NUL-terminated buffer
p=test1.getBuffer(256);
for(int32_t i=0; i<test1.getCapacity(); ++i) {
- p[i]=(UChar)1; // fill the buffer with all non-NUL code units
+ p[i]=(char16_t)1; // fill the buffer with all non-NUL code units
}
test1.releaseBuffer(); // implicit -1
if(test1.length()!=test1.getCapacity() || test1.charAt(1)!=1 || test1.charAt(100)!=1 || test1.charAt(test1.getCapacity()-1)!=1) {
errln("getTerminatedBuffer()[length]!=0");
}
- const UChar u[]={ 5, 6, 7, 8, 0 };
+ const char16_t u[]={ 5, 6, 7, 8, 0 };
test1.setTo(false, u, 3);
q=test1.getTerminatedBuffer();
if(q==u || q[0]!=5 || q[1]!=6 || q[2]!=7 || q[3]!=0) {
// as u" lila", offset by 3 code units
test1=UnicodeString(true, u"la", 2);
test1.append(UnicodeString(true, u" lila", 5).getTerminatedBuffer(), 0, -1);
- assertEquals("UnicodeString::append(const UChar *, start, length) failed",
+ assertEquals("UnicodeString::append(const char16_t *, start, length) failed",
u"la lila", test1);
test1.insert(3, UnicodeString(true, u"dudum ", 6), 0, INT32_MAX);
assertEquals("UnicodeString::insert(start, const UniStr &, start, length) failed",
u"la dudum lila", test1);
- static const UChar ucs[]={ 0x68, 0x6d, 0x20, 0 };
+ static const char16_t ucs[]={ 0x68, 0x6d, 0x20, 0 };
test1.insert(9, ucs, -1);
- assertEquals("UnicodeString::insert(start, const UChar *, length) failed",
+ assertEquals("UnicodeString::insert(start, const char16_t *, length) failed",
u"la dudum hm lila", test1);
- test1.replace(9, 2, (UChar)0x2b);
- assertEquals("UnicodeString::replace(start, length, UChar) failed",
+ test1.replace(9, 2, (char16_t)0x2b);
+ assertEquals("UnicodeString::replace(start, length, char16_t) failed",
u"la dudum + lila", test1);
if(test1.hasMetaData() || UnicodeString().hasMetaData()) {
void
UnicodeStringTest::TestStackAllocation()
{
- UChar testString[] ={
+ char16_t testString[] ={
0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x63, 0x72, 0x61, 0x7a, 0x79, 0x20, 0x74, 0x65, 0x73, 0x74, 0x2e, 0 };
- UChar guardWord = 0x4DED;
+ char16_t guardWord = 0x4DED;
UnicodeString* test = 0;
test = new UnicodeString(testString);
// explicitly, since we can't overload operator delete
delete test;
- UChar workingBuffer[] = {
+ char16_t workingBuffer[] = {
0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20,
0x66, 0x6f, 0x72, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x6d, 0x65, 0x6e, 0x20, 0x74, 0x6f, 0x20,
0x63, 0x6f, 0x6d, 0x65, 0xffff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- UChar guardWord2 = 0x4DED;
+ char16_t guardWord2 = 0x4DED;
test = new UnicodeString(workingBuffer, 35, 100);
if (*test != "Now is the time for all men to come")
delete test;
test=new UnicodeString();
- UChar buffer[]={0x0061, 0x0062, 0x20ac, 0x0043, 0x0042, 0x0000};
+ char16_t buffer[]={0x0061, 0x0062, 0x20ac, 0x0043, 0x0042, 0x0000};
test->setTo(buffer, 4, 10);
if(test->length() !=4 || test->charAt(0) != 0x0061 || test->charAt(1) != 0x0062 ||
test->charAt(2) != 0x20ac || test->charAt(3) != 0x0043){
- errln((UnicodeString)"UnicodeString.setTo(UChar*, length, capacity) does not work correctly\n" + prettify(*test));
+ errln((UnicodeString)"UnicodeString.setTo(char16_t*, length, capacity) does not work correctly\n" + prettify(*test));
}
delete test;
void UnicodeStringTest::TestUnescape(void) {
UnicodeString IN("abc\\u4567 \\n\\r \\U00101234xyz\\x1\\x{5289}\\x1b", -1, US_INV);
UnicodeString OUT("abc");
- OUT.append((UChar)0x4567);
+ OUT.append((char16_t)0x4567);
OUT.append(" ");
- OUT.append((UChar)0xA);
- OUT.append((UChar)0xD);
+ OUT.append((char16_t)0xA);
+ OUT.append((char16_t)0xD);
OUT.append(" ");
OUT.append((UChar32)0x00101234);
OUT.append("xyz");
- OUT.append((UChar32)1).append((UChar32)0x5289).append((UChar)0x1b);
+ OUT.append((UChar32)1).append((UChar32)0x5289).append((char16_t)0x1b);
UnicodeString result = IN.unescape();
if (result != OUT) {
errln("FAIL: " + prettify(IN) + ".unescape() -> " +
}
// NUL-terminate the string buffer and test u_countChar32(length=-1)
- const UChar *buffer=s.getTerminatedBuffer();
+ const char16_t *buffer=s.getTerminatedBuffer();
if(
u_countChar32(buffer, -1)!=4 ||
u_countChar32(buffer+1, -1)!=4 ||
}
/* test data and variables for hasMoreChar32Than() */
- static const UChar str[]={
+ static const char16_t str[]={
0x61, 0x62, 0xd800, 0xdc00,
0xd801, 0xdc01, 0x63, 0xd802,
0x64, 0xdc03, 0x65, 0x66,
// verify that non-assignment modifications fail and do not revive a bogus string
test3.setToBogus();
- test3.append((UChar)0x61);
+ test3.append((char16_t)0x61);
if(!test3.isBogus() || test3.getBuffer()!=0) {
errln("bogus.append('a') worked but must not");
}
test3.setToBogus();
- test3.findAndReplace(UnicodeString((UChar)0x61), test2);
+ test3.findAndReplace(UnicodeString((char16_t)0x61), test2);
if(!test3.isBogus() || test3.getBuffer()!=0) {
errln("bogus.findAndReplace() worked but must not");
}
test3.setToBogus();
if(!test3.isBogus() || test3.setTo(test1.getBuffer(), test1.length()).isBogus() || test3!=test1) {
- errln("bogus.setTo(const UChar *, len) failed");
+ errln("bogus.setTo(const char16_t *, len) failed");
}
test3.setToBogus();
- if(!test3.isBogus() || test3.setTo((UChar)0x2028).isBogus() || test3!=UnicodeString((UChar)0x2028)) {
- errln("bogus.setTo(UChar) failed");
+ if(!test3.isBogus() || test3.setTo((char16_t)0x2028).isBogus() || test3!=UnicodeString((char16_t)0x2028)) {
+ errln("bogus.setTo(char16_t) failed");
}
test3.setToBogus();
// writable alias to another string's buffer: very bad idea, just convenient for this test
test3.setToBogus();
if(!test3.isBogus() ||
- test3.setTo(const_cast<UChar *>(test1.getBuffer()),
+ test3.setTo(const_cast<char16_t *>(test1.getBuffer()),
test1.length(), test1.getCapacity()).isBogus() ||
test3!=test1) {
errln("bogus.setTo(writable alias) failed");
errln("bogus.setTo((UChar32)-1) failed");
}
- static const UChar nul=0;
+ static const char16_t nul=0;
test3.setToBogus();
if(!test3.isBogus() || test3.setTo(&nul, 0).isBogus() || !test3.isEmpty()) {
UErrorCode errorCode=U_ZERO_ERROR;
UnicodeString
- test4((const UChar *)nullptr),
- test5(true, (const UChar *)nullptr, 1),
- test6((UChar *)nullptr, 5, 5),
+ test4((const char16_t *)nullptr),
+ test5(true, (const char16_t *)nullptr, 1),
+ test6((char16_t *)nullptr, 5, 5),
test7((const char *)nullptr, 3, nullptr, errorCode);
if(test4.isBogus() || test5.isBogus() || test6.isBogus() || test7.isBogus()) {
errln("a constructor set to bogus for a nullptr input string, should be empty");
}
test4.setTo(nullptr, 3);
- test5.setTo(true, (const UChar *)nullptr, 1);
- test6.setTo((UChar *)nullptr, 5, 5);
+ test5.setTo(true, (const char16_t *)nullptr, 1);
+ test6.setTo((char16_t *)nullptr, 5, 5);
if(test4.isBogus() || test5.isBogus() || test6.isBogus()) {
errln("a setTo() set to bogus for a nullptr input string, should be empty");
}
int32_t i, length;
UErrorCode status;
- const UChar *pu;
+ const char16_t *pu;
const char *pc;
// test the next() default implementation and ensureCharsCapacity()
public:
enum EInvariant { kInvariant };
UnicodeString() : i(1) {}
- UnicodeString(UBool /*isTerminated*/, const UChar * /*text*/, int32_t textLength) : i(textLength) {(void)i;}
+ UnicodeString(UBool /*isTerminated*/, const char16_t * /*text*/, int32_t textLength) : i(textLength) {(void)i;}
UnicodeString(const char * /*src*/, int32_t length, enum EInvariant /*inv*/
) : i(length) {}
private:
0x41, 0xd900, 0x61, 0xdc00, -1, 0x110000, 0x5a, 0x50000, 0x7a,
0x10000, 0x20000, 0xe0000, 0x10ffff
};
- static const UChar expected_utf16[] = {
+ static const char16_t expected_utf16[] = {
0x41, 0xfffd, 0x61, 0xfffd, 0xfffd, 0xfffd, 0x5a, 0xd900, 0xdc00, 0x7a,
0xd800, 0xdc00, 0xd840, 0xdc00, 0xdb40, 0xdc00, 0xdbff, 0xdfff
};
errln("UnicodeString::fromUTF32() did not create the expected string.");
}
- static const UChar utf16[] = {
+ static const char16_t utf16[] = {
0x41, 0xd900, 0x61, 0xdc00, 0x5a, 0xd900, 0xdc00, 0x7a, 0xd800, 0xdc00, 0xdbff, 0xdfff
};
static const UChar32 expected_utf32[] = {
0xf0, 0x90, 0x80, 0x80, 0xf0, 0xa0, 0x80, 0x80,
0xf3, 0xa0, 0x80, 0x80, 0xf4, 0x8f, 0xbf, 0xbf
};
- static const UChar expected_utf16[] = {
+ static const char16_t expected_utf16[] = {
0x41, 0xfffd, 0xfffd, 0xfffd,
0x61, 0xfffd, 0xfffd, 0xfffd,
0xfffd, 0xfffd, 0xfffd, 0xfffd,0x5a,
errln("UnicodeString::fromUTF8(std::string) did not create the expected string.");
}
- static const UChar utf16[] = {
+ static const char16_t utf16[] = {
0x41, 0xd900, 0x61, 0xdc00, 0x5a, 0xd900, 0xdc00, 0x7a, 0xd800, 0xdc00, 0xdbff, 0xdfff
};
static const uint8_t expected_utf8[] = {
}
// Test if this compiler supports Return Value Optimization of unnamed temporary objects.
-static UnicodeString wrapUChars(const UChar *uchars) {
+static UnicodeString wrapUChars(const char16_t *uchars) {
return UnicodeString(true, uchars, -1);
}
void
UnicodeStringTest::TestReadOnlyAlias() {
- UChar uchars[]={ 0x61, 0x62, 0 };
+ char16_t uchars[]={ 0x61, 0x62, 0 };
UnicodeString alias(true, uchars, 2);
if(alias.length()!=2 || alias.getBuffer()!=uchars || alias.getTerminatedBuffer()!=uchars) {
errln("UnicodeString read-only-aliasing constructor does not behave as expected.");
errln("UnicodeString.setTo(read-only-alias).retainBetween(6, 30) did not preserve aliasing as expected.");
}
- UChar abc[]={ 0x61, 0x62, 0x63, 0 };
+ char16_t abc[]={ 0x61, 0x62, 0x63, 0 };
UBool hasRVO= wrapUChars(abc).getBuffer()==abc;
UnicodeString temp;
void
UnicodeStringTest::doTestAppendable(UnicodeString &dest, Appendable &app) {
- static const UChar cde[3]={ 0x63, 0x64, 0x65 };
- static const UChar fg[3]={ 0x66, 0x67, 0 };
+ static const char16_t cde[3]={ 0x63, 0x64, 0x65 };
+ static const char16_t fg[3]={ 0x66, 0x67, 0 };
if(!app.reserveAppendCapacity(12)) {
errln("Appendable.reserve(12) failed");
}
app.appendCodePoint(0x50000);
app.appendString(cde, 3);
app.appendString(fg, -1);
- UChar scratch[3];
+ char16_t scratch[3];
int32_t capacity=-1;
- UChar *buffer=app.getAppendBuffer(3, 3, scratch, 3, &capacity);
+ char16_t *buffer=app.getAppendBuffer(3, 3, scratch, 3, &capacity);
if(capacity<3) {
errln("Appendable.getAppendBuffer(min=3) returned capacity=%d<3", (int)capacity);
return;
}
- static const UChar hij[3]={ 0x68, 0x69, 0x6a };
+ static const char16_t hij[3]={ 0x68, 0x69, 0x6a };
u_memcpy(buffer, hij, 3);
app.appendString(buffer, 3);
if(dest!=UNICODE_STRING_SIMPLE("ab\\U00050000cdefghij").unescape()) {
class SimpleAppendable : public Appendable {
public:
explicit SimpleAppendable(UnicodeString &dest) : str(dest) {}
- virtual UBool appendCodeUnit(UChar c) override { str.append(c); return true; }
+ virtual UBool appendCodeUnit(char16_t c) override { str.append(c); return true; }
SimpleAppendable &reset() { str.remove(); return *this; }
private:
UnicodeString &str;
// is available for internal storage of UChars.
int32_t expectedStackBufferLength=((int32_t)UNISTR_OBJECT_SIZE-sizeof(void *)-2)/U_SIZEOF_UCHAR;
UnicodeString s;
- const UChar *emptyBuffer=s.getBuffer();
+ const char16_t *emptyBuffer=s.getBuffer();
for(int32_t i=0; i<expectedStackBufferLength; ++i) {
- s.append((UChar)0x2e);
+ s.append((char16_t)0x2e);
}
- const UChar *fullBuffer=s.getBuffer();
+ const char16_t *fullBuffer=s.getBuffer();
if(fullBuffer!=emptyBuffer) {
errln("unexpected reallocation when filling with assumed stack buffer size of %d",
expectedStackBufferLength);
}
- const UChar *terminatedBuffer=s.getTerminatedBuffer();
+ const char16_t *terminatedBuffer=s.getTerminatedBuffer();
if(terminatedBuffer==emptyBuffer) {
errln("unexpected keeping stack buffer when overfilling assumed stack buffer size of %d",
expectedStackBufferLength);
void
UnicodeStringTest::TestMoveSwap() {
- static const UChar abc[3] = { 0x61, 0x62, 0x63 }; // "abc"
+ static const char16_t abc[3] = { 0x61, 0x62, 0x63 }; // "abc"
UnicodeString s1(false, abc, UPRV_LENGTHOF(abc)); // read-only alias
UnicodeString s2(100, 0x7a, 100); // 100 * 'z' should be on the heap
UnicodeString s3("defg", 4, US_INV); // in stack buffer
- const UChar *p = s2.getBuffer();
+ const char16_t *p = s2.getBuffer();
s1.swap(s2);
if(s1.getBuffer() != p || s1.length() != 100 || s2.getBuffer() != abc || s2.length() != 3) {
errln("UnicodeString.swap() did not swap");
UIDNA_ERROR_INVALID_ACE_LABEL;
static UBool isASCII(const UnicodeString &str) {
- const UChar *s=str.getBuffer();
+ const char16_t *s=str.getBuffer();
int32_t length=str.length();
for(int32_t i=0; i<length; ++i) {
if(s[i]>=0x80) {
) {
continue;
}
- if(aN.indexOf((UChar)0x2e)<0) {
+ if(aN.indexOf((char16_t)0x2e)<0) {
if(aN!=aNL || aNInfo.getErrors()!=aNLInfo.getErrors()) {
prettify(aN).extract(0, 0x7fffffff, buffer, UPRV_LENGTHOF(buffer));
prettify(aNL).extract(0, 0x7fffffff, buffer2, UPRV_LENGTHOF(buffer2));
continue;
}
}
- if(aT.indexOf((UChar)0x2e)<0) {
+ if(aT.indexOf((char16_t)0x2e)<0) {
if(aT!=aTL || aTInfo.getErrors()!=aTLInfo.getErrors()) {
prettify(aT).extract(0, 0x7fffffff, buffer, UPRV_LENGTHOF(buffer));
prettify(aTL).extract(0, 0x7fffffff, buffer2, UPRV_LENGTHOF(buffer2));
continue;
}
}
- if(uN.indexOf((UChar)0x2e)<0) {
+ if(uN.indexOf((char16_t)0x2e)<0) {
if(uN!=uNL || uNInfo.getErrors()!=uNLInfo.getErrors()) {
prettify(uN).extract(0, 0x7fffffff, buffer, UPRV_LENGTHOF(buffer));
prettify(uNL).extract(0, 0x7fffffff, buffer2, UPRV_LENGTHOF(buffer2));
continue;
}
}
- if(uT.indexOf((UChar)0x2e)<0) {
+ if(uT.indexOf((char16_t)0x2e)<0) {
if(uT!=uTL || uTInfo.getErrors()!=uTLInfo.getErrors()) {
prettify(uT).extract(0, 0x7fffffff, buffer, UPRV_LENGTHOF(buffer));
prettify(uTL).extract(0, 0x7fffffff, buffer2, UPRV_LENGTHOF(buffer2));
for (j=0; j<i; j++) {
if (j+0x30 == 0x5c) {
// backslash. Needs to be escaped
- s.append((UChar)0x5c);
+ s.append((char16_t)0x5c);
}
- s.append(UChar(j+0x30));
+ s.append(char16_t(j+0x30));
}
TestString(s);
}
// looking for glitches at buffer boundaries
for (i=1; i<60; i++) {
s.truncate(0);
- s.append((UChar)0x41);
+ s.append((char16_t)0x41);
for (j=0; j<i; j++) {
s.append(UChar32(j+0x11000));
}
cpMap[j].nativeIdx = i; // position following the last char in utf-16 string.
- // UChar * test, null terminated
+ // char16_t * test, null terminated
status = U_ZERO_ERROR;
- UChar *buf = new UChar[saLen+1];
+ char16_t *buf = new char16_t[saLen+1];
sa.extract(buf, saLen+1, status);
TEST_SUCCESS(status);
ut = utext_openUChars(nullptr, buf, -1, &status);
utext_close(ut);
delete [] buf;
- // UChar * test, with length
+ // char16_t * test, with length
status = U_ZERO_ERROR;
- buf = new UChar[saLen+1];
+ buf = new char16_t[saLen+1];
sa.extract(buf, saLen+1, status);
TEST_SUCCESS(status);
ut = utext_openUChars(nullptr, buf, saLen, &status);
// Character Iterator Tests
status = U_ZERO_ERROR;
- const UChar *cbuf = sa.getBuffer();
+ const char16_t *cbuf = sa.getBuffer();
CharacterIterator *ci = new UCharCharacterIterator(cbuf, saLen, status);
TEST_SUCCESS(status);
ut = utext_openCharacterIterator(nullptr, ci, &status);
//
// Do the replace on the UText under test
//
- const UChar *rs = repStr.getBuffer();
+ const char16_t *rs = repStr.getBuffer();
int32_t rsLen = repStr.length();
int32_t actualDelta = utext_replace(targetUT, nativeStart, nativeLimit, rs, rsLen, &status);
int32_t expectedDelta = repStr.length() - (nativeLimit - nativeStart);
// Extract
//
int bufSize = us.length() + 10;
- UChar *buf = new UChar[bufSize];
+ char16_t *buf = new char16_t[bufSize];
status = U_ZERO_ERROR;
expectedLen = us.length();
len = utext_extract(ut, 0, utlen, buf, bufSize, &status);
UText ut = UTEXT_INITIALIZER;
UText *utp;
UnicodeString s1("Hello, World");
- UChar s2[] = {(UChar)0x41, (UChar)0x42, (UChar)0};
+ char16_t s2[] = {(char16_t)0x41, (char16_t)0x42, (char16_t)0};
const char *s3 = "\x66\x67\x68";
utp = utext_openUnicodeString(&ut, &s1, &status);
c = utext_char32At(ut, 6);
TEST_ASSERT(c == 0x43);
- UChar buf[10];
+ char16_t buf[10];
int n = utext_extract(ut, 0, 9, buf, 10, &status);
TEST_SUCCESS(status);
TEST_ASSERT(n==7);
UnicodeString sa("Hello, this is a string");
UBool isExpensive;
- UChar sb[100];
+ char16_t sb[100];
memset(sb, 0x20, sizeof(sb));
sb[99] = 0;
// Extract from i to i+1, which may be zero or one code points,
// depending on whether the indices straddle a cp boundary.
for (i=0; i<startMapLimit; i++) {
- UChar buf[3];
+ char16_t buf[3];
status = U_ZERO_ERROR;
int32_t extractedLen = utext_extract(ut, i, i+1, buf, 3, &status);
TEST_SUCCESS(status);
// Extract from i to i+1, which may be zero or one code points,
// depending on whether the indices straddle a cp boundary.
for (i=0; i<startMapLimit; i++) {
- UChar buf[3];
+ char16_t buf[3];
status = U_ZERO_ERROR;
int32_t extractedLen = utext_extract(ut, i, i+1, buf, 3, &status);
TEST_SUCCESS(status);
// Extract from i to i+1, which may be zero or one code points,
// depending on whether the indices straddle a cp boundary.
for (i=0; i<startMapLimit; i++) {
- UChar buf[3];
+ char16_t buf[3];
status = U_ZERO_ERROR;
int32_t extractedLen = utext_extract(ut, i, i+1, buf, 3, &status);
TEST_SUCCESS(status);
UnicodeString ustr("Hello, World.");
const char u8str[] = {char(0x31), (char)0x32, (char)0x33, 0};
- const UChar u16str[] = {(UChar)0x31, (UChar)0x32, (UChar)0x44, 0};
+ const char16_t u16str[] = {(char16_t)0x31, (char16_t)0x32, (char16_t)0x44, 0};
UErrorCode status = U_ZERO_ERROR;
UText *ut = nullptr;
static UBool U_CALLCONV
fragTextAccess(UText *ut, int64_t index, UBool forward) {
const UnicodeString *us = (const UnicodeString *)ut->context;
- UChar c;
+ char16_t c;
int32_t length = us->length();
if (forward && index>=0 && index<length) {
c = us->charAt((int32_t)index);
fragmentFuncs.clone = cloneFragmentedUnicodeString;
ut->pFuncs = &fragmentFuncs;
- ut->chunkContents = (UChar *)&ut->b;
+ ut->chunkContents = (char16_t *)&ut->b;
ut->pFuncs->access(ut, 0, true);
return ut;
}
UText ut2 = UTEXT_INITIALIZER;
utext_openUTF8(&ut1, s1, -1, &status);
- UChar c = utext_next32(&ut1);
+ char16_t c = utext_next32(&ut1);
TEST_ASSERT(c == 0x41); // c == 'A'
utext_clone(&ut2, &ut1, true, false, &status);
//
void UTextTest::Ticket6847() {
const int STRLEN = 90;
- UChar s[STRLEN+1];
+ char16_t s[STRLEN+1];
u_memset(s, 0x41, STRLEN);
s[STRLEN] = 0;
utext_close(ut);
}
-// Ticket 12130 - extract on a UText wrapping a null terminated UChar * string
+// Ticket 12130 - extract on a UText wrapping a null terminated char16_t * string
// leaves the iteration position set incorrectly when the
// actual string length is not yet known.
//
"symbols in common use.";
UnicodeString str(text8);
- const UChar *ustr = str.getTerminatedBuffer();
+ const char16_t *ustr = str.getTerminatedBuffer();
UText ut = UTEXT_INITIALIZER;
utext_openUChars(&ut, ustr, -1, &status);
- UChar extractBuffer[50];
+ char16_t extractBuffer[50];
for (int32_t startIdx = 0; startIdx<str.length(); ++startIdx) {
int32_t endIdx = startIdx + 20;
wdf->format(icuNow, udBuffer);
wtf->format(icuNow, utBuffer);
- if (ubBuffer.indexOf((const UChar *)wdBuffer, wdLength - 1, 0) < 0) {
+ if (ubBuffer.indexOf((const char16_t *)wdBuffer, wdLength - 1, 0) < 0) {
UnicodeString baseName(wlocale.getBaseName());
- UnicodeString expected((const UChar *)wdBuffer);
+ UnicodeString expected((const char16_t *)wdBuffer);
log->errln("DateTime format error for locale " + baseName + ": expected date \"" + expected +
"\" got \"" + ubBuffer + "\"");
}
- if (ubBuffer.indexOf((const UChar *)wtBuffer, wtLength - 1, 0) < 0) {
+ if (ubBuffer.indexOf((const char16_t *)wtBuffer, wtLength - 1, 0) < 0) {
UnicodeString baseName(wlocale.getBaseName());
- UnicodeString expected((const UChar *)wtBuffer);
+ UnicodeString expected((const char16_t *)wtBuffer);
log->errln("DateTime format error for locale " + baseName + ": expected time \"" + expected +
"\" got \"" + ubBuffer + "\"");
}
- if (udBuffer.compare((const UChar *)wdBuffer) != 0) {
+ if (udBuffer.compare((const char16_t *)wdBuffer) != 0) {
UnicodeString baseName(wlocale.getBaseName());
- UnicodeString expected((const UChar *)wdBuffer);
+ UnicodeString expected((const char16_t *)wdBuffer);
log->errln("Date format error for locale " + baseName + ": expected \"" + expected +
"\" got \"" + udBuffer + "\"");
}
- if (utBuffer.compare((const UChar *)wtBuffer) != 0) {
+ if (utBuffer.compare((const char16_t *)wtBuffer) != 0) {
UnicodeString baseName(wlocale.getBaseName());
- UnicodeString expected((const UChar *)wtBuffer);
+ UnicodeString expected((const char16_t *)wtBuffer);
log->errln("Time format error for locale " + baseName + ": expected \"" + expected +
"\" got \"" + utBuffer + "\"");
newLength = _vscwprintf(fmt, args);
va_end(args);
- nBuffer = NEW_ARRAY(UChar, newLength + 1);
+ nBuffer = NEW_ARRAY(char16_t, newLength + 1);
va_start(args, fmt);
result = _vsnwprintf(nBuffer, newLength + 1, fmt, args);
}
}
- appendTo.append((const UChar *)buffer, (int32_t) wcslen(buffer));
+ appendTo.append((const char16_t *)buffer, (int32_t) wcslen(buffer));
if (buffer != stackBuffer) {
DELETE_ARRAY(buffer);
#if !UCONFIG_NO_FORMATTING && !UCONFIG_NO_FILE_IO
static int64_t
-uto64(const UChar *buffer)
+uto64(const char16_t *buffer)
{
uint64_t result = 0;
/* iterate through buffer */
/* read the next digit */
result *= 16u;
if (!u_isxdigit(*buffer)) {
- log_err("\\u%04X is not a valid hex digit for this test\n", (UChar)*buffer);
+ log_err("\\u%04X is not a valid hex digit for this test\n", (char16_t)*buffer);
}
result += *buffer - 0x0030 - (*buffer >= 0x0041 ? (*buffer >= 0x0061 ? 39 : 7) : 0);
buffer++;
TestData *testData;
const DataMap *testCase;
DataDrivenLogger logger;
- UChar uBuffer[512];
+ char16_t uBuffer[512];
char cBuffer[512];
char cFormat[sizeof(cBuffer)];
char cExpected[sizeof(cBuffer)];
UnicodeString tempStr;
- UChar format[512];
- UChar expectedResult[512];
- UChar argument[512];
+ char16_t format[512];
+ char16_t expectedResult[512];
+ char16_t argument[512];
int32_t i;
int8_t i8;
int16_t i16;
uBufferLenReturned = u_sprintf_u(uBuffer, format, cBuffer);
uFileBufferLenReturned = u_fprintf_u(testFile.getAlias(), format, cBuffer);
break;
- case 0x53: // 'S' UChar *
+ case 0x53: // 'S' char16_t *
uBufferLenReturned = u_sprintf_u(uBuffer, format, argument);
uFileBufferLenReturned = u_fprintf_u(testFile.getAlias(), format, argument);
break;
TestData *testData;
const DataMap *testCase;
DataDrivenLogger logger;
- UChar uBuffer[512];
+ char16_t uBuffer[512];
char cBuffer[512];
char cExpected[sizeof(cBuffer)];
UnicodeString tempStr;
- UChar format[512];
- UChar expectedResult[512];
- UChar argument[512];
+ char16_t format[512];
+ char16_t expectedResult[512];
+ char16_t argument[512];
int32_t i;
int8_t i8, expected8;
int16_t i16, expected16;
log_err("error in scanf char * string. Got \"%s\" Expected \"%s\". Test case = %d\n", cBuffer, cExpected, i);
}
break;
- case 0x53: // 'S' UChar *
+ case 0x53: // 'S' char16_t *
uBufferLenReturned = u_sscanf_u(argument, format, uBuffer);
//uFileBufferLenReturned = u_fscanf_u(testFile, format, argument);
if (u_strcmp(uBuffer, expectedResult) != 0) {
u_austrcpy(cExpected, format);
u_austrcpy(cBuffer, uBuffer);
- log_err("error in scanf UChar * string %s Got: \"%s\". Test case = %d\n", cExpected, cBuffer, i);
+ log_err("error in scanf char16_t * string %s Got: \"%s\". Test case = %d\n", cExpected, cBuffer, i);
}
break;
default:
TestData *testData;
const DataMap *testCase;
DataDrivenLogger logger;
- UChar uBuffer[512];
+ char16_t uBuffer[512];
char cBuffer[512];
char cFormat[sizeof(cBuffer)];
char cExpected[sizeof(cBuffer)];
UnicodeString tempStr;
- UChar format[512];
- UChar expectedResult[512];
- UChar argument[512];
+ char16_t format[512];
+ char16_t expectedResult[512];
+ char16_t argument[512];
int32_t precision;
int32_t i;
int8_t i8;
u_austrncpy(cBuffer, uBuffer, sizeof(cBuffer));
uBufferLenReturned = u_sprintf_u(uBuffer, format, precision, cBuffer);
break;
- case 0x53: // 'S' UChar *
+ case 0x53: // 'S' char16_t *
uBufferLenReturned = u_sprintf_u(uBuffer, format, precision, argument);
break;
default:
U_CDECL_BEGIN
#if U_PLATFORM_USES_ONLY_WIN32_API
-const UChar NEW_LINE[] = {0x0d,0x0a,0};
+const char16_t NEW_LINE[] = {0x0d,0x0a,0};
const char C_NEW_LINE[] = {0x0d,0x0a,0};
#define UTF8_NEW_LINE "\x0d\x0a"
#else
-const UChar NEW_LINE[] = {0x0a,0};
+const char16_t NEW_LINE[] = {0x0a,0};
const char C_NEW_LINE[] = {'\n',0};
#define UTF8_NEW_LINE "\x0a"
#endif
U_CDECL_BEGIN
static void U_CALLCONV TestStream(void)
{
- const UChar thisMu[] = { 0x74, 0x48, 0x69, 0x73, 0x3BC, 0};
- const UChar mu[] = { 0x6D, 0x75, 0};
+ const char16_t thisMu[] = { 0x74, 0x48, 0x69, 0x73, 0x3BC, 0};
+ const char16_t mu[] = { 0x6D, 0x75, 0};
UnicodeString str1 = UNICODE_STRING_SIMPLE("str1");
UnicodeString str2 = UNICODE_STRING_SIMPLE(" <<");
UnicodeString str3 = UNICODE_STRING_SIMPLE("2");
memset(testLargeStreamBuf, 0, sizeof(testLargeStreamBuf));
ostrstream outLargeStream(testLargeStreamBuf, sizeof(testLargeStreamBuf));
#endif
- UChar large_array[200];
+ char16_t large_array[200];
int32_t large_array_length = UPRV_LENGTHOF(large_array);
for (int32_t i = 0; i < large_array_length; i++) {
large_array[i] = 0x41;
testString(
UnicodeString& str,
const char* testString,
- const UChar* expectedString,
+ const char16_t* expectedString,
int32_t expectedStatus)
{
#ifdef USE_SSTREAM
#else
#define _UNICODE
typedef int DWORD;
-inline int FoldStringW(DWORD dwMapFlags, const UChar* lpSrcStr,int cchSrc, UChar* lpDestStr,int cchDest);
+inline int FoldStringW(DWORD dwMapFlags, const char16_t* lpSrcStr,int cchSrc, char16_t* lpDestStr,int cchDest);
#endif
class BreakItFunction : public UPerfFunction
return UnicodeString(buf, "");
}
case Formattable::kString:
- return UnicodeString((UChar)U_DQUOTE).append(f.getString()).append((UChar)U_DQUOTE);
+ return UnicodeString((char16_t)U_DQUOTE).append(f.getString()).append((char16_t)U_DQUOTE);
case Formattable::kArray:
{
int32_t i, count;
const Formattable* array = f.getArray(count);
- UnicodeString result((UChar)U_LEFT_SQUARE_BRACKET);
+ UnicodeString result((char16_t)U_LEFT_SQUARE_BRACKET);
for (i=0; i<count; ++i) {
if (i > 0) {
- (result += (UChar)U_COMMA) += (UChar)U_SPACE;
+ (result += (char16_t)U_COMMA) += (char16_t)U_SPACE;
}
result += formattableToString(array[i]);
}
- result += (UChar)U_RIGHT_SQUARE_BRACKET;
+ result += (char16_t)U_RIGHT_SQUARE_BRACKET;
return result;
}
default:
// Stubs for Windows API functions when building on UNIXes.
//
typedef int DWORD;
-inline int CompareStringW(DWORD, DWORD, UChar *, int, UChar *, int) {return 0;}
+inline int CompareStringW(DWORD, DWORD, char16_t *, int, char16_t *, int) {return 0;}
#include <sys/time.h>
unsigned long timeGetTime() {
struct timeval t;
val += t.tv_usec / 1000;
return val;
}
-inline int LCMapStringW(DWORD, DWORD, UChar *, int, UChar *, int) {return 0;}
+inline int LCMapStringW(DWORD, DWORD, char16_t *, int, char16_t *, int) {return 0;}
const int LCMAP_SORTKEY = 0;
#define MAKELCID(a,b) 0
const int SORT_DEFAULT = 0;
// one of these structs.
//
struct Line {
- UChar *name;
+ char16_t *name;
int len;
char *winSortKey;
char *icuSortKey;
for (iLoop=0; iLoop < opt_iLoopCount; iLoop++) {
LCMapStringW(gWinLCID, LCMAP_SORTKEY,
gFileLines[line].name, len,
- (UChar *)gFileLines[line].winSortKey, 5000); // TODO something with length.
+ (char16_t *)gFileLines[line].winSortKey, 5000); // TODO something with length.
}
}
}
if (opt_strcmp || opt_strcmpCPO)
{
unsigned long startTime = timeGetTime();
- typedef int32_t (U_EXPORT2 *PF)(const UChar *, const UChar *);
+ typedef int32_t (U_EXPORT2 *PF)(const char16_t *, const char16_t *);
PF pf = u_strcmp;
if (opt_strcmpCPO) {pf = u_strcmpCodePointOrder;}
//if (opt_strcmp && opt_win) {pf = (PF)wcscmp;} // Damn the difference between int32_t and int
}
printf("performance test on strings from file -----------\n");
- UChar dummytext[] = {0, 0};
+ char16_t dummytext[] = {0, 0};
UCollationElements *iter = ucol_openElements(gCol, nullptr, 0, &error);
ucol_setText(iter, dummytext, 1, &error);
while (count < opt_loopCount) {
int linecount = 0;
while (linecount < gNumFileLines) {
- UChar *str = gFileLines[linecount].name;
+ char16_t *str = gFileLines[linecount].name;
int strlen = haslen?gFileLines[linecount].len:-1;
ucol_setText(iter, str, strlen, &error);
while (ucol_next(iter, &error) != UCOL_NULLORDER) {
while (count < opt_loopCount) {
int linecount = 0;
while (linecount < gNumFileLines) {
- UChar *str = gFileLines[linecount].name;
+ char16_t *str = gFileLines[linecount].name;
int strlen = haslen?gFileLines[linecount].len:-1;
ucol_setText(iter, str, strlen, &error);
linecount ++;
printf("performance test on skipped-5 concatenated strings from file -----------\n");
- UChar *str;
+ char16_t *str;
int strlen = 0;
// appending all the strings
int linecount = 0;
u_strlen(gFileLines[linecount].name);
linecount ++;
}
- str = (UChar *)malloc(sizeof(UChar) * strlen);
+ str = (char16_t *)malloc(sizeof(char16_t) * strlen);
int strindex = 0;
linecount = 0;
while (strindex < strlen) {
len += haslen?gFileLines[linecount].len:
u_strlen(gFileLines[linecount].name);
memcpy(str + strindex, gFileLines[linecount].name,
- sizeof(UChar) * len);
+ sizeof(char16_t) * len);
strindex += len;
linecount ++;
}
printf("performance test on strings from file -----------\n");
UCollationElements *iter = ucol_openElements(gCol, nullptr, 0, &error);
- UChar dummytext[] = {0, 0};
+ char16_t dummytext[] = {0, 0};
ucol_setText(iter, dummytext, 1, &error);
gCount = 0;
while (count < opt_loopCount) {
int linecount = 0;
while (linecount < gNumFileLines) {
- UChar *str = gFileLines[linecount].name;
+ char16_t *str = gFileLines[linecount].name;
int strlen = haslen?gFileLines[linecount].len:-1;
ucol_setText(iter, str, strlen, &error);
while (ucol_previous(iter, &error) != UCOL_NULLORDER) {
while (count < opt_loopCount) {
int linecount = 0;
while (linecount < gNumFileLines) {
- UChar *str = gFileLines[linecount].name;
+ char16_t *str = gFileLines[linecount].name;
int strlen = haslen?gFileLines[linecount].len:-1;
ucol_setText(iter, str, strlen, &error);
linecount ++;
printf("performance test on skipped-5 concatenated strings from file -----------\n");
- UChar *str;
+ char16_t *str;
int strlen = 0;
// appending all the strings
int linecount = 0;
u_strlen(gFileLines[linecount].name);
linecount ++;
}
- str = (UChar *)malloc(sizeof(UChar) * strlen);
+ str = (char16_t *)malloc(sizeof(char16_t) * strlen);
int strindex = 0;
linecount = 0;
while (strindex < strlen) {
len += haslen?gFileLines[linecount].len:
u_strlen(gFileLines[linecount].name);
memcpy(str + strindex, gFileLines[linecount].name,
- sizeof(UChar) * len);
+ sizeof(char16_t) * len);
strindex += len;
linecount ++;
}
public:
UCharFile(const char *fileName);
~UCharFile();
- UChar get();
+ char16_t get();
UBool eof() {return fEof;};
UBool error() {return fError;};
const char *fName;
UBool fEof;
UBool fError;
- UChar fPending2ndSurrogate;
+ char16_t fPending2ndSurrogate;
enum {UTF16LE, UTF16BE, UTF8} fEncoding;
};
-UChar UCharFile::get() {
- UChar c;
+char16_t UCharFile::get() {
+ char16_t c;
switch (fEncoding) {
case UTF16LE:
{
break;
}
- int ch = fgetc(fFile); // Note: c and ch are separate cause eof test doesn't work on UChar type.
+ int ch = fgetc(fFile); // Note: c and ch are separate cause eof test doesn't work on char16_t type.
if (ch == EOF) {
c = 0;
fEof = true;
i = 0;
uint32_t cp;
U8_NEXT_UNSAFE(bytes, i, cp);
- c = (UChar)cp;
+ c = (char16_t)cp;
if (cp >= 0x10000) {
// The code point needs to be broken up into a utf-16 surrogate pair.
// Process first half this time through the main loop, and
// remember the other half for the next time through.
- UChar utf16Buf[3];
+ char16_t utf16Buf[3];
i = 0;
UTF16_APPEND_CHAR_UNSAFE(utf16Buf, i, cp);
fPending2ndSurrogate = utf16Buf[1];
}
int bufLen = 10000;
- UChar *buf = (UChar *)malloc(bufLen * sizeof(UChar));
- UChar *tmp;
+ char16_t *buf = (char16_t *)malloc(bufLen * sizeof(char16_t));
+ char16_t *tmp;
int i = 0;
for(;;) {
if (i >= bufLen) {
tmp = buf;
bufLen += 10000;
- buf = (UChar *)realloc(buf, bufLen);
+ buf = (char16_t *)realloc(buf, bufLen);
if (buf == nullptr) {
free(tmp);
return 0;
const int MAXLINES = 100000;
gFileLines = new Line[MAXLINES];
- UChar buf[1024];
+ char16_t buf[1024];
int column = 0;
// Read the file, split into lines, and save in memory.
// (The number of bytes read from file per loop iteration depends on external encoding.)
for (;;) {
- UChar c = f.get();
+ char16_t c = f.get();
if (f.error()){
exit(-1);
}
if (f.eof() || c == 0x0a || c==0x2028) { // Unipad inserts 2028 line separators!
buf[column++] = 0;
if (column > 1) {
- gFileLines[gNumFileLines].name = new UChar[column];
+ gFileLines[gNumFileLines].name = new char16_t[column];
gFileLines[gNumFileLines].len = column-1;
- memcpy(gFileLines[gNumFileLines].name, buf, column * sizeof(UChar));
+ memcpy(gFileLines[gNumFileLines].name, buf, column * sizeof(char16_t));
gNumFileLines++;
column = 0;
if (gNumFileLines >= MAXLINES) {
t=LCMapStringW(gWinLCID, LCMAP_SORTKEY, gFileLines[line].name, -1, buf, sizeof(buf));
gFileLines[line].winSortKey = new char[t];
if (t > (int32_t)sizeof(buf)) {
- t = LCMapStringW(gWinLCID, LCMAP_SORTKEY, gFileLines[line].name, -1, (UChar *)(gFileLines[line].winSortKey), t);
+ t = LCMapStringW(gWinLCID, LCMAP_SORTKEY, gFileLines[line].name, -1, (char16_t *)(gFileLines[line].winSortKey), t);
}
else
{
int i;
for (line=0; line<gNumFileLines; line++) {
for (i=0;;i++) {
- UChar c = gFileLines[line].name[i];
+ char16_t c = gFileLines[line].name[i];
if (c == 0)
break;
if (c < 0x20 || c > 0x7e) {
int32_t lengthOf(int i){return index[i+1] - index[i] - 1; } /*exclude terminating NUL*/ \
};
-//typedef CompactArrays<UChar> CA_uchar;
+//typedef CompactArrays<char16_t> CA_uchar;
//typedef CompactArrays<char> CA_char;
//typedef CompactArrays<uint8_t> CA_uint8;
//typedef CompactArrays<WCHAR> CA_win_wchar;
-COMPATCT_ARRAY(CA_uchar, UChar)
+COMPATCT_ARRAY(CA_uchar, char16_t)
COMPATCT_ARRAY(CA_char, char)
COMPATCT_ARRAY(CA_uint8, uint8_t)
COMPATCT_ARRAY(CA_win_wchar, WCHAR)
static DWORD win_langid; // for qsort callback function
static UCollator * col; // for qsort callback function
uint8_t * icu_key;
- UChar * icu_data;
+ char16_t * icu_data;
int32_t icu_data_len;
char* posix_key;
char* posix_data;
CmdIter(UErrorCode & status, UCollator * col, int32_t count, CA_uchar *data, Func fn, int32_t,int32_t)
:count(count), data(data), fn(fn){
exec_count = 0;
- UChar dummytext[] = {0, 0};
+ char16_t dummytext[] = {0, 0};
iter = ucol_openElements(col, nullptr, 0, &status);
ucol_setText(iter, dummytext, 1, &status);
}
class CmdIterAll : public UPerfFunction {
typedef void (CmdIterAll::* Func)(UErrorCode* status);
int32_t count;
- UChar * data;
+ char16_t * data;
Func fn;
UCollationElements *iter;
int32_t exec_count;
~CmdIterAll(){
ucol_closeElements(iter);
}
- CmdIterAll(UErrorCode & status, UCollator * col, int32_t count, UChar * data, CALL call,int32_t,int32_t)
+ CmdIterAll(UErrorCode & status, UCollator * col, int32_t count, char16_t * data, CALL call,int32_t,int32_t)
:count(count),data(data)
{
exec_count = 0;
UCollator * col;
DWORD win_langid;
- UChar * icu_data_all;
+ char16_t * icu_data_all;
int32_t icu_data_all_len;
int32_t count;
icu_data = new CA_uchar();
// Following code is borrowed from UPerfTest::getLines();
- const UChar* line=nullptr;
+ const char16_t* line=nullptr;
int32_t len =0;
for (;;) {
line = ucbuf_readline(ucharBuf,&len,&status);
continue; //skip empty line
} else {
icu_data->append_one(len);
- memcpy(icu_data->last(), line, len * sizeof(UChar));
+ memcpy(icu_data->last(), line, len * sizeof(char16_t));
icu_data->last()[len -1] = 0;
}
}
icu_data_all_len = icu_data->index[count]; // includes all NULs
icu_data_all_len -= count; // excludes all NULs
icu_data_all_len += 1; // the terminal NUL
- icu_data_all = new UChar[icu_data_all_len];
+ icu_data_all = new char16_t[icu_data_all_len];
icu_data_all[icu_data_all_len - 1] = 0; //the terminal NUL
icu_key = new CA_uint8;
DataIndex::col = col;
- UChar * p = icu_data_all;
+ char16_t * p = icu_data_all;
int32_t s;
int32_t t;
for (int i=0; i < count; i++) {
// ICU all data
- s = sizeof(UChar) * icu_data->lengthOf(i);
+ s = sizeof(char16_t) * icu_data->lengthOf(i);
memcpy(p, icu_data->dataOf(i), s);
p += icu_data->lengthOf(i);
int32_t lengthOf(int i) const {return index[i+1] - index[i] - 1; } /*exclude terminating NUL*/ \
};
-COMPACT_ARRAY(CA_uchar, UChar)
+COMPACT_ARRAY(CA_uchar, char16_t)
COMPACT_ARRAY(CA_char, char)
#define MAX_TEST_STRINGS_FOR_PERMUTING 1000
if (data16) return data16;
CA_uchar* d16 = new CA_uchar();
- const UChar *line = nullptr;
+ const char16_t *line = nullptr;
int32_t len = 0;
int32_t numData = 0;
continue; // skip empty/comment line
} else {
d16->append_one(len);
- UChar *p = d16->last();
+ char16_t *p = d16->last();
u_memcpy(p, line, len - 1); // exclude the CR
p[len - 1] = 0; // NUL-terminate
CA_uchar* modData16 = new CA_uchar();
for (int32_t i = 0; i < d16->count; i++) {
- const UChar *s = d16->dataOf(i);
+ const char16_t *s = d16->dataOf(i);
int32_t len = d16->lengthOf(i) + 1; // including NUL terminator
modData16->append_one(len);
u_memcpy(modData16->last(), s, len);
// replacing the last character with a different character
- UChar *lastChar = &modData16->last()[len -2];
+ char16_t *lastChar = &modData16->last()[len -2];
for (int32_t j = i + 1; j != i; j++) {
if (j >= d16->count) {
j = 0;
}
- const UChar *s1 = d16->dataOf(j);
- UChar lastChar1 = s1[d16->lengthOf(j) - 1];
+ const char16_t *s1 = d16->dataOf(j);
+ char16_t lastChar1 = s1[d16->lengthOf(j) - 1];
if (*lastChar != lastChar1) {
*lastChar = lastChar1;
break;
LocalPointer<CA_uchar> newD16(new CA_uchar());
for (int32_t i = 0; i < d16->count; i++) {
int32_t j = indexes[i];
- const UChar* s = d16->dataOf(j);
+ const char16_t* s = d16->dataOf(j);
int32_t len = d16->lengthOf(j);
int32_t capacity = len + 1; // including NUL terminator
newD16->append_one(capacity);
// UTF-16 -> UTF-8 conversion
LocalPointer<CA_char> d8(new CA_char());
for (int32_t i = 0; i < d16->count; i++) {
- const UChar *s16 = d16->dataOf(i);
+ const char16_t *s16 = d16->dataOf(i);
int32_t length16 = d16->lengthOf(i);
// get length in UTF-8
UPerfFunction* ConverterPerformanceTest::TestICU_UTF8_FromUnicode(){
UErrorCode status = U_ZERO_ERROR;
- ICUFromUnicodePerfFunction* pf = new ICUFromUnicodePerfFunction("utf-8", (UChar *)utf8_uniSource, UPRV_LENGTHOF(utf8_uniSource), status);
+ ICUFromUnicodePerfFunction* pf = new ICUFromUnicodePerfFunction("utf-8", (char16_t *)utf8_uniSource, UPRV_LENGTHOF(utf8_uniSource), status);
if(U_FAILURE(status)){
return nullptr;
}
UPerfFunction* ConverterPerformanceTest::TestICU_Latin1_FromUnicode(){
UErrorCode status = U_ZERO_ERROR;
- ICUFromUnicodePerfFunction* pf = new ICUFromUnicodePerfFunction("iso-8859-1", (UChar *)latin1_uniSource, UPRV_LENGTHOF(latin1_uniSource), status);
+ ICUFromUnicodePerfFunction* pf = new ICUFromUnicodePerfFunction("iso-8859-1", (char16_t *)latin1_uniSource, UPRV_LENGTHOF(latin1_uniSource), status);
if(U_FAILURE(status)){
return nullptr;
}
UPerfFunction* ConverterPerformanceTest::TestICU_Latin8_FromUnicode(){
UErrorCode status = U_ZERO_ERROR;
- ICUFromUnicodePerfFunction* pf = new ICUFromUnicodePerfFunction("iso-8859-8", (UChar *)latin8_uniSource, UPRV_LENGTHOF(latin8_uniSource), status);
+ ICUFromUnicodePerfFunction* pf = new ICUFromUnicodePerfFunction("iso-8859-8", (char16_t *)latin8_uniSource, UPRV_LENGTHOF(latin8_uniSource), status);
if(U_FAILURE(status)){
return nullptr;
}
UPerfFunction* ConverterPerformanceTest::TestICU_EBCDIC_Arabic_FromUnicode(){
UErrorCode status = U_ZERO_ERROR;
- ICUFromUnicodePerfFunction* pf = new ICUFromUnicodePerfFunction("x-EBCDIC-Arabic", (UChar *)ebcdic_arabic_uniSource, UPRV_LENGTHOF(ebcdic_arabic_uniSource), status);
+ ICUFromUnicodePerfFunction* pf = new ICUFromUnicodePerfFunction("x-EBCDIC-Arabic", (char16_t *)ebcdic_arabic_uniSource, UPRV_LENGTHOF(ebcdic_arabic_uniSource), status);
if(U_FAILURE(status)){
return nullptr;
}
UPerfFunction* ConverterPerformanceTest::TestICU_SJIS_FromUnicode(){
UErrorCode status = U_ZERO_ERROR;
- ICUFromUnicodePerfFunction* pf = new ICUFromUnicodePerfFunction("sjis", (UChar *)sjis_uniSource, UPRV_LENGTHOF(sjis_uniSource), status);
+ ICUFromUnicodePerfFunction* pf = new ICUFromUnicodePerfFunction("sjis", (char16_t *)sjis_uniSource, UPRV_LENGTHOF(sjis_uniSource), status);
if(U_FAILURE(status)){
return nullptr;
}
UPerfFunction* ConverterPerformanceTest::TestICU_EUCJP_FromUnicode(){
UErrorCode status = U_ZERO_ERROR;
- ICUFromUnicodePerfFunction* pf = new ICUFromUnicodePerfFunction("euc-jp", (UChar *)eucjp_uniSource, UPRV_LENGTHOF(eucjp_uniSource), status);
+ ICUFromUnicodePerfFunction* pf = new ICUFromUnicodePerfFunction("euc-jp", (char16_t *)eucjp_uniSource, UPRV_LENGTHOF(eucjp_uniSource), status);
if(U_FAILURE(status)){
return nullptr;
}
UPerfFunction* ConverterPerformanceTest::TestICU_GB2312_FromUnicode(){
UErrorCode status = U_ZERO_ERROR;
- ICUFromUnicodePerfFunction* pf = new ICUFromUnicodePerfFunction("gb2312", (UChar *)gb2312_uniSource, UPRV_LENGTHOF(gb2312_uniSource), status);
+ ICUFromUnicodePerfFunction* pf = new ICUFromUnicodePerfFunction("gb2312", (char16_t *)gb2312_uniSource, UPRV_LENGTHOF(gb2312_uniSource), status);
if(U_FAILURE(status)){
return nullptr;
}
UPerfFunction* ConverterPerformanceTest::TestICU_ISO2022KR_FromUnicode(){
UErrorCode status = U_ZERO_ERROR;
- ICUFromUnicodePerfFunction* pf = new ICUFromUnicodePerfFunction("iso-2022-kr", (UChar *)iso2022kr_uniSource, UPRV_LENGTHOF(iso2022kr_uniSource), status);
+ ICUFromUnicodePerfFunction* pf = new ICUFromUnicodePerfFunction("iso-2022-kr", (char16_t *)iso2022kr_uniSource, UPRV_LENGTHOF(iso2022kr_uniSource), status);
if(U_FAILURE(status)){
return nullptr;
}
UPerfFunction* ConverterPerformanceTest::TestICU_ISO2022JP_FromUnicode(){
UErrorCode status = U_ZERO_ERROR;
- ICUFromUnicodePerfFunction* pf = new ICUFromUnicodePerfFunction("iso-2022-jp", (UChar *)iso2022jp_uniSource, UPRV_LENGTHOF(iso2022jp_uniSource), status);
+ ICUFromUnicodePerfFunction* pf = new ICUFromUnicodePerfFunction("iso-2022-jp", (char16_t *)iso2022jp_uniSource, UPRV_LENGTHOF(iso2022jp_uniSource), status);
if(U_FAILURE(status)){
return nullptr;
}
UConverter* conv;
const char* src;
int32_t srcLen;
- UChar* target;
- UChar* targetLimit;
+ char16_t* target;
+ char16_t* targetLimit;
public:
ICUToUnicodePerfFunction(const char* name, const char* source, int32_t sourceLen, UErrorCode& status){
source, srcLen, &status);
if(status==U_BUFFER_OVERFLOW_ERROR) {
status=U_ZERO_ERROR;
- target=(UChar*)malloc((reqdLen) * U_SIZEOF_UCHAR*2);
+ target=(char16_t*)malloc((reqdLen) * U_SIZEOF_UCHAR*2);
targetLimit = target + reqdLen;
if(target == nullptr){
status = U_MEMORY_ALLOCATION_ERROR;
virtual void call(UErrorCode* status){
const char* mySrc = src;
const char* sourceLimit = src + srcLen;
- UChar* myTarget = target;
+ char16_t* myTarget = target;
ucnv_toUnicode(conv, &myTarget, targetLimit, &mySrc, sourceLimit, nullptr, true, status);
}
virtual long getOperationsPerIteration(void){
class ICUFromUnicodePerfFunction : public UPerfFunction{
private:
UConverter* conv;
- const UChar* src;
+ const char16_t* src;
int32_t srcLen;
char* target;
char* targetLimit;
const char* name;
public:
- ICUFromUnicodePerfFunction(const char* name, const UChar* source, int32_t sourceLen, UErrorCode& status){
+ ICUFromUnicodePerfFunction(const char* name, const char16_t* source, int32_t sourceLen, UErrorCode& status){
conv = ucnv_open(name,&status);
src = source;
srcLen = sourceLen;
}
}
virtual void call(UErrorCode* status){
- const UChar* mySrc = src;
- const UChar* sourceLimit = src + srcLen;
+ const char16_t* mySrc = src;
+ const char16_t* sourceLimit = src + srcLen;
char* myTarget = target;
ucnv_fromUnicode(conv,&myTarget, targetLimit, &mySrc, sourceLimit, nullptr, true, status);
}
++numTextLines;
// Remove trailing CR LF.
int32_t len=lines[i].len;
- UChar c;
+ char16_t c;
while(len>0 && ((c=lines[i].name[len-1])==0xa || c==0xd)) {
--len;
}
UChar32 c=utext_next32(text);
// Notes:
// a) CompactTrieDictionary::matches() does not check for U_SENTINEL.
- // b) It also ignores non-BMP code points by casting to UChar!
+ // b) It also ignores non-BMP code points by casting to char16_t!
if(c<0) {
return 0;
}
UChar32 c=utext_next32(text);
// Notes:
// a) CompactTrieDictionary::matches() does not check for U_SENTINEL.
- // b) It also ignores non-BMP code points by casting to UChar!
+ // b) It also ignores non-BMP code points by casting to char16_t!
if(c<0) {
break;
}
}
}
-static UBool thaiWordToBytes(const UChar *s, int32_t length,
+static UBool thaiWordToBytes(const char16_t *s, int32_t length,
CharString &str, UErrorCode &errorCode) {
for(int32_t i=0; i<length; ++i) {
- UChar c=s[i];
+ char16_t c=s[i];
int32_t b=thaiCharToByte(c);
if(b>=0) {
str.append((char)b, errorCode);
const ULine *lines=perf.getCachedLines();
int32_t numLines=perf.getNumLines();
for(int32_t i=0; i<numLines; ++i) {
- const UChar *line=lines[i].name;
+ const char16_t *line=lines[i].name;
// Skip comment lines (start with a character below 'A').
if(line[0]<0x41) {
continue;
UNumberFormat *fFmt;
UnicodeString fPat;
UnicodeString fString;
- const UChar *fStr;
+ const char16_t *fStr;
int32_t fLen;
const char *fFile;
int fLine;
UNumberFormat *fFmt;
UnicodeString fPat;
UnicodeString fString;
- const UChar *fStr;
+ const char16_t *fStr;
int32_t fLen;
const char *fFile;
int fLine;
}
void warmup() {
fFmt = initFmt();
- UChar buf[100];
+ char16_t buf[100];
if(U_SUCCESS(setupStatus)) {
int32_t trial = unum_formatDouble(fFmt,fExpect, buf, 100, nullptr, &setupStatus);
if(!U_SUCCESS(setupStatus)
int32_t run() {
int32_t trial;
int i;
- UChar buf[100];
+ char16_t buf[100];
if(U_SUCCESS(setupStatus)) {
for(i=0;i<U_LOTS_OF_TIMES;i++){
trial = unum_formatDouble(fFmt,fExpect, buf, 100, nullptr, &setupStatus);
UNumberFormat *fFmt;
UnicodeString fPat;
UnicodeString fString;
- const UChar *fStr;
+ const char16_t *fStr;
int32_t fLen;
const char *fFile;
int fLine;
}
void warmup() {
fFmt = initFmt();
- UChar buf[100];
+ char16_t buf[100];
if(U_SUCCESS(setupStatus)) {
int32_t trial = unum_formatInt64(fFmt,fExpect, buf, 100, nullptr, &setupStatus);
if(!U_SUCCESS(setupStatus)
int32_t run() {
int32_t trial;
int i;
- UChar buf[100];
+ char16_t buf[100];
if(U_SUCCESS(setupStatus)) {
for(i=0;i<U_LOTS_OF_TIMES;i++){
trial = unum_formatInt64(fFmt,fExpect, buf, 100, nullptr, &setupStatus);
UNumberFormat *fFmt;
UnicodeString fPat;
UnicodeString fString;
- const UChar *fStr;
+ const char16_t *fStr;
int32_t fLen;
const char *fFile;
int fLine;
#define DO_NumFmtStringPieceTest(p,n,x) { NumFmtStringPieceTest t(p,n,x,__FILE__,__LINE__); runTestOn(t); }
// TODO: move, scope.
-static UChar pattern[] = { 0x23 }; // '#'
-static UChar strdot[] = { '2', '.', '0', 0 };
-static UChar strspc[] = { '2', ' ', 0 };
-static UChar strgrp[] = {'2',',','2','2','2', 0 };
-static UChar strbeng[] = {0x09E8,0x09E8,0x09E8,0x09E8, 0 };
+static char16_t pattern[] = { 0x23 }; // '#'
+static char16_t strdot[] = { '2', '.', '0', 0 };
+static char16_t strspc[] = { '2', ' ', 0 };
+static char16_t strgrp[] = {'2',',','2','2','2', 0 };
+static char16_t strbeng[] = {0x09E8,0x09E8,0x09E8,0x09E8, 0 };
UNumberFormat *NumParseTest_fmt;
// TODO: de-uglify.
-QuickTest(NumParseTest,{ static UChar pattern[] = { 0x23 }; NumParseTest_fmt = unum_open(UNUM_PATTERN_DECIMAL, pattern, 1, TEST_LOCALE, 0, &setupStatus); },{ int32_t i; static UChar str[] = { 0x31 };double val; for(i=0;i<U_LOTS_OF_TIMES;i++) { val=unum_parse(NumParseTest_fmt,str,1,nullptr,&setupStatus); } return i; },{unum_close(NumParseTest_fmt);})
+QuickTest(NumParseTest,{ static char16_t pattern[] = { 0x23 }; NumParseTest_fmt = unum_open(UNUM_PATTERN_DECIMAL, pattern, 1, TEST_LOCALE, 0, &setupStatus); },{ int32_t i; static char16_t str[] = { 0x31 };double val; for(i=0;i<U_LOTS_OF_TIMES;i++) { val=unum_parse(NumParseTest_fmt,str,1,nullptr,&setupStatus); } return i; },{unum_close(NumParseTest_fmt);})
-QuickTest(NumParseTestdot,{ static UChar pattern[] = { 0x23 }; NumParseTest_fmt = unum_open(UNUM_PATTERN_DECIMAL, pattern, 1, TEST_LOCALE, 0, &setupStatus); },{ int32_t i; double val; for(i=0;i<U_LOTS_OF_TIMES;i++) { val=unum_parse(NumParseTest_fmt,strdot,1,nullptr,&setupStatus); } return i; },{unum_close(NumParseTest_fmt);})
-QuickTest(NumParseTestspc,{ static UChar pattern[] = { 0x23 }; NumParseTest_fmt = unum_open(UNUM_PATTERN_DECIMAL, pattern, 1, TEST_LOCALE, 0, &setupStatus); },{ int32_t i; double val; for(i=0;i<U_LOTS_OF_TIMES;i++) { val=unum_parse(NumParseTest_fmt,strspc,1,nullptr,&setupStatus); } return i; },{unum_close(NumParseTest_fmt);})
-QuickTest(NumParseTestgrp,{ static UChar pattern[] = { 0x23 }; NumParseTest_fmt = unum_open(UNUM_PATTERN_DECIMAL, pattern, 1, TEST_LOCALE, 0, &setupStatus); },{ int32_t i; double val; for(i=0;i<U_LOTS_OF_TIMES;i++) { val=unum_parse(NumParseTest_fmt,strgrp,-1,nullptr,&setupStatus); } return i; },{unum_close(NumParseTest_fmt);})
+QuickTest(NumParseTestdot,{ static char16_t pattern[] = { 0x23 }; NumParseTest_fmt = unum_open(UNUM_PATTERN_DECIMAL, pattern, 1, TEST_LOCALE, 0, &setupStatus); },{ int32_t i; double val; for(i=0;i<U_LOTS_OF_TIMES;i++) { val=unum_parse(NumParseTest_fmt,strdot,1,nullptr,&setupStatus); } return i; },{unum_close(NumParseTest_fmt);})
+QuickTest(NumParseTestspc,{ static char16_t pattern[] = { 0x23 }; NumParseTest_fmt = unum_open(UNUM_PATTERN_DECIMAL, pattern, 1, TEST_LOCALE, 0, &setupStatus); },{ int32_t i; double val; for(i=0;i<U_LOTS_OF_TIMES;i++) { val=unum_parse(NumParseTest_fmt,strspc,1,nullptr,&setupStatus); } return i; },{unum_close(NumParseTest_fmt);})
+QuickTest(NumParseTestgrp,{ static char16_t pattern[] = { 0x23 }; NumParseTest_fmt = unum_open(UNUM_PATTERN_DECIMAL, pattern, 1, TEST_LOCALE, 0, &setupStatus); },{ int32_t i; double val; for(i=0;i<U_LOTS_OF_TIMES;i++) { val=unum_parse(NumParseTest_fmt,strgrp,-1,nullptr,&setupStatus); } return i; },{unum_close(NumParseTest_fmt);})
-QuickTest(NumParseTestbeng,{ static UChar pattern[] = { 0x23 }; NumParseTest_fmt = unum_open(UNUM_PATTERN_DECIMAL, pattern, 1, TEST_LOCALE, 0, &setupStatus); },{ int32_t i; double val; for(i=0;i<U_LOTS_OF_TIMES;i++) { val=unum_parse(NumParseTest_fmt,strbeng,-1,nullptr,&setupStatus); } return i; },{unum_close(NumParseTest_fmt);})
+QuickTest(NumParseTestbeng,{ static char16_t pattern[] = { 0x23 }; NumParseTest_fmt = unum_open(UNUM_PATTERN_DECIMAL, pattern, 1, TEST_LOCALE, 0, &setupStatus); },{ int32_t i; double val; for(i=0;i<U_LOTS_OF_TIMES;i++) { val=unum_parse(NumParseTest_fmt,strbeng,-1,nullptr,&setupStatus); } return i; },{unum_close(NumParseTest_fmt);})
UDateFormat *DateFormatTest_fmt = nullptr;
UDate sometime = 100000000.0;
-UChar onekbuf[1024];
+char16_t onekbuf[1024];
const int32_t onekbuf_len = UPRV_LENGTHOF(onekbuf);
#else
#define _UNICODE
typedef int DWORD;
-inline int FoldStringW(DWORD dwMapFlags, const UChar* lpSrcStr,int cchSrc, UChar* lpDestStr,int cchDest);
+inline int FoldStringW(DWORD dwMapFlags, const char16_t* lpSrcStr,int cchSrc, char16_t* lpDestStr,int cchDest);
#endif
class DateTimeRoundTripFunction : public UPerfFunction
}
-void NormalizerPerformanceTest::normalizeInput(ULine* dest,const UChar* src ,int32_t srcLen,UNormalizationMode mode, int32_t options){
+void NormalizerPerformanceTest::normalizeInput(ULine* dest,const char16_t* src ,int32_t srcLen,UNormalizationMode mode, int32_t options){
int32_t reqLen = 0;
UErrorCode status = U_ZERO_ERROR;
for(;;){
reqLen=unorm_normalize(src,srcLen,mode, options,nullptr,0,&status);
if(status==U_BUFFER_OVERFLOW_ERROR){
status=U_ZERO_ERROR;
- dest->name = new UChar[reqLen+1];
+ dest->name = new char16_t[reqLen+1];
reqLen= unorm_normalize(src,srcLen,mode, options,dest->name,reqLen+1,&status);
dest->len=reqLen;
break;
}
}
}
-UChar* NormalizerPerformanceTest::normalizeInput(int32_t& len, const UChar* src ,int32_t srcLen,UNormalizationMode mode, int32_t options){
+char16_t* NormalizerPerformanceTest::normalizeInput(int32_t& len, const char16_t* src ,int32_t srcLen,UNormalizationMode mode, int32_t options){
int32_t reqLen = 0;
UErrorCode status = U_ZERO_ERROR;
- UChar* dest = nullptr;
+ char16_t* dest = nullptr;
for(;;){
/* pure pre-flight */
reqLen=unorm_normalize(src,srcLen,mode, options,nullptr,0,&status);
if(status==U_BUFFER_OVERFLOW_ERROR){
status=U_ZERO_ERROR;
- dest = new UChar[reqLen+1];
+ dest = new char16_t[reqLen+1];
reqLen= unorm_normalize(src,srcLen,mode, options,dest,reqLen+1,&status);
len=reqLen;
break;
}
}else if(bulk_mode){
int32_t srcLen = 0;
- const UChar* src = getBuffer(srcLen,status);
+ const char16_t* src = getBuffer(srcLen,status);
NFDBufferLen = 0;
NFCBufferLen = 0;
#else
#define _UNICODE
typedef int DWORD;
-inline int FoldStringW(DWORD dwMapFlags, const UChar* lpSrcStr,int cchSrc, UChar* lpDestStr,int cchDest);
+inline int FoldStringW(DWORD dwMapFlags, const char16_t* lpSrcStr,int cchSrc, char16_t* lpDestStr,int cchDest);
#endif
#define DEST_BUFFER_CAPACITY 6000
-typedef int32_t (*NormFn)(const UChar* src,int32_t srcLen, UChar* dest,int32_t dstLen, int32_t options, UErrorCode* status);
-typedef int32_t (*QuickCheckFn)(const UChar* src,int32_t srcLen, UNormalizationMode mode, int32_t options, UErrorCode* status);
+typedef int32_t (*NormFn)(const char16_t* src,int32_t srcLen, char16_t* dest,int32_t dstLen, int32_t options, UErrorCode* status);
+typedef int32_t (*QuickCheckFn)(const char16_t* src,int32_t srcLen, UNormalizationMode mode, int32_t options, UErrorCode* status);
class QuickCheckPerfFunction : public UPerfFunction{
private:
UNormalizationMode mode;
int32_t retVal;
UBool uselen;
- const UChar* src;
+ const char16_t* src;
int32_t srcLen;
UBool line_mode;
int32_t options;
srcLen = 0;
line_mode = true;
}
- QuickCheckPerfFunction(QuickCheckFn func, const UChar* source,int32_t sourceLen, UNormalizationMode _mode, int32_t opts, UBool _uselen) : options(opts) {
+ QuickCheckPerfFunction(QuickCheckFn func, const char16_t* source,int32_t sourceLen, UNormalizationMode _mode, int32_t opts, UBool _uselen) : options(opts) {
fn = func;
lines = nullptr;
numLines = 0;
private:
ULine* lines;
int32_t numLines;
- UChar dest[DEST_BUFFER_CAPACITY];
- UChar* pDest;
+ char16_t dest[DEST_BUFFER_CAPACITY];
+ char16_t* pDest;
int32_t destLen;
NormFn fn;
int32_t retVal;
UBool uselen;
- const UChar* src;
+ const char16_t* src;
int32_t srcLen;
UBool line_mode;
int32_t options;
srcLen = 0;
line_mode = true;
}
- NormPerfFunction(NormFn func, int32_t opts, const UChar* source,int32_t sourceLen,UBool _uselen) : options(opts) {
+ NormPerfFunction(NormFn func, int32_t opts, const char16_t* source,int32_t sourceLen,UBool _uselen) : options(opts) {
fn = func;
lines = nullptr;
numLines = 0;
uselen = _uselen;
destLen = sourceLen*3;
- pDest = (UChar*) malloc(destLen * U_SIZEOF_UCHAR);
+ pDest = (char16_t*) malloc(destLen * U_SIZEOF_UCHAR);
src = source;
srcLen = sourceLen;
line_mode = false;
private:
ULine* NFDFileLines;
ULine* NFCFileLines;
- UChar* NFDBuffer;
- UChar* NFCBuffer;
- UChar* origBuffer;
+ char16_t* NFDBuffer;
+ char16_t* NFCBuffer;
+ char16_t* origBuffer;
int32_t origBufferLen;
int32_t NFDBufferLen;
int32_t NFCBufferLen;
int32_t options;
- void normalizeInput(ULine* dest,const UChar* src ,int32_t srcLen,UNormalizationMode mode, int32_t options);
- UChar* normalizeInput(int32_t& len, const UChar* src ,int32_t srcLen,UNormalizationMode mode, int32_t options);
+ void normalizeInput(ULine* dest,const char16_t* src ,int32_t srcLen,UNormalizationMode mode, int32_t options);
+ char16_t* normalizeInput(int32_t& len, const char16_t* src ,int32_t srcLen,UNormalizationMode mode, int32_t options);
public:
#if (U_ICU_VERSION_MAJOR_NUM > 1 ) || ((U_ICU_VERSION_MAJOR_NUM == 1 )&&(U_ICU_VERSION_MINOR_NUM > 8) && (U_ICU_VERSION_PATCHLEVEL_NUM >=1))
-int32_t ICUNormNFD(const UChar* src, int32_t srcLen,UChar* dest, int32_t dstLen, int32_t options, UErrorCode* status) {
+int32_t ICUNormNFD(const char16_t* src, int32_t srcLen,char16_t* dest, int32_t dstLen, int32_t options, UErrorCode* status) {
return unorm_normalize(src,srcLen,UNORM_NFD, options,dest,dstLen,status);
}
-int32_t ICUNormNFC(const UChar* src, int32_t srcLen,UChar* dest, int32_t dstLen, int32_t options, UErrorCode* status) {
+int32_t ICUNormNFC(const char16_t* src, int32_t srcLen,char16_t* dest, int32_t dstLen, int32_t options, UErrorCode* status) {
return unorm_normalize(src,srcLen,UNORM_NFC, options,dest,dstLen,status);
}
-int32_t ICUNormNFKD(const UChar* src, int32_t srcLen,UChar* dest, int32_t dstLen, int32_t options, UErrorCode* status) {
+int32_t ICUNormNFKD(const char16_t* src, int32_t srcLen,char16_t* dest, int32_t dstLen, int32_t options, UErrorCode* status) {
return unorm_normalize(src,srcLen,UNORM_NFKD, options,dest,dstLen,status);
}
-int32_t ICUNormNFKC(const UChar* src, int32_t srcLen,UChar* dest, int32_t dstLen, int32_t options, UErrorCode* status) {
+int32_t ICUNormNFKC(const char16_t* src, int32_t srcLen,char16_t* dest, int32_t dstLen, int32_t options, UErrorCode* status) {
return unorm_normalize(src,srcLen,UNORM_NFKC, options,dest,dstLen,status);
}
-int32_t ICUNormFCD(const UChar* src, int32_t srcLen,UChar* dest, int32_t dstLen, int32_t options, UErrorCode* status) {
+int32_t ICUNormFCD(const char16_t* src, int32_t srcLen,char16_t* dest, int32_t dstLen, int32_t options, UErrorCode* status) {
return unorm_normalize(src,srcLen,UNORM_FCD, options,dest,dstLen,status);
}
-int32_t ICUQuickCheck(const UChar* src,int32_t srcLen, UNormalizationMode mode, int32_t options, UErrorCode* status){
+int32_t ICUQuickCheck(const char16_t* src,int32_t srcLen, UNormalizationMode mode, int32_t options, UErrorCode* status){
#if (U_ICU_VERSION_MAJOR_NUM > 2 ) || ((U_ICU_VERSION_MAJOR_NUM == 2 )&&(U_ICU_VERSION_MINOR_NUM >= 6))
return unorm_quickCheckWithOptions(src,srcLen,mode, options, status);
#else
return unorm_quickCheck(src,srcLen,mode,status);
#endif
}
-int32_t ICUIsNormalized(const UChar* src,int32_t srcLen, UNormalizationMode mode, int32_t options, UErrorCode* status){
+int32_t ICUIsNormalized(const char16_t* src,int32_t srcLen, UNormalizationMode mode, int32_t options, UErrorCode* status){
return unorm_isNormalized(src,srcLen,mode,status);
}
#else
-int32_t ICUNormNFD(const UChar* src, int32_t srcLen,UChar* dest, int32_t dstLen, int32_t options, UErrorCode* status) {
+int32_t ICUNormNFD(const char16_t* src, int32_t srcLen,char16_t* dest, int32_t dstLen, int32_t options, UErrorCode* status) {
return unorm_normalize(src,srcLen,UCOL_DECOMP_CAN, options,dest,dstLen,status);
}
-int32_t ICUNormNFC(const UChar* src, int32_t srcLen,UChar* dest, int32_t dstLen, int32_t options, UErrorCode* status) {
+int32_t ICUNormNFC(const char16_t* src, int32_t srcLen,char16_t* dest, int32_t dstLen, int32_t options, UErrorCode* status) {
return unorm_normalize(src,srcLen,UCOL_COMPOSE_CAN, options,dest,dstLen,status);
}
-int32_t ICUNormNFKD(const UChar* src, int32_t srcLen,UChar* dest, int32_t dstLen, int32_t options, UErrorCode* status) {
+int32_t ICUNormNFKD(const char16_t* src, int32_t srcLen,char16_t* dest, int32_t dstLen, int32_t options, UErrorCode* status) {
return unorm_normalize(src,srcLen,UCOL_DECOMP_COMPAT, options,dest,dstLen,status);
}
-int32_t ICUNormNFKC(const UChar* src, int32_t srcLen,UChar* dest, int32_t dstLen, int32_t options, UErrorCode* status) {
+int32_t ICUNormNFKC(const char16_t* src, int32_t srcLen,char16_t* dest, int32_t dstLen, int32_t options, UErrorCode* status) {
return unorm_normalize(src,srcLen,UCOL_COMPOSE_COMPAT, options,dest,dstLen,status);
}
-int32_t ICUNormFCD(const UChar* src, int32_t srcLen,UChar* dest, int32_t dstLen, int32_t options, UErrorCode* status) {
+int32_t ICUNormFCD(const char16_t* src, int32_t srcLen,char16_t* dest, int32_t dstLen, int32_t options, UErrorCode* status) {
return unorm_normalize(src,srcLen,UNORM_FCD, options,dest,dstLen,status);
}
-int32_t ICUQuickCheck(const UChar* src,int32_t srcLen, UNormalizationMode mode, int32_t options, UErrorCode* status){
+int32_t ICUQuickCheck(const char16_t* src,int32_t srcLen, UNormalizationMode mode, int32_t options, UErrorCode* status){
return unorm_quickCheck(src,srcLen,mode,status);
}
-int32_t ICUIsNormalized(const UChar* src,int32_t srcLen, UNormalizationMode mode, int32_t options, UErrorCode* status){
+int32_t ICUIsNormalized(const char16_t* src,int32_t srcLen, UNormalizationMode mode, int32_t options, UErrorCode* status){
return 0;
}
#endif
#if U_PLATFORM_HAS_WIN32_API
-int32_t WinNormNFD(const UChar* src, int32_t srcLen, UChar* dest, int32_t dstLen, int32_t options, UErrorCode* status) {
+int32_t WinNormNFD(const char16_t* src, int32_t srcLen, char16_t* dest, int32_t dstLen, int32_t options, UErrorCode* status) {
return FoldStringW(MAP_COMPOSITE, toOldUCharPtr(src),srcLen, toOldUCharPtr(dest),dstLen);
}
-int32_t WinNormNFC(const UChar* src, int32_t srcLen, UChar* dest, int32_t dstLen, int32_t options, UErrorCode* status) {
+int32_t WinNormNFC(const char16_t* src, int32_t srcLen, char16_t* dest, int32_t dstLen, int32_t options, UErrorCode* status) {
return FoldStringW(MAP_PRECOMPOSED, toOldUCharPtr(src),srcLen, toOldUCharPtr(dest),dstLen);
}
-int32_t WinNormNFKD(const UChar* src, int32_t srcLen, UChar* dest, int32_t dstLen, int32_t options, UErrorCode* status) {
+int32_t WinNormNFKD(const char16_t* src, int32_t srcLen, char16_t* dest, int32_t dstLen, int32_t options, UErrorCode* status) {
return FoldStringW(MAP_COMPOSITE+MAP_FOLDCZONE, toOldUCharPtr(src),srcLen, toOldUCharPtr(dest),dstLen);
}
-int32_t WinNormNFKC(const UChar* src, int32_t srcLen, UChar* dest, int32_t dstLen, int32_t options, UErrorCode* status) {
+int32_t WinNormNFKC(const char16_t* src, int32_t srcLen, char16_t* dest, int32_t dstLen, int32_t options, UErrorCode* status) {
return FoldStringW(MAP_FOLDCZONE, toOldUCharPtr(src),srcLen, toOldUCharPtr(dest),dstLen);
}
#else
-int32_t WinNormNFD(const UChar* src, int32_t srcLen, UChar* dest, int32_t dstLen, int32_t options, UErrorCode* status) {
+int32_t WinNormNFD(const char16_t* src, int32_t srcLen, char16_t* dest, int32_t dstLen, int32_t options, UErrorCode* status) {
return 0 ;
}
-int32_t WinNormNFC(const UChar* src, int32_t srcLen, UChar* dest, int32_t dstLen, int32_t options, UErrorCode* status) {
+int32_t WinNormNFC(const char16_t* src, int32_t srcLen, char16_t* dest, int32_t dstLen, int32_t options, UErrorCode* status) {
return 0;
}
-int32_t WinNormNFKD(const UChar* src, int32_t srcLen, UChar* dest, int32_t dstLen, int32_t options, UErrorCode* status) {
+int32_t WinNormNFKD(const char16_t* src, int32_t srcLen, char16_t* dest, int32_t dstLen, int32_t options, UErrorCode* status) {
return 0;
}
-int32_t WinNormNFKC(const UChar* src, int32_t srcLen, UChar* dest, int32_t dstLen, int32_t options, UErrorCode* status) {
+int32_t WinNormNFKC(const char16_t* src, int32_t srcLen, char16_t* dest, int32_t dstLen, int32_t options, UErrorCode* status) {
return 0;
}
#endif
return result;
}
- static const UChar *const latin1;
- static const UChar *const lowercaseLatin1;
- static const UChar *const ascii;
- static const UChar *const japanese;
- static const UChar *const arabic;
+ static const char16_t *const latin1;
+ static const char16_t *const lowercaseLatin1;
+ static const char16_t *const ascii;
+ static const char16_t *const japanese;
+ static const char16_t *const arabic;
};
-const UChar *const CommonChars::latin1 =
+const char16_t *const CommonChars::latin1 =
// Goethe’s Bergschloß in normal sentence case.
u"Da droben auf jenem Berge, da steht ein altes Schloß, "
u"wo hinter Toren und Türen sonst lauerten Ritter und Roß.\n"
u"Und Knapp und Kellnerin glänzen als Herren weit und breit; "
u"sie nimmt sich zum Kredenzen und er zum Danke sich Zeit.\n";
-const UChar *const CommonChars::lowercaseLatin1 =
+const char16_t *const CommonChars::lowercaseLatin1 =
// Goethe’s Bergschloß in all lowercase
u"da droben auf jenem berge, da steht ein altes schloß, "
u"wo hinter toren und türen sonst lauerten ritter und roß.\n"
u"und knapp und kellnerin glänzen als herren weit und breit; "
u"sie nimmt sich zum kredenzen und er zum danke sich zeit.\n";
-const UChar *const CommonChars::ascii =
+const char16_t *const CommonChars::ascii =
// Goethe’s Bergschloß in normal sentence case but ASCII-fied
u"Da droben auf jenem Berge, da steht ein altes Schloss, "
u"wo hinter Toren und Tueren sonst lauerten Ritter und Ross.\n"
u"Und Knapp und Kellnerin glaenzen als Herren weit und breit; "
u"sie nimmt sich zum Kredenzen und er zum Danke sich Zeit.\n";
-const UChar *const CommonChars::japanese =
+const char16_t *const CommonChars::japanese =
// Ame ni mo makezu = Be not Defeated by the Rain, by Kenji Miyazawa.
u"雨にもまけず風にもまけず雪にも夏の暑さにもまけぬ"
u"丈夫なからだをもち慾はなく決して瞋らず"
u"さむさのなつはおろおろあるきみんなにでくのぼうとよばれ"
u"ほめられもせずくにもされずそういうものにわたしはなりたい";
-const UChar *const CommonChars::arabic =
+const char16_t *const CommonChars::arabic =
// Some Arabic for variety. "What is Unicode?"
// http://www.unicode.org/standard/translations/arabic.html
u"تتعامل الحواسيب بالأسام مع الأرقام فقط، "
private:
const Normalizer2 &norm2;
UnicodeString src;
- const UChar *s;
+ const char16_t *s;
UnicodeString dest;
};
start = ubrk_preceding(brk, 1000);
end = ubrk_following(brk, start);
pttrnLen = end - start;
- UChar* temp = (UChar*)malloc(sizeof(UChar)*(pttrnLen));
+ char16_t* temp = (char16_t*)malloc(sizeof(char16_t)*(pttrnLen));
for (int i = 0; i < pttrnLen; i++) {
temp[i] = src[start++];
}
start = 0;
for(end = start; ; end += 1) {
- UChar ch = src[end];
+ char16_t ch = src[end];
if (ch == 0x000A || ch == 0x000D || ch == 0x2028) {
break;
}
pttrnLen = end - start;
- UChar* temp = (UChar*)malloc(sizeof(UChar)*(pttrnLen));
+ char16_t* temp = (char16_t*)malloc(sizeof(char16_t)*(pttrnLen));
for (int i = 0; i < pttrnLen; i++) {
temp[i] = src[start++];
}
#include <stdlib.h>
#include <stdio.h>
-typedef void (*StrSrchFn)(UStringSearch* srch, const UChar* src,int32_t srcLen, const UChar* pttrn, int32_t pttrnLen, UErrorCode* status);
+typedef void (*StrSrchFn)(UStringSearch* srch, const char16_t* src,int32_t srcLen, const char16_t* pttrn, int32_t pttrnLen, UErrorCode* status);
class StringSearchPerfFunction : public UPerfFunction {
private:
StrSrchFn fn;
- const UChar* src;
+ const char16_t* src;
int32_t srcLen;
- const UChar* pttrn;
+ const char16_t* pttrn;
int32_t pttrnLen;
UStringSearch* srch;
return (long) srcLen;
}
- StringSearchPerfFunction(StrSrchFn func, UStringSearch* search, const UChar* source,int32_t sourceLen, const UChar* pattern, int32_t patternLen) {
+ StringSearchPerfFunction(StrSrchFn func, UStringSearch* search, const char16_t* source,int32_t sourceLen, const char16_t* pattern, int32_t patternLen) {
fn = func;
src = source;
srcLen = sourceLen;
class StringSearchPerformanceTest : public UPerfTest {
private:
- const UChar* src;
+ const char16_t* src;
int32_t srcLen;
- UChar* pttrn;
+ char16_t* pttrn;
int32_t pttrnLen;
UStringSearch* srch;
};
-void ICUForwardSearch(UStringSearch *srch, const UChar* source, int32_t sourceLen, const UChar* pattern, int32_t patternLen, UErrorCode* status) {
+void ICUForwardSearch(UStringSearch *srch, const char16_t* source, int32_t sourceLen, const char16_t* pattern, int32_t patternLen, UErrorCode* status) {
int32_t match;
match = usearch_first(srch, status);
}
}
-void ICUBackwardSearch(UStringSearch *srch, const UChar* source, int32_t sourceLen, const UChar* pattern, int32_t patternLen, UErrorCode* status) {
+void ICUBackwardSearch(UStringSearch *srch, const char16_t* source, int32_t sourceLen, const char16_t* pattern, int32_t patternLen, UErrorCode* status) {
int32_t match;
match = usearch_last(srch, status);
class ICUBreakFunction : public UPerfFunction {
protected:
BreakIterator *m_brkIt_;
- const UChar *m_file_;
+ const char16_t *m_file_;
int32_t m_fileLen_;
int32_t m_noBreaks_;
UErrorCode m_status_;
public:
- ICUBreakFunction(const char *locale, const char *mode, const UChar *file, int32_t file_len) :
+ ICUBreakFunction(const char *locale, const char *mode, const char16_t *file, int32_t file_len) :
m_brkIt_(nullptr),
m_file_(file),
m_fileLen_(file_len),
class ICUIsBound : public ICUBreakFunction {
public:
- ICUIsBound(const char *locale, const char *mode, const UChar *file, int32_t file_len) :
+ ICUIsBound(const char *locale, const char *mode, const char16_t *file, int32_t file_len) :
ICUBreakFunction(locale, mode, file, file_len)
{
m_noBreaks_ = 0;
class ICUForward : public ICUBreakFunction {
public:
- ICUForward(const char *locale, const char *mode, const UChar *file, int32_t file_len) :
+ ICUForward(const char *locale, const char *mode, const char16_t *file, int32_t file_len) :
ICUBreakFunction(locale, mode, file, file_len)
{
m_noBreaks_ = 0;
class BreakIteratorPerformanceTest : public UPerfTest {
private:
const char* m_mode_;
- const UChar* m_file_;
+ const char16_t* m_file_;
int32_t m_fileLen_;
public:
//DWORD gWinLCID;
BreakIterator *brkit = nullptr;
-UChar *text = nullptr;
+char16_t *text = nullptr;
int32_t textSize = 0;
public:
UCharFile(const char *fileName);
~UCharFile();
- UChar get();
+ char16_t get();
UBool eof() {return fEof;};
UBool error() {return fError;};
int32_t size() { return fFileSize; };
const char *fName;
UBool fEof;
UBool fError;
- UChar fPending2ndSurrogate;
+ char16_t fPending2ndSurrogate;
int32_t fFileSize;
enum {UTF16LE, UTF16BE, UTF8} fEncoding;
-UChar UCharFile::get() {
- UChar c;
+char16_t UCharFile::get() {
+ char16_t c;
switch (fEncoding) {
case UTF16LE:
{
break;
}
- int ch = fgetc(fFile); // Note: c and ch are separate cause eof test doesn't work on UChar type.
+ int ch = fgetc(fFile); // Note: c and ch are separate cause eof test doesn't work on char16_t type.
if (ch == EOF) {
c = 0;
fEof = true;
i = 0;
uint32_t cp;
U8_NEXT_UNSAFE(bytes, i, cp);
- c = (UChar)cp;
+ c = (char16_t)cp;
if (cp >= 0x10000) {
// The code point needs to be broken up into a utf-16 surrogate pair.
// Process first half this time through the main loop, and
// remember the other half for the next time through.
- UChar utf16Buf[3];
+ char16_t utf16Buf[3];
i = 0;
UTF16_APPEND_CHAR_UNSAFE(utf16Buf, i, cp);
fPending2ndSurrogate = utf16Buf[1];
int32_t bufSize = 0;
int32_t charCount = 0;
if(fileSize != -1) {
- text = (UChar *)malloc(fileSize*sizeof(UChar));
+ text = (char16_t *)malloc(fileSize*sizeof(char16_t));
bufSize = fileSize;
} else {
- text = (UChar *)malloc(STARTSIZE*sizeof(UChar));
+ text = (char16_t *)malloc(STARTSIZE*sizeof(char16_t));
bufSize = STARTSIZE;
}
if(text == nullptr) {
// (The number of bytes read from file per loop iteration depends on external encoding.)
for (;;) {
- UChar c = f.get();
+ char16_t c = f.get();
if(f.eof()) {
break;
}
// We now have a good UTF-16 value in c.
text[charCount++] = c;
if(charCount == bufSize) {
- text = (UChar *)realloc(text, 2*bufSize*sizeof(UChar));
+ text = (char16_t *)realloc(text, 2*bufSize*sizeof(char16_t));
if(text == nullptr) {
fprintf(stderr, "Reallocating buffer failed\n");
exit(-1);
virtual UBool contains(UChar32 c) const = 0;
- virtual int32_t span(const UChar *s, int32_t length);
+ virtual int32_t span(const char16_t *s, int32_t length);
- virtual int32_t spanNot(const UChar *s, int32_t length);
+ virtual int32_t spanNot(const char16_t *s, int32_t length);
- virtual int32_t spanUTF8(const UChar *s, int32_t length);
+ virtual int32_t spanUTF8(const char16_t *s, int32_t length);
- virtual int32_t spanNotUTF8(const UChar *s, int32_t length);
+ virtual int32_t spanNotUTF8(const char16_t *s, int32_t length);
virtual UClassID getDynamicClassID(void) const;
};
if(verbose) {
printf("code points:%ld len16:%ld len8:%ld spans:%ld "
- "cp/span:%.3g UChar/span:%.3g B/span:%.3g B/cp:%.3g\n",
+ "cp/span:%.3g char16_t/span:%.3g B/span:%.3g B/cp:%.3g\n",
(long)countInputCodePoints, (long)bufferLen, (long)utf8Length, (long)spanCount,
(double)countInputCodePoints/spanCount, (double)bufferLen/spanCount, (double)utf8Length/spanCount,
(double)utf8Length/countInputCodePoints);
// If the very first character is in the set, then one additional
// not-span is counted.
void countSpans() {
- const UChar *s=getBuffer();
+ const char16_t *s=getBuffer();
int32_t length=getBufferLen();
int32_t i=0;
UBool tf=false;
++spanCount;
}
}
- int32_t span(const UChar *s, int32_t length, int32_t start, UBool tf) const {
+ int32_t span(const char16_t *s, int32_t length, int32_t start, UBool tf) const {
UChar32 c;
int32_t prev;
while((prev=start)<length) {
return prev;
}
- const UChar *getBuffer() const { return buffer; }
+ const char16_t *getBuffer() const { return buffer; }
int32_t getBufferLen() const { return bufferLen; }
char *utf8;
}
virtual void call(UErrorCode* pErrorCode) {
const UnicodeSet &set=testcase.set;
- const UChar *s=testcase.getBuffer();
+ const char16_t *s=testcase.getBuffer();
int32_t length=testcase.getBufferLen();
int32_t count=0;
int32_t i=0;
(long)count, (long)testcase.spanCount);
}
}
- static int32_t span(const UnicodeSet &set, const UChar *s, int32_t length, UBool tf) {
+ static int32_t span(const UnicodeSet &set, const char16_t *s, int32_t length, UBool tf) {
UChar32 c;
int32_t start=0, prev;
while((prev=start)<length) {
SpanUTF16(const UnicodeSetPerformanceTest &testcase) : Command(testcase) {
// Verify that the frozen set is equal to the unfrozen one.
UnicodeSet set;
- UChar utf16[2];
+ char16_t utf16[2];
UChar32 c, c2;
for(c=0; c<=0xffff; ++c) {
- utf16[0]=(UChar)c;
+ utf16[0]=(char16_t)c;
if(testcase.set.span(utf16, 1, USET_SPAN_CONTAINED)>0) {
set.add(c);
}
}
for(c=0xd800; c<=0xdbff; ++c) {
- utf16[0]=(UChar)c;
+ utf16[0]=(char16_t)c;
for(c2=0xdc00; c2<=0xdfff; ++c2) {
- utf16[1]=(UChar)c2;
+ utf16[1]=(char16_t)c2;
if(testcase.set.span(utf16, 2, USET_SPAN_CONTAINED)>0) {
set.add(U16_GET_SUPPLEMENTARY(c, c2));
}
}
virtual void call(UErrorCode* pErrorCode) {
const UnicodeSet &set=testcase.set;
- const UChar *s=testcase.getBuffer();
+ const char16_t *s=testcase.getBuffer();
int32_t length=testcase.getBufferLen();
int32_t count=0;
int32_t i=0;
SpanBackUTF16(const UnicodeSetPerformanceTest &testcase) : Command(testcase) {
// Verify that the frozen set is equal to the unfrozen one.
UnicodeSet set;
- UChar utf16[2];
+ char16_t utf16[2];
UChar32 c, c2;
for(c=0; c<=0xffff; ++c) {
- utf16[0]=(UChar)c;
+ utf16[0]=(char16_t)c;
if(testcase.set.spanBack(utf16, 1, USET_SPAN_CONTAINED)==0) {
set.add(c);
}
}
for(c=0xd800; c<=0xdbff; ++c) {
- utf16[0]=(UChar)c;
+ utf16[0]=(char16_t)c;
for(c2=0xdc00; c2<=0xdfff; ++c2) {
- utf16[1]=(UChar)c2;
+ utf16[1]=(char16_t)c2;
if(testcase.set.spanBack(utf16, 2, USET_SPAN_CONTAINED)==0) {
set.add(U16_GET_SUPPLEMENTARY(c, c2));
}
}
virtual void call(UErrorCode* pErrorCode) {
const UnicodeSet &set=testcase.set;
- const UChar *s=testcase.getBuffer();
+ const char16_t *s=testcase.getBuffer();
int32_t length=testcase.getBufferLen();
int32_t count=0;
/*
filelines_ = new ULine[numLines];
for (int i =0; i < numLines; i++) {
len = filelines[i].len;
- filelines_[i].name = new UChar[len];
+ filelines_[i].name = new char16_t[len];
filelines_[i].len = len;
memcpy(filelines_[i].name, filelines[i].name, len * U_SIZEOF_UCHAR);
}
}else if(bulk_mode){
int32_t srcLen = 0;
- const UChar* src = getBuffer(srcLen,status);
+ const char16_t* src = getBuffer(srcLen,status);
if(U_FAILURE(status)){
fprintf(stderr, "FAILED to read buffer from file and create UPerfTest object. Error: %s\n", u_errorName(status));
return;
}
- StrBuffer = new UChar[srcLen];
+ StrBuffer = new char16_t[srcLen];
StrBufferLen = srcLen;
memcpy(StrBuffer, src, srcLen * U_SIZEOF_UCHAR);
//#define LOOPS 10
#define catenate_STRLEN 2
-const UChar uTESTCHAR1 = 'a';
+const char16_t uTESTCHAR1 = 'a';
const wchar_t wTESTCHAR1 = 'a';
const UnicodeString uEMPTY;
const stlstring sEMPTY;
enum FnType { Fn_ICU, Fn_STD };
typedef FnType FnType;
-typedef void (*ICUStringPerfFn)(const UChar* src,int32_t srcLen, UnicodeString s0);
+typedef void (*ICUStringPerfFn)(const char16_t* src,int32_t srcLen, UnicodeString s0);
typedef void (*StdStringPerfFn)(const wchar_t* src,int32_t srcLen, stlstring s0);
prepareLinesForStd();
}
- StringPerfFunction(ICUStringPerfFn func, UChar* source, int32_t sourceLen, UBool uselen)
+ StringPerfFunction(ICUStringPerfFn func, char16_t* source, int32_t sourceLen, UBool uselen)
{
fn1_ = func;
numLines_=0;
uselen_=uselen;
line_mode_=false;
- src_ = new UChar[sourceLen];
+ src_ = new char16_t[sourceLen];
memcpy(src_, source, sourceLen * U_SIZEOF_UCHAR);
srcLen_ = sourceLen;
wsrc_ = nullptr;
sbulk_=nullptr;
}
- StringPerfFunction(StdStringPerfFn func, UChar* source, int32_t sourceLen, UBool uselen)
+ StringPerfFunction(StdStringPerfFn func, char16_t* source, int32_t sourceLen, UBool uselen)
{
fn2_ = func;
numLines_=0;
uselen_=uselen;
line_mode_=false;
- src_ = new UChar[sourceLen];
+ src_ = new char16_t[sourceLen];
memcpy(src_, source, sourceLen * U_SIZEOF_UCHAR);
srcLen_ = sourceLen;
fnType_ = Fn_STD;
{
UErrorCode err=U_ZERO_ERROR;
- const UChar* uSrc = src_;
+ const char16_t* uSrc = src_;
int32_t uSrcLen = srcLen_;
wchar_t* wDest = nullptr;
int32_t wDestLen = 0;
int32_t numLines_;
UBool uselen_;
- UChar* src_;
+ char16_t* src_;
int32_t srcLen_;
wchar_t* wsrc_;
int32_t wsrcLen_;
private:
long COUNT_;
ULine* filelines_;
- UChar* StrBuffer;
+ char16_t* StrBuffer;
int32_t StrBufferLen;
};
-inline void ctor(const UChar* src,int32_t srcLen, UnicodeString s0)
+inline void ctor(const char16_t* src,int32_t srcLen, UnicodeString s0)
{
UnicodeString a;
}
-inline void ctor1(const UChar* src,int32_t srcLen, UnicodeString s0)
+inline void ctor1(const char16_t* src,int32_t srcLen, UnicodeString s0)
{
UnicodeString b(uTESTCHAR1);
}
-inline void ctor2(const UChar* src,int32_t srcLen, UnicodeString s0)
+inline void ctor2(const char16_t* src,int32_t srcLen, UnicodeString s0)
{
UnicodeString c(uEMPTY);
}
-inline void ctor3(const UChar* src,int32_t srcLen, UnicodeString s0)
+inline void ctor3(const char16_t* src,int32_t srcLen, UnicodeString s0)
{
UnicodeString d(src,srcLen);
}
-inline UnicodeString icu_assign_helper(const UChar* src,int32_t srcLen)
+inline UnicodeString icu_assign_helper(const char16_t* src,int32_t srcLen)
{
if (srcLen==-1) { return src;}
else { return UnicodeString(src, srcLen);}
}
-inline void assign(const UChar* src,int32_t srcLen, UnicodeString s0)
+inline void assign(const char16_t* src,int32_t srcLen, UnicodeString s0)
{
unistr = icu_assign_helper(src,srcLen);
}
-inline void assign1(const UChar* src,int32_t srcLen, UnicodeString s0)
+inline void assign1(const char16_t* src,int32_t srcLen, UnicodeString s0)
{
unistr.setTo(src, srcLen);
}
-inline void assign2(const UChar* src,int32_t srcLen, UnicodeString s0)
+inline void assign2(const char16_t* src,int32_t srcLen, UnicodeString s0)
{
unistr = s0;
}
-inline void getch(const UChar* src,int32_t srcLen, UnicodeString s0)
+inline void getch(const char16_t* src,int32_t srcLen, UnicodeString s0)
{
s0.charAt(0);
}
-inline void catenate(const UChar* src,int32_t srcLen, UnicodeString s0)
+inline void catenate(const char16_t* src,int32_t srcLen, UnicodeString s0)
{
UTimer mystart, mystop;
utimer_getTime(&mystart);
volatile int scan_idx;
U_STRING_DECL(SCAN1, "123", 3);
-inline void scan(const UChar* src,int32_t srcLen, UnicodeString s0)
+inline void scan(const char16_t* src,int32_t srcLen, UnicodeString s0)
{
- UChar c='.';
+ char16_t c='.';
scan_idx = uScan_STRING.indexOf(c);
}
-inline void scan1(const UChar* src,int32_t srcLen, UnicodeString s0)
+inline void scan1(const char16_t* src,int32_t srcLen, UnicodeString s0)
{
scan_idx = uScan_STRING.indexOf(SCAN1,3);
}
-inline void scan2(const UChar* src,int32_t srcLen, UnicodeString s0)
+inline void scan2(const char16_t* src,int32_t srcLen, UnicodeString s0)
{
- UChar c1='s';
- UChar c2='m';
+ char16_t c1='s';
+ char16_t c2='m';
scan_idx = uScan_STRING.indexOf(c1);
scan_idx = uScan_STRING.indexOf(c2);
}
#define OUTPUT_CAPACITY INPUT_CAPACITY
static char utf8[INPUT_CAPACITY];
-static UChar pivot[INTERMEDIATE_CAPACITY];
+static char16_t pivot[INTERMEDIATE_CAPACITY];
-static UChar output[OUTPUT_CAPACITY];
+static char16_t output[OUTPUT_CAPACITY];
static char intermediate[OUTPUT_CAPACITY];
static int32_t utf8Length, encodedLength, outputLength, countInputCodePoints;
virtual UPerfFunction* runIndexedTest(int32_t index, UBool exec, const char* &name, char* par = nullptr);
- const UChar *getBuffer() const { return buffer; }
+ const char16_t *getBuffer() const { return buffer; }
int32_t getBufferLen() const { return bufferLen; }
const char *charset;
static void U_CALLCONV
fromUCallback(const void *context,
UConverterFromUnicodeArgs *fromUArgs,
- const UChar *codeUnits,
+ const char16_t *codeUnits,
int32_t length,
UChar32 codePoint,
UConverterCallbackReason reason,
}
const UtfPerformanceTest &testcase;
- const UChar *input;
+ const char16_t *input;
int32_t inputLength;
UErrorCode errorCode;
UConverter *cnv;
}
}
virtual void call(UErrorCode* pErrorCode){
- const UChar *pIn, *pInLimit;
- UChar *pOut, *pOutLimit;
+ const char16_t *pIn, *pInLimit;
+ char16_t *pOut, *pOutLimit;
char *pInter, *pInterLimit;
const char *p;
UBool flush;
}
}
virtual void call(UErrorCode* pErrorCode){
- const UChar *pIn, *pInLimit;
+ const char16_t *pIn, *pInLimit;
char *pInter, *pInterLimit;
ucnv_resetFromUnicode(cnv);
virtual void call(UErrorCode* pErrorCode){
const char *pIn, *pInLimit;
char *pInter, *pInterLimit;
- UChar *pivotSource, *pivotTarget, *pivotLimit;
+ char16_t *pivotSource, *pivotTarget, *pivotLimit;
ucnv_resetToUnicode(utf8Cnv);
ucnv_resetFromUnicode(cnv);
virtual UPerfFunction* runIndexedTest(int32_t index, UBool exec, const char* &name, char* par = nullptr);
- const UChar *getBuffer() const { return buffer; }
+ const char16_t *getBuffer() const { return buffer; }
int32_t getBufferLen() const { return bufferLen; }
char *utf8;
UNORM_NFC, 0,
nullptr, 0,
&errorCode);
- dest=new UChar[destCapacity];
+ dest=new char16_t[destCapacity];
}
~ToNFC() {
delete [] dest;
}
private:
- UChar *dest;
+ char16_t *dest;
int32_t destCapacity;
};
return new GetBiDiClass(testcase);
}
virtual void call(UErrorCode* pErrorCode) {
- const UChar *buffer=testcase.getBuffer();
+ const char16_t *buffer=testcase.getBuffer();
int32_t length=testcase.getBufferLen();
UChar32 c;
int32_t i;
// The constructor:
// text - pointer to an array of UChars to iterate over
// count - the number of UChars in text
- SpaceBreakIterator(const UChar *text, int32_t count);
+ SpaceBreakIterator(const char16_t *text, int32_t count);
// the destructor
~SpaceBreakIterator();
// The underlying BreakIterator
BreakIterator *fBreakIter;
- // address of the UChar array
- const UChar *fText;
+ // address of the char16_t array
+ const char16_t *fText;
// number of UChars in fText
int32_t fTextCount;
{
public:
// The main constructor:
- // spaces - pointer to a UChar array for the text with spaces
+ // spaces - pointer to a char16_t array for the text with spaces
// spaceCount - the number of characters in the spaces array
- // noSpaces - pointer to a UChar array for the text without spaces
+ // noSpaces - pointer to a char16_t array for the text without spaces
// noSpaceCount - the number of characters in the noSpaces array
// verbose - report all breaks if true, otherwise just report differences
- ThaiWordbreakTest(const UChar *spaces, int32_t spaceCount, const UChar *noSpaces, int32_t noSpaceCount, UBool verbose);
+ ThaiWordbreakTest(const char16_t *spaces, int32_t spaceCount, const char16_t *noSpaces, int32_t noSpaceCount, UBool verbose);
~ThaiWordbreakTest();
// returns the number of breaks that are in the spaces array
// reads the input Unicode text file:
// fileName - the path name of the file
// charCount - set to the number of UChars read from the file
- // returns - the address of the UChar array containing the characters
- static const UChar *readFile(char *fileName, int32_t &charCount);
+ // returns - the address of the char16_t array containing the characters
+ static const char16_t *readFile(char *fileName, int32_t &charCount);
- // removes spaces form the input UChar array:
- // spaces - pointer to the input UChar array
+ // removes spaces form the input char16_t array:
+ // spaces - pointer to the input char16_t array
// count - number of UChars in the spaces array
// nonSpaceCount - the number of UChars in the result array
- // returns - the address of the UChar array with spaces removed
- static const UChar *crunchSpaces(const UChar *spaces, int32_t count, int32_t &nonSpaceCount);
+ // returns - the address of the char16_t array with spaces removed
+ static const char16_t *crunchSpaces(const char16_t *spaces, int32_t count, int32_t &nonSpaceCount);
private:
// The no arg constructor - private so clients can't call it
ThaiWordbreakTest();
// This does the actual comparison:
- // spaces - the address of the UChar array for the text with spaces
+ // spaces - the address of the char16_t array for the text with spaces
// spaceCount - the number of UChars in the spaces array
- // noSpaces - the address of the UChar array for the text without spaces
+ // noSpaces - the address of the char16_t array for the text without spaces
// noSpaceCount - the number of UChars in the noSpaces array
// returns - true if all breaks match, false otherwise
- UBool compareWordBreaks(const UChar *spaces, int32_t spaceCount,
- const UChar *noSpaces, int32_t noSpaceCount);
+ UBool compareWordBreaks(const char16_t *spaces, int32_t spaceCount,
+ const char16_t *noSpaces, int32_t noSpaceCount);
// helper method to report a break in the spaces
// array that's not found in the noSpaces array
/*
* The main constructor: it calls compareWordBreaks and reports any differences
*/
-ThaiWordbreakTest::ThaiWordbreakTest(const UChar *spaces, int32_t spaceCount,
- const UChar *noSpaces, int32_t noSpaceCount, UBool verbose)
+ThaiWordbreakTest::ThaiWordbreakTest(const char16_t *spaces, int32_t spaceCount,
+ const char16_t *noSpaces, int32_t noSpaceCount, UBool verbose)
: fBreaksNotFound(0), fInvalidBreaks(0), fWordCount(0), fVerbose(verbose)
{
compareWordBreaks(spaces, spaceCount, noSpaces, noSpaceCount);
* and a word instance of a Thai BreakIterator to iterate over the text
* without spaces.
*/
-UBool ThaiWordbreakTest::compareWordBreaks(const UChar *spaces, int32_t spaceCount,
- const UChar *noSpaces, int32_t noSpaceCount)
+UBool ThaiWordbreakTest::compareWordBreaks(const char16_t *spaces, int32_t spaceCount,
+ const char16_t *noSpaces, int32_t noSpaceCount)
{
UBool result = true;
Locale thai("th");
* Read the text from a file. The text must start with a Unicode Byte
* Order Mark (BOM) so that we know what order to read the bytes in.
*/
-const UChar *ThaiWordbreakTest::readFile(char *fileName, int32_t &charCount)
+const char16_t *ThaiWordbreakTest::readFile(char *fileName, int32_t &charCount)
{
FILE *f;
int32_t fileSize;
- UChar *buffer;
+ char16_t *buffer;
char *bufferChars;
f = fopen(fileName, "rb");
delete[] bufferChars;
charCount = myText.length();
- buffer = new UChar[charCount];
+ buffer = new char16_t[charCount];
if(buffer == 0) {
fprintf(stderr,"Couldn't get memory for reading %s reason: %s \n", fileName, strerror(errno));
return 0;
}
/*
- * Remove spaces from the input UChar array.
+ * Remove spaces from the input char16_t array.
*
* We check explicitly for a Unicode code value of 0x0020
* because Unicode::isSpaceChar returns true for CR, LF, etc.
*
*/
-const UChar *ThaiWordbreakTest::crunchSpaces(const UChar *spaces, int32_t count, int32_t &nonSpaceCount)
+const char16_t *ThaiWordbreakTest::crunchSpaces(const char16_t *spaces, int32_t count, int32_t &nonSpaceCount)
{
int32_t i, out, spaceCount;
}
nonSpaceCount = count - spaceCount;
- UChar *noSpaces = new UChar[nonSpaceCount];
+ char16_t *noSpaces = new char16_t[nonSpaceCount];
if (noSpaces == 0) {
fprintf(stderr, "Couldn't allocate memory for the space stripped text.\n");
/*
* Generate a text file with spaces in it from a file without.
*/
-int generateFile(const UChar *chars, int32_t length) {
+int generateFile(const char16_t *chars, int32_t length) {
Locale root("");
UCharCharacterIterator *noSpaceIter = new UCharCharacterIterator(chars, length);
UErrorCode status = U_ZERO_ERROR;
breakIter->adoptText(noSpaceIter);
char outbuf[1024];
int32_t strlength;
- UChar bom = 0xFEFF;
+ char16_t bom = 0xFEFF;
printf("%s", u_strToUTF8(outbuf, sizeof(outbuf), &strlength, &bom, 1, &status));
int32_t prevbreak = 0;
}
int32_t spaceCount, nonSpaceCount;
- const UChar *spaces, *noSpaces;
+ const char16_t *spaces, *noSpaces;
spaces = ThaiWordbreakTest::readFile(fileName, spaceCount);
* The main constructor. Clear all the counts and construct a default
* word instance of a BreakIterator.
*/
-SpaceBreakIterator::SpaceBreakIterator(const UChar *text, int32_t count)
+SpaceBreakIterator::SpaceBreakIterator(const char16_t *text, int32_t count)
: fBreakIter(0), fText(text), fTextCount(count), fWordCount(0), fSpaceCount(0), fDone(false)
{
UCharCharacterIterator *iter = new UCharCharacterIterator(text, count);
DataMap::utoi(const UnicodeString &s) const
{
char ch[256];
- const UChar *u = toUCharPtr(s.getBuffer());
+ const char16_t *u = toUCharPtr(s.getBuffer());
int32_t len = s.length();
u_UCharsToChars(u, ch, len);
ch[len] = 0; /* include terminating \0 */
int32_t i = 0;
fData->removeAll();
UResourceBundle *t = nullptr;
- const UChar *key = nullptr;
+ const char16_t *key = nullptr;
int32_t keyLen = 0;
if(ures_getSize(headers) == ures_getSize(data)) {
for(i = 0; i < ures_getSize(data); i++) {
ULine* getLines(UErrorCode& status);
- const UChar* getBuffer(int32_t& len,UErrorCode& status);
+ const char16_t* getBuffer(int32_t& len,UErrorCode& status);
protected:
UPerfTest(int32_t argc, const char* argv[], UErrorCode& status);
ULine* lines;
int32_t numLines;
UBool line_mode;
- UChar* buffer;
+ char16_t* buffer;
int32_t bufferLen;
UBool verbose;
UBool bulk_mode;
* <code>
* typedef Params Params;
* struct Params{
- * UChar* target;
+ * char16_t* target;
* int32_t targetLen;
- * const UChar* source;
+ * const char16_t* source;
* int32_t sourceLen;
* UNormalizationMode mode;
* }
* int line;
* int loops;
* UErrorCode error = U_ZERO_ERROR;
- * UChar* dest=nullptr;
+ * char16_t* dest=nullptr;
* int32_t destCapacity=0;
* int len =-1;
* double elapsedTime = 0;
* int retVal=0;
*
- * UChar arr[5000];
+ * char16_t arr[5000];
* dest=arr;
* destCapacity = 5000;
* UTimer start;
* iii) Let a higher level function do the calculation of confidence levels etc.
* Example:
* <code>
- * void perf(UTimer* timer, UChar* source, int32_t sourceLen, UChar* target, int32_t targetLen, int32_t loopCount,UNormalizationMode mode, UErrorCode* error){
+ * void perf(UTimer* timer, char16_t* source, int32_t sourceLen, char16_t* target, int32_t targetLen, int32_t loopCount,UNormalizationMode mode, UErrorCode* error){
* int32_t loops;
* for (loops=0; loops<loopCount; loops++) {
* unorm_normalize(source,sourceLen,target, targetLen,mode,error);
lines = new ULine[MAXLINES];
int maxLines = MAXLINES;
numLines=0;
- const UChar* line=nullptr;
+ const char16_t* line=nullptr;
int32_t len =0;
for (;;) {
line = ucbuf_readline(ucharBuf,&len,&status);
if(line == nullptr || U_FAILURE(status)){
break;
}
- lines[numLines].name = new UChar[len];
+ lines[numLines].name = new char16_t[len];
lines[numLines].len = len;
memcpy(lines[numLines].name, line, len * U_SIZEOF_UCHAR);
}
return lines;
}
-const UChar* UPerfTest::getBuffer(int32_t& len, UErrorCode& status){
+const char16_t* UPerfTest::getBuffer(int32_t& len, UErrorCode& status){
if (U_FAILURE(status)) {
return nullptr;
}
len = ucbuf_size(ucharBuf);
- buffer = (UChar*) uprv_malloc(U_SIZEOF_UCHAR * (len+1));
+ buffer = (char16_t*) uprv_malloc(U_SIZEOF_UCHAR * (len+1));
u_strncpy(buffer,ucbuf_getBuffer(ucharBuf,&bufferLen,&status),len);
buffer[len]=0;
len = bufferLen;
for(int i=0x00; i<0x100; i++) {
char cp1047[1];
cp1047[0] = i;
- UChar u[1];
- UChar *target = u;
+ char16_t u[1];
+ char16_t *target = u;
const char *source = cp1047;
ucnv_toUnicode(cnv.getAlias(), &target, u+1, &source, cp1047+1, nullptr, true, &status);
if(U_FAILURE(status)) {
printf("static const bool oldIllegal[256] = { \n");
- for(UChar i=0x00; i<0x100;i++) {
+ for(char16_t i=0x00; i<0x100;i++) {
printf(" %s, /* U+%04X */\n",
(oldIllegal.contains(i))?" true":"false",
i);
}
//
- // Convert the rules to UChar.
+ // Convert the rules to char16_t.
// Preflight first to determine required buffer size.
//
uint32_t destCap = ucnv_toUChars(conv,
}
status = U_ZERO_ERROR;
- UChar *ruleSourceU = new UChar[destCap+1];
+ char16_t *ruleSourceU = new char16_t[destCap+1];
ucnv_toUChars(conv,
ruleSourceU, // dest,
destCap+1,
}
- const UChar *buf = pattern.getBuffer();
+ const char16_t *buf = pattern.getBuffer();
int32_t needed = pattern.length();
// print
#if PATTERN
printf("#define COLLUNSAFE_PATTERN 1\n");
printf("static const int32_t collunsafe_len = %d;\n", needed);
- printf("static const UChar collunsafe_pattern[collunsafe_len] = {\n");
+ printf("static const char16_t collunsafe_pattern[collunsafe_len] = {\n");
for(int i=0;i<needed;i++) {
if( (i>0) && (i%8 == 0) ) {
printf(" // %d\n", i);
};
#endif
-static const UChar LINEFEED_CHARACTER = 0x000A;
-static const UChar CARRIAGE_RETURN_CHARACTER = 0x000D;
+static const char16_t LINEFEED_CHARACTER = 0x000A;
+static const char16_t CARRIAGE_RETURN_CHARACTER = 0x000D;
static UBool readLine(UCHARBUF *f, UnicodeString &fileLine, IcuToolErrorCode &errorCode) {
int32_t lineLength;
- const UChar *line = ucbuf_readline(f, &lineLength, errorCode);
+ const char16_t *line = ucbuf_readline(f, &lineLength, errorCode);
if(line == nullptr || errorCode.isFailure()) { return false; }
// Strip trailing CR/LF, comments, and spaces.
- const UChar *comment = u_memchr(line, 0x23, lineLength); // '#'
+ const char16_t *comment = u_memchr(line, 0x23, lineLength); // '#'
if(comment != nullptr) {
lineLength = (int32_t)(comment - line);
} else {
printf("%s -> %i\n", s.data(), val);
}
} else {
- UCharsTrie::Iterator it((const UChar *)outData, outDataSize, status);
+ UCharsTrie::Iterator it((const char16_t *)outData, outDataSize, status);
while (it.hasNext()) {
it.next(status);
const UnicodeString s = it.getString();
(long)c, Normalizer2Impl::MAPPING_LENGTH_MASK);
exit(U_INVALID_FORMAT_ERROR);
}
- UChar rm0=rm.charAt(0);
+ char16_t rm0=rm.charAt(0);
if( rmLength==length-1 &&
// 99: overlong substring lengths get pinned to remainder lengths anyway
0==rm.compare(1, 99, m, 2, 99) &&
} else {
// Store the raw mapping with its length.
dataString.append(rm);
- dataString.append((UChar)rmLength);
+ dataString.append((char16_t)rmLength);
preMappingLength=rmLength+1;
}
firstUnit|=Normalizer2Impl::MAPPING_HAS_RAW_MAPPING;
}
int32_t cccLccc=norm.cc|(norm.leadCC<<8);
if(cccLccc!=0) {
- dataString.append((UChar)cccLccc);
+ dataString.append((char16_t)cccLccc);
++preMappingLength;
firstUnit|=Normalizer2Impl::MAPPING_HAS_CCC_LCCC_WORD;
}
- dataString.append((UChar)firstUnit);
+ dataString.append((char16_t)firstUnit);
dataString.append(m);
return preMappingLength;
}
if(i==(length-1)) {
firstUnit|=Normalizer2Impl::COMP_1_LAST_TUPLE;
}
- dataString.append((UChar)firstUnit).append((UChar)secondUnit);
+ dataString.append((char16_t)firstUnit).append((char16_t)secondUnit);
if(thirdUnit>=0) {
- dataString.append((UChar)thirdUnit);
+ dataString.append((char16_t)thirdUnit);
}
}
}
continue;
}
if(*delimiter=='=' || *delimiter=='>') {
- UChar uchars[Normalizer2Impl::MAPPING_LENGTH_MASK];
+ char16_t uchars[Normalizer2Impl::MAPPING_LENGTH_MASK];
int32_t length=u_parseString(delimiter+1, uchars, UPRV_LENGTHOF(uchars), nullptr, errorCode);
if(errorCode.isFailure()) {
fprintf(stderr, "gennorm2 error: parsing mapping string from %s\n", line);
// Pad the maybeYesCompositions length to a multiple of 4,
// so that NO_NO_DELTA bits 2..1 can be used without subtracting the center.
while(extra.maybeYesCompositions.length()&3) {
- extra.maybeYesCompositions.append((UChar)0);
+ extra.maybeYesCompositions.append((char16_t)0);
}
extraData.insert(0, extra.maybeYesCompositions);
indexes[Normalizer2Impl::IX_MIN_MAYBE_YES]=
// Pad to even length for 4-byte alignment of following data.
if(extraData.length()&1) {
- extraData.append((UChar)0);
+ extraData.append((char16_t)0);
}
int32_t minNoNoDelta=getMinNoNoDelta();
if(!norm.hasMapping()) { return; }
const UnicodeString &m=*norm.mapping;
UnicodeString *decomposed=nullptr;
- const UChar *s=toUCharPtr(m.getBuffer());
+ const char16_t *s=toUCharPtr(m.getBuffer());
int32_t length=m.length();
int32_t prev, i=0;
UChar32 c;
}
decomposed->append(*cNorm.mapping);
} else if(Hangul::isHangul(c)) {
- UChar buffer[3];
+ char16_t buffer[3];
int32_t hangulLength=Hangul::decompose(c, buffer);
if(norm.mappingType==Norm::ROUND_TRIP && prev!=0) {
fprintf(stderr,
static const char *getEncodingName(const char *encoding);
static void reportError(const char *pname, UErrorCode *status, const char *when);
-static UChar *quotedString(const UChar *string);
+static char16_t *quotedString(const char16_t *string);
static void printOutBundle(UFILE *out, UResourceBundle *resource, int32_t indent, const char *pname, UErrorCode *status);
-static void printString(UFILE *out, const UChar *str, int32_t len);
+static void printString(UFILE *out, const char16_t *str, int32_t len);
static void printCString(UFILE *out, const char *str, int32_t len);
static void printIndent(UFILE *out, int32_t indent);
static void printHex(UFILE *out, uint8_t what);
ustderr = u_finit(stderr, nullptr, nullptr);
for (i = 1; i < argc; ++i) {
- static const UChar sp[] = { 0x0020 }; /* " " */
+ static const char16_t sp[] = { 0x0020 }; /* " " */
arg = getLongPathname(argv[i]);
return 0;
}
-static UChar *quotedString(const UChar *string) {
+static char16_t *quotedString(const char16_t *string) {
int len = u_strlen(string);
int alen = len;
- const UChar *sp;
- UChar *newstr, *np;
+ const char16_t *sp;
+ char16_t *newstr, *np;
for (sp = string; *sp; ++sp) {
switch (*sp) {
}
}
- newstr = (UChar *) uprv_malloc((1 + alen) * U_SIZEOF_UCHAR);
+ newstr = (char16_t *) uprv_malloc((1 + alen) * U_SIZEOF_UCHAR);
for (sp = string, np = newstr; *sp; ++sp) {
switch (*sp) {
case '\n':
}
-static void printString(UFILE *out, const UChar *str, int32_t len) {
+static void printString(UFILE *out, const char16_t *str, int32_t len) {
u_file_write(str, len, out);
}
static void printHex(UFILE *out, uint8_t what) {
static const char map[] = "0123456789ABCDEF";
- UChar hex[2];
+ char16_t hex[2];
hex[0] = map[what >> 4];
hex[1] = map[what & 0xf];
}
static void printOutAlias(UFILE *out, UResourceBundle *parent, Resource r, const char *key, int32_t indent, const char *pname, UErrorCode *status) {
- static const UChar cr[] = { 0xA }; // LF
+ static const char16_t cr[] = { 0xA }; // LF
int32_t len = 0;
- const UChar* thestr = res_getAlias(&(parent->getResData()), r, &len);
- UChar *string = quotedString(thestr);
+ const char16_t* thestr = res_getAlias(&(parent->getResData()), r, &len);
+ char16_t *string = quotedString(thestr);
if(opt_truncate && len > truncsize) {
char msg[128];
printIndent(out, indent);
len = truncsize;
}
if(U_SUCCESS(*status)) {
- static const UChar openStr[] = { 0x003A, 0x0061, 0x006C, 0x0069, 0x0061, 0x0073, 0x0020, 0x007B, 0x0020, 0x0022 }; /* ":alias { \"" */
- static const UChar closeStr[] = { 0x0022, 0x0020, 0x007D, 0x0020 }; /* "\" } " */
+ static const char16_t openStr[] = { 0x003A, 0x0061, 0x006C, 0x0069, 0x0061, 0x0073, 0x0020, 0x007B, 0x0020, 0x0022 }; /* ":alias { \"" */
+ static const char16_t closeStr[] = { 0x0022, 0x0020, 0x007D, 0x0020 }; /* "\" } " */
printIndent(out, indent);
if(key != nullptr) {
printCString(out, key, -1);
static void printOutBundle(UFILE *out, UResourceBundle *resource, int32_t indent, const char *pname, UErrorCode *status)
{
- static const UChar cr[] = { 0xA }; // LF
+ static const char16_t cr[] = { 0xA }; // LF
/* int32_t noOfElements = ures_getSize(resource);*/
int32_t i = 0;
case URES_STRING :
{
int32_t len=0;
- const UChar* thestr = ures_getString(resource, &len, status);
- UChar *string = quotedString(thestr);
+ const char16_t* thestr = ures_getString(resource, &len, status);
+ char16_t *string = quotedString(thestr);
/* TODO: String truncation */
if(opt_truncate && len > truncsize) {
}
printIndent(out, indent);
if(key != nullptr) {
- static const UChar openStr[] = { 0x0020, 0x007B, 0x0020, 0x0022 }; /* " { \"" */
- static const UChar closeStr[] = { 0x0022, 0x0020, 0x007D }; /* "\" }" */
+ static const char16_t openStr[] = { 0x0020, 0x007B, 0x0020, 0x0022 }; /* " { \"" */
+ static const char16_t closeStr[] = { 0x0022, 0x0020, 0x007D }; /* "\" }" */
printCString(out, key, (int32_t)uprv_strlen(key));
printString(out, openStr, UPRV_LENGTHOF(openStr));
printString(out, string, len);
printString(out, closeStr, UPRV_LENGTHOF(closeStr));
} else {
- static const UChar openStr[] = { 0x0022 }; /* "\"" */
- static const UChar closeStr[] = { 0x0022, 0x002C }; /* "\"," */
+ static const char16_t openStr[] = { 0x0022 }; /* "\"" */
+ static const char16_t closeStr[] = { 0x0022, 0x002C }; /* "\"," */
printString(out, openStr, UPRV_LENGTHOF(openStr));
printString(out, string, (int32_t)(u_strlen(string)));
case URES_INT :
{
- static const UChar openStr[] = { 0x003A, 0x0069, 0x006E, 0x0074, 0x0020, 0x007B, 0x0020 }; /* ":int { " */
- static const UChar closeStr[] = { 0x0020, 0x007D }; /* " }" */
- UChar num[20];
+ static const char16_t openStr[] = { 0x003A, 0x0069, 0x006E, 0x0074, 0x0020, 0x007B, 0x0020 }; /* ":int { " */
+ static const char16_t closeStr[] = { 0x0020, 0x007D }; /* " }" */
+ char16_t num[20];
printIndent(out, indent);
if(key != nullptr) {
len = truncsize;
}
if(U_SUCCESS(*status)) {
- static const UChar openStr[] = { 0x003A, 0x0062, 0x0069, 0x006E, 0x0061, 0x0072, 0x0079, 0x0020, 0x007B, 0x0020 }; /* ":binary { " */
- static const UChar closeStr[] = { 0x0020, 0x007D, 0x0020 }; /* " } " */
+ static const char16_t openStr[] = { 0x003A, 0x0062, 0x0069, 0x006E, 0x0061, 0x0072, 0x0079, 0x0020, 0x007B, 0x0020 }; /* ":binary { " */
+ static const char16_t closeStr[] = { 0x0020, 0x007D, 0x0020 }; /* " } " */
printIndent(out, indent);
if(key != nullptr) {
printCString(out, key, -1);
int32_t len = 0;
const int32_t *data = ures_getIntVector(resource, &len, status);
if(U_SUCCESS(*status)) {
- static const UChar openStr[] = { 0x003A, 0x0069, 0x006E, 0x0074, 0x0076, 0x0065, 0x0063, 0x0074, 0x006F, 0x0072, 0x0020, 0x007B, 0x0020 }; /* ":intvector { " */
- static const UChar closeStr[] = { 0x0020, 0x007D, 0x0020 }; /* " } " */
- UChar num[20];
+ static const char16_t openStr[] = { 0x003A, 0x0069, 0x006E, 0x0074, 0x0076, 0x0065, 0x0063, 0x0074, 0x006F, 0x0072, 0x0020, 0x007B, 0x0020 }; /* ":intvector { " */
+ static const char16_t closeStr[] = { 0x0020, 0x007D, 0x0020 }; /* " } " */
+ char16_t num[20];
printIndent(out, indent);
if(key != nullptr) {
case URES_TABLE :
case URES_ARRAY :
{
- static const UChar openStr[] = { 0x007B }; /* "{" */
- static const UChar closeStr[] = { 0x007D, '\n' }; /* "}\n" */
+ static const char16_t openStr[] = { 0x007B }; /* "{" */
+ static const char16_t closeStr[] = { 0x007D, '\n' }; /* "}\n" */
UResourceBundle *t = nullptr;
ures_resetIterator(resource);
}
// The PseudoListResource constructor call did not allocate further memory.
assert(U_SUCCESS(status));
- const UChar *p = (const UChar *)(pRoot + keysTop);
+ const char16_t *p = (const char16_t *)(pRoot + keysTop);
int32_t remaining = stringUnitsLength;
do {
int32_t first = *p;
};
/* Just to store "TRUE" */
-//static const UChar trueValue[] = {0x0054, 0x0052, 0x0055, 0x0045, 0x0000};
+//static const char16_t trueValue[] = {0x0054, 0x0052, 0x0055, 0x0045, 0x0000};
typedef struct {
struct Lookahead lookahead[MAX_LOOKAHEAD + 1];
UCHARBUF *ucbuf=nullptr;
UChar32 c = 0;
const char* cp = nullptr;
- UChar *pTarget = nullptr;
- UChar *target = nullptr;
- UChar *targetLimit = nullptr;
+ char16_t *pTarget = nullptr;
+ char16_t *target = nullptr;
+ char16_t *targetLimit = nullptr;
int32_t size = 0;
expect(state, TOK_STRING, &tokenValue, nullptr, &line, status);
* is not known in UTF-8 byte stream
*/
size = ucbuf_size(ucbuf) + 1;
- pTarget = (UChar*) uprv_malloc(U_SIZEOF_UCHAR * size);
+ pTarget = (char16_t*) uprv_malloc(U_SIZEOF_UCHAR * size);
uprv_memset(pTarget, 0, size*U_SIZEOF_UCHAR);
target = pTarget;
targetLimit = pTarget+size;
continue;
}
- /* Append UChar * after dissembling if c > 0xffff*/
+ /* Append char16_t * after dissembling if c > 0xffff*/
if (c != (UChar32)U_EOF)
{
U_APPEND_CHAR32_ONLY(c, target);
uint32_t line;
UCHARBUF *ucbuf=nullptr;
const char* cp = nullptr;
- UChar *pTarget = nullptr;
- const UChar *pSource = nullptr;
+ char16_t *pTarget = nullptr;
+ const char16_t *pSource = nullptr;
int32_t size = 0;
expect(state, TOK_STRING, &tokenValue, nullptr, &line, status);
* is not known in UTF-8 byte stream
*/
pSource = ucbuf_getBuffer(ucbuf, &size, status);
- pTarget = (UChar*) uprv_malloc(U_SIZEOF_UCHAR * (size + 1));
+ pTarget = (char16_t*) uprv_malloc(U_SIZEOF_UCHAR * (size + 1));
uprv_memset(pTarget, 0, size*U_SIZEOF_UCHAR);
#if !UCONFIG_NO_TRANSLITERATION
// Quick-and-dirty escaping function.
// Assumes that we are on an ASCII-based platform.
static void
-escape(const UChar *s, char *buffer, size_t n) {
+escape(const char16_t *s, char *buffer, size_t n) {
int32_t length = u_strlen(s);
int32_t i = 0;
for (;;) {
int32_t len=0;
char *filename;
uint32_t line;
- UChar *pTarget = nullptr;
+ char16_t *pTarget = nullptr;
UCHARBUF *ucbuf;
char *fullname = nullptr;
const char* cp = nullptr;
- const UChar* uBuffer = nullptr;
+ const char16_t* uBuffer = nullptr;
int32_t stringLength;
filename = getInvariantString(state, &line, nullptr, stringLength, status);
static struct {
const char *nameChars; /* only used for debugging */
- const UChar *nameUChars;
+ const char16_t *nameUChars;
ParseResourceFunction *parseFunction;
} gResourceTypes[] = {
{"Unknown", nullptr, nullptr},
};
U_CFUNC int32_t
-removeText(UChar *source, int32_t srcLen,
+removeText(char16_t *source, int32_t srcLen,
UnicodeString patString,uint32_t options,
UnicodeString replaceText, UErrorCode *status){
}
U_CFUNC int32_t
-trim(UChar *src, int32_t srcLen, UErrorCode *status){
+trim(char16_t *src, int32_t srcLen, UErrorCode *status){
srcLen = removeText(src, srcLen, UnicodeString("^[ \\r\\n]+ "), 0, UnicodeString(), status); // remove leading new lines
srcLen = removeText(src, srcLen, UnicodeString("^\\s+"), 0, UnicodeString(), status); // remove leading spaces
srcLen = removeText(src, srcLen, UnicodeString("\\s+$"), 0, UnicodeString(), status); // remove trailing spcaes
}
U_CFUNC int32_t
-removeCmtText(UChar* source, int32_t srcLen, UErrorCode* status){
+removeCmtText(char16_t* source, int32_t srcLen, UErrorCode* status){
srcLen = trim(source, srcLen, status);
UnicodeString patString("^\\s*?\\*\\s*?"); // remove pattern like " * " at the beginning of the line
srcLen = removeText(source, srcLen, patString, UREGEX_MULTILINE, UnicodeString(), status);
}
U_CFUNC int32_t
-getText(const UChar* source, int32_t srcLen,
- UChar** dest, int32_t destCapacity,
+getText(const char16_t* source, int32_t srcLen,
+ char16_t** dest, int32_t destCapacity,
UnicodeString patternString,
UErrorCode* status){
#define AT_SIGN 0x0040
U_CFUNC int32_t
-getDescription( const UChar* source, int32_t srcLen,
- UChar** dest, int32_t destCapacity,
+getDescription( const char16_t* source, int32_t srcLen,
+ char16_t** dest, int32_t destCapacity,
UErrorCode* status){
if(status == nullptr || U_FAILURE(*status)){
return 0;
}
pattern->split(src, stringArray,MAX_SPLIT_STRINGS , *status);
- if(stringArray[0].indexOf((UChar)AT_SIGN)==-1){
+ if(stringArray[0].indexOf((char16_t)AT_SIGN)==-1){
int32_t destLen = stringArray[0].extract(*dest, destCapacity, *status);
return trim(*dest, destLen, status);
}
}
U_CFUNC int32_t
-getCount(const UChar* source, int32_t srcLen,
+getCount(const char16_t* source, int32_t srcLen,
UParseCommentsOption option, UErrorCode *status){
if(status == nullptr || U_FAILURE(*status)){
}
U_CFUNC int32_t
-getAt(const UChar* source, int32_t srcLen,
- UChar** dest, int32_t destCapacity,
+getAt(const char16_t* source, int32_t srcLen,
+ char16_t** dest, int32_t destCapacity,
int32_t index,
UParseCommentsOption option,
UErrorCode* status){
}
U_CFUNC int32_t
-getTranslate( const UChar* source, int32_t srcLen,
- UChar** dest, int32_t destCapacity,
+getTranslate( const char16_t* source, int32_t srcLen,
+ char16_t** dest, int32_t destCapacity,
UErrorCode* status){
UnicodeString notePatternString("^translate\\s*?(.*)");
}
U_CFUNC int32_t
-getNote(const UChar* source, int32_t srcLen,
- UChar** dest, int32_t destCapacity,
+getNote(const char16_t* source, int32_t srcLen,
+ char16_t** dest, int32_t destCapacity,
UErrorCode* status){
UnicodeString notePatternString("^note\\s*?(.*)");
U_IS_BIG_ENDIAN,
U_CHARSET_FAMILY,
- sizeof(UChar),
+ sizeof(char16_t),
0,
{0x52, 0x65, 0x73, 0x42}, /* dataFormat="ResB" */
}
StringBaseResource::StringBaseResource(SRBRoot *bundle, const char *tag, int8_t type,
- const UChar *value, int32_t len,
+ const char16_t *value, int32_t len,
const UString* comment, UErrorCode &errorCode)
: SResource(bundle, tag, type, comment, errorCode) {
if (len == 0 && gFormatVersion > 1) {
}
// Pool bundle string, alias the buffer. Guaranteed NUL-terminated and not empty.
-StringBaseResource::StringBaseResource(int8_t type, const UChar *value, int32_t len,
+StringBaseResource::StringBaseResource(int8_t type, const char16_t *value, int32_t len,
UErrorCode &errorCode)
: SResource(nullptr, nullptr, type, nullptr, errorCode), fString(true, value, len) {
assert(len > 0);
if (bundle->fStringsForm != STRINGS_UTF16_V1) {
int32_t len = length();
if (len <= MAX_IMPLICIT_STRING_LENGTH &&
- !U16_IS_TRAIL(fString[0]) && fString.indexOf((UChar)0) < 0) {
+ !U16_IS_TRAIL(fString[0]) && fString.indexOf((char16_t)0) < 0) {
/*
* This string will be stored without an explicit length.
* Runtime will detect !U16_IS_TRAIL(s[0]) and call u_strlen().
void
ContainerResource::writeAllRes16(SRBRoot *bundle) {
for (SResource *current = fFirst; current != nullptr; current = current->fNext) {
- bundle->f16BitUnits.append((UChar)current->fRes16);
+ bundle->f16BitUnits.append((char16_t)current->fRes16);
}
fWritten = true;
}
}
if (fCount <= 0xffff && res16 >= 0 && gFormatVersion > 1) {
fRes = URES_MAKE_RESOURCE(URES_ARRAY16, bundle->f16BitUnits.length());
- bundle->f16BitUnits.append((UChar)fCount);
+ bundle->f16BitUnits.append((char16_t)fCount);
writeAllRes16(bundle);
}
}
if (res16 >= 0 && gFormatVersion > 1) {
/* 16-bit count, key offsets and values */
fRes = URES_MAKE_RESOURCE(URES_TABLE16, bundle->f16BitUnits.length());
- bundle->f16BitUnits.append((UChar)fCount);
+ bundle->f16BitUnits.append((char16_t)fCount);
for (SResource *current = fFirst; current != nullptr; current = current->fNext) {
- bundle->f16BitUnits.append((UChar)current->fKey16);
+ bundle->f16BitUnits.append((char16_t)current->fKey16);
}
writeAllRes16(bundle);
} else {
return;
}
if (f16BitUnits.length() & 1) {
- f16BitUnits.append((UChar)0xaaaa); /* pad to multiple of 4 bytes */
+ f16BitUnits.append((char16_t)0xaaaa); /* pad to multiple of 4 bytes */
}
byteOffset = fKeysTop + f16BitUnits.length() * 2;
return U_SUCCESS(*status) ? res.orphan() : nullptr;
}
-struct SResource *string_open(struct SRBRoot *bundle, const char *tag, const UChar *value, int32_t len, const struct UString* comment, UErrorCode *status) {
+struct SResource *string_open(struct SRBRoot *bundle, const char *tag, const char16_t *value, int32_t len, const struct UString* comment, UErrorCode *status) {
LocalPointer<SResource> res(
new StringResource(bundle, tag, value, len, comment, *status), *status);
return U_SUCCESS(*status) ? res.orphan() : nullptr;
}
-struct SResource *alias_open(struct SRBRoot *bundle, const char *tag, UChar *value, int32_t len, const struct UString* comment, UErrorCode *status) {
+struct SResource *alias_open(struct SRBRoot *bundle, const char *tag, char16_t *value, int32_t len, const struct UString* comment, UErrorCode *status) {
LocalPointer<SResource> res(
new AliasResource(bundle, tag, value, len, comment, *status), *status);
return U_SUCCESS(*status) ? res.orphan() : nullptr;
if (gFormatVersion > 1) {
// f16BitUnits must start with a zero for empty resources.
// We might be able to omit it if there are no empty 16-bit resources.
- f16BitUnits.append((UChar)0);
+ f16BitUnits.append((char16_t)0);
}
fKeys = (char *) uprv_malloc(sizeof(char) * KEY_SPACE_SIZE);
/* Misc Functions */
-void SRBRoot::setLocale(UChar *locale, UErrorCode &errorCode) {
+void SRBRoot::setLocale(char16_t *locale, UErrorCode &errorCode) {
if(U_FAILURE(errorCode)) {
return;
}
compareStringSuffixes(const void * /*context*/, const void *l, const void *r) {
const StringResource *left = *((const StringResource **)l);
const StringResource *right = *((const StringResource **)r);
- const UChar *lStart = left->getBuffer();
- const UChar *lLimit = lStart + left->length();
- const UChar *rStart = right->getBuffer();
- const UChar *rLimit = rStart + right->length();
+ const char16_t *lStart = left->getBuffer();
+ const char16_t *lLimit = lStart + left->length();
+ const char16_t *rStart = right->getBuffer();
+ const char16_t *rLimit = rStart + right->length();
int32_t diff;
/* compare keys in reverse character order */
while (lStart < lLimit && rStart < rLimit) {
case 0:
break;
case 1:
- dest.append((UChar)(0xdc00 + len));
+ dest.append((char16_t)(0xdc00 + len));
break;
case 2:
- dest.append((UChar)(0xdfef + (len >> 16)));
- dest.append((UChar)len);
+ dest.append((char16_t)(0xdfef + (len >> 16)));
+ dest.append((char16_t)len);
break;
case 3:
- dest.append((UChar)0xdfff);
- dest.append((UChar)(len >> 16));
- dest.append((UChar)len);
+ dest.append((char16_t)0xdfff);
+ dest.append((char16_t)(len >> 16));
+ dest.append((char16_t)len);
break;
default:
break; /* will not occur */
}
dest.append(fString);
- dest.append((UChar)0);
+ dest.append((char16_t)0);
}
void
void write(const char *outputDir, const char *outputPkg,
char *writtenFilename, int writtenFilenameLen, UErrorCode &errorCode);
- void setLocale(UChar *locale, UErrorCode &errorCode);
+ void setLocale(char16_t *locale, UErrorCode &errorCode);
int32_t addTag(const char *tag, UErrorCode &errorCode);
const char *getKeyString(int32_t key) const;
ArrayResource *array_open(struct SRBRoot *bundle, const char *tag, const struct UString* comment, UErrorCode *status);
-struct SResource *string_open(struct SRBRoot *bundle, const char *tag, const UChar *value, int32_t len, const struct UString* comment, UErrorCode *status);
+struct SResource *string_open(struct SRBRoot *bundle, const char *tag, const char16_t *value, int32_t len, const struct UString* comment, UErrorCode *status);
-struct SResource *alias_open(struct SRBRoot *bundle, const char *tag, UChar *value, int32_t len, const struct UString* comment, UErrorCode *status);
+struct SResource *alias_open(struct SRBRoot *bundle, const char *tag, char16_t *value, int32_t len, const struct UString* comment, UErrorCode *status);
IntVectorResource *intvector_open(struct SRBRoot *bundle, const char *tag, const struct UString* comment, UErrorCode *status);
class StringBaseResource : public SResource {
public:
StringBaseResource(SRBRoot *bundle, const char *tag, int8_t type,
- const UChar *value, int32_t len,
+ const char16_t *value, int32_t len,
const UString* comment, UErrorCode &errorCode);
StringBaseResource(SRBRoot *bundle, int8_t type,
const icu::UnicodeString &value, UErrorCode &errorCode);
- StringBaseResource(int8_t type, const UChar *value, int32_t len, UErrorCode &errorCode);
+ StringBaseResource(int8_t type, const char16_t *value, int32_t len, UErrorCode &errorCode);
virtual ~StringBaseResource();
- const UChar *getBuffer() const { return icu::toUCharPtr(fString.getBuffer()); }
+ const char16_t *getBuffer() const { return icu::toUCharPtr(fString.getBuffer()); }
int32_t length() const { return fString.length(); }
virtual void handlePreWrite(uint32_t *byteOffset) override;
class StringResource : public StringBaseResource {
public:
- StringResource(SRBRoot *bundle, const char *tag, const UChar *value, int32_t len,
+ StringResource(SRBRoot *bundle, const char *tag, const char16_t *value, int32_t len,
const UString* comment, UErrorCode &errorCode)
: StringBaseResource(bundle, tag, URES_STRING, value, len, comment, errorCode),
fSame(nullptr), fSuffixOffset(0),
fSame(nullptr), fSuffixOffset(0),
fNumCopies(0), fNumUnitsSaved(0), fNumCharsForLength(0) {}
StringResource(int32_t poolStringIndex, int8_t numCharsForLength,
- const UChar *value, int32_t length,
+ const char16_t *value, int32_t length,
UErrorCode &errorCode)
: StringBaseResource(URES_STRING, value, length, errorCode),
fSame(nullptr), fSuffixOffset(0),
class AliasResource : public StringBaseResource {
public:
- AliasResource(SRBRoot *bundle, const char *tag, const UChar *value, int32_t len,
+ AliasResource(SRBRoot *bundle, const char *tag, const char16_t *value, int32_t len,
const UString* comment, UErrorCode &errorCode)
: StringBaseResource(bundle, tag, URES_ALIAS, value, len, comment, errorCode) {}
virtual ~AliasResource();
static UConverter* conv = nullptr;
static int32_t
-uCharsToChars(char *target, int32_t targetLen, const UChar *source, int32_t sourceLen, UErrorCode *status) {
+uCharsToChars(char *target, int32_t targetLen, const char16_t *source, int32_t sourceLen, UErrorCode *status) {
int i=0, j=0;
char str[30]={'\0'};
while(i<sourceLen){
return columnCount;
}
static void
-str_write_java(const UChar *src, int32_t srcLen, UBool printEndLine, UErrorCode *status) {
+str_write_java(const char16_t *src, int32_t srcLen, UBool printEndLine, UErrorCode *status) {
uint32_t length = srcLen*8;
uint32_t bufLen = 0;
void res_write_xml(struct SResource *res, const char* id, const char* language, UBool isTopLevel, UErrorCode *status);
static char* convertAndEscape(char** pDest, int32_t destCap, int32_t* destLength,
- const UChar* src, int32_t srcLen, UErrorCode* status){
+ const char16_t* src, int32_t srcLen, UErrorCode* status){
int32_t srcIndex=0;
char* dest=nullptr;
char* temp=nullptr;
}
static void
-print(UChar* src, int32_t srcLen,const char *tagStart,const char *tagEnd, UErrorCode *status){
+print(char16_t* src, int32_t srcLen,const char *tagStart,const char *tagEnd, UErrorCode *status){
int32_t bufCapacity = srcLen*4;
char *buf = nullptr;
int32_t bufLen = 0;
#if UCONFIG_NO_REGULAR_EXPRESSIONS==0 /* donot compile when no RegularExpressions are available */
int32_t capacity = 0;
- UChar* note = nullptr;
+ char16_t* note = nullptr;
int32_t noteLen = 0;
int32_t count = 0,i;
}
capacity = src->fLength;
- note = (UChar*) uprv_malloc(U_SIZEOF_UCHAR * capacity);
+ note = (char16_t*) uprv_malloc(U_SIZEOF_UCHAR * capacity);
count = getCount(src->fChars,src->fLength, UPC_NOTE, status);
if(U_FAILURE(*status)){
int32_t capacity = src->fLength + 1;
char* buf = nullptr;
int32_t bufLen = 0;
- UChar* desc = (UChar*) uprv_malloc(U_SIZEOF_UCHAR * capacity);
- UChar* trans = (UChar*) uprv_malloc(U_SIZEOF_UCHAR * capacity);
+ char16_t* desc = (char16_t*) uprv_malloc(U_SIZEOF_UCHAR * capacity);
+ char16_t* trans = (char16_t*) uprv_malloc(U_SIZEOF_UCHAR * capacity);
int32_t descLen = 0, transLen=0;
if(desc==nullptr || trans==nullptr){
U_IS_BIG_ENDIAN,
U_CHARSET_FAMILY,
- sizeof(UChar),
+ sizeof(char16_t),
0,
{0x63, 0x6e, 0x76, 0x74}, /* dataFormat="cnvt" */
udbg_stoi(const UnicodeString &s)
{
char ch[256];
- const UChar *u = toUCharPtr(s.getBuffer());
+ const char16_t *u = toUCharPtr(s.getBuffer());
int32_t len = s.length();
u_UCharsToChars(u, ch, len);
ch[len] = 0; /* include terminating \0 */
udbg_stod(const UnicodeString &s)
{
char ch[256];
- const UChar *u = toUCharPtr(s.getBuffer());
+ const char16_t *u = toUCharPtr(s.getBuffer());
int32_t len = s.length();
u_UCharsToChars(u, ch, len);
ch[len] = 0; /* include terminating \0 */
{
dst->remove();
for (int32_t i = 0; i < src.length(); ++i) {
- UChar c = src[i];
+ char16_t c = src[i];
if(ICU_Utility::isUnprintable(c)) {
*dst += UnicodeString("[");
ICU_Utility::escapeUnprintable(*dst, c);
U_IS_BIG_ENDIAN,
U_CHARSET_FAMILY,
- (uint8_t)sizeof(UChar),
+ (uint8_t)sizeof(char16_t),
0,
{0x43, 0x6d, 0x6e, 0x44}, /* dataFormat="CmnD" */
U_IS_BIG_ENDIAN,
U_CHARSET_FAMILY,
- sizeof(UChar),
+ sizeof(char16_t),
0,
{0x43, 0x6d, 0x6e, 0x44}, /* dataFormat="CmnD" */
// get dependencies from resource bundles ---------------------------------- ***
-static const UChar SLASH=0x2f;
+static const char16_t SLASH=0x2f;
/*
* Check for the alias from the string or alias resource res.
*/
static void
checkAlias(const char *itemName,
- Resource res, const UChar *alias, int32_t length, UBool useResSuffix,
+ Resource res, const char16_t *alias, int32_t length, UBool useResSuffix,
CheckDependency check, void *context, UErrorCode *pErrorCode) {
int32_t i;
doCheckParent = false;
// No tracing: build tool
int32_t length;
- const UChar *alias=res_getStringNoTrace(pResData, res, &length);
+ const char16_t *alias=res_getStringNoTrace(pResData, res, &length);
checkAlias(itemName, res, alias, length, /*useResSuffix=*/ true,
check, context, pErrorCode);
// If there is a %%ALIAS, then there should be nothing else in this resource bundle.
// Explicit declaration of a dependency of this item on that one.
// No tracing: build tool
int32_t length;
- const UChar *alias=res_getStringNoTrace(pResData, res, &length);
+ const char16_t *alias=res_getStringNoTrace(pResData, res, &length);
checkAlias(itemName, res, alias, length, /*useResSuffix=*/ false,
check, context, pErrorCode);
}
case URES_ALIAS:
{
int32_t length;
- const UChar *alias=res_getAlias(pResData, res, &length);
+ const char16_t *alias=res_getAlias(pResData, res, &length);
checkAlias(itemName, res, alias, length, true, check, context, pErrorCode);
}
break;
void
PreparsedUCD::parseString(const char *s, UnicodeString &uni, UErrorCode &errorCode) {
- UChar *buffer=toUCharPtr(uni.getBuffer(-1));
+ char16_t *buffer=toUCharPtr(uni.getBuffer(-1));
int32_t length=u_parseString(s, buffer, uni.getCapacity(), nullptr, &errorCode);
if(errorCode==U_BUFFER_OVERFLOW_ERROR) {
errorCode=U_ZERO_ERROR;
/*
* swap the UChars
- * U const UChar uchars[2*(i3-i2)];
+ * U const char16_t uchars[2*(i3-i2)];
*/
ds->swapArray16(ds,
inData32+dataIndexes[UPROPS_EXCEPTIONS_TOP_INDEX],
{
/* convert the data format from ASCII to Unicode to the system charset */
- UChar u[4]={
+ char16_t u[4]={
pInfo->dataFormat[0], pInfo->dataFormat[1],
pInfo->dataFormat[2], pInfo->dataFormat[3]
};
#define CONTEXT_LEN 20
struct UCHARBUF {
- UChar* buffer;
- UChar* currentPos;
- UChar* bufLimit;
+ char16_t* buffer;
+ char16_t* currentPos;
+ char16_t* bufLimit;
int32_t bufCapacity;
int32_t remaining;
int32_t signatureLength;
char start[8];
int32_t numRead;
- UChar target[1]={ 0 };
- UChar* pTarget;
+ char16_t target[1]={ 0 };
+ char16_t* pTarget;
const char* pStart;
/* read a few bytes */
/* fill the uchar buffer */
static UCHARBUF*
ucbuf_fillucbuf( UCHARBUF* buf,UErrorCode* error){
- UChar* pTarget=nullptr;
- UChar* target=nullptr;
+ char16_t* pTarget=nullptr;
+ char16_t* target=nullptr;
const char* source=nullptr;
char carr[MAX_IN_BUF] = {'\0'};
char* cbuf = carr;
/* check if we arrived here without exhausting the buffer*/
if(buf->currentPos<buf->bufLimit){
offset = (int32_t)(buf->bufLimit-buf->currentPos);
- memmove(buf->buffer,buf->currentPos,offset* sizeof(UChar));
+ memmove(buf->buffer,buf->currentPos,offset* sizeof(char16_t));
}
#ifdef UCBUF_DEBUG
- memset(pTarget+offset,0xff,sizeof(UChar)*(MAX_IN_BUF-offset));
+ memset(pTarget+offset,0xff,sizeof(char16_t)*(MAX_IN_BUF-offset));
#endif
if(buf->isBuffered){
cbufSize = MAX_IN_BUF;
-/* get a UChar from the stream*/
+/* get a char16_t from the stream*/
U_CAPI int32_t U_EXPORT2
ucbuf_getc(UCHARBUF* buf,UErrorCode* error){
if(error==nullptr || U_FAILURE(*error)){
return retVal;
}
-/* u_unescapeAt() callback to return a UChar*/
-static UChar U_CALLCONV
+/* u_unescapeAt() callback to return a char16_t*/
+static char16_t U_CALLCONV
_charAt(int32_t offset, void *context) {
return ((UCHARBUF*) context)->currentPos[offset];
}
}else{
buf->bufCapacity=buf->remaining+buf->signatureLength+1/*for terminating nul*/;
}
- buf->buffer=(UChar*) uprv_malloc(U_SIZEOF_UCHAR * buf->bufCapacity );
+ buf->buffer=(char16_t*) uprv_malloc(U_SIZEOF_UCHAR * buf->bufCapacity );
if (buf->buffer == nullptr) {
*error = U_MEMORY_ALLOCATION_ERROR;
ucbuf_close(buf);
}
}
-/* frees the resources of UChar* buffer */
+/* frees the resources of char16_t* buffer */
static void
ucbuf_closebuf(UCHARBUF* buf){
uprv_free(buf->buffer);
ucnv_resetToUnicode(buf->conv);
if(buf->signatureLength>0) {
- UChar target[1]={ 0 };
- UChar* pTarget;
+ char16_t target[1]={ 0 };
+ char16_t* pTarget;
char start[8];
const char* pStart;
int32_t numRead;
return 0;
}
-U_CAPI const UChar* U_EXPORT2
+U_CAPI const char16_t* U_EXPORT2
ucbuf_getBuffer(UCHARBUF* buf,int32_t* len,UErrorCode* error){
if(error==nullptr || U_FAILURE(*error)){
return nullptr;
* to CR+LF combination which needs to be
* handled separately
*/
-static UBool ucbuf_isCharNewLine(UChar c){
+static UBool ucbuf_isCharNewLine(char16_t c){
switch(c){
case 0x000A: /* LF */
case 0x000D: /* CR */
}
}
-U_CAPI const UChar* U_EXPORT2
+U_CAPI const char16_t* U_EXPORT2
ucbuf_readline(UCHARBUF* buf,int32_t* len,UErrorCode* err){
- UChar* temp = buf->currentPos;
- UChar* savePos =nullptr;
- UChar c=0x0000;
+ char16_t* temp = buf->currentPos;
+ char16_t* savePos =nullptr;
+ char16_t c=0x0000;
if(buf->isBuffered){
/* The input is buffered we have to do more
* for returning a pointer U_TRUNCATED_CHAR_FOUND
U_CAPI int32_t
paramTimezoneDefault(const USystemParams * /* param */, char *target, int32_t targetCapacity, UErrorCode *status) {
if(U_FAILURE(*status))return 0;
- UChar buf[100];
+ char16_t buf[100];
char buf2[100];
int32_t len;
public:
KnownIssues();
~KnownIssues();
- void add(const char *ticket, const char *where, const UChar *msg, UBool *firstForTicket, UBool *firstForWhere);
+ void add(const char *ticket, const char *where, const char16_t *msg, UBool *firstForTicket, UBool *firstForWhere);
void add(const char *ticket, const char *where, const char *msg, UBool *firstForTicket, UBool *firstForWhere);
UBool print();
private:
return ticket;
}
-void KnownIssues::add(const char *ticketStr, const char *where, const UChar *msg, UBool *firstForTicket, UBool *firstForWhere)
+void KnownIssues::add(const char *ticketStr, const char *where, const char16_t *msg, UBool *firstForTicket, UBool *firstForWhere)
{
const std::string ticket = mapTicketId(ticketStr);
if(fTable.find(ticket) == fTable.end()) {
return true;
}
-U_CAPI void *udbg_knownIssue_openU(void *ptr, const char *ticket, char *where, const UChar *msg, UBool *firstForTicket,
+U_CAPI void *udbg_knownIssue_openU(void *ptr, const char *ticket, char *where, const char16_t *msg, UBool *firstForTicket,
UBool *firstForWhere) {
KnownIssues *t = static_cast<KnownIssues*>(ptr);
if(t==nullptr) {
}
U_CAPI void U_EXPORT2
-udata_writeUString(UNewDataMemory *pData, const UChar *s, int32_t length) {
+udata_writeUString(UNewDataMemory *pData, const char16_t *s, int32_t length) {
if(pData!=nullptr && pData->file!=nullptr) {
if(length==-1) {
length=u_strlen(s);
}
if(length>0) {
- T_FileStream_write(pData->file, s, length*sizeof(UChar));
+ T_FileStream_write(pData->file, s, length*sizeof(char16_t));
}
}
}
*/
U_CAPI int32_t U_EXPORT2
u_parseString(const char *s,
- UChar *dest, int32_t destCapacity,
+ char16_t *dest, int32_t destCapacity,
uint32_t *pFirst,
UErrorCode *pErrorCode) {
char *end;
U_CAPI void U_EXPORT2
usrc_writeStringAsASCII(FILE *f,
- const UChar* ptr, int32_t length,
+ const char16_t* ptr, int32_t length,
UTargetSyntax) {
// For now, assume all UTargetSyntax values are valid here.
fprintf(f, "\"");
fNames(status),
fElementStack(status),
- fOneLF((UChar)0x0a) // Plain new-line string, used in new line normalization.
+ fOneLF((char16_t)0x0a) // Plain new-line string, used in new line normalization.
{
}
const char *charset, *pb;
UnicodeString src;
UConverter *cnv;
- UChar *buffer, *pu;
+ char16_t *buffer, *pu;
int32_t fileLength, bytesLength, length, capacity;
UBool flush;
if(mXMLDecl.reset(src).lookingAt(0, errorCode)) {
int32_t declEnd=mXMLDecl.end(errorCode);
// go beyond <?xml
- int32_t pos=src.indexOf((UChar)x_l)+1;
+ int32_t pos=src.indexOf((char16_t)x_l)+1;
mAttrValue.reset(src);
while(pos<declEnd && mAttrValue.lookingAt(pos, errorCode)) { // loop runs once per attribute on this element.
// Next change all xml white space chars to plain \u0020 spaces.
mAttrNormalizer.reset(attValue);
- UnicodeString oneSpace((UChar)0x0020);
+ UnicodeString oneSpace((char16_t)0x0020);
attValue = mAttrNormalizer.replaceAll(oneSpace, status);
// Replace character entities.
// which is flagged by start() of that group not being -1.
while (mAmps.find()) {
if (mAmps.start(1, status) != -1) {
- replacement.setTo((UChar)x_AMP);
+ replacement.setTo((char16_t)x_AMP);
} else if (mAmps.start(2, status) != -1) {
- replacement.setTo((UChar)x_LT);
+ replacement.setTo((char16_t)x_LT);
} else if (mAmps.start(3, status) != -1) {
- replacement.setTo((UChar)x_GT);
+ replacement.setTo((char16_t)x_GT);
} else if (mAmps.start(4, status) != -1) {
- replacement.setTo((UChar)x_APOS);
+ replacement.setTo((char16_t)x_APOS);
} else if (mAmps.start(5, status) != -1) {
- replacement.setTo((UChar)x_QUOT);
+ replacement.setTo((char16_t)x_QUOT);
} else if (mAmps.start(6, status) != -1) {
UnicodeString hexString = mAmps.group(6, status);
UChar32 val = 0;
int line = 0;
int ci = 0;
while (ci < fPos && ci>=0) {
- ci = src.indexOf((UChar)0x0a, ci+1);
+ ci = src.indexOf((char16_t)0x0a, ci+1);
line++;
}
fprintf(stderr, "Error: %s at line %d\n", message, line);
// Stubs for Windows API functions when building on UNIXes.
//
typedef int DWORD;
-inline int CompareStringW(DWORD, DWORD, UChar *, int, UChar *, int) {return 0;};
+inline int CompareStringW(DWORD, DWORD, char16_t *, int, char16_t *, int) {return 0;};
#include <sys/time.h>
unsigned long timeGetTime() {
struct timeval t;
val += t.tv_usec / 1000;
return val;
};
-inline int LCMapStringW(DWORD, DWORD, UChar *, int, UChar *, int) {return 0;};
+inline int LCMapStringW(DWORD, DWORD, char16_t *, int, char16_t *, int) {return 0;};
const int LCMAP_SORTKEY = 0;
#define MAKELCID(a,b) 0
const int SORT_DEFAULT = 0;
Hashtable gExpansions(false);
CompareFn gComparer;
-const UChar separatorChar = 0x0030;
+const char16_t separatorChar = 0x0030;
UFILE *out = nullptr;
UFILE *err = nullptr;
}
-void printRules(const UChar *name, int32_t len, UFILE *file) {
+void printRules(const char16_t *name, int32_t len, UFILE *file) {
// very rudimentary pretty rules print
int32_t i = 0;
- UChar toPrint[16384];
+ char16_t toPrint[16384];
int32_t toPrintIndex = 0;
for(i = 0; i < len; i++) {
if(name[i] == 0x0026) {
}
-void escapeString(const UChar *name, int32_t len, UFILE *file) {
+void escapeString(const char16_t *name, int32_t len, UFILE *file) {
u_fprintf(file, "%U", name);
/*
int32_t j = 0;
return size;
}
-UBool trySwamped(Line **smaller, Line **greater, UChar chars[2], CompareFn comparer) {
+UBool trySwamped(Line **smaller, Line **greater, char16_t chars[2], CompareFn comparer) {
u_strcpy(gSource->name, (*smaller)->name);
gSource->name[(*smaller)->len] = separatorChar;
gSource->name[(*smaller)->len+1] = chars[0];
}
}
-UBool trySwamps(Line **smaller, Line **greater, UChar chars[2], CompareFn comparer) {
+UBool trySwamps(Line **smaller, Line **greater, char16_t chars[2], CompareFn comparer) {
gSource->name[0] = chars[0];
gSource->name[1] = separatorChar;
u_strcpy(gSource->name+2, (*smaller)->name);
probeStrength(Line** prevLine, Line **currLine, CompareFn comparer) {
// Primary swamps secondary
// have pairs where [0] 2> [1]
- UChar primSwamps[][2] = {
+ char16_t primSwamps[][2] = {
{ 0x00E0, 0x0061 },
{ 0x0450, 0x0435 },
{ 0x31a3, 0x310d }
};
// Secondary swamps tertiary
// have pairs where [0] 3> [1]
- UChar secSwamps[][2] = {
+ char16_t secSwamps[][2] = {
{ 0x0053, 0x0073 },
{ 0x0415, 0x0435 },
{ 0x31b6, 0x310e }
};
// Secondary is swamped by primary
// have pairs where [0] 1> [1]
- UChar secSwamped[][2] = {
+ char16_t secSwamped[][2] = {
{ 0x0062, 0x0061 },
{ 0x0436, 0x0454 },
{ 0x310e, 0x310d }
};
// Tertiary is swamped by secondary
// have pairs where [0] 2> [1]
- UChar terSwamped[][2] = {
+ char16_t terSwamped[][2] = {
{ 0x00E0, 0x0061 },
{ 0x0450, 0x0435 },
{ 0x31a3, 0x310d }
// check for craziness such as s = ss/s
// such line would consist of previous (or next) concatenated with the expansion value
// make a test
- UChar fullString[256];
+ char16_t fullString[256];
u_strcpy(fullString, toMove->previous->name);
u_strcat(fullString, toMove->expansionString);
if(u_strcmp(fullString, toMove->name) == 0) {
u_fprintf(log, "\n");
}
} else if(toMove->next->strength == UCOL_IDENTICAL) {
- UChar fullString[256];
+ char16_t fullString[256];
u_strcpy(fullString, toMove->next->name);
u_strcat(fullString, toMove->expansionString);
if(u_strcmp(fullString, toMove->name) == 0) {
// Check whether upper case comes before lower case or vice-versa
int32_t
checkCaseOrdering(void) {
- UChar stuff[][3] = {
+ char16_t stuff[][3] = {
{ 0x0061, separatorChar, 0x0061}, //"aa",
{ 0x0061, separatorChar, 0x0041 }, //"a\\u00E0",
{ 0x0041, separatorChar, 0x0061 }, //"\\u00E0a",
// Check whether the secondaries are in the straight or reversed order
int32_t
checkSecondaryOrdering(void) {
- UChar stuff[][5] = {
+ char16_t stuff[][5] = {
{ 0x0061, separatorChar, 0x0061, separatorChar, 0x00E0 }, //"aa",
{ 0x0061, separatorChar, 0x00E0, separatorChar, 0x0061 }, //"a\\u00E0",
{ 0x00E0, separatorChar, 0x0061, separatorChar, 0x0061 }, //"\\u00E0a",
processCollator(UCollator *col, UErrorCode &status) {
int32_t i = 0;
gCol = col;
- UChar ruleString[16384];
+ char16_t ruleString[16384];
int32_t ruleStringLength = ucol_getRulesEx(gCol, UCOL_TAILORING_ONLY, ruleString, 16384);
if(!gQuiet) {
u_fprintf(out, "ICU rules:\n");
if(gRulesStdin) {
char buffer[1024];
- UChar ruleBuffer[16384];
- UChar *rules = ruleBuffer;
+ char16_t ruleBuffer[16384];
+ char16_t *rules = ruleBuffer;
int32_t maxRuleLen = 16384;
int32_t rLen = 0;
while(gets(buffer)) {
#include "unicode/normlzr.h"
typedef int (*CompareFn) (const void *elem1, const void *elem2);
-typedef int (*GetSortKeyFn) (const UChar *string, int32_t len, uint8_t *buffer, int32_t buffCapacity);
+typedef int (*GetSortKeyFn) (const char16_t *string, int32_t len, uint8_t *buffer, int32_t buffCapacity);
//typedef int (__cdecl *CompareFn)(const void *elem1, const void *elem2);
void generateRepertoire(const char *locale, UnicodeSet &rep, UBool &hanAppears, UErrorCode &status);
UnicodeSet flatten(const UnicodeSet &source, UErrorCode &status);
// Stubs for Windows API functions when building on UNIXes.
//
typedef int DWORD;
-inline int CompareStringW(DWORD, DWORD, UChar *, int, UChar *, int) {return 0;};
+inline int CompareStringW(DWORD, DWORD, char16_t *, int, char16_t *, int) {return 0;};
//#else
//#error "Not POSIX or Windows. Won't work."
#endif
UnicodeSet gExcludeSet;
UnicodeSet gRepertoire;
-const UChar separatorChar = 0x0030;
+const char16_t separatorChar = 0x0030;
UPrinter *logger;
UPrinter *debug;
/*18*/ UOPTION_DEF("output", 0, UOPT_REQUIRES_ARG)
};
-UChar compA[256];
-UChar compB[256];
+char16_t compA[256];
+char16_t compB[256];
int32_t compALen = 0;
int32_t compBLen = 0;
return t;
}
-int UNIXgetSortKey(const UChar *string, int32_t len, uint8_t *buffer, int32_t buffCapacity) {
+int UNIXgetSortKey(const char16_t *string, int32_t len, uint8_t *buffer, int32_t buffCapacity) {
UErrorCode status = U_ZERO_ERROR;
compALen = unorm_normalize(string, len, UNORM_NFC, 0, compA, 256, &status);
compUTF8ALen = ucnv_fromUChars(utf8cnv, compUTF8A, 256, compA, compALen, &status);
return t-2;
}
-int WingetSortKey(const UChar *string, int32_t len, uint8_t *buffer, int32_t buffCapacity) {
+int WingetSortKey(const char16_t *string, int32_t len, uint8_t *buffer, int32_t buffCapacity) {
UErrorCode status = U_ZERO_ERROR;
compALen = unorm_normalize(string, len, UNORM_NFC, 0, compA, 256, &status);
return LCMapStringW(gWinLCID, LCMAP_SORTKEY | SORT_STRINGSORT, compA, compALen, (unsigned short *)buffer, buffCapacity);
if(a == b);
return 0;
}
-int WingetSortKey(const UChar *, int32_t , uint8_t *, int32_t ) {
+int WingetSortKey(const char16_t *, int32_t , uint8_t *, int32_t ) {
return 0;
}
#endif
return 0;
}
-int ICUgetSortKey(const UChar *string, int32_t len, uint8_t *buffer, int32_t buffCapacity) {
+int ICUgetSortKey(const char16_t *string, int32_t len, uint8_t *buffer, int32_t buffCapacity) {
return ucol_getSortKey(gCol, string, len, buffer, buffCapacity);
}
// Check whether upper case comes before lower case or vice-versa
int32_t
checkCaseOrdering(void) {
- UChar stuff[][3] = {
+ char16_t stuff[][3] = {
{ 0x0061, separatorChar, 0x0061}, //"aa",
{ 0x0061, separatorChar, 0x0041 }, //"a\\u00E0",
{ 0x0041, separatorChar, 0x0061 }, //"\\u00E0a",
}
}
-UChar probeChars[][4] = {
+char16_t probeChars[][4] = {
{ 0x0061, 0x0062, 0x00E1, 0x0041 }, // latin with a-grave
{ 0x0041, 0x0042, 0x00C1, 0x0061 }, // upper first
{ 0x006E, 0x006F, 0x00F1, 0x004E }, // latin with n-tilda
int32_t i = 0;
uint32_t j = 0;
gCol = col;
- UChar ruleString[16384];
+ char16_t ruleString[16384];
char myLoc[256];
int32_t ruleStringLength = ucol_getRulesEx(gCol, UCOL_TAILORING_ONLY, ruleString, 16384);
} else {
if(gRulesStdin) {
char buffer[1024];
- UChar ruleBuffer[16384];
- UChar *rules = ruleBuffer;
+ char16_t ruleBuffer[16384];
+ char16_t *rules = ruleBuffer;
int32_t maxRuleLen = 16384;
int32_t rLen = 0;
while(fgets(buffer, 1024, stdin)) {
{
UnicodeSet trailings(UnicodeString("[\\uFE7D\\uFE7C\\u30FD\\uFF70\\u30FC\\u309D\\u3032\\u3031\\u3005\\u0651]"), status);
char intChar[] = "\\uFE7D\\uFE7C\\u30FD\\uFF70\\u30FC\\u309D\\u3032\\u3031\\u3005\\u0651";
- UChar interesting[256];
+ char16_t interesting[256];
int32_t intLen = u_unescape(intChar, interesting, 256);
- UChar i = 0;
- UChar j = 0, k = 0;
+ char16_t i = 0;
+ char16_t j = 0, k = 0;
int32_t count;
Line myCh, combo, trial, inter, kLine;
for(i = 0; i < intLen; i++) {
Line::Line()
{
init();
- memset(name, 0, 25*sizeof(UChar));
- memset(expansionString, 0, 25*sizeof(UChar));
+ memset(name, 0, 25*sizeof(char16_t));
+ memset(expansionString, 0, 25*sizeof(char16_t));
}
-Line::Line(const UChar* name, int32_t len)
+Line::Line(const char16_t* name, int32_t len)
{
init();
this->len = len;
u_memcpy(this->name, name, len);
- memset(expansionString, 0, 25*sizeof(UChar));
+ memset(expansionString, 0, 25*sizeof(char16_t));
UChar32 c;
U16_GET(name, 0, 0, len, c);
firstCC = u_getCombiningClass(c);
lastCC = u_getCombiningClass(c);
}
-Line::Line(const UChar name)
+Line::Line(const char16_t name)
{
init();
len = 1;
this->name[0] = name;
this->name[1] = 0;
- memset(expansionString, 0, 25*sizeof(UChar));
+ memset(expansionString, 0, 25*sizeof(char16_t));
firstCC = u_getCombiningClass(name);
lastCC = firstCC;
}
}
void
-Line::setName(const UChar* name, int32_t len) {
+Line::setName(const char16_t* name, int32_t len) {
this->len = len;
u_memcpy(this->name, name, len);
UChar32 c;
}
UnicodeString
-Line::stringToName(UChar *string, int32_t len) {
+Line::stringToName(char16_t *string, int32_t len) {
UErrorCode status = U_ZERO_ERROR;
UnicodeString result;
char buffer[256];
if(!needsQuoting) {
needsQuoting = new UnicodeSet("[[:whitespace:][:c:][:z:][[:ascii:]-[a-zA-Z0-9]]]", status);
}
- UChar NFC[50];
+ char16_t NFC[50];
int32_t NFCLen = unorm_normalize(name, len, UNORM_NFC, 0, NFC, 50, &status);
result.append("\"");
if(isReset) {
{
UnicodeString result;
UErrorCode status = U_ZERO_ERROR;
- UChar NFC[50];
+ char16_t NFC[50];
int32_t NFCLen = unorm_normalize(name, len, UNORM_NFC, 0, NFC, 50, &status);
result.append("<span title=\"");
result.append(stringToName(NFC, NFCLen));
}
} else {
UErrorCode status = U_ZERO_ERROR;
- UChar NFC[50];
+ char16_t NFC[50];
int32_t NFCLen = unorm_normalize(name, len, UNORM_NFC, 0, NFC, 50, &status);
result.setTo(NFC, NFCLen);
if(expLen) {
}
void
-Line::append(const UChar* n, int32_t length)
+Line::append(const char16_t* n, int32_t length)
{
u_strncat(name, n, length);
name[len+length] = 0;
}
void
-Line::append(const UChar n)
+Line::append(const char16_t n)
{
name[len] = n;
name[len+1] = 0;
Line::write(char *buff, int32_t, UErrorCode &)
{
/*
- UChar name[25];
+ char16_t name[25];
int32_t len;
- UChar expansionString[25];
+ char16_t expansionString[25];
int32_t expLen;
UColAttributeValue strength;
}
void
-Line::swapCase(UChar *string, int32_t &sLen)
+Line::swapCase(char16_t *string, int32_t &sLen)
{
UChar32 c = 0;
int32_t i = 0, j = 0;
- UChar buff[256];
+ char16_t buff[256];
UBool isError = false;
while(i < sLen) {
U16_NEXT(string, i, sLen, c);
static void copyArray(Line *dest, const Line *src, int32_t size);
Line();
Line(const Line &other);
- Line(const UChar* name, int32_t len);
+ Line(const char16_t* name, int32_t len);
Line(const UnicodeString &string);
- Line(const UChar name);
+ Line(const char16_t name);
Line(const char *buff, int32_t buffLen, UErrorCode &status);
~Line();
Line & operator=(const Line &other);
UBool operator==(const Line &other) const;
UBool operator!=(const Line &other) const;
void setToConcat(const Line *first, const Line *second);
- void setName(const UChar* name, int32_t len);
+ void setName(const char16_t* name, int32_t len);
UnicodeString toString(UBool pretty = false);
UnicodeString toBundleString();
UnicodeString toHTMLString();
UnicodeString strengthIndent(UColAttributeValue strength, int indentSize, UnicodeString &result);
UnicodeString strengthToString(UColAttributeValue strength, UBool pretty, UBool html = false);
- UnicodeString stringToName(UChar *string, int32_t len);
+ UnicodeString stringToName(char16_t *string, int32_t len);
void setTo(const UnicodeString &string);
void setTo(const UChar32 n);
UBool equals(const Line &other) const;
Line *nextInteresting();
- void append(const UChar n);
- void append(const UChar* n, int32_t length);
+ void append(const char16_t n);
+ void append(const char16_t* n, int32_t length);
void append(const Line &l);
void clear();
void swapCase();
- void swapCase(UChar *string, int32_t &sLen);
+ void swapCase(char16_t *string, int32_t &sLen);
UnicodeString dumpSortkey();
void init();
public:
- UChar name[25];
+ char16_t name[25];
int32_t len;
- UChar expansionString[25];
+ char16_t expansionString[25];
int32_t expLen;
UColAttributeValue strength;
UConverter *conv = ucnv_open("utf8", &status);
- UChar UBuffer[256];
+ char16_t UBuffer[256];
int32_t uBufLen = 0;
char buffer[256];
int32_t bufLen = 0;
//u_strcpy(UB[strength], toSort[size-1]->name);
// a different solution for bounds: go from end and see if the guys on the top
// cause duplication for things
- UChar dupch[] = { 0x0020, 0x0030, 0x0042, 0x0051, 0x0062, 0x0071, 0x0391, 0x0396, 0x03b1, 0x03b6 };
+ char16_t dupch[] = { 0x0020, 0x0030, 0x0042, 0x0051, 0x0062, 0x0071, 0x0391, 0x0396, 0x03b1, 0x03b6 };
j = 1;
Line dup;
Line bound;
int i = 0, j = 0, k = 0;
Line lower, upper, trial, toAdd, helper;
UChar32 firstStart, firstEnd, secondStart;
- UChar NFCTrial[256];
+ char16_t NFCTrial[256];
int32_t NFCTrialLen = 0;
UBool thai;
i = -1;
SortedLines::removeDecompositionsFromRepertoire() {
UnicodeSetIterator repertoireIter(repertoire);
UErrorCode status = U_ZERO_ERROR;
- UChar string[256];
- UChar composed[256];
+ char16_t string[256];
+ char16_t composed[256];
int32_t len = 0, compLen = 0;
UnicodeString compString;
UnicodeSet toRemove;
#include "strengthprobe.h"
-StrengthProbe::StrengthProbe(CompareFn comparer, GetSortKeyFn getter, UChar SE,
- UChar B0, UChar B1, UChar B2, UChar B3) :
+StrengthProbe::StrengthProbe(CompareFn comparer, GetSortKeyFn getter, char16_t SE,
+ char16_t B0, char16_t B1, char16_t B2, char16_t B3) :
SE(SE),
B0(B0), B1(B1), B2(B2), B3(B3),
utilFirstP(&utilFirst), utilSecondP(&utilSecond),
}
int
-StrengthProbe::setProbeChars(UChar B0, UChar B1, UChar B2, UChar B3)
+StrengthProbe::setProbeChars(char16_t B0, char16_t B1, char16_t B2, char16_t B3)
{
this->B0 = B0;
this->B1 = B1;
}
UBool
-StrengthProbe::probePrefix(const Line &x, const Line &y, UChar first, UChar second) {
+StrengthProbe::probePrefix(const Line &x, const Line &y, char16_t first, char16_t second) {
utilFirst.name[0] = first;
utilFirst.name[1] = SE;
u_strcpy(utilFirst.name+2, x.name);
}
UBool
-StrengthProbe::probeSuffix(const Line &x, const Line &y, UChar first, UChar second) {
+StrengthProbe::probeSuffix(const Line &x, const Line &y, char16_t first, char16_t second) {
u_strcpy(utilFirst.name, x.name);
utilFirst.name[x.len] = SE;
utilFirst.name[x.len+1] = first;
}
UBool
-StrengthProbe::probePrefixNoSep(const Line &x, const Line &y, UChar first, UChar second) {
+StrengthProbe::probePrefixNoSep(const Line &x, const Line &y, char16_t first, char16_t second) {
utilFirst.name[0] = first;
u_strcpy(utilFirst.name+1, x.name);
utilFirst.name[x.len+1] = 0;
}
UBool
-StrengthProbe::probeSuffixNoSep(const Line &x, const Line &y, UChar first, UChar second) {
+StrengthProbe::probeSuffixNoSep(const Line &x, const Line &y, char16_t first, char16_t second) {
u_strcpy(utilFirst.name, x.name);
utilFirst.name[x.len] = first;
utilFirst.name[x.len+1] = 0;
UBool
StrengthProbe::isUpperFirst(UErrorCode &status) {
- UChar i = 0;
+ char16_t i = 0;
int32_t result = 0;
int32_t upper = 0, lower = 0, equal = 0;
for(i = 0x41; i < 0x5B; i++) {
class StrengthProbe {
public:
- UChar SE;
- UChar B0;
- UChar B1;
- UChar B2;
- UChar B3;
+ char16_t SE;
+ char16_t B0;
+ char16_t B1;
+ char16_t B2;
+ char16_t B3;
private:
Line utilFirst;
Line utilSecond;
Line *utilSecondP;
Line contractionUtilFirst;
Line contractionUtilSecond;
- UBool probePrefix(const Line &x, const Line &y, UChar first, UChar second);
- UBool probeSuffix(const Line &x, const Line &y, UChar first, UChar second);
- UBool probePrefixNoSep(const Line &x, const Line &y, UChar first, UChar second);
- UBool probeSuffixNoSep(const Line &x, const Line &y, UChar first, UChar second);
+ UBool probePrefix(const Line &x, const Line &y, char16_t first, char16_t second);
+ UBool probeSuffix(const Line &x, const Line &y, char16_t first, char16_t second);
+ UBool probePrefixNoSep(const Line &x, const Line &y, char16_t first, char16_t second);
+ UBool probeSuffixNoSep(const Line &x, const Line &y, char16_t first, char16_t second);
UBool frenchSecondary;
GetSortKeyFn skgetter;
StrengthProbe() {};
- StrengthProbe(CompareFn comparer, GetSortKeyFn getter, UChar SE = 0x0030, UChar B0 = 0x0061, UChar B1 = 0x0062, UChar B2 = 0x00E1, UChar B3 = 0x0041); //, UChar LB = 0x0039, UChar UB = 0xfa29);
- int setProbeChars(UChar B0, UChar B1, UChar B2, UChar B3);
+ StrengthProbe(CompareFn comparer, GetSortKeyFn getter, char16_t SE = 0x0030, char16_t B0 = 0x0061, char16_t B1 = 0x0062, char16_t B2 = 0x00E1, char16_t B3 = 0x0041); //, char16_t LB = 0x0039, char16_t UB = 0xfa29);
+ int setProbeChars(char16_t B0, char16_t B1, char16_t B2, char16_t B3);
int checkSanity();
StrengthProbe(const StrengthProbe &that);
StrengthProbe &operator=(const StrengthProbe &that);
return skgetter(l.name, l.len, buffer, buffCap);
};
- int getSortKey(UChar *string, int32_t sLen, uint8_t *buffer, int32_t buffCap) {
+ int getSortKey(char16_t *string, int32_t sLen, uint8_t *buffer, int32_t buffCap) {
return skgetter(string, sLen, buffer, buffCap);
};
}
void
-UPrinter::log(const UChar *string, UBool nl) {
+UPrinter::log(const char16_t *string, UBool nl) {
if(_on) {
u_fprintf(out, "%S", string);
if(nl) {
void UPrinter::log(const char *fmt, ...)
{
- UChar buffer[4000];
+ char16_t buffer[4000];
va_list ap;
va_start(ap, fmt);
class UPrinter {
UFILE *out;
- UChar buffer[256];
+ char16_t buffer[256];
UBool _on;
char _locale[256];
public:
UPrinter(const char *name, const char *locale, const char *encoding, UTransliterator *trans, UBool transliterateNonPrintable);
~UPrinter();
void log(const UnicodeString &string, UBool nl = false);
- void log(const UChar *string, UBool nl = false);
+ void log(const char16_t *string, UBool nl = false);
//void log(const char *string, UBool nl = false);
void log(const Line *line, UBool nl = false);
void log(const char *fmt, ...);
/* Print a ustring to the specified FILE* in the default codepage */
U_CAPI void
-uprint(const UChar *s,
+uprint(const char16_t *s,
FILE *f,
UErrorCode *status)
{
UConverter *converter;
char buf [BUF_SIZE];
int32_t sourceLen;
- const UChar *mySource;
- const UChar *mySourceEnd;
+ const char16_t *mySource;
+ const char16_t *mySourceEnd;
char *myTarget;
int32_t arraySize;
}
/*U_CAPI void U_EXPORT2*/
-static void _versionFromUString(UVersionInfo versionArray, const UChar *versionString) {
+static void _versionFromUString(UVersionInfo versionArray, const char16_t *versionString) {
if(versionArray==nullptr) {
return;
}
// fprintf(stderr, "Err: could not open res_index, %s\n", u_errorName(status));
// fflush(stderr);
// } else {
- const UChar *cldrver;
+ const char16_t *cldrver;
int32_t len;
cldrver = ures_getStringByKey(resindx, "cldrVersion", &len, status);
if(!U_FAILURE(*status)) {
// fprintf(stderr, "Err: could not open res_index, %s\n", u_errorName(status));
// fflush(stderr);
// } else {
- const UChar *cldrver;
+ const char16_t *cldrver;
int32_t len;
cldrver = ures_getStringByKey(resindx, "CLDRVersion", &len, status);
if(!U_FAILURE(*status)) {
int *starts = nullptr;
-UChar ***rootdata = nullptr;
+char16_t ***rootdata = nullptr;
void initroot(UErrorCode *status) {
UDateFormat *fmt;
fmt = udat_open(UDAT_DEFAULT, UDAT_DEFAULT, "root", nullptr, -1,nullptr,0, status);
- rootdata = (UChar***)malloc((sizeof(scanArray)/sizeof(scanArray[0]))*sizeof(rootdata[0]));
+ rootdata = (char16_t***)malloc((sizeof(scanArray)/sizeof(scanArray[0]))*sizeof(rootdata[0]));
starts = (int*)malloc((sizeof(scanArray)/sizeof(scanArray[0]))*sizeof(starts[0]));
for(int i=0;U_SUCCESS(*status)&&i<sizeof(scanArray)/sizeof(scanArray[0]);i++) {
int thisCount = udat_countSymbols(fmt, scanArray[i]);
rootdata[i]=0;
- rootdata[i]=(UChar**)malloc(thisCount*sizeof(rootdata[i][0]));
+ rootdata[i]=(char16_t**)malloc(thisCount*sizeof(rootdata[i][0]));
switch(scanArray[i]) {
case UDAT_WEEKDAYS:
case UDAT_SHORT_WEEKDAYS:
starts[i]=0;
}
for(int j=starts[i];U_SUCCESS(*status)&&j<thisCount;j++) {
- rootdata[i][j]=(UChar*)malloc(1024);
+ rootdata[i][j]=(char16_t*)malloc(1024);
int sz =
udat_getSymbols(fmt,
scanArray[i],
/* Format the date */
static void
-date(const UChar *tz,
+date(const char16_t *tz,
UDateFormatStyle style,
char *format,
const char *locale, char *comments,
UErrorCode *status)
{
- UChar *s = 0;
+ char16_t *s = 0;
int32_t len = 0;
UDateFormat *fmt;
- UChar uFormat[100];
+ char16_t uFormat[100];
char tmp[200];
int tc=0; // total count
len = udat_format(fmt, ucal_getNow(), 0, len, 0, status);
if(*status == U_BUFFER_OVERFLOW_ERROR) {
*status = U_ZERO_ERROR;
- s = (UChar*) malloc(sizeof(UChar) * (len+1));
+ s = (char16_t*) malloc(sizeof(char16_t) * (len+1));
if(s == 0) goto finish;
udat_format(fmt, ucal_getNow(), s, len + 1, 0, status);
if(U_FAILURE(*status)) goto finish;
/* print a trailing newline */
//printf("\n");
/* count bits */
- UChar outbuf[1024];
+ char16_t outbuf[1024];
for(int i=0;U_SUCCESS(*status)&&i<sizeof(scanArray)/sizeof(scanArray[0]);i++) {
int thisCount = udat_countSymbols(fmt, scanArray[i]);
tc += thisCount;
/* String to use. */
-const UChar stuff[] = { 0x30BB, 0x0d4c, 0x53, 0x74, 0x75, 0x66, 0x66, 0x00 }; /* Stuff */
+const char16_t stuff[] = { 0x30BB, 0x0d4c, 0x53, 0x74, 0x75, 0x66, 0x66, 0x00 }; /* Stuff */
#include "provider_version.h"
for(uint32_t s=0;s<sizeof(styles)/sizeof(styles[0]);s++) {
for(int l=0;l<LOCALE_COUNT;l++) {
printf("\n");
- UChar oldChars[200];
+ char16_t oldChars[200];
int32_t oldLen = -1;
for(int v=0;v<=expected;v++) {
printf("%18s : ", locID);
UErrorCode subStatus = U_ZERO_ERROR;
- UChar outchars[200];
+ char16_t outchars[200];
UDateFormat *dat = udat_open(styles[s],styles[s], locID, nullptr, -1, nullptr, 0, &subStatus);
// GLUE_SYM ( DateFormat ) :: create(UDateFormatStyle timeStyle,
// UDateFormatStyle dateStyle,
// const char *locale,
-// const UChar *tzID,
+// const char16_t *tzID,
// int32_t tzIDLength,
-// const UChar *pattern,
+// const char16_t *pattern,
// int32_t patternLength,
// UErrorCode *status,
// const Locale &loc, const char */*ver*/) {
#if CAL_FE_DEBUG
{
char foo[999];
- const UChar *ss = strs[i+j].getTerminatedBuffer();
+ const char16_t *ss = strs[i+j].getTerminatedBuffer();
u_austrcpy(foo, ss);
fprintf(stderr, "VCF " ICUGLUE_VER_STR " appending [%d+%d=%d] <<%s>>\n", i, j, i+j, foo);
}
// virtual Calendar *createFormat(UCalendarStyle timeStyle,
// UCalendarStyle dateStyle,
// const char *locale,
- // const UChar *tzID,
+ // const char16_t *tzID,
// int32_t tzIDLength,
- // const UChar *pattern,
+ // const char16_t *pattern,
// int32_t patternLength,
// UErrorCode *status);
virtual void* getDynamicClassID() const;
virtual Collator* clone() const; \
virtual UCollationResult compare(const UnicodeString&, const UnicodeString&, UErrorCode&) const; \
virtual UCollationResult compare(const UnicodeString&, const UnicodeString&, int32_t, UErrorCode&) const; \
- virtual UCollationResult compare(const UChar*, int32_t, const UChar*, int32_t, UErrorCode&) const; \
+ virtual UCollationResult compare(const char16_t*, int32_t, const char16_t*, int32_t, UErrorCode&) const; \
virtual CollationKey& getCollationKey(const UnicodeString&, CollationKey&, UErrorCode&) const; \
- virtual CollationKey& getCollationKey(const UChar*, int32_t, CollationKey&, UErrorCode&) const; \
+ virtual CollationKey& getCollationKey(const char16_t*, int32_t, CollationKey&, UErrorCode&) const; \
virtual int32_t hashCode() const; \
virtual CONST_BEFORE_50_0_2 Locale getLocale(ULocDataLocaleType, UErrorCode&) const; \
virtual ECollationStrength getStrength() const; \
virtual void getVersion(uint8_t*) const; \
virtual void setAttribute(UColAttribute, UColAttributeValue, UErrorCode&) ; \
virtual UColAttributeValue getAttribute(UColAttribute, UErrorCode&) CONST_AFTER_50_0_2; \
- virtual uint32_t setVariableTop(const UChar*, int32_t, UErrorCode&); \
+ virtual uint32_t setVariableTop(const char16_t*, int32_t, UErrorCode&); \
virtual uint32_t setVariableTop(const UnicodeString REF_AFTER_50_0_2, UErrorCode&); \
virtual void setVariableTop(uint32_t, UErrorCode&); \
virtual uint32_t getVariableTop(UErrorCode&) const; \
virtual Collator* safeClone() CONST_AFTER_50_0_2 ; \
virtual int32_t getSortKey(const UnicodeString&, uint8_t*, int32_t) const; \
- virtual int32_t getSortKey(const UChar*, int32_t, uint8_t*, int32_t) const; \
+ virtual int32_t getSortKey(const char16_t*, int32_t, uint8_t*, int32_t) const; \
public: static int32_t countAvailable(); \
public: static int32_t appendAvailable(UnicodeString* strs, int32_t i, int32_t count); \
public: virtual int32_t internalGetShortDefinitionString(const char *locale, char *buffer, int32_t capacity, UErrorCode &status) const; \
#if 0
U_CFUNC int32_t U_CALLCONV
GLUE_SYM ( glue_calcSortKey) (const UCollator *coll,
- const UChar *source,
+ const char16_t *source,
int32_t sourceLength,
uint8_t **result,
uint32_t resultLength,
}
-UCollationResult GLUE_SYM ( Collator ) :: compare(const UChar* s, int32_t sl, const UChar* d , int32_t dl, UErrorCode&/*e*/ ) const {
+UCollationResult GLUE_SYM ( Collator ) :: compare(const char16_t* s, int32_t sl, const char16_t* d , int32_t dl, UErrorCode&/*e*/ ) const {
return OICU_ucol_strcoll(_this, s, sl, d, dl);
}
}
-CollationKey& GLUE_SYM ( Collator ) :: getCollationKey(const UChar*, int32_t, CollationKey&, UErrorCode&) const {
+CollationKey& GLUE_SYM ( Collator ) :: getCollationKey(const char16_t*, int32_t, CollationKey&, UErrorCode&) const {
fprintf(stderr, "VCF " ICUGLUE_VER_STR " GKK2 - notimp");
return kk;
}
}
-uint32_t GLUE_SYM ( Collator ) :: setVariableTop(const UChar*, int32_t, UErrorCode&) {
+uint32_t GLUE_SYM ( Collator ) :: setVariableTop(const char16_t*, int32_t, UErrorCode&) {
return 0;
}
-int32_t GLUE_SYM ( Collator ) :: getSortKey(const UChar*s, int32_t l, uint8_t*d, int32_t b) const {
+int32_t GLUE_SYM ( Collator ) :: getSortKey(const char16_t*s, int32_t l, uint8_t*d, int32_t b) const {
#if COLL_FE_DEBUG
fprintf(stderr, "VCF " ICUGLUE_VER_STR " GKS");
#endif
#if COLL_FE_DEBUG
{
char foo[999];
- const UChar *ss = strs[i+j].getTerminatedBuffer();
+ const char16_t *ss = strs[i+j].getTerminatedBuffer();
u_austrcpy(foo, ss);
debugfprintf((stderr, "VCF " ICUGLUE_VER_STR " appending [%d+%d=%d] <<%s>>\n", i, j, i+j, foo));
}
public: static DateFormat *create(UDateFormatStyle timeStyle, \
UDateFormatStyle dateStyle, \
const char *locale, \
- const UChar *tzID, \
+ const char16_t *tzID, \
int32_t tzIDLength, \
- const UChar *pattern, \
+ const char16_t *pattern, \
int32_t patternLength, \
UErrorCode *status, const Locale &loc, const char *ver); \
private: UDateFormat *_this; GLUE_SYM_V( DateFormat, x ) ( UDateFormat* tn ); \
GLUE_SYM ( DateFormat ) :: create(UDateFormatStyle timeStyle,
UDateFormatStyle dateStyle,
const char *locale,
- const UChar *tzID,
+ const char16_t *tzID,
int32_t tzIDLength,
- const UChar *pattern,
+ const char16_t *pattern,
int32_t patternLength,
UErrorCode *status,
const Locale &loc, const char */*ver*/) {
#endif
int32_t len = appendTo.length();
- UChar junk[200];
+ char16_t junk[200];
UErrorCode status = U_ZERO_ERROR;
UFieldPosition pos2;
#if DATE_FE_DEBUG
{
char foo[999];
- const UChar *ss = strs[i+j].getTerminatedBuffer();
+ const char16_t *ss = strs[i+j].getTerminatedBuffer();
u_austrcpy(foo, ss);
// fprintf(stderr, "VCF " ICUGLUE_VER_STR " appending [%d+%d=%d] <<%s>>\n", i, j, i+j, foo);
}
virtual DateFormat *createFormat(UDateFormatStyle timeStyle,
UDateFormatStyle dateStyle,
const char *locale,
- const UChar *tzID,
+ const char16_t *tzID,
int32_t tzIDLength,
- const UChar *pattern,
+ const char16_t *pattern,
int32_t patternLength,
UErrorCode *status);
virtual const UnicodeString *getSupportedIDs(int32_t &count, UErrorCode &status);
DateFormat *VersionDateFormatFactory::createFormat(UDateFormatStyle timeStyle,
UDateFormatStyle dateStyle,
const char *locale,
- const UChar *tzID,
+ const char16_t *tzID,
int32_t tzIDLength,
- const UChar *pattern,
+ const char16_t *pattern,
int32_t patternLength,
UErrorCode *status) {
Locale loc(locale);
extern "C" UDateFormat *versionDateFormatOpener(UDateFormatStyle timeStyle,
UDateFormatStyle dateStyle,
const char *locale,
- const UChar *tzID,
+ const char16_t *tzID,
int32_t tzIDLength,
- const UChar *pattern,
+ const char16_t *pattern,
int32_t patternLength,
UErrorCode *status) {
DateFormat *df = vdf.createFormat(timeStyle,dateStyle,locale,tzID,tzIDLength,pattern,patternLength,status);
const uint16_t exceptions[exceptionsLength];
- const UChar unfold[unfoldLength];
+ const char16_t unfold[unfoldLength];
Trie data word:
// Write "unfold" meta data into the first row. Must be UGENCASE_UNFOLD_WIDTH UChars.
unfold.
append(0).
- append((UChar)UGENCASE_UNFOLD_WIDTH).
- append((UChar)UGENCASE_UNFOLD_STRING_WIDTH).
+ append((char16_t)UGENCASE_UNFOLD_WIDTH).
+ append((char16_t)UGENCASE_UNFOLD_STRING_WIDTH).
append(0).
append(0);
U_ASSERT(unfold.length()==UGENCASE_UNFOLD_WIDTH);
static int32_t U_CALLCONV
compareUnfold(const void *context, const void *left, const void *right) {
- return u_memcmp((const UChar *)left, (const UChar *)right, UGENCASE_UNFOLD_WIDTH);
+ return u_memcmp((const char16_t *)left, (const char16_t *)right, UGENCASE_UNFOLD_WIDTH);
}
void
CasePropsBuilder::makeUnfoldData(UErrorCode &errorCode) {
if(U_FAILURE(errorCode)) { return; }
- UChar *p, *q;
+ char16_t *p, *q;
int32_t i, j, k;
/* sort the data */
int32_t unfoldLength=unfold.length();
int32_t unfoldRows=unfoldLength/UGENCASE_UNFOLD_WIDTH-1;
- UChar *unfoldBuffer=unfold.getBuffer(-1);
+ char16_t *unfoldBuffer=unfold.getBuffer(-1);
uprv_sortArray(unfoldBuffer+UGENCASE_UNFOLD_WIDTH, unfoldRows, UGENCASE_UNFOLD_WIDTH*2,
compareUnfold, nullptr, false, &errorCode);
}
}
- unfoldBuffer[UCASE_UNFOLD_ROWS]=(UChar)unfoldRows;
+ unfoldBuffer[UCASE_UNFOLD_ROWS]=(char16_t)unfoldRows;
if(beVerbose) {
puts("unfold data:");
/* use the "unfold" data to add mappings */
/* p always points to the code points; this loop ignores the strings completely */
- const UChar *p=unfold.getBuffer()+UGENCASE_UNFOLD_WIDTH+UGENCASE_UNFOLD_STRING_WIDTH;
+ const char16_t *p=unfold.getBuffer()+UGENCASE_UNFOLD_WIDTH+UGENCASE_UNFOLD_STRING_WIDTH;
int32_t unfoldRows=unfold.length()/UGENCASE_UNFOLD_WIDTH-1;
for(int32_t i=0; i<unfoldRows; p+=UGENCASE_UNFOLD_WIDTH, ++i) {
}
/* copy and shift the soft-dotted and case-sensitive bits */
- UChar excWord=(UChar)((value&(UCASE_DOT_MASK|UCASE_SENSITIVE))<<UCASE_EXC_DOT_SHIFT);
+ char16_t excWord=(char16_t)((value&(UCASE_DOT_MASK|UCASE_SENSITIVE))<<UCASE_EXC_DOT_SHIFT);
UniProps &p=ep.props;
if(count==0) {
/* No optional slots: Try to share excWord entries. */
- int32_t excIndex=exceptions.indexOf((UChar)excWord);
+ int32_t excIndex=exceptions.indexOf((char16_t)excWord);
if(excIndex>=0) {
return excIndex;
}
/* not found */
excIndex=exceptions.length();
- exceptions.append((UChar)excWord);
+ exceptions.append((char16_t)excWord);
return excIndex;
} else {
/* write slots */
UnicodeString excString;
- excString.append((UChar)0); /* placeholder for excWord which will be stored at excIndex */
+ excString.append((char16_t)0); /* placeholder for excWord which will be stored at excIndex */
if(slotBits<=0xffff) {
for(int32_t i=0; i<count; ++i) {
- excString.append((UChar)slots[i]);
+ excString.append((char16_t)slots[i]);
}
} else {
excWord|=UCASE_EXC_DOUBLE_SLOTS;
for(int32_t i=0; i<count; ++i) {
- excString.append((UChar)(slots[i]>>16));
- excString.append((UChar)slots[i]);
+ excString.append((char16_t)(slots[i]>>16));
+ excString.append((char16_t)slots[i]);
}
}
excString.append(closureString);
/* write the main exceptions word */
- excString.setCharAt(0, (UChar)excWord);
+ excString.setCharAt(0, (char16_t)excWord);
// Try to share data.
if(count==1 && ep.delta!=0) {
P const uint32_t props32[i1-i0];
E const uint32_t exceptions[i2-i1];
- U const UChar uchars[2*(i3-i2)];
+ U const char16_t uchars[2*(i3-i2)];
AT serialized trie for additional properties (byte size: 4*(i4-i3))
PV const uint32_t propsVectors[(i6-i4)/i5][i5]==uint32_t propsVectors[i6-i4];
) {
UnicodeString codes; // vector of 16-bit UScriptCode values
UnicodeSetIterator iter(props.scx);
- while(iter.next()) { codes.append((UChar)iter.getCodepoint()); }
+ while(iter.next()) { codes.append((char16_t)iter.getCodepoint()); }
// Set bit 15 on the last script code, for termination.
int32_t length=codes.length();
- codes.setCharAt(length-1, (UChar)(codes[length-1]|0x8000));
+ codes.setCharAt(length-1, (char16_t)(codes[length-1]|0x8000));
// Find this list of codes in the Script_Extensions data so far, or add this list.
int32_t index=scriptExtensions.indexOf(codes);
if(index<0) {
// Store an additional pair of 16-bit units for an unusual main Script code
// together with the Script_Extensions index.
UnicodeString codeIndexPair;
- codeIndexPair.append((UChar)script).append((UChar)index);
+ codeIndexPair.append((char16_t)script).append((char16_t)index);
index=scriptExtensions.indexOf(codeIndexPair);
if(index<0) {
index=scriptExtensions.length();
/* round up scriptExtensions to multiple of 4 bytes */
if(scriptExtensions.length()&1) {
- scriptExtensions.append((UChar)0);
+ scriptExtensions.append((char16_t)0);
}
/* set indexes */
// 23F0 ; Basic_Emoji ; alarm clock
// 23F1 FE0F ; Basic_Emoji ; stopwatch
uint32_t first;
- UChar s[100];
+ char16_t s[100];
int32_t length = u_parseString(rangeOrString, s, UPRV_LENGTHOF(s), &first, &errorCode);
if (U_FAILURE(errorCode)) { return; }
if (length == 0) {
U_IS_BIG_ENDIAN,
U_CHARSET_FAMILY,
- sizeof(UChar),
+ sizeof(char16_t),
0,
{0x75, 0x6e, 0x61, 0x6d}, /* dataFormat="unam" */
U_IS_BIG_ENDIAN,
U_CHARSET_FAMILY,
- sizeof(UChar),
+ sizeof(char16_t),
0,
{ PNAME_SIG_0, PNAME_SIG_1, PNAME_SIG_2, PNAME_SIG_3 },
}
std::cout << "0};\n\n";
- std::cout << " static const UChar RECaseFixData[] = {";
+ std::cout << " static const char16_t RECaseFixData[] = {";
for (int i=0; i<outString.length(); i++) {
if (i % 10 == 0) {
std::cout << "\n ";
// Add a mapping for the first-unassigned boundary,
// which is the AlphabeticIndex overflow boundary.
- UnicodeString s((UChar)0xfdd1); // Script boundary contractions start with U+FDD1.
- s.append((UChar)0xfdd0); // Zzzz script sample character U+FDD0.
+ UnicodeString s((char16_t)0xfdd1); // Script boundary contractions start with U+FDD1.
+ s.append((char16_t)0xfdd0); // Zzzz script sample character U+FDD0.
int64_t ce = Collation::makeCE(Collation::FIRST_UNASSIGNED_PRIMARY);
add(UnicodeString(), s, &ce, 1, errorCode);
if (pipePointer != nullptr) {
// Read the prefix string which precedes the actual string.
input.append(startCodePoint, (int32_t)(pipePointer - startCodePoint), *status);
- UChar *prefixChars = prefix.getBuffer(32);
+ char16_t *prefixChars = prefix.getBuffer(32);
int32_t prefixSize =
u_parseString(input.data(),
prefixChars, prefix.getCapacity(),
// Read the string which gets the CE(s) assigned.
input.append(startCodePoint, (int32_t)(endCodePoint - startCodePoint), *status);
- UChar *uchars = s.getBuffer(32);
+ char16_t *uchars = s.getBuffer(32);
int32_t cSize =
u_parseString(input.data(),
uchars, s.getCapacity(),
static void
setLeadSurrogatesForAssociatedSupplementary(UnicodeSet &bmp, const UnicodeSet &supp) {
UChar32 c = 0x10000;
- for(UChar lead = 0xd800; lead < 0xdc00; ++lead, c += 0x400) {
+ for(char16_t lead = 0xd800; lead < 0xdc00; ++lead, c += 0x400) {
if(supp.containsSome(c, c + 0x3ff)) {
bmp.add(lead);
}
static int
toIDNA2003(const UStringPrepProfile *prep, UChar32 c, icu::UnicodeString &destString) {
- UChar src[2];
+ char16_t src[2];
int32_t srcLength=0;
U16_APPEND_UNSAFE(src, srcLength, c);
- UChar *dest;
+ char16_t *dest;
int32_t destLength;
dest=destString.getBuffer(32);
if(dest==nullptr) {
printf("; %s", statusNames[status]);
if(status==MAPPED || status==DEVIATION || !mapping.isEmpty()) {
printf(" ;");
- const UChar *buffer=mapping.getBuffer();
+ const char16_t *buffer=mapping.getBuffer();
int32_t length=mapping.length();
int32_t i=0;
UChar32 c;