ICU-12992 add char16ptr.h with pointer conversions; use Char16Ptr for input parameters where possible; make UChar configurable but default to char16_t; add OldUChar same as ICU 58 UChar except not configurable; in public C++ headers change all UChar to char16_t (integrate branches/markus/ucharptr2)
X-SVN-Rev: 39762
This commit is contained in:
commit
05c591d7ef
@ -311,12 +311,12 @@ void U_EXPORT2 CanonicalIterator::permute(UnicodeString &source, UBool skipZeros
|
|||||||
|
|
||||||
// see what the permutations of the characters before and after this one are
|
// see what the permutations of the characters before and after this one are
|
||||||
//Hashtable *subpermute = permute(source.substring(0,i) + source.substring(i + UTF16.getCharCount(cp)));
|
//Hashtable *subpermute = permute(source.substring(0,i) + source.substring(i + UTF16.getCharCount(cp)));
|
||||||
permute(subPermuteString.replace(i, U16_LENGTH(cp), NULL, 0), skipZeros, &subpermute, status);
|
permute(subPermuteString.remove(i, U16_LENGTH(cp)), skipZeros, &subpermute, status);
|
||||||
/* Test for buffer overflows */
|
/* Test for buffer overflows */
|
||||||
if(U_FAILURE(status)) {
|
if(U_FAILURE(status)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// The upper replace is destructive. The question is do we have to make a copy, or we don't care about the contents
|
// The upper remove is destructive. The question is do we have to make a copy, or we don't care about the contents
|
||||||
// of source at this point.
|
// of source at this point.
|
||||||
|
|
||||||
// prefix this character to all of them
|
// prefix this character to all of them
|
||||||
|
@ -1530,6 +1530,20 @@
|
|||||||
</Command>
|
</Command>
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>
|
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy "%(FullPath)" ..\..\include\unicode
|
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy "%(FullPath)" ..\..\include\unicode
|
||||||
|
</Command>
|
||||||
|
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>
|
||||||
|
</CustomBuild>
|
||||||
|
<CustomBuild Include="unicode\char16ptr.h">
|
||||||
|
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy "%(FullPath)" ..\..\include\unicode
|
||||||
|
</Command>
|
||||||
|
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>
|
||||||
|
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">copy "%(FullPath)" ..\..\include\unicode
|
||||||
|
</Command>
|
||||||
|
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>
|
||||||
|
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">copy "%(FullPath)" ..\..\include\unicode
|
||||||
|
</Command>
|
||||||
|
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>
|
||||||
|
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy "%(FullPath)" ..\..\include\unicode
|
||||||
</Command>
|
</Command>
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>
|
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>
|
||||||
</CustomBuild>
|
</CustomBuild>
|
||||||
|
@ -1105,6 +1105,9 @@
|
|||||||
<CustomBuild Include="unicode\casemap.h">
|
<CustomBuild Include="unicode\casemap.h">
|
||||||
<Filter>strings</Filter>
|
<Filter>strings</Filter>
|
||||||
</CustomBuild>
|
</CustomBuild>
|
||||||
|
<CustomBuild Include="unicode\char16ptr.h">
|
||||||
|
<Filter>strings</Filter>
|
||||||
|
</CustomBuild>
|
||||||
<CustomBuild Include="unicode\chariter.h">
|
<CustomBuild Include="unicode\chariter.h">
|
||||||
<Filter>strings</Filter>
|
<Filter>strings</Filter>
|
||||||
</CustomBuild>
|
</CustomBuild>
|
||||||
|
@ -176,7 +176,7 @@ public:
|
|||||||
lastCC=0;
|
lastCC=0;
|
||||||
}
|
}
|
||||||
void copyReorderableSuffixTo(UnicodeString &s) const {
|
void copyReorderableSuffixTo(UnicodeString &s) const {
|
||||||
s.setTo(reorderStart, (int32_t)(limit-reorderStart));
|
s.setTo(ConstChar16Ptr(reorderStart), (int32_t)(limit-reorderStart));
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
/*
|
/*
|
||||||
|
@ -40,7 +40,7 @@ Normalizer::Normalizer(const UnicodeString& str, UNormalizationMode mode) :
|
|||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
Normalizer::Normalizer(const UChar *str, int32_t length, UNormalizationMode mode) :
|
Normalizer::Normalizer(ConstChar16Ptr str, int32_t length, UNormalizationMode mode) :
|
||||||
UObject(), fFilteredNorm2(NULL), fNorm2(NULL), fUMode(mode), fOptions(0),
|
UObject(), fFilteredNorm2(NULL), fNorm2(NULL), fUMode(mode), fOptions(0),
|
||||||
text(new UCharCharacterIterator(str, length)),
|
text(new UCharCharacterIterator(str, length)),
|
||||||
currentIndex(0), nextIndex(0),
|
currentIndex(0), nextIndex(0),
|
||||||
@ -435,7 +435,7 @@ Normalizer::setText(const CharacterIterator& newText,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Normalizer::setText(const UChar* newText,
|
Normalizer::setText(ConstChar16Ptr newText,
|
||||||
int32_t length,
|
int32_t length,
|
||||||
UErrorCode &status)
|
UErrorCode &status)
|
||||||
{
|
{
|
||||||
|
@ -175,7 +175,8 @@ UCharsTrie::next(int32_t uchar) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
UStringTrieResult
|
UStringTrieResult
|
||||||
UCharsTrie::next(const UChar *s, int32_t sLength) {
|
UCharsTrie::next(ConstChar16Ptr ptr, int32_t sLength) {
|
||||||
|
const UChar *s=ptr;
|
||||||
if(sLength<0 ? *s==0 : sLength==0) {
|
if(sLength<0 ? *s==0 : sLength==0) {
|
||||||
// Empty input.
|
// Empty input.
|
||||||
return current();
|
return current();
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
U_NAMESPACE_BEGIN
|
U_NAMESPACE_BEGIN
|
||||||
|
|
||||||
UCharsTrie::Iterator::Iterator(const UChar *trieUChars, int32_t maxStringLength,
|
UCharsTrie::Iterator::Iterator(ConstChar16Ptr trieUChars, int32_t maxStringLength,
|
||||||
UErrorCode &errorCode)
|
UErrorCode &errorCode)
|
||||||
: uchars_(trieUChars),
|
: uchars_(trieUChars),
|
||||||
pos_(uchars_), initialPos_(uchars_),
|
pos_(uchars_), initialPos_(uchars_),
|
||||||
|
@ -25,14 +25,14 @@ UCharCharacterIterator::UCharCharacterIterator()
|
|||||||
// never default construct!
|
// never default construct!
|
||||||
}
|
}
|
||||||
|
|
||||||
UCharCharacterIterator::UCharCharacterIterator(const UChar* textPtr,
|
UCharCharacterIterator::UCharCharacterIterator(ConstChar16Ptr textPtr,
|
||||||
int32_t length)
|
int32_t length)
|
||||||
: CharacterIterator(textPtr != 0 ? (length>=0 ? length : u_strlen(textPtr)) : 0),
|
: CharacterIterator(textPtr != 0 ? (length>=0 ? length : u_strlen(textPtr)) : 0),
|
||||||
text(textPtr)
|
text(textPtr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
UCharCharacterIterator::UCharCharacterIterator(const UChar* textPtr,
|
UCharCharacterIterator::UCharCharacterIterator(ConstChar16Ptr textPtr,
|
||||||
int32_t length,
|
int32_t length,
|
||||||
int32_t position)
|
int32_t position)
|
||||||
: CharacterIterator(textPtr != 0 ? (length>=0 ? length : u_strlen(textPtr)) : 0, position),
|
: CharacterIterator(textPtr != 0 ? (length>=0 ? length : u_strlen(textPtr)) : 0, position),
|
||||||
@ -40,7 +40,7 @@ UCharCharacterIterator::UCharCharacterIterator(const UChar* textPtr,
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
UCharCharacterIterator::UCharCharacterIterator(const UChar* textPtr,
|
UCharCharacterIterator::UCharCharacterIterator(ConstChar16Ptr textPtr,
|
||||||
int32_t length,
|
int32_t length,
|
||||||
int32_t textBegin,
|
int32_t textBegin,
|
||||||
int32_t textEnd,
|
int32_t textEnd,
|
||||||
@ -349,7 +349,7 @@ UCharCharacterIterator::move32(int32_t delta, CharacterIterator::EOrigin origin)
|
|||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UCharCharacterIterator::setText(const UChar* newText,
|
void UCharCharacterIterator::setText(ConstChar16Ptr newText,
|
||||||
int32_t newTextLength) {
|
int32_t newTextLength) {
|
||||||
text = newText;
|
text = newText;
|
||||||
if(newText == 0 || newTextLength < 0) {
|
if(newText == 0 || newTextLength < 0) {
|
||||||
|
@ -1030,7 +1030,8 @@ collectCurrencyNames(const char* locale,
|
|||||||
const UnicodeString *symbol;
|
const UnicodeString *symbol;
|
||||||
while ((symbol = iter.next()) != NULL) {
|
while ((symbol = iter.next()) != NULL) {
|
||||||
(*currencySymbols)[*total_currency_symbol_count].IsoCode = iso;
|
(*currencySymbols)[*total_currency_symbol_count].IsoCode = iso;
|
||||||
(*currencySymbols)[*total_currency_symbol_count].currencyName = (UChar*) symbol->getBuffer();
|
(*currencySymbols)[*total_currency_symbol_count].currencyName =
|
||||||
|
const_cast<UChar*>(symbol->getBuffer());
|
||||||
(*currencySymbols)[*total_currency_symbol_count].flag = 0;
|
(*currencySymbols)[*total_currency_symbol_count].flag = 0;
|
||||||
(*currencySymbols)[(*total_currency_symbol_count)++].currencyNameLen = symbol->length();
|
(*currencySymbols)[(*total_currency_symbol_count)++].currencyNameLen = symbol->length();
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ uprv_isInvariantUString(const UChar *s, int32_t length);
|
|||||||
*/
|
*/
|
||||||
U_INTERNAL inline UBool U_EXPORT2
|
U_INTERNAL inline UBool U_EXPORT2
|
||||||
uprv_isInvariantUnicodeString(const icu::UnicodeString &s) {
|
uprv_isInvariantUnicodeString(const icu::UnicodeString &s) {
|
||||||
return uprv_isInvariantUString(s.getBuffer(), s.length());
|
return uprv_isInvariantUString(icu::toUCharPtr(s.getBuffer()), s.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \file
|
* \file
|
||||||
* \brief C++ API: Appendable class: Sink for Unicode code points and 16-bit code units (UChars).
|
* \brief C++ API: Appendable class: Sink for Unicode code points and 16-bit code units (char16_ts).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "unicode/utypes.h"
|
#include "unicode/utypes.h"
|
||||||
@ -34,10 +34,10 @@ class UnicodeString;
|
|||||||
* Combines elements of Java Appendable and ICU4C ByteSink.
|
* Combines elements of Java Appendable and ICU4C ByteSink.
|
||||||
*
|
*
|
||||||
* This class can be used in APIs where it does not matter whether the actual destination is
|
* This class can be used in APIs where it does not matter whether the actual destination is
|
||||||
* a UnicodeString, a UChar[] array, a UnicodeSet, or any other object
|
* a UnicodeString, a char16_t[] array, a UnicodeSet, or any other object
|
||||||
* that receives and processes characters and/or strings.
|
* that receives and processes characters and/or strings.
|
||||||
*
|
*
|
||||||
* Implementation classes must implement at least appendCodeUnit(UChar).
|
* Implementation classes must implement at least appendCodeUnit(char16_t).
|
||||||
* The base class provides default implementations for the other methods.
|
* The base class provides default implementations for the other methods.
|
||||||
*
|
*
|
||||||
* The methods do not take UErrorCode parameters.
|
* The methods do not take UErrorCode parameters.
|
||||||
@ -62,11 +62,11 @@ public:
|
|||||||
* @return TRUE if the operation succeeded
|
* @return TRUE if the operation succeeded
|
||||||
* @stable ICU 4.8
|
* @stable ICU 4.8
|
||||||
*/
|
*/
|
||||||
virtual UBool appendCodeUnit(UChar c) = 0;
|
virtual UBool appendCodeUnit(char16_t c) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Appends a code point.
|
* Appends a code point.
|
||||||
* The default implementation calls appendCodeUnit(UChar) once or twice.
|
* The default implementation calls appendCodeUnit(char16_t) once or twice.
|
||||||
* @param c code point 0..0x10ffff
|
* @param c code point 0..0x10ffff
|
||||||
* @return TRUE if the operation succeeded
|
* @return TRUE if the operation succeeded
|
||||||
* @stable ICU 4.8
|
* @stable ICU 4.8
|
||||||
@ -75,20 +75,20 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Appends a string.
|
* Appends a string.
|
||||||
* The default implementation calls appendCodeUnit(UChar) for each code unit.
|
* The default implementation calls appendCodeUnit(char16_t) for each code unit.
|
||||||
* @param s string, must not be NULL if length!=0
|
* @param s string, must not be NULL if length!=0
|
||||||
* @param length string length, or -1 if NUL-terminated
|
* @param length string length, or -1 if NUL-terminated
|
||||||
* @return TRUE if the operation succeeded
|
* @return TRUE if the operation succeeded
|
||||||
* @stable ICU 4.8
|
* @stable ICU 4.8
|
||||||
*/
|
*/
|
||||||
virtual UBool appendString(const UChar *s, int32_t length);
|
virtual UBool appendString(const char16_t *s, int32_t length);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tells the object that the caller is going to append roughly
|
* Tells the object that the caller is going to append roughly
|
||||||
* appendCapacity UChars. A subclass might use this to pre-allocate
|
* appendCapacity char16_ts. A subclass might use this to pre-allocate
|
||||||
* a larger buffer if necessary.
|
* a larger buffer if necessary.
|
||||||
* The default implementation does nothing. (It always returns TRUE.)
|
* The default implementation does nothing. (It always returns TRUE.)
|
||||||
* @param appendCapacity estimated number of UChars that will be appended
|
* @param appendCapacity estimated number of char16_ts that will be appended
|
||||||
* @return TRUE if the operation succeeded
|
* @return TRUE if the operation succeeded
|
||||||
* @stable ICU 4.8
|
* @stable ICU 4.8
|
||||||
*/
|
*/
|
||||||
@ -102,19 +102,19 @@ public:
|
|||||||
* The returned buffer is only valid until the next operation
|
* The returned buffer is only valid until the next operation
|
||||||
* on this Appendable.
|
* on this Appendable.
|
||||||
*
|
*
|
||||||
* After writing at most *resultCapacity UChars, call appendString() with the
|
* After writing at most *resultCapacity char16_ts, call appendString() with the
|
||||||
* pointer returned from this function and the number of UChars written.
|
* pointer returned from this function and the number of char16_ts written.
|
||||||
* Many appendString() implementations will avoid copying UChars if this function
|
* Many appendString() implementations will avoid copying char16_ts if this function
|
||||||
* returned an internal buffer.
|
* returned an internal buffer.
|
||||||
*
|
*
|
||||||
* Partial usage example:
|
* Partial usage example:
|
||||||
* \code
|
* \code
|
||||||
* int32_t capacity;
|
* int32_t capacity;
|
||||||
* UChar* buffer = app.getAppendBuffer(..., &capacity);
|
* char16_t* buffer = app.getAppendBuffer(..., &capacity);
|
||||||
* ... Write n UChars into buffer, with n <= capacity.
|
* ... Write n char16_ts into buffer, with n <= capacity.
|
||||||
* app.appendString(buffer, n);
|
* app.appendString(buffer, n);
|
||||||
* \endcode
|
* \endcode
|
||||||
* In many implementations, that call to append will avoid copying UChars.
|
* In many implementations, that call to append will avoid copying char16_ts.
|
||||||
*
|
*
|
||||||
* If the Appendable allocates or reallocates an internal buffer, it should use
|
* If the Appendable allocates or reallocates an internal buffer, it should use
|
||||||
* the desiredCapacityHint if appropriate.
|
* the desiredCapacityHint if appropriate.
|
||||||
@ -138,9 +138,9 @@ public:
|
|||||||
* @return a buffer with *resultCapacity>=minCapacity
|
* @return a buffer with *resultCapacity>=minCapacity
|
||||||
* @stable ICU 4.8
|
* @stable ICU 4.8
|
||||||
*/
|
*/
|
||||||
virtual UChar *getAppendBuffer(int32_t minCapacity,
|
virtual char16_t *getAppendBuffer(int32_t minCapacity,
|
||||||
int32_t desiredCapacityHint,
|
int32_t desiredCapacityHint,
|
||||||
UChar *scratch, int32_t scratchCapacity,
|
char16_t *scratch, int32_t scratchCapacity,
|
||||||
int32_t *resultCapacity);
|
int32_t *resultCapacity);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ public:
|
|||||||
* @return TRUE if the operation succeeded
|
* @return TRUE if the operation succeeded
|
||||||
* @stable ICU 4.8
|
* @stable ICU 4.8
|
||||||
*/
|
*/
|
||||||
virtual UBool appendCodeUnit(UChar c);
|
virtual UBool appendCodeUnit(char16_t c);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Appends a code point to the string.
|
* Appends a code point to the string.
|
||||||
@ -188,12 +188,12 @@ public:
|
|||||||
* @return TRUE if the operation succeeded
|
* @return TRUE if the operation succeeded
|
||||||
* @stable ICU 4.8
|
* @stable ICU 4.8
|
||||||
*/
|
*/
|
||||||
virtual UBool appendString(const UChar *s, int32_t length);
|
virtual UBool appendString(const char16_t *s, int32_t length);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tells the UnicodeString that the caller is going to append roughly
|
* Tells the UnicodeString that the caller is going to append roughly
|
||||||
* appendCapacity UChars.
|
* appendCapacity char16_ts.
|
||||||
* @param appendCapacity estimated number of UChars that will be appended
|
* @param appendCapacity estimated number of char16_ts that will be appended
|
||||||
* @return TRUE if the operation succeeded
|
* @return TRUE if the operation succeeded
|
||||||
* @stable ICU 4.8
|
* @stable ICU 4.8
|
||||||
*/
|
*/
|
||||||
@ -220,9 +220,9 @@ public:
|
|||||||
* @return a buffer with *resultCapacity>=minCapacity
|
* @return a buffer with *resultCapacity>=minCapacity
|
||||||
* @stable ICU 4.8
|
* @stable ICU 4.8
|
||||||
*/
|
*/
|
||||||
virtual UChar *getAppendBuffer(int32_t minCapacity,
|
virtual char16_t *getAppendBuffer(int32_t minCapacity,
|
||||||
int32_t desiredCapacityHint,
|
int32_t desiredCapacityHint,
|
||||||
UChar *scratch, int32_t scratchCapacity,
|
char16_t *scratch, int32_t scratchCapacity,
|
||||||
int32_t *resultCapacity);
|
int32_t *resultCapacity);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -127,14 +127,14 @@ private:
|
|||||||
void buildBytes(UStringTrieBuildOption buildOption, UErrorCode &errorCode);
|
void buildBytes(UStringTrieBuildOption buildOption, UErrorCode &errorCode);
|
||||||
|
|
||||||
virtual int32_t getElementStringLength(int32_t i) const;
|
virtual int32_t getElementStringLength(int32_t i) const;
|
||||||
virtual UChar getElementUnit(int32_t i, int32_t byteIndex) const;
|
virtual char16_t getElementUnit(int32_t i, int32_t byteIndex) const;
|
||||||
virtual int32_t getElementValue(int32_t i) const;
|
virtual int32_t getElementValue(int32_t i) const;
|
||||||
|
|
||||||
virtual int32_t getLimitOfLinearMatch(int32_t first, int32_t last, int32_t byteIndex) const;
|
virtual int32_t getLimitOfLinearMatch(int32_t first, int32_t last, int32_t byteIndex) const;
|
||||||
|
|
||||||
virtual int32_t countElementUnits(int32_t start, int32_t limit, int32_t byteIndex) const;
|
virtual int32_t countElementUnits(int32_t start, int32_t limit, int32_t byteIndex) const;
|
||||||
virtual int32_t skipElementsBySomeUnits(int32_t i, int32_t byteIndex, int32_t count) const;
|
virtual int32_t skipElementsBySomeUnits(int32_t i, int32_t byteIndex, int32_t count) const;
|
||||||
virtual int32_t indexOfElementWithNextUnit(int32_t i, int32_t byteIndex, UChar byte) const;
|
virtual int32_t indexOfElementWithNextUnit(int32_t i, int32_t byteIndex, char16_t byte) const;
|
||||||
|
|
||||||
virtual UBool matchNodesCanHaveValues() const { return FALSE; }
|
virtual UBool matchNodesCanHaveValues() const { return FALSE; }
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ private:
|
|||||||
UnicodeString *getEquivalents(const UnicodeString &segment, int32_t &result_len, UErrorCode &status); //private String[] getEquivalents(String segment)
|
UnicodeString *getEquivalents(const UnicodeString &segment, int32_t &result_len, UErrorCode &status); //private String[] getEquivalents(String segment)
|
||||||
|
|
||||||
//Set getEquivalents2(String segment);
|
//Set getEquivalents2(String segment);
|
||||||
Hashtable *getEquivalents2(Hashtable *fillinResult, const UChar *segment, int32_t segLen, UErrorCode &status);
|
Hashtable *getEquivalents2(Hashtable *fillinResult, const char16_t *segment, int32_t segLen, UErrorCode &status);
|
||||||
//Hashtable *getEquivalents2(const UnicodeString &segment, int32_t segLen, UErrorCode &status);
|
//Hashtable *getEquivalents2(const UnicodeString &segment, int32_t segLen, UErrorCode &status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -196,7 +196,7 @@ private:
|
|||||||
* If so, take the remainder, and return the equivalents
|
* If so, take the remainder, and return the equivalents
|
||||||
*/
|
*/
|
||||||
//Set extract(int comp, String segment, int segmentPos, StringBuffer buffer);
|
//Set extract(int comp, String segment, int segmentPos, StringBuffer buffer);
|
||||||
Hashtable *extract(Hashtable *fillinResult, UChar32 comp, const UChar *segment, int32_t segLen, int32_t segmentPos, UErrorCode &status);
|
Hashtable *extract(Hashtable *fillinResult, UChar32 comp, const char16_t *segment, int32_t segLen, int32_t segmentPos, UErrorCode &status);
|
||||||
//Hashtable *extract(UChar32 comp, const UnicodeString &segment, int32_t segLen, int32_t segmentPos, UErrorCode &status);
|
//Hashtable *extract(UChar32 comp, const UnicodeString &segment, int32_t segLen, int32_t segmentPos, UErrorCode &status);
|
||||||
|
|
||||||
void cleanPieces();
|
void cleanPieces();
|
||||||
|
@ -42,7 +42,7 @@ public:
|
|||||||
* @param dest A buffer for the result string. The result will be NUL-terminated if
|
* @param dest A buffer for the result string. The result will be NUL-terminated if
|
||||||
* the buffer is large enough.
|
* the buffer is large enough.
|
||||||
* The contents is undefined in case of failure.
|
* The contents is undefined in case of failure.
|
||||||
* @param destCapacity The size of the buffer (number of UChars). If it is 0, then
|
* @param destCapacity The size of the buffer (number of char16_ts). If it is 0, then
|
||||||
* dest may be NULL and the function will only return the length of the result
|
* dest may be NULL and the function will only return the length of the result
|
||||||
* without writing any of the result string.
|
* without writing any of the result string.
|
||||||
* @param edits Records edits for index mapping, working with styled text,
|
* @param edits Records edits for index mapping, working with styled text,
|
||||||
@ -59,8 +59,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
static int32_t toLower(
|
static int32_t toLower(
|
||||||
const char *locale, uint32_t options,
|
const char *locale, uint32_t options,
|
||||||
const UChar *src, int32_t srcLength,
|
const char16_t *src, int32_t srcLength,
|
||||||
UChar *dest, int32_t destCapacity, Edits *edits,
|
char16_t *dest, int32_t destCapacity, Edits *edits,
|
||||||
UErrorCode &errorCode);
|
UErrorCode &errorCode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -76,7 +76,7 @@ public:
|
|||||||
* @param dest A buffer for the result string. The result will be NUL-terminated if
|
* @param dest A buffer for the result string. The result will be NUL-terminated if
|
||||||
* the buffer is large enough.
|
* the buffer is large enough.
|
||||||
* The contents is undefined in case of failure.
|
* The contents is undefined in case of failure.
|
||||||
* @param destCapacity The size of the buffer (number of UChars). If it is 0, then
|
* @param destCapacity The size of the buffer (number of char16_ts). If it is 0, then
|
||||||
* dest may be NULL and the function will only return the length of the result
|
* dest may be NULL and the function will only return the length of the result
|
||||||
* without writing any of the result string.
|
* without writing any of the result string.
|
||||||
* @param edits Records edits for index mapping, working with styled text,
|
* @param edits Records edits for index mapping, working with styled text,
|
||||||
@ -93,8 +93,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
static int32_t toUpper(
|
static int32_t toUpper(
|
||||||
const char *locale, uint32_t options,
|
const char *locale, uint32_t options,
|
||||||
const UChar *src, int32_t srcLength,
|
const char16_t *src, int32_t srcLength,
|
||||||
UChar *dest, int32_t destCapacity, Edits *edits,
|
char16_t *dest, int32_t destCapacity, Edits *edits,
|
||||||
UErrorCode &errorCode);
|
UErrorCode &errorCode);
|
||||||
|
|
||||||
#if !UCONFIG_NO_BREAK_ITERATION
|
#if !UCONFIG_NO_BREAK_ITERATION
|
||||||
@ -122,7 +122,7 @@ public:
|
|||||||
* @param dest A buffer for the result string. The result will be NUL-terminated if
|
* @param dest A buffer for the result string. The result will be NUL-terminated if
|
||||||
* the buffer is large enough.
|
* the buffer is large enough.
|
||||||
* The contents is undefined in case of failure.
|
* The contents is undefined in case of failure.
|
||||||
* @param destCapacity The size of the buffer (number of UChars). If it is 0, then
|
* @param destCapacity The size of the buffer (number of char16_ts). If it is 0, then
|
||||||
* dest may be NULL and the function will only return the length of the result
|
* dest may be NULL and the function will only return the length of the result
|
||||||
* without writing any of the result string.
|
* without writing any of the result string.
|
||||||
* @param edits Records edits for index mapping, working with styled text,
|
* @param edits Records edits for index mapping, working with styled text,
|
||||||
@ -140,8 +140,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
static int32_t toTitle(
|
static int32_t toTitle(
|
||||||
const char *locale, uint32_t options, BreakIterator *iter,
|
const char *locale, uint32_t options, BreakIterator *iter,
|
||||||
const UChar *src, int32_t srcLength,
|
const char16_t *src, int32_t srcLength,
|
||||||
UChar *dest, int32_t destCapacity, Edits *edits,
|
char16_t *dest, int32_t destCapacity, Edits *edits,
|
||||||
UErrorCode &errorCode);
|
UErrorCode &errorCode);
|
||||||
|
|
||||||
#endif // UCONFIG_NO_BREAK_ITERATION
|
#endif // UCONFIG_NO_BREAK_ITERATION
|
||||||
@ -163,7 +163,7 @@ public:
|
|||||||
* @param dest A buffer for the result string. The result will be NUL-terminated if
|
* @param dest A buffer for the result string. The result will be NUL-terminated if
|
||||||
* the buffer is large enough.
|
* the buffer is large enough.
|
||||||
* The contents is undefined in case of failure.
|
* The contents is undefined in case of failure.
|
||||||
* @param destCapacity The size of the buffer (number of UChars). If it is 0, then
|
* @param destCapacity The size of the buffer (number of char16_ts). If it is 0, then
|
||||||
* dest may be NULL and the function will only return the length of the result
|
* dest may be NULL and the function will only return the length of the result
|
||||||
* without writing any of the result string.
|
* without writing any of the result string.
|
||||||
* @param edits Records edits for index mapping, working with styled text,
|
* @param edits Records edits for index mapping, working with styled text,
|
||||||
@ -180,8 +180,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
static int32_t fold(
|
static int32_t fold(
|
||||||
uint32_t options,
|
uint32_t options,
|
||||||
const UChar *src, int32_t srcLength,
|
const char16_t *src, int32_t srcLength,
|
||||||
UChar *dest, int32_t destCapacity, Edits *edits,
|
char16_t *dest, int32_t destCapacity, Edits *edits,
|
||||||
UErrorCode &errorCode);
|
UErrorCode &errorCode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
289
icu4c/source/common/unicode/char16ptr.h
Normal file
289
icu4c/source/common/unicode/char16ptr.h
Normal file
@ -0,0 +1,289 @@
|
|||||||
|
// © 2017 and later: Unicode, Inc. and others.
|
||||||
|
// License & terms of use: http://www.unicode.org/copyright.html
|
||||||
|
|
||||||
|
// char16ptr.h
|
||||||
|
// created: 2017feb28 Markus W. Scherer
|
||||||
|
|
||||||
|
#ifndef __CHAR16PTR_H__
|
||||||
|
#define __CHAR16PTR_H__
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
#include "unicode/utypes.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file
|
||||||
|
* \brief C++ API: char16_t pointer wrappers with
|
||||||
|
* implicit conversion to/from bit-compatible raw pointer types.
|
||||||
|
* Also conversion functions from char16_t * to UChar * and OldUChar *.
|
||||||
|
*/
|
||||||
|
|
||||||
|
U_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \def U_ALIASING_BARRIER
|
||||||
|
* Barrier for pointer anti-aliasing optimizations even across function boundaries.
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
#ifdef U_ALIASING_BARRIER
|
||||||
|
// Use the predefined value.
|
||||||
|
#elif defined(__clang__) || defined(__GNUC__)
|
||||||
|
# define U_ALIASING_BARRIER(ptr) asm volatile("" : : "rm"(ptr) : "memory")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* char16_t * wrapper with implicit conversion from distinct but bit-compatible pointer types.
|
||||||
|
* @draft ICU 59
|
||||||
|
*/
|
||||||
|
class U_COMMON_API Char16Ptr U_FINAL {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Copies the pointer.
|
||||||
|
* @param p pointer
|
||||||
|
* @draft ICU 59
|
||||||
|
*/
|
||||||
|
inline Char16Ptr(char16_t *p);
|
||||||
|
/**
|
||||||
|
* Converts the pointer to char16_t *.
|
||||||
|
* @param p pointer to be converted
|
||||||
|
* @draft ICU 59
|
||||||
|
*/
|
||||||
|
inline Char16Ptr(uint16_t *p);
|
||||||
|
#if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN)
|
||||||
|
/**
|
||||||
|
* Converts the pointer to char16_t *.
|
||||||
|
* (Only defined if U_SIZEOF_WCHAR_T==2.)
|
||||||
|
* @param p pointer to be converted
|
||||||
|
* @draft ICU 59
|
||||||
|
*/
|
||||||
|
inline Char16Ptr(wchar_t *p);
|
||||||
|
#endif
|
||||||
|
/**
|
||||||
|
* nullptr constructor.
|
||||||
|
* @param p nullptr
|
||||||
|
* @draft ICU 59
|
||||||
|
*/
|
||||||
|
inline Char16Ptr(std::nullptr_t p);
|
||||||
|
/**
|
||||||
|
* Destructor.
|
||||||
|
* @draft ICU 59
|
||||||
|
*/
|
||||||
|
inline ~Char16Ptr();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pointer access.
|
||||||
|
* @return the wrapped pointer
|
||||||
|
* @draft ICU 59
|
||||||
|
*/
|
||||||
|
inline char16_t *get() const;
|
||||||
|
/**
|
||||||
|
* char16_t pointer access via type conversion (e.g., static_cast).
|
||||||
|
* @return the wrapped pointer
|
||||||
|
* @draft ICU 59
|
||||||
|
*/
|
||||||
|
inline operator char16_t *() const { return get(); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
Char16Ptr() = delete;
|
||||||
|
|
||||||
|
#ifdef U_ALIASING_BARRIER
|
||||||
|
template<typename T> static char16_t *cast(T *t) {
|
||||||
|
U_ALIASING_BARRIER(t);
|
||||||
|
return reinterpret_cast<char16_t *>(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
char16_t *p;
|
||||||
|
#else
|
||||||
|
union {
|
||||||
|
char16_t *cp;
|
||||||
|
uint16_t *up;
|
||||||
|
wchar_t *wp;
|
||||||
|
} u;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef U_ALIASING_BARRIER
|
||||||
|
|
||||||
|
Char16Ptr::Char16Ptr(char16_t *p) : p(p) {}
|
||||||
|
Char16Ptr::Char16Ptr(uint16_t *p) : p(cast(p)) {}
|
||||||
|
#if U_SIZEOF_WCHAR_T==2
|
||||||
|
Char16Ptr::Char16Ptr(wchar_t *p) : p(cast(p)) {}
|
||||||
|
#endif
|
||||||
|
Char16Ptr::Char16Ptr(std::nullptr_t p) : p(p) {}
|
||||||
|
Char16Ptr::~Char16Ptr() {
|
||||||
|
U_ALIASING_BARRIER(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
char16_t *Char16Ptr::get() const { return p; }
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
Char16Ptr::Char16Ptr(char16_t *p) { u.cp = p; }
|
||||||
|
Char16Ptr::Char16Ptr(uint16_t *p) { u.up = p; }
|
||||||
|
#if U_SIZEOF_WCHAR_T==2
|
||||||
|
Char16Ptr::Char16Ptr(wchar_t *p) { u.wp = p; }
|
||||||
|
#endif
|
||||||
|
Char16Ptr::Char16Ptr(std::nullptr_t p) { u.cp = p; }
|
||||||
|
Char16Ptr::~Char16Ptr() {}
|
||||||
|
|
||||||
|
char16_t *Char16Ptr::get() const { return u.cp; }
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* const char16_t * wrapper with implicit conversion from distinct but bit-compatible pointer types.
|
||||||
|
* @draft ICU 59
|
||||||
|
*/
|
||||||
|
class U_COMMON_API ConstChar16Ptr U_FINAL {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Copies the pointer.
|
||||||
|
* @param p pointer
|
||||||
|
* @draft ICU 59
|
||||||
|
*/
|
||||||
|
inline ConstChar16Ptr(const char16_t *p);
|
||||||
|
/**
|
||||||
|
* Converts the pointer to char16_t *.
|
||||||
|
* @param p pointer to be converted
|
||||||
|
* @draft ICU 59
|
||||||
|
*/
|
||||||
|
inline ConstChar16Ptr(const uint16_t *p);
|
||||||
|
#if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN)
|
||||||
|
/**
|
||||||
|
* Converts the pointer to char16_t *.
|
||||||
|
* (Only defined if U_SIZEOF_WCHAR_T==2.)
|
||||||
|
* @param p pointer to be converted
|
||||||
|
* @draft ICU 59
|
||||||
|
*/
|
||||||
|
inline ConstChar16Ptr(const wchar_t *p);
|
||||||
|
#endif
|
||||||
|
/**
|
||||||
|
* nullptr constructor.
|
||||||
|
* @param p nullptr
|
||||||
|
* @draft ICU 59
|
||||||
|
*/
|
||||||
|
inline ConstChar16Ptr(const std::nullptr_t p);
|
||||||
|
/**
|
||||||
|
* Destructor.
|
||||||
|
* @draft ICU 59
|
||||||
|
*/
|
||||||
|
inline ~ConstChar16Ptr();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pointer access.
|
||||||
|
* @return the wrapped pointer
|
||||||
|
* @draft ICU 59
|
||||||
|
*/
|
||||||
|
inline const char16_t *get() const;
|
||||||
|
/**
|
||||||
|
* char16_t pointer access via type conversion (e.g., static_cast).
|
||||||
|
* @return the wrapped pointer
|
||||||
|
* @draft ICU 59
|
||||||
|
*/
|
||||||
|
inline operator const char16_t *() const { return get(); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
ConstChar16Ptr() = delete;
|
||||||
|
|
||||||
|
#ifdef U_ALIASING_BARRIER
|
||||||
|
template<typename T> static const char16_t *cast(const T *t) {
|
||||||
|
U_ALIASING_BARRIER(t);
|
||||||
|
return reinterpret_cast<const char16_t *>(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char16_t *p;
|
||||||
|
#else
|
||||||
|
union {
|
||||||
|
const char16_t *cp;
|
||||||
|
const uint16_t *up;
|
||||||
|
const wchar_t *wp;
|
||||||
|
} u;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef U_ALIASING_BARRIER
|
||||||
|
|
||||||
|
ConstChar16Ptr::ConstChar16Ptr(const char16_t *p) : p(p) {}
|
||||||
|
ConstChar16Ptr::ConstChar16Ptr(const uint16_t *p) : p(cast(p)) {}
|
||||||
|
#if U_SIZEOF_WCHAR_T==2
|
||||||
|
ConstChar16Ptr::ConstChar16Ptr(const wchar_t *p) : p(cast(p)) {}
|
||||||
|
#endif
|
||||||
|
ConstChar16Ptr::ConstChar16Ptr(const std::nullptr_t p) : p(p) {}
|
||||||
|
ConstChar16Ptr::~ConstChar16Ptr() {
|
||||||
|
U_ALIASING_BARRIER(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char16_t *ConstChar16Ptr::get() const { return p; }
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
ConstChar16Ptr::ConstChar16Ptr(const char16_t *p) { u.cp = p; }
|
||||||
|
ConstChar16Ptr::ConstChar16Ptr(const uint16_t *p) { u.up = p; }
|
||||||
|
#if U_SIZEOF_WCHAR_T==2
|
||||||
|
ConstChar16Ptr::ConstChar16Ptr(const wchar_t *p) { u.wp = p; }
|
||||||
|
#endif
|
||||||
|
ConstChar16Ptr::ConstChar16Ptr(const std::nullptr_t p) { u.cp = p; }
|
||||||
|
ConstChar16Ptr::~ConstChar16Ptr() {}
|
||||||
|
|
||||||
|
const char16_t *ConstChar16Ptr::get() const { return u.cp; }
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts from const char16_t * to const UChar *.
|
||||||
|
* Includes an aliasing barrier if available.
|
||||||
|
* @param p pointer
|
||||||
|
* @return p as const UChar *
|
||||||
|
* @draft ICU 59
|
||||||
|
*/
|
||||||
|
inline U_COMMON_API const UChar *toUCharPtr(const char16_t *p) {
|
||||||
|
#ifdef U_ALIASING_BARRIER
|
||||||
|
U_ALIASING_BARRIER(p);
|
||||||
|
#endif
|
||||||
|
return reinterpret_cast<const UChar *>(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts from char16_t * to UChar *.
|
||||||
|
* Includes an aliasing barrier if available.
|
||||||
|
* @param p pointer
|
||||||
|
* @return p as UChar *
|
||||||
|
* @draft ICU 59
|
||||||
|
*/
|
||||||
|
inline U_COMMON_API UChar *toUCharPtr(char16_t *p) {
|
||||||
|
#ifdef U_ALIASING_BARRIER
|
||||||
|
U_ALIASING_BARRIER(p);
|
||||||
|
#endif
|
||||||
|
return reinterpret_cast<UChar *>(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts from const char16_t * to const OldUChar *.
|
||||||
|
* Includes an aliasing barrier if available.
|
||||||
|
* @param p pointer
|
||||||
|
* @return p as const OldUChar *
|
||||||
|
* @draft ICU 59
|
||||||
|
*/
|
||||||
|
inline U_COMMON_API const OldUChar *toOldUCharPtr(const char16_t *p) {
|
||||||
|
#ifdef U_ALIASING_BARRIER
|
||||||
|
U_ALIASING_BARRIER(p);
|
||||||
|
#endif
|
||||||
|
return reinterpret_cast<const OldUChar *>(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts from char16_t * to OldUChar *.
|
||||||
|
* Includes an aliasing barrier if available.
|
||||||
|
* @param p pointer
|
||||||
|
* @return p as OldUChar *
|
||||||
|
* @draft ICU 59
|
||||||
|
*/
|
||||||
|
inline U_COMMON_API OldUChar *toOldUCharPtr(char16_t *p) {
|
||||||
|
#ifdef U_ALIASING_BARRIER
|
||||||
|
U_ALIASING_BARRIER(p);
|
||||||
|
#endif
|
||||||
|
return reinterpret_cast<OldUChar *>(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
U_NAMESPACE_END
|
||||||
|
|
||||||
|
#endif // __CHAR16PTR_H__
|
@ -78,7 +78,7 @@ U_NAMESPACE_BEGIN
|
|||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* void function1(ForwardCharacterIterator &it) {
|
* void function1(ForwardCharacterIterator &it) {
|
||||||
* UChar c;
|
* char16_t c;
|
||||||
* while((c=it.nextPostInc())!=ForwardCharacterIterator::DONE) {
|
* while((c=it.nextPostInc())!=ForwardCharacterIterator::DONE) {
|
||||||
* // use c
|
* // use c
|
||||||
* }
|
* }
|
||||||
@ -149,7 +149,7 @@ public:
|
|||||||
* @return the current code unit.
|
* @return the current code unit.
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
virtual UChar nextPostInc(void) = 0;
|
virtual char16_t nextPostInc(void) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the current code point for returning and advances to the next code point
|
* Gets the current code point for returning and advances to the next code point
|
||||||
@ -230,7 +230,7 @@ protected:
|
|||||||
* showing a way to convert simple for() loops:
|
* showing a way to convert simple for() loops:
|
||||||
* \code
|
* \code
|
||||||
* void forward2(CharacterIterator &it) {
|
* void forward2(CharacterIterator &it) {
|
||||||
* UChar c;
|
* char16_t c;
|
||||||
* for(c=it.firstPostInc(); c!=CharacterIterator::DONE; c=it.nextPostInc()) {
|
* for(c=it.firstPostInc(); c!=CharacterIterator::DONE; c=it.nextPostInc()) {
|
||||||
* // use c
|
* // use c
|
||||||
* }
|
* }
|
||||||
@ -249,7 +249,7 @@ protected:
|
|||||||
* Backward iteration with a more traditional for() loop:
|
* Backward iteration with a more traditional for() loop:
|
||||||
* \code
|
* \code
|
||||||
* void backward2(CharacterIterator &it) {
|
* void backward2(CharacterIterator &it) {
|
||||||
* UChar c;
|
* char16_t c;
|
||||||
* for(c=it.last(); c!=CharacterIterator::DONE; c=it.previous()) {
|
* for(c=it.last(); c!=CharacterIterator::DONE; c=it.previous()) {
|
||||||
* // use c
|
* // use c
|
||||||
* }
|
* }
|
||||||
@ -266,7 +266,7 @@ protected:
|
|||||||
* // get the position
|
* // get the position
|
||||||
* int32_t pos=it.getIndex();
|
* int32_t pos=it.getIndex();
|
||||||
* // get the previous code unit
|
* // get the previous code unit
|
||||||
* UChar u=it.previous();
|
* char16_t u=it.previous();
|
||||||
* // move back one more code unit
|
* // move back one more code unit
|
||||||
* it.move(-1, CharacterIterator::kCurrent);
|
* it.move(-1, CharacterIterator::kCurrent);
|
||||||
* // set the position back to where it was
|
* // set the position back to where it was
|
||||||
@ -283,7 +283,7 @@ protected:
|
|||||||
* Function processing characters, in this example simple output
|
* Function processing characters, in this example simple output
|
||||||
* <pre>
|
* <pre>
|
||||||
* \code
|
* \code
|
||||||
* void processChar( UChar c )
|
* void processChar( char16_t c )
|
||||||
* {
|
* {
|
||||||
* cout << " " << c;
|
* cout << " " << c;
|
||||||
* }
|
* }
|
||||||
@ -294,7 +294,7 @@ protected:
|
|||||||
* \code
|
* \code
|
||||||
* void traverseForward(CharacterIterator& iter)
|
* void traverseForward(CharacterIterator& iter)
|
||||||
* {
|
* {
|
||||||
* for(UChar c = iter.first(); c != CharacterIterator.DONE; c = iter.next()) {
|
* for(char16_t c = iter.first(); c != CharacterIterator.DONE; c = iter.next()) {
|
||||||
* processChar(c);
|
* processChar(c);
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
@ -305,7 +305,7 @@ protected:
|
|||||||
* \code
|
* \code
|
||||||
* void traverseBackward(CharacterIterator& iter)
|
* void traverseBackward(CharacterIterator& iter)
|
||||||
* {
|
* {
|
||||||
* for(UChar c = iter.last(); c != CharacterIterator.DONE; c = iter.previous()) {
|
* for(char16_t c = iter.last(); c != CharacterIterator.DONE; c = iter.previous()) {
|
||||||
* processChar(c);
|
* processChar(c);
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
@ -317,7 +317,7 @@ protected:
|
|||||||
* \code
|
* \code
|
||||||
* void traverseOut(CharacterIterator& iter, int32_t pos)
|
* void traverseOut(CharacterIterator& iter, int32_t pos)
|
||||||
* {
|
* {
|
||||||
* UChar c;
|
* char16_t c;
|
||||||
* for (c = iter.setIndex(pos);
|
* for (c = iter.setIndex(pos);
|
||||||
* c != CharacterIterator.DONE && (Unicode::isLetter(c) || Unicode::isDigit(c));
|
* c != CharacterIterator.DONE && (Unicode::isLetter(c) || Unicode::isDigit(c));
|
||||||
* c = iter.next()) {}
|
* c = iter.next()) {}
|
||||||
@ -386,7 +386,7 @@ public:
|
|||||||
* @return the first code unit in its iteration range.
|
* @return the first code unit in its iteration range.
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
virtual UChar first(void) = 0;
|
virtual char16_t first(void) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the iterator to refer to the first code unit in its
|
* Sets the iterator to refer to the first code unit in its
|
||||||
@ -396,7 +396,7 @@ public:
|
|||||||
* @return the first code unit in its iteration range.
|
* @return the first code unit in its iteration range.
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
virtual UChar firstPostInc(void);
|
virtual char16_t firstPostInc(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the iterator to refer to the first code point in its
|
* Sets the iterator to refer to the first code point in its
|
||||||
@ -435,7 +435,7 @@ public:
|
|||||||
* @return the last code unit.
|
* @return the last code unit.
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
virtual UChar last(void) = 0;
|
virtual char16_t last(void) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the iterator to refer to the last code point in its
|
* Sets the iterator to refer to the last code point in its
|
||||||
@ -463,7 +463,7 @@ public:
|
|||||||
* @return the "position"-th code unit.
|
* @return the "position"-th code unit.
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
virtual UChar setIndex(int32_t position) = 0;
|
virtual char16_t setIndex(int32_t position) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the iterator to refer to the beginning of the code point
|
* Sets the iterator to refer to the beginning of the code point
|
||||||
@ -483,7 +483,7 @@ public:
|
|||||||
* @return the current code unit.
|
* @return the current code unit.
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
virtual UChar current(void) const = 0;
|
virtual char16_t current(void) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the code point the iterator currently refers to.
|
* Returns the code point the iterator currently refers to.
|
||||||
@ -499,7 +499,7 @@ public:
|
|||||||
* @return the next code unit.
|
* @return the next code unit.
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
virtual UChar next(void) = 0;
|
virtual char16_t next(void) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Advances to the next code point in the iteration range
|
* Advances to the next code point in the iteration range
|
||||||
@ -520,7 +520,7 @@ public:
|
|||||||
* @return the previous code unit.
|
* @return the previous code unit.
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
virtual UChar previous(void) = 0;
|
virtual char16_t previous(void) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Advances to the previous code point in the iteration range
|
* Advances to the previous code point in the iteration range
|
||||||
|
@ -174,9 +174,9 @@ private:
|
|||||||
* \code
|
* \code
|
||||||
* LocalPointer<UnicodeString> s(new UnicodeString((UChar32)0x50005));
|
* LocalPointer<UnicodeString> s(new UnicodeString((UChar32)0x50005));
|
||||||
* int32_t length=s->length(); // 2
|
* int32_t length=s->length(); // 2
|
||||||
* UChar lead=s->charAt(0); // 0xd900
|
* char16_t lead=s->charAt(0); // 0xd900
|
||||||
* if(some condition) { return; } // no need to explicitly delete the pointer
|
* if(some condition) { return; } // no need to explicitly delete the pointer
|
||||||
* s.adoptInstead(new UnicodeString((UChar)0xfffc));
|
* s.adoptInstead(new UnicodeString((char16_t)0xfffc));
|
||||||
* length=s->length(); // 1
|
* length=s->length(); // 1
|
||||||
* // no need to explicitly delete the pointer
|
* // no need to explicitly delete the pointer
|
||||||
* \endcode
|
* \endcode
|
||||||
@ -323,10 +323,10 @@ public:
|
|||||||
* Usage example:
|
* Usage example:
|
||||||
* \code
|
* \code
|
||||||
* LocalArray<UnicodeString> a(new UnicodeString[2]);
|
* LocalArray<UnicodeString> a(new UnicodeString[2]);
|
||||||
* a[0].append((UChar)0x61);
|
* a[0].append((char16_t)0x61);
|
||||||
* if(some condition) { return; } // no need to explicitly delete the array
|
* if(some condition) { return; } // no need to explicitly delete the array
|
||||||
* a.adoptInstead(new UnicodeString[4]);
|
* 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();
|
||||||
* // no need to explicitly delete the array
|
* // no need to explicitly delete the array
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
|
@ -282,7 +282,7 @@ public:
|
|||||||
*
|
*
|
||||||
* When used on a standard NFC Normalizer2 instance,
|
* When used on a standard NFC Normalizer2 instance,
|
||||||
* it returns the Decomposition_Mapping only if the Decomposition_Type (dt) is Canonical (Can);
|
* it returns the Decomposition_Mapping only if the Decomposition_Type (dt) is Canonical (Can);
|
||||||
* in this case, the result contains either one or two code points (=1..4 UChars).
|
* in this case, the result contains either one or two code points (=1..4 char16_ts).
|
||||||
*
|
*
|
||||||
* This function is independent of the mode of the Normalizer2.
|
* This function is independent of the mode of the Normalizer2.
|
||||||
* The default implementation returns FALSE.
|
* The default implementation returns FALSE.
|
||||||
|
@ -168,7 +168,7 @@ public:
|
|||||||
* @param mode The normalization mode.
|
* @param mode The normalization mode.
|
||||||
* @deprecated ICU 56 Use Normalizer2 instead.
|
* @deprecated ICU 56 Use Normalizer2 instead.
|
||||||
*/
|
*/
|
||||||
Normalizer(const UChar* str, int32_t length, UNormalizationMode mode);
|
Normalizer(ConstChar16Ptr str, int32_t length, UNormalizationMode mode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new <code>Normalizer</code> object for iterating over the
|
* Creates a new <code>Normalizer</code> object for iterating over the
|
||||||
@ -704,7 +704,7 @@ public:
|
|||||||
* @param status a UErrorCode
|
* @param status a UErrorCode
|
||||||
* @deprecated ICU 56 Use Normalizer2 instead.
|
* @deprecated ICU 56 Use Normalizer2 instead.
|
||||||
*/
|
*/
|
||||||
void setText(const UChar* newText,
|
void setText(ConstChar16Ptr newText,
|
||||||
int32_t length,
|
int32_t length,
|
||||||
UErrorCode &status);
|
UErrorCode &status);
|
||||||
/**
|
/**
|
||||||
@ -796,8 +796,8 @@ Normalizer::compare(const UnicodeString &s1, const UnicodeString &s2,
|
|||||||
uint32_t options,
|
uint32_t options,
|
||||||
UErrorCode &errorCode) {
|
UErrorCode &errorCode) {
|
||||||
// all argument checking is done in unorm_compare
|
// all argument checking is done in unorm_compare
|
||||||
return unorm_compare(s1.getBuffer(), s1.length(),
|
return unorm_compare(toUCharPtr(s1.getBuffer()), s1.length(),
|
||||||
s2.getBuffer(), s2.length(),
|
toUCharPtr(s2.getBuffer()), s2.length(),
|
||||||
options,
|
options,
|
||||||
&errorCode);
|
&errorCode);
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ public:
|
|||||||
* @return 16-bit code unit of text at given offset
|
* @return 16-bit code unit of text at given offset
|
||||||
* @stable ICU 1.8
|
* @stable ICU 1.8
|
||||||
*/
|
*/
|
||||||
inline UChar charAt(int32_t offset) const;
|
inline char16_t charAt(int32_t offset) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the 32-bit code point at the given 16-bit offset into
|
* Returns the 32-bit code point at the given 16-bit offset into
|
||||||
@ -230,7 +230,7 @@ protected:
|
|||||||
* Virtual version of charAt().
|
* Virtual version of charAt().
|
||||||
* @stable ICU 2.4
|
* @stable ICU 2.4
|
||||||
*/
|
*/
|
||||||
virtual UChar getCharAt(int32_t offset) const = 0;
|
virtual char16_t getCharAt(int32_t offset) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Virtual version of char32At().
|
* Virtual version of char32At().
|
||||||
@ -246,7 +246,7 @@ Replaceable::length() const {
|
|||||||
return getLength();
|
return getLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline UChar
|
inline char16_t
|
||||||
Replaceable::charAt(int32_t offset) const {
|
Replaceable::charAt(int32_t offset) const {
|
||||||
return getCharAt(offset);
|
return getCharAt(offset);
|
||||||
}
|
}
|
||||||
|
@ -216,7 +216,7 @@ public:
|
|||||||
* could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found
|
* could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found
|
||||||
* could be a warning
|
* could be a warning
|
||||||
* e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>
|
* e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>
|
||||||
* @return a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file.
|
* @return a pointer to a zero-terminated char16_t array which lives in a memory mapped/DLL file.
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
UnicodeString
|
UnicodeString
|
||||||
|
@ -175,7 +175,7 @@ protected:
|
|||||||
* @param newTextLength The length of the String
|
* @param newTextLength The length of the String
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
void setText(const UChar* newText, int32_t newTextLength);
|
void setText(const char16_t* newText, int32_t newTextLength);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy of the iterated string object.
|
* Copy of the iterated string object.
|
||||||
|
@ -57,7 +57,7 @@ public:
|
|||||||
* Default constructor.
|
* Default constructor.
|
||||||
* @draft ICU 57
|
* @draft ICU 57
|
||||||
*/
|
*/
|
||||||
SimpleFormatter() : compiledPattern((UChar)0) {}
|
SimpleFormatter() : compiledPattern((char16_t)0) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a formatter from the pattern string.
|
* Constructs a formatter from the pattern string.
|
||||||
@ -275,15 +275,15 @@ private:
|
|||||||
*/
|
*/
|
||||||
UnicodeString compiledPattern;
|
UnicodeString compiledPattern;
|
||||||
|
|
||||||
static inline int32_t getArgumentLimit(const UChar *compiledPattern,
|
static inline int32_t getArgumentLimit(const char16_t *compiledPattern,
|
||||||
int32_t compiledPatternLength) {
|
int32_t compiledPatternLength) {
|
||||||
return compiledPatternLength == 0 ? 0 : compiledPattern[0];
|
return compiledPatternLength == 0 ? 0 : compiledPattern[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
static UnicodeString getTextWithNoArguments(const UChar *compiledPattern, int32_t compiledPatternLength);
|
static UnicodeString getTextWithNoArguments(const char16_t *compiledPattern, int32_t compiledPatternLength);
|
||||||
|
|
||||||
static UnicodeString &format(
|
static UnicodeString &format(
|
||||||
const UChar *compiledPattern, int32_t compiledPatternLength,
|
const char16_t *compiledPattern, int32_t compiledPatternLength,
|
||||||
const UnicodeString *const *values,
|
const UnicodeString *const *values,
|
||||||
UnicodeString &result, const UnicodeString *resultCopy, UBool forbidResultAsValue,
|
UnicodeString &result, const UnicodeString *resultCopy, UBool forbidResultAsValue,
|
||||||
int32_t *offsets, int32_t offsetsLength,
|
int32_t *offsets, int32_t offsetsLength,
|
||||||
|
@ -35,7 +35,7 @@ U_NAMESPACE_BEGIN
|
|||||||
* call, so the returned string still might not be 'valid' on
|
* call, so the returned string still might not be 'valid' on
|
||||||
* subsequent use.</p>
|
* subsequent use.</p>
|
||||||
*
|
*
|
||||||
* <p>Strings may take the form of const char*, const UChar*, or const
|
* <p>Strings may take the form of const char*, const char16_t*, or const
|
||||||
* UnicodeString*. The type you get is determine by the variant of
|
* UnicodeString*. The type you get is determine by the variant of
|
||||||
* 'next' that you call. In general the StringEnumeration is
|
* 'next' that you call. In general the StringEnumeration is
|
||||||
* optimized for one of these types, but all StringEnumerations can
|
* optimized for one of these types, but all StringEnumerations can
|
||||||
@ -112,7 +112,7 @@ public:
|
|||||||
* <p>If the iterator is out of sync with its service, status is set
|
* <p>If the iterator is out of sync with its service, status is set
|
||||||
* to U_ENUM_OUT_OF_SYNC_ERROR and NULL is returned.</p>
|
* to U_ENUM_OUT_OF_SYNC_ERROR and NULL is returned.</p>
|
||||||
*
|
*
|
||||||
* <p>If the native service string is a UChar* string, it is
|
* <p>If the native service string is a char16_t* string, it is
|
||||||
* converted to char* with the invariant converter. If the
|
* converted to char* with the invariant converter. If the
|
||||||
* conversion fails (because a character cannot be converted) then
|
* conversion fails (because a character cannot be converted) then
|
||||||
* status is set to U_INVARIANT_CONVERSION_ERROR and the return
|
* status is set to U_INVARIANT_CONVERSION_ERROR and the return
|
||||||
@ -131,7 +131,7 @@ public:
|
|||||||
virtual const char* next(int32_t *resultLength, UErrorCode& status);
|
virtual const char* next(int32_t *resultLength, UErrorCode& status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Returns the next element as a NUL-terminated UChar*. If there
|
* <p>Returns the next element as a NUL-terminated char16_t*. If there
|
||||||
* are no more elements, returns NULL. If the resultLength pointer
|
* are no more elements, returns NULL. If the resultLength pointer
|
||||||
* is not NULL, the length of the string (not counting the
|
* is not NULL, the length of the string (not counting the
|
||||||
* terminating NUL) is returned at that address. If an error
|
* terminating NUL) is returned at that address. If an error
|
||||||
@ -153,7 +153,7 @@ public:
|
|||||||
*
|
*
|
||||||
* @stable ICU 2.4
|
* @stable ICU 2.4
|
||||||
*/
|
*/
|
||||||
virtual const UChar* unext(int32_t *resultLength, UErrorCode& status);
|
virtual const char16_t* unext(int32_t *resultLength, UErrorCode& status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Returns the next element a UnicodeString*. If there are no
|
* <p>Returns the next element a UnicodeString*. If there are no
|
||||||
|
@ -105,7 +105,7 @@ protected:
|
|||||||
/** @internal */
|
/** @internal */
|
||||||
virtual int32_t getElementStringLength(int32_t i) const = 0;
|
virtual int32_t getElementStringLength(int32_t i) const = 0;
|
||||||
/** @internal */
|
/** @internal */
|
||||||
virtual UChar getElementUnit(int32_t i, int32_t unitIndex) const = 0;
|
virtual char16_t getElementUnit(int32_t i, int32_t unitIndex) const = 0;
|
||||||
/** @internal */
|
/** @internal */
|
||||||
virtual int32_t getElementValue(int32_t i) const = 0;
|
virtual int32_t getElementValue(int32_t i) const = 0;
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ protected:
|
|||||||
/** @internal */
|
/** @internal */
|
||||||
virtual int32_t skipElementsBySomeUnits(int32_t i, int32_t unitIndex, int32_t count) const = 0;
|
virtual int32_t skipElementsBySomeUnits(int32_t i, int32_t unitIndex, int32_t count) const = 0;
|
||||||
/** @internal */
|
/** @internal */
|
||||||
virtual int32_t indexOfElementWithNextUnit(int32_t i, int32_t unitIndex, UChar unit) const = 0;
|
virtual int32_t indexOfElementWithNextUnit(int32_t i, int32_t unitIndex, char16_t unit) const = 0;
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
virtual UBool matchNodesCanHaveValues() const = 0;
|
virtual UBool matchNodesCanHaveValues() const = 0;
|
||||||
@ -137,7 +137,7 @@ protected:
|
|||||||
/** @internal */
|
/** @internal */
|
||||||
static const int32_t kMaxBranchLinearSubNodeLength=5;
|
static const int32_t kMaxBranchLinearSubNodeLength=5;
|
||||||
|
|
||||||
// Maximum number of nested split-branch levels for a branch on all 2^16 possible UChar units.
|
// Maximum number of nested split-branch levels for a branch on all 2^16 possible char16_t units.
|
||||||
// log2(2^16/kMaxBranchLinearSubNodeLength) rounded up.
|
// log2(2^16/kMaxBranchLinearSubNodeLength) rounded up.
|
||||||
/** @internal */
|
/** @internal */
|
||||||
static const int32_t kMaxSplitBranchLevels=14;
|
static const int32_t kMaxSplitBranchLevels=14;
|
||||||
@ -338,7 +338,7 @@ protected:
|
|||||||
virtual void write(StringTrieBuilder &builder);
|
virtual void write(StringTrieBuilder &builder);
|
||||||
// Adds a unit with a final value.
|
// Adds a unit with a final value.
|
||||||
void add(int32_t c, int32_t value) {
|
void add(int32_t c, int32_t value) {
|
||||||
units[length]=(UChar)c;
|
units[length]=(char16_t)c;
|
||||||
equal[length]=NULL;
|
equal[length]=NULL;
|
||||||
values[length]=value;
|
values[length]=value;
|
||||||
++length;
|
++length;
|
||||||
@ -346,7 +346,7 @@ protected:
|
|||||||
}
|
}
|
||||||
// Adds a unit which leads to another match node.
|
// Adds a unit which leads to another match node.
|
||||||
void add(int32_t c, Node *node) {
|
void add(int32_t c, Node *node) {
|
||||||
units[length]=(UChar)c;
|
units[length]=(char16_t)c;
|
||||||
equal[length]=node;
|
equal[length]=node;
|
||||||
values[length]=0;
|
values[length]=0;
|
||||||
++length;
|
++length;
|
||||||
@ -356,7 +356,7 @@ protected:
|
|||||||
Node *equal[kMaxBranchLinearSubNodeLength]; // NULL means "has final value".
|
Node *equal[kMaxBranchLinearSubNodeLength]; // NULL means "has final value".
|
||||||
int32_t length;
|
int32_t length;
|
||||||
int32_t values[kMaxBranchLinearSubNodeLength];
|
int32_t values[kMaxBranchLinearSubNodeLength];
|
||||||
UChar units[kMaxBranchLinearSubNodeLength];
|
char16_t units[kMaxBranchLinearSubNodeLength];
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -364,7 +364,7 @@ protected:
|
|||||||
*/
|
*/
|
||||||
class SplitBranchNode : public BranchNode {
|
class SplitBranchNode : public BranchNode {
|
||||||
public:
|
public:
|
||||||
SplitBranchNode(UChar middleUnit, Node *lessThanNode, Node *greaterOrEqualNode)
|
SplitBranchNode(char16_t middleUnit, Node *lessThanNode, Node *greaterOrEqualNode)
|
||||||
: BranchNode(((0x555555*37+middleUnit)*37+
|
: BranchNode(((0x555555*37+middleUnit)*37+
|
||||||
hashCode(lessThanNode))*37+hashCode(greaterOrEqualNode)),
|
hashCode(lessThanNode))*37+hashCode(greaterOrEqualNode)),
|
||||||
unit(middleUnit), lessThan(lessThanNode), greaterOrEqual(greaterOrEqualNode) {}
|
unit(middleUnit), lessThan(lessThanNode), greaterOrEqual(greaterOrEqualNode) {}
|
||||||
@ -372,7 +372,7 @@ protected:
|
|||||||
virtual int32_t markRightEdgesFirst(int32_t edgeNumber);
|
virtual int32_t markRightEdgesFirst(int32_t edgeNumber);
|
||||||
virtual void write(StringTrieBuilder &builder);
|
virtual void write(StringTrieBuilder &builder);
|
||||||
protected:
|
protected:
|
||||||
UChar unit;
|
char16_t unit;
|
||||||
Node *lessThan;
|
Node *lessThan;
|
||||||
Node *greaterOrEqual;
|
Node *greaterOrEqual;
|
||||||
};
|
};
|
||||||
|
@ -36,7 +36,7 @@ class UVector32;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Light-weight, non-const reader class for a UCharsTrie.
|
* Light-weight, non-const reader class for a UCharsTrie.
|
||||||
* Traverses a UChar-serialized data structure with minimal state,
|
* Traverses a char16_t-serialized data structure with minimal state,
|
||||||
* for mapping strings (16-bit-unit sequences) to non-negative integer values.
|
* for mapping strings (16-bit-unit sequences) to non-negative integer values.
|
||||||
*
|
*
|
||||||
* This class owns the serialized trie data only if it was constructed by
|
* This class owns the serialized trie data only if it was constructed by
|
||||||
@ -52,18 +52,18 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Constructs a UCharsTrie reader instance.
|
* Constructs a UCharsTrie reader instance.
|
||||||
*
|
*
|
||||||
* The trieUChars must contain a copy of a UChar sequence from the UCharsTrieBuilder,
|
* The trieUChars must contain a copy of a char16_t sequence from the UCharsTrieBuilder,
|
||||||
* starting with the first UChar of that sequence.
|
* starting with the first char16_t of that sequence.
|
||||||
* The UCharsTrie object will not read more UChars than
|
* The UCharsTrie object will not read more char16_ts than
|
||||||
* the UCharsTrieBuilder generated in the corresponding build() call.
|
* the UCharsTrieBuilder generated in the corresponding build() call.
|
||||||
*
|
*
|
||||||
* The array is not copied/cloned and must not be modified while
|
* The array is not copied/cloned and must not be modified while
|
||||||
* the UCharsTrie object is in use.
|
* the UCharsTrie object is in use.
|
||||||
*
|
*
|
||||||
* @param trieUChars The UChar array that contains the serialized trie.
|
* @param trieUChars The char16_t array that contains the serialized trie.
|
||||||
* @stable ICU 4.8
|
* @stable ICU 4.8
|
||||||
*/
|
*/
|
||||||
UCharsTrie(const UChar *trieUChars)
|
UCharsTrie(ConstChar16Ptr trieUChars)
|
||||||
: ownedArray_(NULL), uchars_(trieUChars),
|
: ownedArray_(NULL), uchars_(trieUChars),
|
||||||
pos_(uchars_), remainingMatchLength_(-1) {}
|
pos_(uchars_), remainingMatchLength_(-1) {}
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy constructor, copies the other trie reader object and its state,
|
* Copy constructor, copies the other trie reader object and its state,
|
||||||
* but not the UChar array which will be shared. (Shallow copy.)
|
* but not the char16_t array which will be shared. (Shallow copy.)
|
||||||
* @param other Another UCharsTrie object.
|
* @param other Another UCharsTrie object.
|
||||||
* @stable ICU 4.8
|
* @stable ICU 4.8
|
||||||
*/
|
*/
|
||||||
@ -109,8 +109,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
friend class UCharsTrie;
|
friend class UCharsTrie;
|
||||||
|
|
||||||
const UChar *uchars;
|
const char16_t *uchars;
|
||||||
const UChar *pos;
|
const char16_t *pos;
|
||||||
int32_t remainingMatchLength;
|
int32_t remainingMatchLength;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -148,14 +148,14 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines whether the string so far matches, whether it has a value,
|
* Determines whether the string so far matches, whether it has a value,
|
||||||
* and whether another input UChar can continue a matching string.
|
* and whether another input char16_t can continue a matching string.
|
||||||
* @return The match/value Result.
|
* @return The match/value Result.
|
||||||
* @stable ICU 4.8
|
* @stable ICU 4.8
|
||||||
*/
|
*/
|
||||||
UStringTrieResult current() const;
|
UStringTrieResult current() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Traverses the trie from the initial state for this input UChar.
|
* Traverses the trie from the initial state for this input char16_t.
|
||||||
* Equivalent to reset().next(uchar).
|
* Equivalent to reset().next(uchar).
|
||||||
* @param uchar Input char value. Values below 0 and above 0xffff will never match.
|
* @param uchar Input char value. Values below 0 and above 0xffff will never match.
|
||||||
* @return The match/value Result.
|
* @return The match/value Result.
|
||||||
@ -177,7 +177,7 @@ public:
|
|||||||
UStringTrieResult firstForCodePoint(UChar32 cp);
|
UStringTrieResult firstForCodePoint(UChar32 cp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Traverses the trie from the current state for this input UChar.
|
* Traverses the trie from the current state for this input char16_t.
|
||||||
* @param uchar Input char value. Values below 0 and above 0xffff will never match.
|
* @param uchar Input char value. Values below 0 and above 0xffff will never match.
|
||||||
* @return The match/value Result.
|
* @return The match/value Result.
|
||||||
* @stable ICU 4.8
|
* @stable ICU 4.8
|
||||||
@ -208,7 +208,7 @@ public:
|
|||||||
* @return The match/value Result.
|
* @return The match/value Result.
|
||||||
* @stable ICU 4.8
|
* @stable ICU 4.8
|
||||||
*/
|
*/
|
||||||
UStringTrieResult next(const UChar *s, int32_t length);
|
UStringTrieResult next(ConstChar16Ptr s, int32_t length);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a matching string's value if called immediately after
|
* Returns a matching string's value if called immediately after
|
||||||
@ -220,7 +220,7 @@ public:
|
|||||||
* @stable ICU 4.8
|
* @stable ICU 4.8
|
||||||
*/
|
*/
|
||||||
inline int32_t getValue() const {
|
inline int32_t getValue() const {
|
||||||
const UChar *pos=pos_;
|
const char16_t *pos=pos_;
|
||||||
int32_t leadUnit=*pos++;
|
int32_t leadUnit=*pos++;
|
||||||
// U_ASSERT(leadUnit>=kMinValueLead);
|
// U_ASSERT(leadUnit>=kMinValueLead);
|
||||||
return leadUnit&kValueIsFinal ?
|
return leadUnit&kValueIsFinal ?
|
||||||
@ -237,16 +237,16 @@ public:
|
|||||||
* @stable ICU 4.8
|
* @stable ICU 4.8
|
||||||
*/
|
*/
|
||||||
inline UBool hasUniqueValue(int32_t &uniqueValue) const {
|
inline UBool hasUniqueValue(int32_t &uniqueValue) const {
|
||||||
const UChar *pos=pos_;
|
const char16_t *pos=pos_;
|
||||||
// Skip the rest of a pending linear-match node.
|
// Skip the rest of a pending linear-match node.
|
||||||
return pos!=NULL && findUniqueValue(pos+remainingMatchLength_+1, FALSE, uniqueValue);
|
return pos!=NULL && findUniqueValue(pos+remainingMatchLength_+1, FALSE, uniqueValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds each UChar which continues the string from the current state.
|
* Finds each char16_t which continues the string from the current state.
|
||||||
* That is, each UChar c for which it would be next(c)!=USTRINGTRIE_NO_MATCH now.
|
* That is, each char16_t c for which it would be next(c)!=USTRINGTRIE_NO_MATCH now.
|
||||||
* @param out Each next UChar is appended to this object.
|
* @param out Each next char16_t is appended to this object.
|
||||||
* @return the number of UChars which continue the string from here
|
* @return the number of char16_ts which continue the string from here
|
||||||
* @stable ICU 4.8
|
* @stable ICU 4.8
|
||||||
*/
|
*/
|
||||||
int32_t getNextUChars(Appendable &out) const;
|
int32_t getNextUChars(Appendable &out) const;
|
||||||
@ -258,8 +258,8 @@ public:
|
|||||||
class U_COMMON_API Iterator : public UMemory {
|
class U_COMMON_API Iterator : public UMemory {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Iterates from the root of a UChar-serialized UCharsTrie.
|
* Iterates from the root of a char16_t-serialized UCharsTrie.
|
||||||
* @param trieUChars The trie UChars.
|
* @param trieUChars The trie char16_ts.
|
||||||
* @param maxStringLength If 0, the iterator returns full strings.
|
* @param maxStringLength If 0, the iterator returns full strings.
|
||||||
* Otherwise, the iterator returns strings with this maximum length.
|
* Otherwise, the iterator returns strings with this maximum length.
|
||||||
* @param errorCode Standard ICU error code. Its input value must
|
* @param errorCode Standard ICU error code. Its input value must
|
||||||
@ -268,7 +268,7 @@ public:
|
|||||||
* function chaining. (See User Guide for details.)
|
* function chaining. (See User Guide for details.)
|
||||||
* @stable ICU 4.8
|
* @stable ICU 4.8
|
||||||
*/
|
*/
|
||||||
Iterator(const UChar *trieUChars, int32_t maxStringLength, UErrorCode &errorCode);
|
Iterator(ConstChar16Ptr trieUChars, int32_t maxStringLength, UErrorCode &errorCode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterates from the current state of the specified UCharsTrie.
|
* Iterates from the current state of the specified UCharsTrie.
|
||||||
@ -336,11 +336,11 @@ public:
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
const UChar *branchNext(const UChar *pos, int32_t length, UErrorCode &errorCode);
|
const char16_t *branchNext(const char16_t *pos, int32_t length, UErrorCode &errorCode);
|
||||||
|
|
||||||
const UChar *uchars_;
|
const char16_t *uchars_;
|
||||||
const UChar *pos_;
|
const char16_t *pos_;
|
||||||
const UChar *initialPos_;
|
const char16_t *initialPos_;
|
||||||
int32_t remainingMatchLength_;
|
int32_t remainingMatchLength_;
|
||||||
int32_t initialRemainingMatchLength_;
|
int32_t initialRemainingMatchLength_;
|
||||||
UBool skipValue_; // Skip intermediate value which was already delivered.
|
UBool skipValue_; // Skip intermediate value which was already delivered.
|
||||||
@ -368,7 +368,7 @@ private:
|
|||||||
* this constructor adopts the builder's array.
|
* this constructor adopts the builder's array.
|
||||||
* This constructor is only called by the builder.
|
* This constructor is only called by the builder.
|
||||||
*/
|
*/
|
||||||
UCharsTrie(UChar *adoptUChars, const UChar *trieUChars)
|
UCharsTrie(char16_t *adoptUChars, const char16_t *trieUChars)
|
||||||
: ownedArray_(adoptUChars), uchars_(trieUChars),
|
: ownedArray_(adoptUChars), uchars_(trieUChars),
|
||||||
pos_(uchars_), remainingMatchLength_(-1) {}
|
pos_(uchars_), remainingMatchLength_(-1) {}
|
||||||
|
|
||||||
@ -381,7 +381,7 @@ private:
|
|||||||
|
|
||||||
// Reads a compact 32-bit integer.
|
// Reads a compact 32-bit integer.
|
||||||
// pos is already after the leadUnit, and the lead unit has bit 15 reset.
|
// pos is already after the leadUnit, and the lead unit has bit 15 reset.
|
||||||
static inline int32_t readValue(const UChar *pos, int32_t leadUnit) {
|
static inline int32_t readValue(const char16_t *pos, int32_t leadUnit) {
|
||||||
int32_t value;
|
int32_t value;
|
||||||
if(leadUnit<kMinTwoUnitValueLead) {
|
if(leadUnit<kMinTwoUnitValueLead) {
|
||||||
value=leadUnit;
|
value=leadUnit;
|
||||||
@ -392,7 +392,7 @@ private:
|
|||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
static inline const UChar *skipValue(const UChar *pos, int32_t leadUnit) {
|
static inline const char16_t *skipValue(const char16_t *pos, int32_t leadUnit) {
|
||||||
if(leadUnit>=kMinTwoUnitValueLead) {
|
if(leadUnit>=kMinTwoUnitValueLead) {
|
||||||
if(leadUnit<kThreeUnitValueLead) {
|
if(leadUnit<kThreeUnitValueLead) {
|
||||||
++pos;
|
++pos;
|
||||||
@ -402,12 +402,12 @@ private:
|
|||||||
}
|
}
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
static inline const UChar *skipValue(const UChar *pos) {
|
static inline const char16_t *skipValue(const char16_t *pos) {
|
||||||
int32_t leadUnit=*pos++;
|
int32_t leadUnit=*pos++;
|
||||||
return skipValue(pos, leadUnit&0x7fff);
|
return skipValue(pos, leadUnit&0x7fff);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int32_t readNodeValue(const UChar *pos, int32_t leadUnit) {
|
static inline int32_t readNodeValue(const char16_t *pos, int32_t leadUnit) {
|
||||||
// U_ASSERT(kMinValueLead<=leadUnit && leadUnit<kValueIsFinal);
|
// U_ASSERT(kMinValueLead<=leadUnit && leadUnit<kValueIsFinal);
|
||||||
int32_t value;
|
int32_t value;
|
||||||
if(leadUnit<kMinTwoUnitNodeValueLead) {
|
if(leadUnit<kMinTwoUnitNodeValueLead) {
|
||||||
@ -419,7 +419,7 @@ private:
|
|||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
static inline const UChar *skipNodeValue(const UChar *pos, int32_t leadUnit) {
|
static inline const char16_t *skipNodeValue(const char16_t *pos, int32_t leadUnit) {
|
||||||
// U_ASSERT(kMinValueLead<=leadUnit && leadUnit<kValueIsFinal);
|
// U_ASSERT(kMinValueLead<=leadUnit && leadUnit<kValueIsFinal);
|
||||||
if(leadUnit>=kMinTwoUnitNodeValueLead) {
|
if(leadUnit>=kMinTwoUnitNodeValueLead) {
|
||||||
if(leadUnit<kThreeUnitNodeValueLead) {
|
if(leadUnit<kThreeUnitNodeValueLead) {
|
||||||
@ -431,7 +431,7 @@ private:
|
|||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline const UChar *jumpByDelta(const UChar *pos) {
|
static inline const char16_t *jumpByDelta(const char16_t *pos) {
|
||||||
int32_t delta=*pos++;
|
int32_t delta=*pos++;
|
||||||
if(delta>=kMinTwoUnitDeltaLead) {
|
if(delta>=kMinTwoUnitDeltaLead) {
|
||||||
if(delta==kThreeUnitDeltaLead) {
|
if(delta==kThreeUnitDeltaLead) {
|
||||||
@ -444,7 +444,7 @@ private:
|
|||||||
return pos+delta;
|
return pos+delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const UChar *skipDelta(const UChar *pos) {
|
static const char16_t *skipDelta(const char16_t *pos) {
|
||||||
int32_t delta=*pos++;
|
int32_t delta=*pos++;
|
||||||
if(delta>=kMinTwoUnitDeltaLead) {
|
if(delta>=kMinTwoUnitDeltaLead) {
|
||||||
if(delta==kThreeUnitDeltaLead) {
|
if(delta==kThreeUnitDeltaLead) {
|
||||||
@ -461,28 +461,28 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Handles a branch node for both next(uchar) and next(string).
|
// Handles a branch node for both next(uchar) and next(string).
|
||||||
UStringTrieResult branchNext(const UChar *pos, int32_t length, int32_t uchar);
|
UStringTrieResult branchNext(const char16_t *pos, int32_t length, int32_t uchar);
|
||||||
|
|
||||||
// Requires remainingLength_<0.
|
// Requires remainingLength_<0.
|
||||||
UStringTrieResult nextImpl(const UChar *pos, int32_t uchar);
|
UStringTrieResult nextImpl(const char16_t *pos, int32_t uchar);
|
||||||
|
|
||||||
// Helper functions for hasUniqueValue().
|
// Helper functions for hasUniqueValue().
|
||||||
// Recursively finds a unique value (or whether there is not a unique one)
|
// Recursively finds a unique value (or whether there is not a unique one)
|
||||||
// from a branch.
|
// from a branch.
|
||||||
static const UChar *findUniqueValueFromBranch(const UChar *pos, int32_t length,
|
static const char16_t *findUniqueValueFromBranch(const char16_t *pos, int32_t length,
|
||||||
UBool haveUniqueValue, int32_t &uniqueValue);
|
UBool haveUniqueValue, int32_t &uniqueValue);
|
||||||
// Recursively finds a unique value (or whether there is not a unique one)
|
// Recursively finds a unique value (or whether there is not a unique one)
|
||||||
// starting from a position on a node lead unit.
|
// starting from a position on a node lead unit.
|
||||||
static UBool findUniqueValue(const UChar *pos, UBool haveUniqueValue, int32_t &uniqueValue);
|
static UBool findUniqueValue(const char16_t *pos, UBool haveUniqueValue, int32_t &uniqueValue);
|
||||||
|
|
||||||
// Helper functions for getNextUChars().
|
// Helper functions for getNextUChars().
|
||||||
// getNextUChars() when pos is on a branch node.
|
// getNextUChars() when pos is on a branch node.
|
||||||
static void getNextBranchUChars(const UChar *pos, int32_t length, Appendable &out);
|
static void getNextBranchUChars(const char16_t *pos, int32_t length, Appendable &out);
|
||||||
|
|
||||||
// UCharsTrie data structure
|
// UCharsTrie data structure
|
||||||
//
|
//
|
||||||
// The trie consists of a series of UChar-serialized nodes for incremental
|
// The trie consists of a series of char16_t-serialized nodes for incremental
|
||||||
// Unicode string/UChar sequence matching. (UChar=16-bit unsigned integer)
|
// Unicode string/char16_t sequence matching. (char16_t=16-bit unsigned integer)
|
||||||
// The root node is at the beginning of the trie data.
|
// The root node is at the beginning of the trie data.
|
||||||
//
|
//
|
||||||
// Types of nodes are distinguished by their node lead unit ranges.
|
// Types of nodes are distinguished by their node lead unit ranges.
|
||||||
@ -491,9 +491,9 @@ private:
|
|||||||
//
|
//
|
||||||
// Node types:
|
// Node types:
|
||||||
// - Final-value node: Stores a 32-bit integer in a compact, variable-length format.
|
// - Final-value node: Stores a 32-bit integer in a compact, variable-length format.
|
||||||
// The value is for the string/UChar sequence so far.
|
// The value is for the string/char16_t sequence so far.
|
||||||
// - Match node, optionally with an intermediate value in a different compact format.
|
// - Match node, optionally with an intermediate value in a different compact format.
|
||||||
// The value, if present, is for the string/UChar sequence so far.
|
// The value, if present, is for the string/char16_t sequence so far.
|
||||||
//
|
//
|
||||||
// Aside from the value, which uses the node lead unit's high bits:
|
// Aside from the value, which uses the node lead unit's high bits:
|
||||||
//
|
//
|
||||||
@ -560,15 +560,15 @@ private:
|
|||||||
|
|
||||||
static const int32_t kMaxTwoUnitDelta=((kThreeUnitDeltaLead-kMinTwoUnitDeltaLead)<<16)-1; // 0x03feffff
|
static const int32_t kMaxTwoUnitDelta=((kThreeUnitDeltaLead-kMinTwoUnitDeltaLead)<<16)-1; // 0x03feffff
|
||||||
|
|
||||||
UChar *ownedArray_;
|
char16_t *ownedArray_;
|
||||||
|
|
||||||
// Fixed value referencing the UCharsTrie words.
|
// Fixed value referencing the UCharsTrie words.
|
||||||
const UChar *uchars_;
|
const char16_t *uchars_;
|
||||||
|
|
||||||
// Iterator variables.
|
// Iterator variables.
|
||||||
|
|
||||||
// Pointer to next trie unit to read. NULL if no more matches.
|
// Pointer to next trie unit to read. NULL if no more matches.
|
||||||
const UChar *pos_;
|
const char16_t *pos_;
|
||||||
// Remaining length of a linear-match node, minus 1. Negative if not in such a node.
|
// Remaining length of a linear-match node, minus 1. Negative if not in such a node.
|
||||||
int32_t remainingMatchLength_;
|
int32_t remainingMatchLength_;
|
||||||
};
|
};
|
||||||
|
@ -89,21 +89,21 @@ public:
|
|||||||
UCharsTrie *build(UStringTrieBuildOption buildOption, UErrorCode &errorCode);
|
UCharsTrie *build(UStringTrieBuildOption buildOption, UErrorCode &errorCode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds a UCharsTrie for the add()ed data and UChar-serializes it.
|
* Builds a UCharsTrie for the add()ed data and char16_t-serializes it.
|
||||||
* Once built, no further data can be add()ed until clear() is called.
|
* Once built, no further data can be add()ed until clear() is called.
|
||||||
*
|
*
|
||||||
* A UCharsTrie cannot be empty. At least one (string, value) pair
|
* A UCharsTrie cannot be empty. At least one (string, value) pair
|
||||||
* must have been add()ed.
|
* must have been add()ed.
|
||||||
*
|
*
|
||||||
* Multiple calls to buildUnicodeString() set the UnicodeStrings to the
|
* Multiple calls to buildUnicodeString() set the UnicodeStrings to the
|
||||||
* builder's same UChar array, without rebuilding.
|
* builder's same char16_t array, without rebuilding.
|
||||||
* If buildUnicodeString() is called after build(), the trie will be
|
* If buildUnicodeString() is called after build(), the trie will be
|
||||||
* re-serialized into a new array.
|
* re-serialized into a new array.
|
||||||
* If build() is called after buildUnicodeString(), the trie object will become
|
* If build() is called after buildUnicodeString(), the trie object will become
|
||||||
* the owner of the previously returned array.
|
* the owner of the previously returned array.
|
||||||
* After clear() has been called, a new array will be used as well.
|
* After clear() has been called, a new array will be used as well.
|
||||||
* @param buildOption Build option, see UStringTrieBuildOption.
|
* @param buildOption Build option, see UStringTrieBuildOption.
|
||||||
* @param result A UnicodeString which will be set to the UChar-serialized
|
* @param result A UnicodeString which will be set to the char16_t-serialized
|
||||||
* UCharsTrie for the add()ed data.
|
* UCharsTrie for the add()ed data.
|
||||||
* @param errorCode Standard ICU error code. Its input value must
|
* @param errorCode Standard ICU error code. Its input value must
|
||||||
* pass the U_SUCCESS() test, or else the function returns
|
* pass the U_SUCCESS() test, or else the function returns
|
||||||
@ -135,14 +135,14 @@ private:
|
|||||||
void buildUChars(UStringTrieBuildOption buildOption, UErrorCode &errorCode);
|
void buildUChars(UStringTrieBuildOption buildOption, UErrorCode &errorCode);
|
||||||
|
|
||||||
virtual int32_t getElementStringLength(int32_t i) const;
|
virtual int32_t getElementStringLength(int32_t i) const;
|
||||||
virtual UChar getElementUnit(int32_t i, int32_t unitIndex) const;
|
virtual char16_t getElementUnit(int32_t i, int32_t unitIndex) const;
|
||||||
virtual int32_t getElementValue(int32_t i) const;
|
virtual int32_t getElementValue(int32_t i) const;
|
||||||
|
|
||||||
virtual int32_t getLimitOfLinearMatch(int32_t first, int32_t last, int32_t unitIndex) const;
|
virtual int32_t getLimitOfLinearMatch(int32_t first, int32_t last, int32_t unitIndex) const;
|
||||||
|
|
||||||
virtual int32_t countElementUnits(int32_t start, int32_t limit, int32_t unitIndex) const;
|
virtual int32_t countElementUnits(int32_t start, int32_t limit, int32_t unitIndex) const;
|
||||||
virtual int32_t skipElementsBySomeUnits(int32_t i, int32_t unitIndex, int32_t count) const;
|
virtual int32_t skipElementsBySomeUnits(int32_t i, int32_t unitIndex, int32_t count) const;
|
||||||
virtual int32_t indexOfElementWithNextUnit(int32_t i, int32_t unitIndex, UChar unit) const;
|
virtual int32_t indexOfElementWithNextUnit(int32_t i, int32_t unitIndex, char16_t unit) const;
|
||||||
|
|
||||||
virtual UBool matchNodesCanHaveValues() const { return TRUE; }
|
virtual UBool matchNodesCanHaveValues() const { return TRUE; }
|
||||||
|
|
||||||
@ -152,11 +152,11 @@ private:
|
|||||||
|
|
||||||
class UCTLinearMatchNode : public LinearMatchNode {
|
class UCTLinearMatchNode : public LinearMatchNode {
|
||||||
public:
|
public:
|
||||||
UCTLinearMatchNode(const UChar *units, int32_t len, Node *nextNode);
|
UCTLinearMatchNode(const char16_t *units, int32_t len, Node *nextNode);
|
||||||
virtual UBool operator==(const Node &other) const;
|
virtual UBool operator==(const Node &other) const;
|
||||||
virtual void write(StringTrieBuilder &builder);
|
virtual void write(StringTrieBuilder &builder);
|
||||||
private:
|
private:
|
||||||
const UChar *s;
|
const char16_t *s;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual Node *createLinearMatchNode(int32_t i, int32_t unitIndex, int32_t length,
|
virtual Node *createLinearMatchNode(int32_t i, int32_t unitIndex, int32_t length,
|
||||||
@ -164,7 +164,7 @@ private:
|
|||||||
|
|
||||||
UBool ensureCapacity(int32_t length);
|
UBool ensureCapacity(int32_t length);
|
||||||
virtual int32_t write(int32_t unit);
|
virtual int32_t write(int32_t unit);
|
||||||
int32_t write(const UChar *s, int32_t length);
|
int32_t write(const char16_t *s, int32_t length);
|
||||||
virtual int32_t writeElementUnits(int32_t i, int32_t unitIndex, int32_t length);
|
virtual int32_t writeElementUnits(int32_t i, int32_t unitIndex, int32_t length);
|
||||||
virtual int32_t writeValueAndFinal(int32_t i, UBool isFinal);
|
virtual int32_t writeValueAndFinal(int32_t i, UBool isFinal);
|
||||||
virtual int32_t writeValueAndType(UBool hasValue, int32_t value, int32_t node);
|
virtual int32_t writeValueAndType(UBool hasValue, int32_t value, int32_t node);
|
||||||
@ -175,9 +175,9 @@ private:
|
|||||||
int32_t elementsCapacity;
|
int32_t elementsCapacity;
|
||||||
int32_t elementsLength;
|
int32_t elementsLength;
|
||||||
|
|
||||||
// UChar serialization of the trie.
|
// char16_t serialization of the trie.
|
||||||
// Grows from the back: ucharsLength measures from the end of the buffer!
|
// Grows from the back: ucharsLength measures from the end of the buffer!
|
||||||
UChar *uchars;
|
char16_t *uchars;
|
||||||
int32_t ucharsCapacity;
|
int32_t ucharsCapacity;
|
||||||
int32_t ucharsLength;
|
int32_t ucharsLength;
|
||||||
};
|
};
|
||||||
|
@ -15,18 +15,18 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \file
|
* \file
|
||||||
* \brief C++ API: UChar Character Iterator
|
* \brief C++ API: char16_t Character Iterator
|
||||||
*/
|
*/
|
||||||
|
|
||||||
U_NAMESPACE_BEGIN
|
U_NAMESPACE_BEGIN
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A concrete subclass of CharacterIterator that iterates over the
|
* A concrete subclass of CharacterIterator that iterates over the
|
||||||
* characters (code units or code points) in a UChar array.
|
* characters (code units or code points) in a char16_t array.
|
||||||
* It's possible not only to create an
|
* It's possible not only to create an
|
||||||
* iterator that iterates over an entire UChar array, but also to
|
* iterator that iterates over an entire char16_t array, but also to
|
||||||
* create one that iterates over only a subrange of a UChar array
|
* create one that iterates over only a subrange of a char16_t array
|
||||||
* (iterators over different subranges of the same UChar array don't
|
* (iterators over different subranges of the same char16_t array don't
|
||||||
* compare equal).
|
* compare equal).
|
||||||
* @see CharacterIterator
|
* @see CharacterIterator
|
||||||
* @see ForwardCharacterIterator
|
* @see ForwardCharacterIterator
|
||||||
@ -35,34 +35,34 @@ U_NAMESPACE_BEGIN
|
|||||||
class U_COMMON_API UCharCharacterIterator : public CharacterIterator {
|
class U_COMMON_API UCharCharacterIterator : public CharacterIterator {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Create an iterator over the UChar array referred to by "textPtr".
|
* Create an iterator over the char16_t array referred to by "textPtr".
|
||||||
* The iteration range is 0 to <code>length-1</code>.
|
* The iteration range is 0 to <code>length-1</code>.
|
||||||
* text is only aliased, not adopted (the
|
* text is only aliased, not adopted (the
|
||||||
* destructor will not delete it).
|
* destructor will not delete it).
|
||||||
* @param textPtr The UChar array to be iterated over
|
* @param textPtr The char16_t array to be iterated over
|
||||||
* @param length The length of the UChar array
|
* @param length The length of the char16_t array
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
UCharCharacterIterator(const UChar* textPtr, int32_t length);
|
UCharCharacterIterator(ConstChar16Ptr textPtr, int32_t length);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an iterator over the UChar array referred to by "textPtr".
|
* Create an iterator over the char16_t array referred to by "textPtr".
|
||||||
* The iteration range is 0 to <code>length-1</code>.
|
* The iteration range is 0 to <code>length-1</code>.
|
||||||
* text is only aliased, not adopted (the
|
* text is only aliased, not adopted (the
|
||||||
* destructor will not delete it).
|
* destructor will not delete it).
|
||||||
* The starting
|
* The starting
|
||||||
* position is specified by "position". If "position" is outside the valid
|
* position is specified by "position". If "position" is outside the valid
|
||||||
* iteration range, the behavior of this object is undefined.
|
* iteration range, the behavior of this object is undefined.
|
||||||
* @param textPtr The UChar array to be iteratd over
|
* @param textPtr The char16_t array to be iteratd over
|
||||||
* @param length The length of the UChar array
|
* @param length The length of the char16_t array
|
||||||
* @param position The starting position of the iteration
|
* @param position The starting position of the iteration
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
UCharCharacterIterator(const UChar* textPtr, int32_t length,
|
UCharCharacterIterator(ConstChar16Ptr textPtr, int32_t length,
|
||||||
int32_t position);
|
int32_t position);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an iterator over the UChar array referred to by "textPtr".
|
* Create an iterator over the char16_t array referred to by "textPtr".
|
||||||
* The iteration range is 0 to <code>end-1</code>.
|
* The iteration range is 0 to <code>end-1</code>.
|
||||||
* text is only aliased, not adopted (the
|
* text is only aliased, not adopted (the
|
||||||
* destructor will not delete it).
|
* destructor will not delete it).
|
||||||
@ -70,14 +70,14 @@ public:
|
|||||||
* position is specified by "position". If begin and end do not
|
* position is specified by "position". If begin and end do not
|
||||||
* form a valid iteration range or "position" is outside the valid
|
* form a valid iteration range or "position" is outside the valid
|
||||||
* iteration range, the behavior of this object is undefined.
|
* iteration range, the behavior of this object is undefined.
|
||||||
* @param textPtr The UChar array to be iterated over
|
* @param textPtr The char16_t array to be iterated over
|
||||||
* @param length The length of the UChar array
|
* @param length The length of the char16_t array
|
||||||
* @param textBegin The begin position of the iteration range
|
* @param textBegin The begin position of the iteration range
|
||||||
* @param textEnd The end position of the iteration range
|
* @param textEnd The end position of the iteration range
|
||||||
* @param position The starting position of the iteration
|
* @param position The starting position of the iteration
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
UCharCharacterIterator(const UChar* textPtr, int32_t length,
|
UCharCharacterIterator(ConstChar16Ptr textPtr, int32_t length,
|
||||||
int32_t textBegin,
|
int32_t textBegin,
|
||||||
int32_t textEnd,
|
int32_t textEnd,
|
||||||
int32_t position);
|
int32_t position);
|
||||||
@ -141,7 +141,7 @@ public:
|
|||||||
* @return the first code unit in its iteration range.
|
* @return the first code unit in its iteration range.
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
virtual UChar first(void);
|
virtual char16_t first(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the iterator to refer to the first code unit in its
|
* Sets the iterator to refer to the first code unit in its
|
||||||
@ -151,7 +151,7 @@ public:
|
|||||||
* @return the first code unit in its iteration range
|
* @return the first code unit in its iteration range
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
virtual UChar firstPostInc(void);
|
virtual char16_t firstPostInc(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the iterator to refer to the first code point in its
|
* Sets the iterator to refer to the first code point in its
|
||||||
@ -181,7 +181,7 @@ public:
|
|||||||
* @return the last code unit in its iteration range.
|
* @return the last code unit in its iteration range.
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
virtual UChar last(void);
|
virtual char16_t last(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the iterator to refer to the last code point in its
|
* Sets the iterator to refer to the last code point in its
|
||||||
@ -200,7 +200,7 @@ public:
|
|||||||
* @return the code unit
|
* @return the code unit
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
virtual UChar setIndex(int32_t position);
|
virtual char16_t setIndex(int32_t position);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the iterator to refer to the beginning of the code point
|
* Sets the iterator to refer to the beginning of the code point
|
||||||
@ -220,7 +220,7 @@ public:
|
|||||||
* @return the code unit the iterator currently refers to.
|
* @return the code unit the iterator currently refers to.
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
virtual UChar current(void) const;
|
virtual char16_t current(void) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the code point the iterator currently refers to.
|
* Returns the code point the iterator currently refers to.
|
||||||
@ -236,7 +236,7 @@ public:
|
|||||||
* @return the next code unit in the iteration range.
|
* @return the next code unit in the iteration range.
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
virtual UChar next(void);
|
virtual char16_t next(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the current code unit for returning and advances to the next code unit
|
* Gets the current code unit for returning and advances to the next code unit
|
||||||
@ -246,7 +246,7 @@ public:
|
|||||||
* @return the current code unit.
|
* @return the current code unit.
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
virtual UChar nextPostInc(void);
|
virtual char16_t nextPostInc(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Advances to the next code point in the iteration range (toward
|
* Advances to the next code point in the iteration range (toward
|
||||||
@ -288,7 +288,7 @@ public:
|
|||||||
* @return the previous code unit in the iteration range.
|
* @return the previous code unit in the iteration range.
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
virtual UChar previous(void);
|
virtual char16_t previous(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Advances to the previous code point in the iteration range (toward
|
* Advances to the previous code point in the iteration range (toward
|
||||||
@ -340,10 +340,10 @@ public:
|
|||||||
* Sets the iterator to iterate over a new range of text
|
* Sets the iterator to iterate over a new range of text
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
void setText(const UChar* newText, int32_t newTextLength);
|
void setText(ConstChar16Ptr newText, int32_t newTextLength);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copies the UChar array under iteration into the UnicodeString
|
* Copies the char16_t array under iteration into the UnicodeString
|
||||||
* referred to by "result". Even if this iterator iterates across
|
* referred to by "result". Even if this iterator iterates across
|
||||||
* only a part of this string, the whole string is copied.
|
* only a part of this string, the whole string is copied.
|
||||||
* @param result Receives a copy of the text under iteration.
|
* @param result Receives a copy of the text under iteration.
|
||||||
@ -375,7 +375,7 @@ protected:
|
|||||||
* Protected member text
|
* Protected member text
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
const UChar* text;
|
const char16_t* text;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -301,32 +301,75 @@ typedef int8_t UBool;
|
|||||||
/**
|
/**
|
||||||
* \var UChar
|
* \var UChar
|
||||||
*
|
*
|
||||||
* For C++, UChar is always defined to be char16_t.
|
* The base type for UTF-16 code units and pointers.
|
||||||
|
* Unsigned 16-bit integer.
|
||||||
|
* Starting with ICU 59, C++ API uses char16_t directly, while C API continues to use UChar.
|
||||||
*
|
*
|
||||||
* For plain C, define UChar to be UCHAR_TYPE, if that is #defined (for example, to char16_t),
|
* UChar is configurable by defining the macro UCHAR_TYPE
|
||||||
* or wchar_t if that is 16 bits wide; always assumed to be unsigned.
|
* on the preprocessor or compiler command line:
|
||||||
* If neither is available, then define UChar to be uint16_t.
|
* -DUCHAR_TYPE=uint16_t or -DUCHAR_TYPE=wchar_t (if U_SIZEOF_WCHAR_T==2) etc.
|
||||||
|
* (The UCHAR_TYPE can also be #defined earlier in this file, for outside the ICU library code.)
|
||||||
|
* This is for transitional use from application code that uses uint16_t or wchar_t for UTF-16.
|
||||||
*
|
*
|
||||||
* This makes the definition of UChar platform-dependent
|
* The default is UChar=char16_t.
|
||||||
* but allows direct string type compatibility with platforms with
|
*
|
||||||
* 16-bit wchar_t types.
|
* C++11 defines char16_t as bit-compatible with uint16_t, but as a distinct type.
|
||||||
|
*
|
||||||
|
* In C, char16_t is a simple typedef of uint_least16_t.
|
||||||
|
* ICU requires uint_least16_t=uint16_t for data memory mapping.
|
||||||
|
* On macOS, char16_t is not available because the uchar.h standard header is missing.
|
||||||
*
|
*
|
||||||
* @stable ICU 4.4
|
* @stable ICU 4.4
|
||||||
*/
|
*/
|
||||||
#ifdef __cplusplus
|
|
||||||
|
#if 1
|
||||||
|
// #if 1 is normal. UChar defaults to char16_t in C++.
|
||||||
|
// For configuration testing of UChar=uint16_t temporarily change this to #if 0.
|
||||||
|
// The intltest Makefile #defines UCHAR_TYPE=char16_t,
|
||||||
|
// so we only #define it to uint16_t if it is undefined so far.
|
||||||
|
#elif !defined(UCHAR_TYPE)
|
||||||
|
# define UCHAR_TYPE uint16_t
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(U_COMBINED_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION) || \
|
||||||
|
defined(U_I18N_IMPLEMENTATION) || defined(U_IO_IMPLEMENTATION)
|
||||||
|
// Inside the ICU library code, never configurable.
|
||||||
typedef char16_t UChar;
|
typedef char16_t UChar;
|
||||||
#elif defined(UCHAR_TYPE)
|
#elif defined(UCHAR_TYPE)
|
||||||
typedef UCHAR_TYPE UChar;
|
typedef UCHAR_TYPE UChar;
|
||||||
#elif U_SIZEOF_WCHAR_T==2
|
#elif defined(__cplusplus)
|
||||||
typedef wchar_t UChar;
|
|
||||||
#elif U_HAVE_CHAR16_T
|
|
||||||
typedef char16_t UChar;
|
typedef char16_t UChar;
|
||||||
#elif defined(__CHAR16_TYPE__)
|
|
||||||
typedef __CHAR16_TYPE__ UChar;
|
|
||||||
#else
|
#else
|
||||||
typedef uint16_t UChar;
|
typedef uint16_t UChar;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \var OldUChar
|
||||||
|
* Default ICU 58 definition of UChar.
|
||||||
|
* A base type for UTF-16 code units and pointers.
|
||||||
|
* Unsigned 16-bit integer.
|
||||||
|
*
|
||||||
|
* Define OldUChar to be wchar_t if that is 16 bits wide.
|
||||||
|
* If wchar_t is not 16 bits wide, then define UChar to be uint16_t.
|
||||||
|
*
|
||||||
|
* This makes the definition of OldUChar platform-dependent
|
||||||
|
* but allows direct string type compatibility with platforms with
|
||||||
|
* 16-bit wchar_t types.
|
||||||
|
*
|
||||||
|
* This is how UChar was defined in ICU 58, for transition convenience.
|
||||||
|
* Exception: ICU 58 UChar was defined to UCHAR_TYPE if that macro was defined.
|
||||||
|
* The current UChar responds to UCHAR_TYPE but OldUChar does not.
|
||||||
|
*
|
||||||
|
* @draft ICU 59
|
||||||
|
*/
|
||||||
|
#if U_SIZEOF_WCHAR_T==2
|
||||||
|
typedef wchar_t OldUChar;
|
||||||
|
#elif defined(__CHAR16_TYPE__)
|
||||||
|
typedef __CHAR16_TYPE__ OldUChar;
|
||||||
|
#else
|
||||||
|
typedef uint16_t OldUChar;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define UChar32 as a type for single Unicode code points.
|
* Define UChar32 as a type for single Unicode code points.
|
||||||
* UChar32 is a signed 32-bit integer (same as int32_t).
|
* UChar32 is a signed 32-bit integer (same as int32_t).
|
||||||
|
@ -30,7 +30,7 @@ U_NAMESPACE_BEGIN
|
|||||||
* defined range.
|
* defined range.
|
||||||
* @stable ICU 3.0
|
* @stable ICU 3.0
|
||||||
*/
|
*/
|
||||||
#define U_ETHER ((UChar)0xFFFF)
|
#define U_ETHER ((char16_t)0xFFFF)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -294,7 +294,7 @@ class U_COMMON_API UnicodeSet U_FINAL : public UnicodeFilter {
|
|||||||
* indicating that toPattern() must generate a pattern
|
* indicating that toPattern() must generate a pattern
|
||||||
* representation from the inversion list.
|
* representation from the inversion list.
|
||||||
*/
|
*/
|
||||||
UChar *pat;
|
char16_t *pat;
|
||||||
UVector* strings; // maintained in sorted order
|
UVector* strings; // maintained in sorted order
|
||||||
UnicodeSetStringSpan *stringSpan;
|
UnicodeSetStringSpan *stringSpan;
|
||||||
|
|
||||||
@ -891,7 +891,7 @@ public:
|
|||||||
* @stable ICU 3.8
|
* @stable ICU 3.8
|
||||||
* @see USetSpanCondition
|
* @see USetSpanCondition
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the end of the substring of the input string according to the USetSpanCondition.
|
* Returns the end of the substring of the input string according to the USetSpanCondition.
|
||||||
@ -924,7 +924,7 @@ public:
|
|||||||
* @stable ICU 3.8
|
* @stable ICU 3.8
|
||||||
* @see USetSpanCondition
|
* @see USetSpanCondition
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the start of the substring of the input string according to the USetSpanCondition.
|
* Returns the start of the substring of the input string according to the USetSpanCondition.
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -178,12 +178,12 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \def NULL
|
* \def NULL
|
||||||
* Define NULL if necessary, to 0 for C++ and to ((void *)0) for C.
|
* Define NULL if necessary, to nullptr for C++ and to ((void *)0) for C.
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
#ifndef NULL
|
#ifndef NULL
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#define NULL 0
|
#define NULL nullptr
|
||||||
#else
|
#else
|
||||||
#define NULL ((void *)0)
|
#define NULL ((void *)0)
|
||||||
#endif
|
#endif
|
||||||
|
@ -218,9 +218,10 @@ UnicodeString::UnicodeString(const UChar *text,
|
|||||||
}
|
}
|
||||||
|
|
||||||
UnicodeString::UnicodeString(UBool isTerminated,
|
UnicodeString::UnicodeString(UBool isTerminated,
|
||||||
const UChar *text,
|
ConstChar16Ptr textPtr,
|
||||||
int32_t textLength) {
|
int32_t textLength) {
|
||||||
fUnion.fFields.fLengthAndFlags = kReadonlyAlias;
|
fUnion.fFields.fLengthAndFlags = kReadonlyAlias;
|
||||||
|
const UChar *text = textPtr;
|
||||||
if(text == NULL) {
|
if(text == NULL) {
|
||||||
// treat as an empty string, do not alias
|
// treat as an empty string, do not alias
|
||||||
setToEmpty();
|
setToEmpty();
|
||||||
@ -234,7 +235,8 @@ UnicodeString::UnicodeString(UBool isTerminated,
|
|||||||
// text is terminated, or else it would have failed the above test
|
// text is terminated, or else it would have failed the above test
|
||||||
textLength = u_strlen(text);
|
textLength = u_strlen(text);
|
||||||
}
|
}
|
||||||
setArray((UChar *)text, textLength, isTerminated ? textLength + 1 : textLength);
|
setArray(const_cast<UChar *>(text), textLength,
|
||||||
|
isTerminated ? textLength + 1 : textLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -873,7 +875,7 @@ UnicodeString::doExtract(int32_t start,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t
|
int32_t
|
||||||
UnicodeString::extract(UChar *dest, int32_t destCapacity,
|
UnicodeString::extract(Char16Ptr dest, int32_t destCapacity,
|
||||||
UErrorCode &errorCode) const {
|
UErrorCode &errorCode) const {
|
||||||
int32_t len = length();
|
int32_t len = length();
|
||||||
if(U_SUCCESS(errorCode)) {
|
if(U_SUCCESS(errorCode)) {
|
||||||
@ -1215,10 +1217,10 @@ UnicodeString::unBogus() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const UChar *
|
const char16_t *
|
||||||
UnicodeString::getTerminatedBuffer() {
|
UnicodeString::getTerminatedBuffer() {
|
||||||
if(!isWritable()) {
|
if(!isWritable()) {
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
UChar *array = getArrayStart();
|
UChar *array = getArrayStart();
|
||||||
int32_t len = length();
|
int32_t len = length();
|
||||||
@ -1249,14 +1251,14 @@ UnicodeString::getTerminatedBuffer() {
|
|||||||
array[len] = 0;
|
array[len] = 0;
|
||||||
return array;
|
return array;
|
||||||
} else {
|
} else {
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// setTo() analogous to the readonly-aliasing constructor with the same signature
|
// setTo() analogous to the readonly-aliasing constructor with the same signature
|
||||||
UnicodeString &
|
UnicodeString &
|
||||||
UnicodeString::setTo(UBool isTerminated,
|
UnicodeString::setTo(UBool isTerminated,
|
||||||
const UChar *text,
|
ConstChar16Ptr textPtr,
|
||||||
int32_t textLength)
|
int32_t textLength)
|
||||||
{
|
{
|
||||||
if(fUnion.fFields.fLengthAndFlags & kOpenGetBuffer) {
|
if(fUnion.fFields.fLengthAndFlags & kOpenGetBuffer) {
|
||||||
@ -1264,6 +1266,7 @@ UnicodeString::setTo(UBool isTerminated,
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const UChar *text = textPtr;
|
||||||
if(text == NULL) {
|
if(text == NULL) {
|
||||||
// treat as an empty string, do not alias
|
// treat as an empty string, do not alias
|
||||||
releaseArray();
|
releaseArray();
|
||||||
@ -1713,14 +1716,14 @@ UnicodeString::doHashCode() const
|
|||||||
// External Buffer
|
// External Buffer
|
||||||
//========================================
|
//========================================
|
||||||
|
|
||||||
UChar *
|
char16_t *
|
||||||
UnicodeString::getBuffer(int32_t minCapacity) {
|
UnicodeString::getBuffer(int32_t minCapacity) {
|
||||||
if(minCapacity>=-1 && cloneArrayIfNeeded(minCapacity)) {
|
if(minCapacity>=-1 && cloneArrayIfNeeded(minCapacity)) {
|
||||||
fUnion.fFields.fLengthAndFlags|=kOpenGetBuffer;
|
fUnion.fFields.fLengthAndFlags|=kOpenGetBuffer;
|
||||||
setZeroLength();
|
setZeroLength();
|
||||||
return getArrayStart();
|
return getArrayStart();
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2242,13 +2242,13 @@ unistrTextCopy(UText *ut,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(move) {
|
if(move) {
|
||||||
// move: copy to destIndex, then replace original with nothing
|
// move: copy to destIndex, then remove original
|
||||||
int32_t segLength=limit32-start32;
|
int32_t segLength=limit32-start32;
|
||||||
us->copy(start32, limit32, destIndex32);
|
us->copy(start32, limit32, destIndex32);
|
||||||
if(destIndex32<start32) {
|
if(destIndex32<start32) {
|
||||||
start32+=segLength;
|
start32+=segLength;
|
||||||
}
|
}
|
||||||
us->replace(start32, segLength, NULL, 0);
|
us->remove(start32, segLength);
|
||||||
} else {
|
} else {
|
||||||
// copy
|
// copy
|
||||||
us->copy(start32, limit32, destIndex32);
|
us->copy(start32, limit32, destIndex32);
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#if !UCONFIG_NO_COLLATION
|
#if !UCONFIG_NO_COLLATION
|
||||||
|
|
||||||
|
#include "unicode/chariter.h"
|
||||||
#include "unicode/coleitr.h"
|
#include "unicode/coleitr.h"
|
||||||
#include "unicode/tblcoll.h"
|
#include "unicode/tblcoll.h"
|
||||||
#include "unicode/ustring.h"
|
#include "unicode/ustring.h"
|
||||||
|
@ -19,12 +19,12 @@
|
|||||||
|
|
||||||
U_NAMESPACE_BEGIN
|
U_NAMESPACE_BEGIN
|
||||||
|
|
||||||
CurrencyAmount::CurrencyAmount(const Formattable& amount, const UChar* isoCode,
|
CurrencyAmount::CurrencyAmount(const Formattable& amount, ConstChar16Ptr isoCode,
|
||||||
UErrorCode& ec) :
|
UErrorCode& ec) :
|
||||||
Measure(amount, new CurrencyUnit(isoCode, ec), ec) {
|
Measure(amount, new CurrencyUnit(isoCode, ec), ec) {
|
||||||
}
|
}
|
||||||
|
|
||||||
CurrencyAmount::CurrencyAmount(double amount, const UChar* isoCode,
|
CurrencyAmount::CurrencyAmount(double amount, ConstChar16Ptr isoCode,
|
||||||
UErrorCode& ec) :
|
UErrorCode& ec) :
|
||||||
Measure(Formattable(amount), new CurrencyUnit(isoCode, ec), ec) {
|
Measure(Formattable(amount), new CurrencyUnit(isoCode, ec), ec) {
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,10 @@
|
|||||||
|
|
||||||
U_NAMESPACE_BEGIN
|
U_NAMESPACE_BEGIN
|
||||||
|
|
||||||
CurrencyUnit::CurrencyUnit(const UChar* _isoCode, UErrorCode& ec) {
|
CurrencyUnit::CurrencyUnit(ConstChar16Ptr _isoCode, UErrorCode& ec) {
|
||||||
*isoCode = 0;
|
*isoCode = 0;
|
||||||
if (U_SUCCESS(ec)) {
|
if (U_SUCCESS(ec)) {
|
||||||
if (_isoCode && u_strlen(_isoCode)==3) {
|
if (_isoCode != nullptr && u_strlen(_isoCode)==3) {
|
||||||
u_strcpy(isoCode, _isoCode);
|
u_strcpy(isoCode, _isoCode);
|
||||||
char simpleIsoCode[4];
|
char simpleIsoCode[4];
|
||||||
u_UCharsToChars(isoCode, simpleIsoCode, 4);
|
u_UCharsToChars(isoCode, simpleIsoCode, 4);
|
||||||
|
@ -1368,7 +1368,7 @@ DateFormatSymbols::setZoneStrings(const UnicodeString* const *strings, int32_t r
|
|||||||
|
|
||||||
//------------------------------------------------------
|
//------------------------------------------------------
|
||||||
|
|
||||||
const UChar * U_EXPORT2
|
const char16_t * U_EXPORT2
|
||||||
DateFormatSymbols::getPatternUChars(void)
|
DateFormatSymbols::getPatternUChars(void)
|
||||||
{
|
{
|
||||||
return gPatternChars;
|
return gPatternChars;
|
||||||
|
@ -1188,7 +1188,7 @@ void NumberFormat::setCurrency(const UChar* theCurrency, UErrorCode& ec) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const UChar* NumberFormat::getCurrency() const {
|
const char16_t* NumberFormat::getCurrency() const {
|
||||||
return fCurrency;
|
return fCurrency;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@
|
|||||||
|
|
||||||
#include "unicode/uobject.h"
|
#include "unicode/uobject.h"
|
||||||
#include "unicode/ucol.h"
|
#include "unicode/ucol.h"
|
||||||
#include "unicode/normlzr.h"
|
#include "unicode/unorm.h"
|
||||||
#include "unicode/locid.h"
|
#include "unicode/locid.h"
|
||||||
#include "unicode/uniset.h"
|
#include "unicode/uniset.h"
|
||||||
#include "unicode/umisc.h"
|
#include "unicode/umisc.h"
|
||||||
@ -158,7 +158,7 @@ class CollationKey;
|
|||||||
* @see CollationKey
|
* @see CollationKey
|
||||||
* @see CollationElementIterator
|
* @see CollationElementIterator
|
||||||
* @see Locale
|
* @see Locale
|
||||||
* @see Normalizer
|
* @see Normalizer2
|
||||||
* @version 2.0 11/15/01
|
* @version 2.0 11/15/01
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -393,8 +393,8 @@ public:
|
|||||||
* is less than, greater than or equal to another string array.
|
* is less than, greater than or equal to another string array.
|
||||||
* <p>Example of use:
|
* <p>Example of use:
|
||||||
* <pre>
|
* <pre>
|
||||||
* . UChar ABC[] = {0x41, 0x42, 0x43, 0}; // = "ABC"
|
* . char16_t ABC[] = {0x41, 0x42, 0x43, 0}; // = "ABC"
|
||||||
* . UChar abc[] = {0x61, 0x62, 0x63, 0}; // = "abc"
|
* . char16_t abc[] = {0x61, 0x62, 0x63, 0}; // = "abc"
|
||||||
* . UErrorCode status = U_ZERO_ERROR;
|
* . UErrorCode status = U_ZERO_ERROR;
|
||||||
* . Collator *myCollation =
|
* . Collator *myCollation =
|
||||||
* . Collator::createInstance(Locale::getUS(), status);
|
* . Collator::createInstance(Locale::getUS(), status);
|
||||||
@ -420,8 +420,8 @@ public:
|
|||||||
* target
|
* target
|
||||||
* @deprecated ICU 2.6 use the overload with UErrorCode &
|
* @deprecated ICU 2.6 use the overload with UErrorCode &
|
||||||
*/
|
*/
|
||||||
virtual EComparisonResult compare(const UChar* source, int32_t sourceLength,
|
virtual EComparisonResult compare(const char16_t* source, int32_t sourceLength,
|
||||||
const UChar* target, int32_t targetLength)
|
const char16_t* target, int32_t targetLength)
|
||||||
const;
|
const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -440,8 +440,8 @@ public:
|
|||||||
* than target
|
* than target
|
||||||
* @stable ICU 2.6
|
* @stable ICU 2.6
|
||||||
*/
|
*/
|
||||||
virtual UCollationResult compare(const UChar* source, int32_t sourceLength,
|
virtual UCollationResult compare(const char16_t* source, int32_t sourceLength,
|
||||||
const UChar* target, int32_t targetLength,
|
const char16_t* target, int32_t targetLength,
|
||||||
UErrorCode &status) const = 0;
|
UErrorCode &status) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -517,7 +517,7 @@ public:
|
|||||||
* @see CollationKey#compare
|
* @see CollationKey#compare
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
virtual CollationKey& getCollationKey(const UChar*source,
|
virtual CollationKey& getCollationKey(const char16_t*source,
|
||||||
int32_t sourceLength,
|
int32_t sourceLength,
|
||||||
CollationKey& key,
|
CollationKey& key,
|
||||||
UErrorCode& status) const = 0;
|
UErrorCode& status) const = 0;
|
||||||
@ -911,7 +911,7 @@ public:
|
|||||||
* the top of one of the supported reordering groups,
|
* the top of one of the supported reordering groups,
|
||||||
* and it must not be beyond the last of those groups.
|
* and it must not be beyond the last of those groups.
|
||||||
* See setMaxVariable().
|
* See setMaxVariable().
|
||||||
* @param varTop one or more (if contraction) UChars to which the variable top should be set
|
* @param varTop one or more (if contraction) char16_ts to which the variable top should be set
|
||||||
* @param len length of variable top string. If -1 it is considered to be zero terminated.
|
* @param len length of variable top string. If -1 it is considered to be zero terminated.
|
||||||
* @param status error code. If error code is set, the return value is undefined. Errors set by this function are: <br>
|
* @param status error code. If error code is set, the return value is undefined. Errors set by this function are: <br>
|
||||||
* U_CE_NOT_FOUND_ERROR if more than one character was passed and there is no such contraction<br>
|
* U_CE_NOT_FOUND_ERROR if more than one character was passed and there is no such contraction<br>
|
||||||
@ -920,7 +920,7 @@ public:
|
|||||||
* @return variable top primary weight
|
* @return variable top primary weight
|
||||||
* @deprecated ICU 53 Call setMaxVariable() instead.
|
* @deprecated ICU 53 Call setMaxVariable() instead.
|
||||||
*/
|
*/
|
||||||
virtual uint32_t setVariableTop(const UChar *varTop, int32_t len, UErrorCode &status) = 0;
|
virtual uint32_t setVariableTop(const char16_t *varTop, int32_t len, UErrorCode &status) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the variable top to the primary weight of the specified string.
|
* Sets the variable top to the primary weight of the specified string.
|
||||||
@ -929,7 +929,7 @@ public:
|
|||||||
* the top of one of the supported reordering groups,
|
* the top of one of the supported reordering groups,
|
||||||
* and it must not be beyond the last of those groups.
|
* and it must not be beyond the last of those groups.
|
||||||
* See setMaxVariable().
|
* See setMaxVariable().
|
||||||
* @param varTop a UnicodeString size 1 or more (if contraction) of UChars to which the variable top should be set
|
* @param varTop a UnicodeString size 1 or more (if contraction) of char16_ts to which the variable top should be set
|
||||||
* @param status error code. If error code is set, the return value is undefined. Errors set by this function are: <br>
|
* @param status error code. If error code is set, the return value is undefined. Errors set by this function are: <br>
|
||||||
* U_CE_NOT_FOUND_ERROR if more than one character was passed and there is no such contraction<br>
|
* U_CE_NOT_FOUND_ERROR if more than one character was passed and there is no such contraction<br>
|
||||||
* U_ILLEGAL_ARGUMENT_ERROR if the variable top is beyond
|
* U_ILLEGAL_ARGUMENT_ERROR if the variable top is beyond
|
||||||
@ -1002,7 +1002,7 @@ public:
|
|||||||
int32_t resultLength) const = 0;
|
int32_t resultLength) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the sort key as an array of bytes from a UChar buffer.
|
* Get the sort key as an array of bytes from a char16_t buffer.
|
||||||
* Sort key byte arrays are zero-terminated and can be compared using
|
* Sort key byte arrays are zero-terminated and can be compared using
|
||||||
* strcmp().
|
* strcmp().
|
||||||
*
|
*
|
||||||
@ -1020,7 +1020,7 @@ public:
|
|||||||
* @return Number of bytes needed for storing the sort key
|
* @return Number of bytes needed for storing the sort key
|
||||||
* @stable ICU 2.2
|
* @stable ICU 2.2
|
||||||
*/
|
*/
|
||||||
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 = 0;
|
uint8_t*result, int32_t resultLength) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,7 +46,7 @@ class U_I18N_API CurrencyAmount: public Measure {
|
|||||||
* is invalid, then this will be set to a failing value.
|
* is invalid, then this will be set to a failing value.
|
||||||
* @stable ICU 3.0
|
* @stable ICU 3.0
|
||||||
*/
|
*/
|
||||||
CurrencyAmount(const Formattable& amount, const UChar* isoCode,
|
CurrencyAmount(const Formattable& amount, ConstChar16Ptr isoCode,
|
||||||
UErrorCode &ec);
|
UErrorCode &ec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,7 +59,7 @@ class U_I18N_API CurrencyAmount: public Measure {
|
|||||||
* then this will be set to a failing value.
|
* then this will be set to a failing value.
|
||||||
* @stable ICU 3.0
|
* @stable ICU 3.0
|
||||||
*/
|
*/
|
||||||
CurrencyAmount(double amount, const UChar* isoCode,
|
CurrencyAmount(double amount, ConstChar16Ptr isoCode,
|
||||||
UErrorCode &ec);
|
UErrorCode &ec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -115,14 +115,14 @@ class U_I18N_API CurrencyAmount: public Measure {
|
|||||||
* Return the ISO currency code of this object.
|
* Return the ISO currency code of this object.
|
||||||
* @stable ICU 3.0
|
* @stable ICU 3.0
|
||||||
*/
|
*/
|
||||||
inline const UChar* getISOCurrency() const;
|
inline const char16_t* getISOCurrency() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline const CurrencyUnit& CurrencyAmount::getCurrency() const {
|
inline const CurrencyUnit& CurrencyAmount::getCurrency() const {
|
||||||
return (const CurrencyUnit&) getUnit();
|
return (const CurrencyUnit&) getUnit();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const UChar* CurrencyAmount::getISOCurrency() const {
|
inline const char16_t* CurrencyAmount::getISOCurrency() const {
|
||||||
return getCurrency().getISOCurrency();
|
return getCurrency().getISOCurrency();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ U_NAMESPACE_BEGIN
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A unit of currency, such as USD (U.S. dollars) or JPY (Japanese
|
* A unit of currency, such as USD (U.S. dollars) or JPY (Japanese
|
||||||
* yen). This class is a thin wrapper over a UChar string that
|
* yen). This class is a thin wrapper over a char16_t string that
|
||||||
* subclasses MeasureUnit, for use with Measure and MeasureFormat.
|
* subclasses MeasureUnit, for use with Measure and MeasureFormat.
|
||||||
*
|
*
|
||||||
* @author Alan Liu
|
* @author Alan Liu
|
||||||
@ -44,7 +44,7 @@ class U_I18N_API CurrencyUnit: public MeasureUnit {
|
|||||||
* then this will be set to a failing value.
|
* then this will be set to a failing value.
|
||||||
* @stable ICU 3.0
|
* @stable ICU 3.0
|
||||||
*/
|
*/
|
||||||
CurrencyUnit(const UChar* isoCode, UErrorCode &ec);
|
CurrencyUnit(ConstChar16Ptr isoCode, UErrorCode &ec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy constructor
|
* Copy constructor
|
||||||
@ -93,16 +93,16 @@ class U_I18N_API CurrencyUnit: public MeasureUnit {
|
|||||||
* Return the ISO currency code of this object.
|
* Return the ISO currency code of this object.
|
||||||
* @stable ICU 3.0
|
* @stable ICU 3.0
|
||||||
*/
|
*/
|
||||||
inline const UChar* getISOCurrency() const;
|
inline const char16_t* getISOCurrency() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* The ISO 4217 code of this object.
|
* The ISO 4217 code of this object.
|
||||||
*/
|
*/
|
||||||
UChar isoCode[4];
|
char16_t isoCode[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
inline const UChar* CurrencyUnit::getISOCurrency() const {
|
inline const char16_t* CurrencyUnit::getISOCurrency() const {
|
||||||
return isoCode;
|
return isoCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,7 +393,7 @@ public:
|
|||||||
* Returns that pattern stored in currecy info. Internal API for use by NumberFormat API.
|
* Returns that pattern stored in currecy info. Internal API for use by NumberFormat API.
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
inline const UChar* getCurrencyPattern(void) const;
|
inline const char16_t* getCurrencyPattern(void) const;
|
||||||
#endif /* U_HIDE_INTERNAL_API */
|
#endif /* U_HIDE_INTERNAL_API */
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -424,7 +424,7 @@ private:
|
|||||||
|
|
||||||
char actualLocale[ULOC_FULLNAME_CAPACITY];
|
char actualLocale[ULOC_FULLNAME_CAPACITY];
|
||||||
char validLocale[ULOC_FULLNAME_CAPACITY];
|
char validLocale[ULOC_FULLNAME_CAPACITY];
|
||||||
const UChar* currPattern;
|
const char16_t* currPattern;
|
||||||
|
|
||||||
UnicodeString currencySpcBeforeSym[UNUM_CURRENCY_SPACING_COUNT];
|
UnicodeString currencySpcBeforeSym[UNUM_CURRENCY_SPACING_COUNT];
|
||||||
UnicodeString currencySpcAfterSym[UNUM_CURRENCY_SPACING_COUNT];
|
UnicodeString currencySpcAfterSym[UNUM_CURRENCY_SPACING_COUNT];
|
||||||
@ -492,7 +492,7 @@ DecimalFormatSymbols::getLocale() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef U_HIDE_INTERNAL_API
|
#ifndef U_HIDE_INTERNAL_API
|
||||||
inline const UChar*
|
inline const char16_t*
|
||||||
DecimalFormatSymbols::getCurrencyPattern() const {
|
DecimalFormatSymbols::getCurrencyPattern() const {
|
||||||
return currPattern;
|
return currPattern;
|
||||||
}
|
}
|
||||||
|
@ -604,7 +604,7 @@ template class U_I18N_API EnumSet<UNumberFormatAttribute,
|
|||||||
* including prefix and suffix, determines the format width. For example, in
|
* including prefix and suffix, determines the format width. For example, in
|
||||||
* the pattern <code>"* #0 o''clock"</code>, the format width is 10.
|
* the pattern <code>"* #0 o''clock"</code>, the format width is 10.
|
||||||
*
|
*
|
||||||
* <li>The width is counted in 16-bit code units (UChars).
|
* <li>The width is counted in 16-bit code units (char16_ts).
|
||||||
*
|
*
|
||||||
* <li>Some parameters which usually do not matter have meaning when padding is
|
* <li>Some parameters which usually do not matter have meaning when padding is
|
||||||
* used, because the pattern width is significant with padding. In the pattern
|
* used, because the pattern width is significant with padding. In the pattern
|
||||||
@ -1961,14 +1961,14 @@ public:
|
|||||||
* @param ec input-output error code
|
* @param ec input-output error code
|
||||||
* @stable ICU 3.0
|
* @stable ICU 3.0
|
||||||
*/
|
*/
|
||||||
virtual void setCurrency(const UChar* theCurrency, UErrorCode& ec);
|
virtual void setCurrency(const char16_t* theCurrency, UErrorCode& ec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the currency used to display currency amounts. See
|
* Sets the currency used to display currency amounts. See
|
||||||
* setCurrency(const UChar*, UErrorCode&).
|
* setCurrency(const char16_t*, UErrorCode&).
|
||||||
* @deprecated ICU 3.0. Use setCurrency(const UChar*, UErrorCode&).
|
* @deprecated ICU 3.0. Use setCurrency(const char16_t*, UErrorCode&).
|
||||||
*/
|
*/
|
||||||
virtual void setCurrency(const UChar* theCurrency);
|
virtual void setCurrency(const char16_t* theCurrency);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the <tt>Currency Context</tt> object used to display currency.
|
* Sets the <tt>Currency Context</tt> object used to display currency.
|
||||||
@ -2108,7 +2108,7 @@ private:
|
|||||||
void parse(const UnicodeString& text,
|
void parse(const UnicodeString& text,
|
||||||
Formattable& result,
|
Formattable& result,
|
||||||
ParsePosition& pos,
|
ParsePosition& pos,
|
||||||
UChar* currency) const;
|
char16_t* currency) const;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
fgStatusInfinite,
|
fgStatusInfinite,
|
||||||
@ -2124,7 +2124,7 @@ private:
|
|||||||
int8_t type,
|
int8_t type,
|
||||||
ParsePosition& parsePosition,
|
ParsePosition& parsePosition,
|
||||||
DigitList& digits, UBool* status,
|
DigitList& digits, UBool* status,
|
||||||
UChar* currency) const;
|
char16_t* currency) const;
|
||||||
|
|
||||||
// Mixed style parsing for currency.
|
// Mixed style parsing for currency.
|
||||||
// It parses against the current currency pattern
|
// It parses against the current currency pattern
|
||||||
@ -2135,7 +2135,7 @@ private:
|
|||||||
ParsePosition& parsePosition,
|
ParsePosition& parsePosition,
|
||||||
DigitList& digits,
|
DigitList& digits,
|
||||||
UBool* status,
|
UBool* status,
|
||||||
UChar* currency) const;
|
char16_t* currency) const;
|
||||||
|
|
||||||
int32_t skipPadding(const UnicodeString& text, int32_t position) const;
|
int32_t skipPadding(const UnicodeString& text, int32_t position) const;
|
||||||
|
|
||||||
@ -2146,7 +2146,7 @@ private:
|
|||||||
const UnicodeString* affixPat,
|
const UnicodeString* affixPat,
|
||||||
UBool complexCurrencyParsing,
|
UBool complexCurrencyParsing,
|
||||||
int8_t type,
|
int8_t type,
|
||||||
UChar* currency) const;
|
char16_t* currency) const;
|
||||||
|
|
||||||
static UnicodeString& trimMarksFromAffix(const UnicodeString& affix, UnicodeString& trimmedAffix);
|
static UnicodeString& trimMarksFromAffix(const UnicodeString& affix, UnicodeString& trimmedAffix);
|
||||||
|
|
||||||
@ -2169,7 +2169,7 @@ private:
|
|||||||
const UnicodeString& input,
|
const UnicodeString& input,
|
||||||
int32_t pos,
|
int32_t pos,
|
||||||
int8_t type,
|
int8_t type,
|
||||||
UChar* currency) const;
|
char16_t* currency) const;
|
||||||
|
|
||||||
static int32_t match(const UnicodeString& text, int32_t pos, UChar32 ch);
|
static int32_t match(const UnicodeString& text, int32_t pos, UChar32 ch);
|
||||||
|
|
||||||
@ -2195,11 +2195,11 @@ private:
|
|||||||
void setupCurrencyAffixPatterns(UErrorCode& status);
|
void setupCurrencyAffixPatterns(UErrorCode& status);
|
||||||
|
|
||||||
// get the currency rounding with respect to currency usage
|
// get the currency rounding with respect to currency usage
|
||||||
double getCurrencyRounding(const UChar* currency,
|
double getCurrencyRounding(const char16_t* currency,
|
||||||
UErrorCode* ec) const;
|
UErrorCode* ec) const;
|
||||||
|
|
||||||
// get the currency fraction with respect to currency usage
|
// get the currency fraction with respect to currency usage
|
||||||
int getCurrencyFractionDigits(const UChar* currency,
|
int getCurrencyFractionDigits(const char16_t* currency,
|
||||||
UErrorCode* ec) const;
|
UErrorCode* ec) const;
|
||||||
|
|
||||||
// hashtable operations
|
// hashtable operations
|
||||||
@ -2271,7 +2271,7 @@ protected:
|
|||||||
* have a capacity of at least 4
|
* have a capacity of at least 4
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
virtual void getEffectiveCurrency(UChar* result, UErrorCode& ec) const;
|
virtual void getEffectiveCurrency(char16_t* result, UErrorCode& ec) const;
|
||||||
|
|
||||||
/** number of integer digits
|
/** number of integer digits
|
||||||
* @stable ICU 2.4
|
* @stable ICU 2.4
|
||||||
|
@ -426,13 +426,13 @@ public:
|
|||||||
* doesn't specify any time separator, and always recognized when parsing.
|
* doesn't specify any time separator, and always recognized when parsing.
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
static const UChar DEFAULT_TIME_SEPARATOR = 0x003a; // ':'
|
static const char16_t DEFAULT_TIME_SEPARATOR = 0x003a; // ':'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This alternate time separator is always recognized when parsing.
|
* This alternate time separator is always recognized when parsing.
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
static const UChar ALTERNATE_TIME_SEPARATOR = 0x002e; // '.'
|
static const char16_t ALTERNATE_TIME_SEPARATOR = 0x002e; // '.'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the time separator string. For example: ":".
|
* Gets the time separator string. For example: ":".
|
||||||
@ -566,7 +566,7 @@ public:
|
|||||||
* @return the non-localized date-time pattern characters
|
* @return the non-localized date-time pattern characters
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
static const UChar * U_EXPORT2 getPatternUChars(void);
|
static const char16_t * U_EXPORT2 getPatternUChars(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets localized date-time pattern characters. For example: 'u', 't', etc.
|
* Gets localized date-time pattern characters. For example: 'u', 't', etc.
|
||||||
@ -977,7 +977,7 @@ private:
|
|||||||
* Returns the date format field index of the pattern character c,
|
* Returns the date format field index of the pattern character c,
|
||||||
* or UDAT_FIELD_COUNT if c is not a pattern character.
|
* or UDAT_FIELD_COUNT if c is not a pattern character.
|
||||||
*/
|
*/
|
||||||
static UDateFormatField U_EXPORT2 getPatternCharIndex(UChar c);
|
static UDateFormatField U_EXPORT2 getPatternCharIndex(char16_t c);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns TRUE if f (with its pattern character repeated count times) is a numeric field.
|
* Returns TRUE if f (with its pattern character repeated count times) is a numeric field.
|
||||||
@ -987,7 +987,7 @@ private:
|
|||||||
/**
|
/**
|
||||||
* Returns TRUE if c (repeated count times) is the pattern character for a numeric field.
|
* Returns TRUE if c (repeated count times) is the pattern character for a numeric field.
|
||||||
*/
|
*/
|
||||||
static UBool U_EXPORT2 isNumericPatternChar(UChar c, int32_t count);
|
static UBool U_EXPORT2 isNumericPatternChar(char16_t c, int32_t count);
|
||||||
public:
|
public:
|
||||||
#ifndef U_HIDE_INTERNAL_API
|
#ifndef U_HIDE_INTERNAL_API
|
||||||
/**
|
/**
|
||||||
|
@ -996,7 +996,7 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
// from calendar field to pattern letter
|
// from calendar field to pattern letter
|
||||||
static const UChar fgCalendarFieldToPatternLetter[];
|
static const char16_t fgCalendarFieldToPatternLetter[];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -517,7 +517,7 @@ private:
|
|||||||
DateTimeMatcher *skipMatcher;
|
DateTimeMatcher *skipMatcher;
|
||||||
Hashtable *fAvailableFormatKeyHash;
|
Hashtable *fAvailableFormatKeyHash;
|
||||||
UnicodeString emptyString;
|
UnicodeString emptyString;
|
||||||
UChar fDefaultHourFormatChar;
|
char16_t fDefaultHourFormatChar;
|
||||||
|
|
||||||
int32_t fAllowedHourFormats[7]; // Actually an array of AllowedHourFormat enum type, ending with UNKNOWN.
|
int32_t fAllowedHourFormats[7]; // Actually an array of AllowedHourFormat enum type, ending with UNKNOWN.
|
||||||
|
|
||||||
|
@ -939,7 +939,7 @@ private:
|
|||||||
* @return the index of the list which matches the keyword s.
|
* @return the index of the list which matches the keyword s.
|
||||||
*/
|
*/
|
||||||
static int32_t findKeyword( const UnicodeString& s,
|
static int32_t findKeyword( const UnicodeString& s,
|
||||||
const UChar * const *list);
|
const char16_t * const *list);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Thin wrapper around the format(... AppendableWrapper ...) variant.
|
* Thin wrapper around the format(... AppendableWrapper ...) variant.
|
||||||
|
@ -931,7 +931,7 @@ public:
|
|||||||
* @param ec input-output error code
|
* @param ec input-output error code
|
||||||
* @stable ICU 3.0
|
* @stable ICU 3.0
|
||||||
*/
|
*/
|
||||||
virtual void setCurrency(const UChar* theCurrency, UErrorCode& ec);
|
virtual void setCurrency(const char16_t* theCurrency, UErrorCode& ec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the currency used to display currency
|
* Gets the currency used to display currency
|
||||||
@ -940,7 +940,7 @@ public:
|
|||||||
* the currency in use, or a pointer to the empty string.
|
* the currency in use, or a pointer to the empty string.
|
||||||
* @stable ICU 2.6
|
* @stable ICU 2.6
|
||||||
*/
|
*/
|
||||||
const UChar* getCurrency() const;
|
const char16_t* getCurrency() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a particular UDisplayContext value in the formatter, such as
|
* Set a particular UDisplayContext value in the formatter, such as
|
||||||
@ -1018,7 +1018,7 @@ protected:
|
|||||||
* have a capacity of at least 4
|
* have a capacity of at least 4
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
virtual void getEffectiveCurrency(UChar* result, UErrorCode& ec) const;
|
virtual void getEffectiveCurrency(char16_t* result, UErrorCode& ec) const;
|
||||||
|
|
||||||
#ifndef U_HIDE_INTERNAL_API
|
#ifndef U_HIDE_INTERNAL_API
|
||||||
/**
|
/**
|
||||||
@ -1065,7 +1065,7 @@ private:
|
|||||||
UBool fLenient; // TRUE => lenient parse is enabled
|
UBool fLenient; // TRUE => lenient parse is enabled
|
||||||
|
|
||||||
// ISO currency code
|
// ISO currency code
|
||||||
UChar fCurrency[4];
|
char16_t fCurrency[4];
|
||||||
|
|
||||||
UDisplayContext fCapitalizationContext;
|
UDisplayContext fCapitalizationContext;
|
||||||
|
|
||||||
|
@ -350,17 +350,17 @@ public:
|
|||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Cause a compilation error if an application accidentally attempts to
|
* Cause a compilation error if an application accidentally attempts to
|
||||||
* create a matcher with a (UChar *) string as input rather than
|
* create a matcher with a (char16_t *) string as input rather than
|
||||||
* a UnicodeString. Avoids a dangling reference to a temporary string.
|
* a UnicodeString. Avoids a dangling reference to a temporary string.
|
||||||
* <p>
|
* <p>
|
||||||
* To efficiently work with UChar *strings, wrap the data in a UnicodeString
|
* To efficiently work with char16_t *strings, wrap the data in a UnicodeString
|
||||||
* using one of the aliasing constructors, such as
|
* using one of the aliasing constructors, such as
|
||||||
* <code>UnicodeString(UBool isTerminated, const UChar *text, int32_t textLength);</code>
|
* <code>UnicodeString(UBool isTerminated, const char16_t *text, int32_t textLength);</code>
|
||||||
* or in a UText, using
|
* or in a UText, using
|
||||||
* <code>utext_openUChars(UText *ut, const UChar *text, int64_t textLength, UErrorCode *status);</code>
|
* <code>utext_openUChars(UText *ut, const char16_t *text, int64_t textLength, UErrorCode *status);</code>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
RegexMatcher *matcher(const UChar *input,
|
RegexMatcher *matcher(const char16_t *input,
|
||||||
UErrorCode &status) const;
|
UErrorCode &status) const;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -748,17 +748,17 @@ public:
|
|||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Cause a compilation error if an application accidentally attempts to
|
* Cause a compilation error if an application accidentally attempts to
|
||||||
* create a matcher with a (UChar *) string as input rather than
|
* create a matcher with a (char16_t *) string as input rather than
|
||||||
* a UnicodeString. Avoids a dangling reference to a temporary string.
|
* a UnicodeString. Avoids a dangling reference to a temporary string.
|
||||||
* <p>
|
* <p>
|
||||||
* To efficiently work with UChar *strings, wrap the data in a UnicodeString
|
* To efficiently work with char16_t *strings, wrap the data in a UnicodeString
|
||||||
* using one of the aliasing constructors, such as
|
* using one of the aliasing constructors, such as
|
||||||
* <code>UnicodeString(UBool isTerminated, const UChar *text, int32_t textLength);</code>
|
* <code>UnicodeString(UBool isTerminated, const char16_t *text, int32_t textLength);</code>
|
||||||
* or in a UText, using
|
* or in a UText, using
|
||||||
* <code>utext_openUChars(UText *ut, const UChar *text, int64_t textLength, UErrorCode *status);</code>
|
* <code>utext_openUChars(UText *ut, const char16_t *text, int64_t textLength, UErrorCode *status);</code>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
RegexMatcher(const UnicodeString ®exp, const UChar *input,
|
RegexMatcher(const UnicodeString ®exp, const char16_t *input,
|
||||||
uint32_t flags, UErrorCode &status);
|
uint32_t flags, UErrorCode &status);
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -1156,17 +1156,17 @@ public:
|
|||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Cause a compilation error if an application accidentally attempts to
|
* Cause a compilation error if an application accidentally attempts to
|
||||||
* reset a matcher with a (UChar *) string as input rather than
|
* reset a matcher with a (char16_t *) string as input rather than
|
||||||
* a UnicodeString. Avoids a dangling reference to a temporary string.
|
* a UnicodeString. Avoids a dangling reference to a temporary string.
|
||||||
* <p>
|
* <p>
|
||||||
* To efficiently work with UChar *strings, wrap the data in a UnicodeString
|
* To efficiently work with char16_t *strings, wrap the data in a UnicodeString
|
||||||
* using one of the aliasing constructors, such as
|
* using one of the aliasing constructors, such as
|
||||||
* <code>UnicodeString(UBool isTerminated, const UChar *text, int32_t textLength);</code>
|
* <code>UnicodeString(UBool isTerminated, const char16_t *text, int32_t textLength);</code>
|
||||||
* or in a UText, using
|
* or in a UText, using
|
||||||
* <code>utext_openUChars(UText *ut, const UChar *text, int64_t textLength, UErrorCode *status);</code>
|
* <code>utext_openUChars(UText *ut, const char16_t *text, int64_t textLength, UErrorCode *status);</code>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
RegexMatcher &reset(const UChar *input);
|
RegexMatcher &reset(const char16_t *input);
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1170,7 +1170,7 @@ public:
|
|||||||
* @param field The UDateFormatField to get
|
* @param field The UDateFormatField to get
|
||||||
* @stable ICU 54
|
* @stable ICU 54
|
||||||
*/
|
*/
|
||||||
const NumberFormat * getNumberFormatForField(UChar field) const;
|
const NumberFormat * getNumberFormatForField(char16_t field) const;
|
||||||
|
|
||||||
#ifndef U_HIDE_INTERNAL_API
|
#ifndef U_HIDE_INTERNAL_API
|
||||||
/**
|
/**
|
||||||
@ -1262,7 +1262,7 @@ private:
|
|||||||
* succeeds.
|
* succeeds.
|
||||||
*/
|
*/
|
||||||
void subFormat(UnicodeString &appendTo,
|
void subFormat(UnicodeString &appendTo,
|
||||||
UChar ch,
|
char16_t ch,
|
||||||
int32_t count,
|
int32_t count,
|
||||||
UDisplayContext capitalizationContext,
|
UDisplayContext capitalizationContext,
|
||||||
int32_t fieldNum,
|
int32_t fieldNum,
|
||||||
@ -1294,7 +1294,7 @@ private:
|
|||||||
* Return true if the given format character, occuring count
|
* Return true if the given format character, occuring count
|
||||||
* times, represents a numeric field.
|
* times, represents a numeric field.
|
||||||
*/
|
*/
|
||||||
static UBool isNumeric(UChar formatChar, int32_t count);
|
static UBool isNumeric(char16_t formatChar, int32_t count);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns TRUE if the patternOffset is at the start of a numeric field.
|
* Returns TRUE if the patternOffset is at the start of a numeric field.
|
||||||
@ -1412,7 +1412,7 @@ private:
|
|||||||
* @return the new start position if matching succeeded; a negative number
|
* @return the new start position if matching succeeded; a negative number
|
||||||
* indicating matching failure, otherwise.
|
* indicating matching failure, otherwise.
|
||||||
*/
|
*/
|
||||||
int32_t subParse(const UnicodeString& text, int32_t& start, UChar ch, int32_t count,
|
int32_t subParse(const UnicodeString& text, int32_t& start, char16_t ch, int32_t count,
|
||||||
UBool obeyCount, UBool allowNegative, UBool ambiguousYear[], int32_t& saveHebrewMonth, Calendar& cal,
|
UBool obeyCount, UBool allowNegative, UBool ambiguousYear[], int32_t& saveHebrewMonth, Calendar& cal,
|
||||||
int32_t patLoc, MessageFormat * numericLeapMonthFormatter, UTimeZoneFormatTimeType *tzTimeType, SimpleDateFormatMutableNFs &mutableNFs,
|
int32_t patLoc, MessageFormat * numericLeapMonthFormatter, UTimeZoneFormatTimeType *tzTimeType, SimpleDateFormatMutableNFs &mutableNFs,
|
||||||
int32_t *dayPeriod=NULL) const;
|
int32_t *dayPeriod=NULL) const;
|
||||||
@ -1523,12 +1523,12 @@ private:
|
|||||||
/**
|
/**
|
||||||
* Map calendar field letter into calendar field level.
|
* Map calendar field letter into calendar field level.
|
||||||
*/
|
*/
|
||||||
static int32_t getLevelFromChar(UChar ch);
|
static int32_t getLevelFromChar(char16_t ch);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tell if a character can be used to define a field in a format string.
|
* Tell if a character can be used to define a field in a format string.
|
||||||
*/
|
*/
|
||||||
static UBool isSyntaxChar(UChar ch);
|
static UBool isSyntaxChar(char16_t ch);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The formatting pattern for this formatter.
|
* The formatting pattern for this formatter.
|
||||||
|
@ -308,8 +308,8 @@ public:
|
|||||||
* than target
|
* than target
|
||||||
* @stable ICU 2.6
|
* @stable ICU 2.6
|
||||||
*/
|
*/
|
||||||
virtual UCollationResult compare(const UChar* source, int32_t sourceLength,
|
virtual UCollationResult compare(const char16_t* source, int32_t sourceLength,
|
||||||
const UChar* target, int32_t targetLength,
|
const char16_t* target, int32_t targetLength,
|
||||||
UErrorCode &status) const;
|
UErrorCode &status) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -377,7 +377,7 @@ public:
|
|||||||
* @see CollationKey
|
* @see CollationKey
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
virtual CollationKey& getCollationKey(const UChar *source,
|
virtual CollationKey& getCollationKey(const char16_t *source,
|
||||||
int32_t sourceLength,
|
int32_t sourceLength,
|
||||||
CollationKey& key,
|
CollationKey& key,
|
||||||
UErrorCode& status) const;
|
UErrorCode& status) const;
|
||||||
@ -552,7 +552,7 @@ public:
|
|||||||
* the top of one of the supported reordering groups,
|
* the top of one of the supported reordering groups,
|
||||||
* and it must not be beyond the last of those groups.
|
* and it must not be beyond the last of those groups.
|
||||||
* See setMaxVariable().
|
* See setMaxVariable().
|
||||||
* @param varTop one or more (if contraction) UChars to which the variable top should be set
|
* @param varTop one or more (if contraction) char16_ts to which the variable top should be set
|
||||||
* @param len length of variable top string. If -1 it is considered to be zero terminated.
|
* @param len length of variable top string. If -1 it is considered to be zero terminated.
|
||||||
* @param status error code. If error code is set, the return value is undefined. Errors set by this function are: <br>
|
* @param status error code. If error code is set, the return value is undefined. Errors set by this function are: <br>
|
||||||
* U_CE_NOT_FOUND_ERROR if more than one character was passed and there is no such contraction<br>
|
* U_CE_NOT_FOUND_ERROR if more than one character was passed and there is no such contraction<br>
|
||||||
@ -561,7 +561,7 @@ public:
|
|||||||
* @return variable top primary weight
|
* @return variable top primary weight
|
||||||
* @deprecated ICU 53 Call setMaxVariable() instead.
|
* @deprecated ICU 53 Call setMaxVariable() instead.
|
||||||
*/
|
*/
|
||||||
virtual uint32_t setVariableTop(const UChar *varTop, int32_t len, UErrorCode &status);
|
virtual uint32_t setVariableTop(const char16_t *varTop, int32_t len, UErrorCode &status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the variable top to the primary weight of the specified string.
|
* Sets the variable top to the primary weight of the specified string.
|
||||||
@ -570,7 +570,7 @@ public:
|
|||||||
* the top of one of the supported reordering groups,
|
* the top of one of the supported reordering groups,
|
||||||
* and it must not be beyond the last of those groups.
|
* and it must not be beyond the last of those groups.
|
||||||
* See setMaxVariable().
|
* See setMaxVariable().
|
||||||
* @param varTop a UnicodeString size 1 or more (if contraction) of UChars to which the variable top should be set
|
* @param varTop a UnicodeString size 1 or more (if contraction) of char16_ts to which the variable top should be set
|
||||||
* @param status error code. If error code is set, the return value is undefined. Errors set by this function are: <br>
|
* @param status error code. If error code is set, the return value is undefined. Errors set by this function are: <br>
|
||||||
* U_CE_NOT_FOUND_ERROR if more than one character was passed and there is no such contraction<br>
|
* U_CE_NOT_FOUND_ERROR if more than one character was passed and there is no such contraction<br>
|
||||||
* U_ILLEGAL_ARGUMENT_ERROR if the variable top is beyond
|
* U_ILLEGAL_ARGUMENT_ERROR if the variable top is beyond
|
||||||
@ -631,7 +631,7 @@ public:
|
|||||||
int32_t resultLength) const;
|
int32_t resultLength) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the sort key as an array of bytes from a UChar buffer.
|
* Get the sort key as an array of bytes from a char16_t buffer.
|
||||||
*
|
*
|
||||||
* Note that sort keys are often less efficient than simply doing comparison.
|
* Note that sort keys are often less efficient than simply doing comparison.
|
||||||
* For more details, see the ICU User Guide.
|
* For more details, see the ICU User Guide.
|
||||||
@ -646,7 +646,7 @@ public:
|
|||||||
* @return Number of bytes needed for storing the sort key
|
* @return Number of bytes needed for storing the sort key
|
||||||
* @stable ICU 2.2
|
* @stable ICU 2.2
|
||||||
*/
|
*/
|
||||||
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;
|
uint8_t *result, int32_t resultLength) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -821,17 +821,17 @@ private:
|
|||||||
void adoptTailoring(CollationTailoring *t, UErrorCode &errorCode);
|
void adoptTailoring(CollationTailoring *t, UErrorCode &errorCode);
|
||||||
|
|
||||||
// Both lengths must be <0 or else both must be >=0.
|
// Both lengths must be <0 or else both must be >=0.
|
||||||
UCollationResult doCompare(const UChar *left, int32_t leftLength,
|
UCollationResult doCompare(const char16_t *left, int32_t leftLength,
|
||||||
const UChar *right, int32_t rightLength,
|
const char16_t *right, int32_t rightLength,
|
||||||
UErrorCode &errorCode) const;
|
UErrorCode &errorCode) const;
|
||||||
UCollationResult doCompare(const uint8_t *left, int32_t leftLength,
|
UCollationResult doCompare(const uint8_t *left, int32_t leftLength,
|
||||||
const uint8_t *right, int32_t rightLength,
|
const uint8_t *right, int32_t rightLength,
|
||||||
UErrorCode &errorCode) const;
|
UErrorCode &errorCode) const;
|
||||||
|
|
||||||
void writeSortKey(const UChar *s, int32_t length,
|
void writeSortKey(const char16_t *s, int32_t length,
|
||||||
SortKeyByteSink &sink, UErrorCode &errorCode) const;
|
SortKeyByteSink &sink, UErrorCode &errorCode) const;
|
||||||
|
|
||||||
void writeIdenticalLevel(const UChar *s, const UChar *limit,
|
void writeIdenticalLevel(const char16_t *s, const char16_t *limit,
|
||||||
SortKeyByteSink &sink, UErrorCode &errorCode) const;
|
SortKeyByteSink &sink, UErrorCode &errorCode) const;
|
||||||
|
|
||||||
const CollationSettings &getDefaultSettings() const;
|
const CollationSettings &getDefaultSettings() const;
|
||||||
|
@ -863,7 +863,7 @@ private:
|
|||||||
* @param id zone id string
|
* @param id zone id string
|
||||||
* @return the pointer of the ID resource, or NULL.
|
* @return the pointer of the ID resource, or NULL.
|
||||||
*/
|
*/
|
||||||
static const UChar* findID(const UnicodeString& id);
|
static const char16_t* findID(const UnicodeString& id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolve a link in Olson tzdata. When the given id is known and it's not a link,
|
* Resolve a link in Olson tzdata. When the given id is known and it's not a link,
|
||||||
@ -873,7 +873,7 @@ private:
|
|||||||
* @param id zone id string
|
* @param id zone id string
|
||||||
* @return the dereferenced zone or NULL
|
* @return the dereferenced zone or NULL
|
||||||
*/
|
*/
|
||||||
static const UChar* dereferOlsonLink(const UnicodeString& id);
|
static const char16_t* dereferOlsonLink(const UnicodeString& id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the region code associated with the given zone,
|
* Returns the region code associated with the given zone,
|
||||||
@ -881,7 +881,7 @@ private:
|
|||||||
* @param id zone id string
|
* @param id zone id string
|
||||||
* @return the region associated with the given zone
|
* @return the region associated with the given zone
|
||||||
*/
|
*/
|
||||||
static const UChar* getRegion(const UnicodeString& id);
|
static const char16_t* getRegion(const UnicodeString& id);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
#ifndef U_HIDE_INTERNAL_API
|
#ifndef U_HIDE_INTERNAL_API
|
||||||
@ -893,7 +893,7 @@ private:
|
|||||||
* @return the region associated with the given zone
|
* @return the region associated with the given zone
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
static const UChar* getRegion(const UnicodeString& id, UErrorCode& status);
|
static const char16_t* getRegion(const UnicodeString& id, UErrorCode& status);
|
||||||
#endif /* U_HIDE_INTERNAL_API */
|
#endif /* U_HIDE_INTERNAL_API */
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -1319,7 +1319,7 @@ inline int32_t Transliterator::getMaximumContextLength(void) const {
|
|||||||
inline void Transliterator::setID(const UnicodeString& id) {
|
inline void Transliterator::setID(const UnicodeString& id) {
|
||||||
ID = id;
|
ID = id;
|
||||||
// NUL-terminate the ID string, which is a non-aliased copy.
|
// 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);
|
ID.truncate(ID.length()-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -942,7 +942,7 @@ private:
|
|||||||
* @param parsedLen the parsed length, or 0 on failure.
|
* @param parsedLen the parsed length, or 0 on failure.
|
||||||
* @return the parsed offset in milliseconds.
|
* @return the parsed offset in milliseconds.
|
||||||
*/
|
*/
|
||||||
int32_t parseDefaultOffsetFields(const UnicodeString& text, int32_t start, UChar separator,
|
int32_t parseDefaultOffsetFields(const UnicodeString& text, int32_t start, char16_t separator,
|
||||||
int32_t& parsedLen) const;
|
int32_t& parsedLen) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -982,7 +982,7 @@ private:
|
|||||||
* @param maxFields The maximum fields
|
* @param maxFields The maximum fields
|
||||||
* @return The offset string
|
* @return The offset string
|
||||||
*/
|
*/
|
||||||
static UnicodeString& formatOffsetWithAsciiDigits(int32_t offset, UChar sep,
|
static UnicodeString& formatOffsetWithAsciiDigits(int32_t offset, char16_t sep,
|
||||||
OffsetFields minFields, OffsetFields maxFields, UnicodeString& result);
|
OffsetFields minFields, OffsetFields maxFields, UnicodeString& result);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1012,7 +1012,7 @@ private:
|
|||||||
* @param maxFields The maximum Fields to be parsed
|
* @param maxFields The maximum Fields to be parsed
|
||||||
* @return Parsed offset, 0 or positive number.
|
* @return Parsed offset, 0 or positive number.
|
||||||
*/
|
*/
|
||||||
static int32_t parseAsciiOffsetFields(const UnicodeString& text, ParsePosition& pos, UChar sep,
|
static int32_t parseAsciiOffsetFields(const UnicodeString& text, ParsePosition& pos, char16_t sep,
|
||||||
OffsetFields minFields, OffsetFields maxFields);
|
OffsetFields minFields, OffsetFields maxFields);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,7 +35,7 @@ BUILDDIR := $(BUILDDIR:test\\intltest/../../=)
|
|||||||
BUILDDIR := $(BUILDDIR:TEST\\INTLTEST/../../=)
|
BUILDDIR := $(BUILDDIR:TEST\\INTLTEST/../../=)
|
||||||
|
|
||||||
CPPFLAGS += -I$(top_srcdir)/common -I$(top_srcdir)/i18n -I$(top_srcdir)/tools/toolutil -I$(top_srcdir)/tools/ctestfw
|
CPPFLAGS += -I$(top_srcdir)/common -I$(top_srcdir)/i18n -I$(top_srcdir)/tools/toolutil -I$(top_srcdir)/tools/ctestfw
|
||||||
CPPFLAGS += -DUNISTR_FROM_CHAR_EXPLICIT= -DUNISTR_FROM_STRING_EXPLICIT=
|
CPPFLAGS += -DUNISTR_FROM_CHAR_EXPLICIT= -DUNISTR_FROM_STRING_EXPLICIT= -DUCHAR_TYPE=char16_t
|
||||||
DEFS += -D'U_TOPSRCDIR="$(top_srcdir)/"' -D'U_TOPBUILDDIR="$(BUILDDIR)"'
|
DEFS += -D'U_TOPSRCDIR="$(top_srcdir)/"' -D'U_TOPBUILDDIR="$(BUILDDIR)"'
|
||||||
LIBS = $(LIBCTESTFW) $(LIBICUI18N) $(LIBICUUC) $(LIBICUTOOLUTIL) $(DEFAULT_LIBS) $(LIB_M) $(LIB_THREAD)
|
LIBS = $(LIBCTESTFW) $(LIBICUI18N) $(LIBICUUC) $(LIBICUTOOLUTIL) $(DEFAULT_LIBS) $(LIB_M) $(LIB_THREAD)
|
||||||
|
|
||||||
|
@ -368,7 +368,7 @@
|
|||||||
<ClCompile Include="idnaconf.cpp" />
|
<ClCompile Include="idnaconf.cpp" />
|
||||||
<ClCompile Include="idnaref.cpp" />
|
<ClCompile Include="idnaref.cpp" />
|
||||||
<ClCompile Include="nptrans.cpp" />
|
<ClCompile Include="nptrans.cpp" />
|
||||||
<ClCompile Include="punyref.c" />
|
<ClCompile Include="punyref.cpp" />
|
||||||
<ClCompile Include="testidn.cpp">
|
<ClCompile Include="testidn.cpp">
|
||||||
<DisableLanguageExtensions>false</DisableLanguageExtensions>
|
<DisableLanguageExtensions>false</DisableLanguageExtensions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -352,7 +352,7 @@
|
|||||||
<ClCompile Include="nptrans.cpp">
|
<ClCompile Include="nptrans.cpp">
|
||||||
<Filter>idna</Filter>
|
<Filter>idna</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="punyref.c">
|
<ClCompile Include="punyref.cpp">
|
||||||
<Filter>idna</Filter>
|
<Filter>idna</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="testidn.cpp">
|
<ClCompile Include="testidn.cpp">
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Corporation and others. All Rights Reserved.
|
* Corporation and others. All Rights Reserved.
|
||||||
*
|
*
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
* file name: punyref.h
|
* file name: punyref.cpp
|
||||||
* encoding: UTF-8
|
* encoding: UTF-8
|
||||||
* tab size: 8 (not used)
|
* tab size: 8 (not used)
|
||||||
* indentation:4
|
* indentation:4
|
@ -644,7 +644,7 @@ void StringSearchTest::TestOpenClose()
|
|||||||
}
|
}
|
||||||
delete result;
|
delete result;
|
||||||
|
|
||||||
text.append(0, 0x1);
|
// No-op: text.append(0, 0x1); -- what was intended here?
|
||||||
status = U_ZERO_ERROR;
|
status = U_ZERO_ERROR;
|
||||||
result = new StringSearch(pattern, text, NULL, NULL, status);
|
result = new StringSearch(pattern, text, NULL, NULL, status);
|
||||||
if (U_SUCCESS(status)) {
|
if (U_SUCCESS(status)) {
|
||||||
|
@ -61,6 +61,9 @@ void UnicodeStringTest::runIndexedTest( int32_t index, UBool exec, const char* &
|
|||||||
TESTCASE_AUTO(TestSizeofUnicodeString);
|
TESTCASE_AUTO(TestSizeofUnicodeString);
|
||||||
TESTCASE_AUTO(TestStartsWithAndEndsWithNulTerminated);
|
TESTCASE_AUTO(TestStartsWithAndEndsWithNulTerminated);
|
||||||
TESTCASE_AUTO(TestMoveSwap);
|
TESTCASE_AUTO(TestMoveSwap);
|
||||||
|
TESTCASE_AUTO(TestUInt16Pointers);
|
||||||
|
TESTCASE_AUTO(TestWCharPointers);
|
||||||
|
TESTCASE_AUTO(TestNullPointers);
|
||||||
TESTCASE_AUTO_END;
|
TESTCASE_AUTO_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1554,7 +1557,10 @@ UnicodeStringTest::TestBogus() {
|
|||||||
|
|
||||||
// writable alias to another string's buffer: very bad idea, just convenient for this test
|
// writable alias to another string's buffer: very bad idea, just convenient for this test
|
||||||
test3.setToBogus();
|
test3.setToBogus();
|
||||||
if(!test3.isBogus() || test3.setTo((UChar *)test1.getBuffer(), test1.length(), test1.getCapacity()).isBogus() || test3!=test1) {
|
if(!test3.isBogus() ||
|
||||||
|
test3.setTo(const_cast<UChar *>(test1.getBuffer()),
|
||||||
|
test1.length(), test1.getCapacity()).isBogus() ||
|
||||||
|
test3!=test1) {
|
||||||
errln("bogus.setTo(writable alias) failed");
|
errln("bogus.setTo(writable alias) failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1609,8 +1615,8 @@ UnicodeStringTest::TestBogus() {
|
|||||||
// test that NULL primitive input string values are treated like
|
// test that NULL primitive input string values are treated like
|
||||||
// empty strings, not errors (bogus)
|
// empty strings, not errors (bogus)
|
||||||
test2.setTo((UChar32)0x10005);
|
test2.setTo((UChar32)0x10005);
|
||||||
if(test2.insert(1, NULL, 1).length()!=2) {
|
if(test2.insert(1, nullptr, 1).length()!=2) {
|
||||||
errln("UniStr.insert(...NULL...) should not modify the string but does");
|
errln("UniStr.insert(...nullptr...) should not modify the string but does");
|
||||||
}
|
}
|
||||||
|
|
||||||
UErrorCode errorCode=U_ZERO_ERROR;
|
UErrorCode errorCode=U_ZERO_ERROR;
|
||||||
@ -2186,3 +2192,64 @@ UnicodeStringTest::TestMoveSwap() {
|
|||||||
errln("UnicodeString copy after self-move did not work");
|
errln("UnicodeString copy after self-move did not work");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
UnicodeStringTest::TestUInt16Pointers() {
|
||||||
|
static const uint16_t carr[] = { 0x61, 0x62, 0x63, 0 };
|
||||||
|
uint16_t arr[4];
|
||||||
|
|
||||||
|
UnicodeString expected(u"abc");
|
||||||
|
assertEquals("abc from pointer", expected, UnicodeString(carr));
|
||||||
|
assertEquals("abc from pointer+length", expected, UnicodeString(carr, 3));
|
||||||
|
assertEquals("abc from read-only-alias pointer", expected, UnicodeString(TRUE, carr, 3));
|
||||||
|
|
||||||
|
UnicodeString alias(arr, 0, 4);
|
||||||
|
alias.append(u'a').append(u'b').append(u'c');
|
||||||
|
assertEquals("abc from writable alias", expected, alias);
|
||||||
|
assertEquals("buffer=abc from writable alias", expected, UnicodeString(arr, 3));
|
||||||
|
|
||||||
|
UErrorCode errorCode = U_ZERO_ERROR;
|
||||||
|
int32_t length = UnicodeString(u"def").extract(arr, 4, errorCode);
|
||||||
|
TEST_ASSERT_STATUS(errorCode);
|
||||||
|
assertEquals("def from extract()", UnicodeString(u"def"), UnicodeString(arr, length));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
UnicodeStringTest::TestWCharPointers() {
|
||||||
|
#if U_SIZEOF_WCHAR_T==2
|
||||||
|
static const wchar_t carr[] = { 0x61, 0x62, 0x63, 0 };
|
||||||
|
wchar_t arr[4];
|
||||||
|
|
||||||
|
UnicodeString expected(u"abc");
|
||||||
|
assertEquals("abc from pointer", expected, UnicodeString(carr));
|
||||||
|
assertEquals("abc from pointer+length", expected, UnicodeString(carr, 3));
|
||||||
|
assertEquals("abc from read-only-alias pointer", expected, UnicodeString(TRUE, carr, 3));
|
||||||
|
|
||||||
|
UnicodeString alias(arr, 0, 4);
|
||||||
|
alias.append(u'a').append(u'b').append(u'c');
|
||||||
|
assertEquals("abc from writable alias", expected, alias);
|
||||||
|
assertEquals("buffer=abc from writable alias", expected, UnicodeString(arr, 3));
|
||||||
|
|
||||||
|
UErrorCode errorCode = U_ZERO_ERROR;
|
||||||
|
int32_t length = UnicodeString(u"def").extract(arr, 4, errorCode);
|
||||||
|
TEST_ASSERT_STATUS(errorCode);
|
||||||
|
assertEquals("def from extract()", UnicodeString(u"def"), UnicodeString(arr, length));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
UnicodeStringTest::TestNullPointers() {
|
||||||
|
assertTrue("empty from nullptr", UnicodeString(nullptr).isEmpty());
|
||||||
|
assertTrue("empty from nullptr+length", UnicodeString(nullptr, 2).isEmpty());
|
||||||
|
assertTrue("empty from read-only-alias nullptr", UnicodeString(TRUE, nullptr, 3).isEmpty());
|
||||||
|
|
||||||
|
UnicodeString alias(nullptr, 4, 4); // empty, no alias
|
||||||
|
assertTrue("empty from writable alias", alias.isEmpty());
|
||||||
|
alias.append(u'a').append(u'b').append(u'c');
|
||||||
|
UnicodeString expected(u"abc");
|
||||||
|
assertEquals("abc from writable alias", expected, alias);
|
||||||
|
|
||||||
|
UErrorCode errorCode = U_ZERO_ERROR;
|
||||||
|
UnicodeString(u"def").extract(nullptr, 0, errorCode);
|
||||||
|
assertEquals("buffer overflow extracting to nullptr", U_BUFFER_OVERFLOW_ERROR, errorCode);
|
||||||
|
}
|
||||||
|
@ -92,6 +92,10 @@ public:
|
|||||||
void TestUnicodeStringImplementsAppendable();
|
void TestUnicodeStringImplementsAppendable();
|
||||||
void TestSizeofUnicodeString();
|
void TestSizeofUnicodeString();
|
||||||
void TestMoveSwap();
|
void TestMoveSwap();
|
||||||
|
|
||||||
|
void TestUInt16Pointers();
|
||||||
|
void TestWCharPointers();
|
||||||
|
void TestNullPointers();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -106,12 +106,12 @@ static void U_CALLCONV TestStream(void)
|
|||||||
|
|
||||||
inTestStream >> inStr >> inStr2;
|
inTestStream >> inStr >> inStr2;
|
||||||
if (inStr.compare(thisMu) != 0) {
|
if (inStr.compare(thisMu) != 0) {
|
||||||
u_austrncpy(inStrC, inStr.getBuffer(), inStr.length());
|
u_austrncpy(inStrC, toUCharPtr(inStr.getBuffer()), inStr.length());
|
||||||
inStrC[inStr.length()] = 0;
|
inStrC[inStr.length()] = 0;
|
||||||
log_err("Got: \"%s\", Expected: \"tHis\\u03BC\"\n", inStrC);
|
log_err("Got: \"%s\", Expected: \"tHis\\u03BC\"\n", inStrC);
|
||||||
}
|
}
|
||||||
if (inStr2.compare(mu) != 0) {
|
if (inStr2.compare(mu) != 0) {
|
||||||
u_austrncpy(inStrC, inStr.getBuffer(), inStr.length());
|
u_austrncpy(inStrC, toUCharPtr(inStr.getBuffer()), inStr.length());
|
||||||
inStrC[inStr.length()] = 0;
|
inStrC[inStr.length()] = 0;
|
||||||
log_err("Got: \"%s\", Expected: \"mu\"\n", inStrC);
|
log_err("Got: \"%s\", Expected: \"mu\"\n", inStrC);
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include "unicode/datamap.h"
|
#include "unicode/datamap.h"
|
||||||
#include "unicode/resbund.h"
|
#include "unicode/resbund.h"
|
||||||
|
#include "unicode/unistr.h"
|
||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
@ -20,7 +21,7 @@ int32_t
|
|||||||
DataMap::utoi(const UnicodeString &s) const
|
DataMap::utoi(const UnicodeString &s) const
|
||||||
{
|
{
|
||||||
char ch[256];
|
char ch[256];
|
||||||
const UChar *u = s.getBuffer();
|
const UChar *u = toUCharPtr(s.getBuffer());
|
||||||
int32_t len = s.length();
|
int32_t len = s.length();
|
||||||
u_UCharsToChars(u, ch, len);
|
u_UCharsToChars(u, ch, len);
|
||||||
ch[len] = 0; /* include terminating \0 */
|
ch[len] = 0; /* include terminating \0 */
|
||||||
|
@ -280,7 +280,7 @@ uint8_t Normalizer2DataBuilder::getCC(UChar32 c) const {
|
|||||||
|
|
||||||
static UBool isWellFormed(const UnicodeString &s) {
|
static UBool isWellFormed(const UnicodeString &s) {
|
||||||
UErrorCode errorCode=U_ZERO_ERROR;
|
UErrorCode errorCode=U_ZERO_ERROR;
|
||||||
u_strToUTF8(NULL, 0, NULL, s.getBuffer(), s.length(), &errorCode);
|
u_strToUTF8(NULL, 0, NULL, toUCharPtr(s.getBuffer()), s.length(), &errorCode);
|
||||||
return U_SUCCESS(errorCode) || errorCode==U_BUFFER_OVERFLOW_ERROR;
|
return U_SUCCESS(errorCode) || errorCode==U_BUFFER_OVERFLOW_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,7 +313,7 @@ void Normalizer2DataBuilder::setRoundTripMapping(UChar32 c, const UnicodeString
|
|||||||
(int)phase, (long)c);
|
(int)phase, (long)c);
|
||||||
exit(U_INVALID_FORMAT_ERROR);
|
exit(U_INVALID_FORMAT_ERROR);
|
||||||
}
|
}
|
||||||
int32_t numCP=u_countChar32(m.getBuffer(), m.length());
|
int32_t numCP=u_countChar32(toUCharPtr(m.getBuffer()), m.length());
|
||||||
if(numCP!=2) {
|
if(numCP!=2) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"error in gennorm2 phase %d: "
|
"error in gennorm2 phase %d: "
|
||||||
@ -450,7 +450,7 @@ Normalizer2DataBuilder::decompose(UChar32 start, UChar32 end, uint32_t value) {
|
|||||||
Norm &norm=norms[value];
|
Norm &norm=norms[value];
|
||||||
const UnicodeString &m=*norm.mapping;
|
const UnicodeString &m=*norm.mapping;
|
||||||
UnicodeString *decomposed=NULL;
|
UnicodeString *decomposed=NULL;
|
||||||
const UChar *s=m.getBuffer();
|
const UChar *s=toUCharPtr(m.getBuffer());
|
||||||
int32_t length=m.length();
|
int32_t length=m.length();
|
||||||
int32_t prev, i=0;
|
int32_t prev, i=0;
|
||||||
UChar32 c;
|
UChar32 c;
|
||||||
@ -605,7 +605,7 @@ Normalizer2DataBuilder::reorder(Norm *p, BuilderReorderingBuffer &buffer) {
|
|||||||
if(length>Normalizer2Impl::MAPPING_LENGTH_MASK) {
|
if(length>Normalizer2Impl::MAPPING_LENGTH_MASK) {
|
||||||
return; // writeMapping() will complain about it and print the code point.
|
return; // writeMapping() will complain about it and print the code point.
|
||||||
}
|
}
|
||||||
const UChar *s=m.getBuffer();
|
const UChar *s=toUCharPtr(m.getBuffer());
|
||||||
int32_t i=0;
|
int32_t i=0;
|
||||||
UChar32 c;
|
UChar32 c;
|
||||||
while(i<length) {
|
while(i<length) {
|
||||||
@ -1207,7 +1207,7 @@ void Normalizer2DataBuilder::writeBinaryFile(const char *filename) {
|
|||||||
}
|
}
|
||||||
udata_writeBlock(pData, indexes, sizeof(indexes));
|
udata_writeBlock(pData, indexes, sizeof(indexes));
|
||||||
udata_writeBlock(pData, norm16TrieBytes.getAlias(), norm16TrieLength);
|
udata_writeBlock(pData, norm16TrieBytes.getAlias(), norm16TrieLength);
|
||||||
udata_writeUString(pData, extraData.getBuffer(), extraData.length());
|
udata_writeUString(pData, toUCharPtr(extraData.getBuffer()), extraData.length());
|
||||||
udata_writeBlock(pData, smallFCD, sizeof(smallFCD));
|
udata_writeBlock(pData, smallFCD, sizeof(smallFCD));
|
||||||
int32_t writtenSize=udata_finish(pData, errorCode);
|
int32_t writtenSize=udata_finish(pData, errorCode);
|
||||||
if(errorCode.isFailure()) {
|
if(errorCode.isFailure()) {
|
||||||
|
@ -271,7 +271,7 @@ StringBaseResource::StringBaseResource(SRBRoot *bundle, const char *tag, int8_t
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fString.setTo(value, len);
|
fString.setTo(ConstChar16Ptr(value), len);
|
||||||
fString.getTerminatedBuffer(); // Some code relies on NUL-termination.
|
fString.getTerminatedBuffer(); // Some code relies on NUL-termination.
|
||||||
if (U_SUCCESS(errorCode) && fString.isBogus()) {
|
if (U_SUCCESS(errorCode) && fString.isBogus()) {
|
||||||
errorCode = U_MEMORY_ALLOCATION_ERROR;
|
errorCode = U_MEMORY_ALLOCATION_ERROR;
|
||||||
@ -1031,7 +1031,7 @@ void SRBRoot::write(const char *outputDir, const char *outputPkg,
|
|||||||
if (f16BitUnits.length() <= 1) {
|
if (f16BitUnits.length() <= 1) {
|
||||||
// no pool strings to checksum
|
// no pool strings to checksum
|
||||||
} else if (U_IS_BIG_ENDIAN) {
|
} else if (U_IS_BIG_ENDIAN) {
|
||||||
checksum = computeCRC((const char *)f16BitUnits.getBuffer(),
|
checksum = computeCRC(reinterpret_cast<const char *>(f16BitUnits.getBuffer()),
|
||||||
(uint32_t)f16BitUnits.length() * 2, checksum);
|
(uint32_t)f16BitUnits.length() * 2, checksum);
|
||||||
} else {
|
} else {
|
||||||
// Swap to big-endian so we get the same checksum on all platforms
|
// Swap to big-endian so we get the same checksum on all platforms
|
||||||
@ -1039,7 +1039,7 @@ void SRBRoot::write(const char *outputDir, const char *outputPkg,
|
|||||||
UnicodeString s(f16BitUnits);
|
UnicodeString s(f16BitUnits);
|
||||||
s.append((UChar)1); // Ensure that we own this buffer.
|
s.append((UChar)1); // Ensure that we own this buffer.
|
||||||
assert(!s.isBogus());
|
assert(!s.isBogus());
|
||||||
uint16_t *p = (uint16_t *)s.getBuffer();
|
uint16_t *p = const_cast<uint16_t *>(reinterpret_cast<const uint16_t *>(s.getBuffer()));
|
||||||
for (int32_t count = f16BitUnits.length(); count > 0; --count) {
|
for (int32_t count = f16BitUnits.length(); count > 0; --count) {
|
||||||
uint16_t x = *p;
|
uint16_t x = *p;
|
||||||
*p++ = (uint16_t)((x << 8) | (x >> 8));
|
*p++ = (uint16_t)((x << 8) | (x >> 8));
|
||||||
|
@ -304,7 +304,7 @@ public:
|
|||||||
StringBaseResource(int8_t type, const UChar *value, int32_t len, UErrorCode &errorCode);
|
StringBaseResource(int8_t type, const UChar *value, int32_t len, UErrorCode &errorCode);
|
||||||
virtual ~StringBaseResource();
|
virtual ~StringBaseResource();
|
||||||
|
|
||||||
const UChar *getBuffer() const { return fString.getBuffer(); }
|
const UChar *getBuffer() const { return icu::toUCharPtr(fString.getBuffer()); }
|
||||||
int32_t length() const { return fString.length(); }
|
int32_t length() const { return fString.length(); }
|
||||||
|
|
||||||
virtual void handlePreWrite(uint32_t *byteOffset);
|
virtual void handlePreWrite(uint32_t *byteOffset);
|
||||||
|
@ -73,7 +73,7 @@ static int32_t write_utf8_file(FileStream* fileStream, UnicodeString outString)
|
|||||||
u_strToUTF8(NULL,
|
u_strToUTF8(NULL,
|
||||||
0,
|
0,
|
||||||
&len,
|
&len,
|
||||||
outString.getBuffer(),
|
toUCharPtr(outString.getBuffer()),
|
||||||
outString.length(),
|
outString.length(),
|
||||||
&status);
|
&status);
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ static int32_t write_utf8_file(FileStream* fileStream, UnicodeString outString)
|
|||||||
u_strToUTF8(dest,
|
u_strToUTF8(dest,
|
||||||
len,
|
len,
|
||||||
&len,
|
&len,
|
||||||
outString.getBuffer(),
|
toUCharPtr(outString.getBuffer()),
|
||||||
outString.length(),
|
outString.length(),
|
||||||
&status);
|
&status);
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ U_CAPI int32_t
|
|||||||
udbg_stoi(const UnicodeString &s)
|
udbg_stoi(const UnicodeString &s)
|
||||||
{
|
{
|
||||||
char ch[256];
|
char ch[256];
|
||||||
const UChar *u = s.getBuffer();
|
const UChar *u = toUCharPtr(s.getBuffer());
|
||||||
int32_t len = s.length();
|
int32_t len = s.length();
|
||||||
u_UCharsToChars(u, ch, len);
|
u_UCharsToChars(u, ch, len);
|
||||||
ch[len] = 0; /* include terminating \0 */
|
ch[len] = 0; /* include terminating \0 */
|
||||||
@ -129,7 +129,7 @@ U_CAPI double
|
|||||||
udbg_stod(const UnicodeString &s)
|
udbg_stod(const UnicodeString &s)
|
||||||
{
|
{
|
||||||
char ch[256];
|
char ch[256];
|
||||||
const UChar *u = s.getBuffer();
|
const UChar *u = toUCharPtr(s.getBuffer());
|
||||||
int32_t len = s.length();
|
int32_t len = s.length();
|
||||||
u_UCharsToChars(u, ch, len);
|
u_UCharsToChars(u, ch, len);
|
||||||
ch[len] = 0; /* include terminating \0 */
|
ch[len] = 0; /* include terminating \0 */
|
||||||
|
@ -515,12 +515,12 @@ PreparsedUCD::parseCodePointRange(const char *s, UChar32 &start, UChar32 &end, U
|
|||||||
|
|
||||||
void
|
void
|
||||||
PreparsedUCD::parseString(const char *s, UnicodeString &uni, UErrorCode &errorCode) {
|
PreparsedUCD::parseString(const char *s, UnicodeString &uni, UErrorCode &errorCode) {
|
||||||
UChar *buffer=uni.getBuffer(-1);
|
UChar *buffer=toUCharPtr(uni.getBuffer(-1));
|
||||||
int32_t length=u_parseString(s, buffer, uni.getCapacity(), NULL, &errorCode);
|
int32_t length=u_parseString(s, buffer, uni.getCapacity(), NULL, &errorCode);
|
||||||
if(errorCode==U_BUFFER_OVERFLOW_ERROR) {
|
if(errorCode==U_BUFFER_OVERFLOW_ERROR) {
|
||||||
errorCode=U_ZERO_ERROR;
|
errorCode=U_ZERO_ERROR;
|
||||||
uni.releaseBuffer(0);
|
uni.releaseBuffer(0);
|
||||||
buffer=uni.getBuffer(length);
|
buffer=toUCharPtr(uni.getBuffer(length));
|
||||||
length=u_parseString(s, buffer, uni.getCapacity(), NULL, &errorCode);
|
length=u_parseString(s, buffer, uni.getCapacity(), NULL, &errorCode);
|
||||||
}
|
}
|
||||||
uni.releaseBuffer(length);
|
uni.releaseBuffer(length);
|
||||||
|
@ -209,7 +209,7 @@ UXMLParser::parseFile(const char *filename, UErrorCode &errorCode) {
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer=src.getBuffer(bytesLength);
|
buffer=toUCharPtr(src.getBuffer(bytesLength));
|
||||||
if(buffer==NULL) {
|
if(buffer==NULL) {
|
||||||
// unexpected failure to reserve some string capacity
|
// unexpected failure to reserve some string capacity
|
||||||
errorCode=U_MEMORY_ALLOCATION_ERROR;
|
errorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||||
@ -278,7 +278,7 @@ UXMLParser::parseFile(const char *filename, UErrorCode &errorCode) {
|
|||||||
pb=bytes;
|
pb=bytes;
|
||||||
for(;;) {
|
for(;;) {
|
||||||
length=src.length();
|
length=src.length();
|
||||||
buffer=src.getBuffer(capacity);
|
buffer=toUCharPtr(src.getBuffer(capacity));
|
||||||
if(buffer==NULL) {
|
if(buffer==NULL) {
|
||||||
// unexpected failure to reserve some string capacity
|
// unexpected failure to reserve some string capacity
|
||||||
errorCode=U_MEMORY_ALLOCATION_ERROR;
|
errorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||||
|
Loading…
Reference in New Issue
Block a user