#include <unistr.h>
Inheritance diagram for UnicodeString:
Public Member Functions | |
UBool | operator== (const UnicodeString &text) const |
Equality operator. | |
UBool | operator!= (const UnicodeString &text) const |
Inequality operator. | |
UBool | operator> (const UnicodeString &text) const |
Greater than operator. | |
UBool | operator< (const UnicodeString &text) const |
Less than operator. | |
UBool | operator>= (const UnicodeString &text) const |
Greater than or equal operator. | |
UBool | operator<= (const UnicodeString &text) const |
Less than or equal operator. | |
int8_t | compare (const UnicodeString &text) const |
Compare the characters bitwise in this UnicodeString to the characters in text . | |
int8_t | compare (int32_t start, int32_t length, const UnicodeString &srcText) const |
Compare the characters bitwise in the range [start , start + length ) with the characters in srcText . | |
int8_t | compare (int32_t start, int32_t length, const UnicodeString &srcText, int32_t srcStart, int32_t srcLength) const |
Compare the characters bitwise in the range [start , start + length ) with the characters in srcText in the range [srcStart , srcStart + srcLength ). | |
int8_t | compare (const UChar *srcChars, int32_t srcLength) const |
Compare the characters bitwise in this UnicodeString with the first srcLength characters in srcChars . | |
int8_t | compare (int32_t start, int32_t length, const UChar *srcChars) const |
Compare the characters bitwise in the range [start , start + length ) with the first length characters in srcChars . | |
int8_t | compare (int32_t start, int32_t length, const UChar *srcChars, int32_t srcStart, int32_t srcLength) const |
Compare the characters bitwise in the range [start , start + length ) with the characters in srcChars in the range [srcStart , srcStart + srcLength ). | |
int8_t | compareBetween (int32_t start, int32_t limit, const UnicodeString &srcText, int32_t srcStart, int32_t srcLimit) const |
Compare the characters bitwise in the range [start , limit ) with the characters in srcText in the range [srcStart , srcLimit ). | |
int8_t | compareCodePointOrder (const UnicodeString &text) const |
Compare two Unicode strings in code point order. | |
int8_t | compareCodePointOrder (int32_t start, int32_t length, const UnicodeString &srcText) const |
Compare two Unicode strings in code point order. | |
int8_t | compareCodePointOrder (int32_t start, int32_t length, const UnicodeString &srcText, int32_t srcStart, int32_t srcLength) const |
Compare two Unicode strings in code point order. | |
int8_t | compareCodePointOrder (const UChar *srcChars, int32_t srcLength) const |
Compare two Unicode strings in code point order. | |
int8_t | compareCodePointOrder (int32_t start, int32_t length, const UChar *srcChars) const |
Compare two Unicode strings in code point order. | |
int8_t | compareCodePointOrder (int32_t start, int32_t length, const UChar *srcChars, int32_t srcStart, int32_t srcLength) const |
Compare two Unicode strings in code point order. | |
int8_t | compareCodePointOrderBetween (int32_t start, int32_t limit, const UnicodeString &srcText, int32_t srcStart, int32_t srcLimit) const |
Compare two Unicode strings in code point order. | |
int8_t | caseCompare (const UnicodeString &text, uint32_t options) const |
Compare two strings case-insensitively using full case folding. | |
int8_t | caseCompare (int32_t start, int32_t length, const UnicodeString &srcText, uint32_t options) const |
Compare two strings case-insensitively using full case folding. | |
int8_t | caseCompare (int32_t start, int32_t length, const UnicodeString &srcText, int32_t srcStart, int32_t srcLength, uint32_t options) const |
Compare two strings case-insensitively using full case folding. | |
int8_t | caseCompare (const UChar *srcChars, int32_t srcLength, uint32_t options) const |
Compare two strings case-insensitively using full case folding. | |
int8_t | caseCompare (int32_t start, int32_t length, const UChar *srcChars, uint32_t options) const |
Compare two strings case-insensitively using full case folding. | |
int8_t | caseCompare (int32_t start, int32_t length, const UChar *srcChars, int32_t srcStart, int32_t srcLength, uint32_t options) const |
Compare two strings case-insensitively using full case folding. | |
int8_t | caseCompareBetween (int32_t start, int32_t limit, const UnicodeString &srcText, int32_t srcStart, int32_t srcLimit, uint32_t options) const |
Compare two strings case-insensitively using full case folding. | |
UBool | startsWith (const UnicodeString &text) const |
Determine if this starts with the characters in text . | |
UBool | startsWith (const UnicodeString &srcText, int32_t srcStart, int32_t srcLength) const |
Determine if this starts with the characters in srcText in the range [srcStart , srcStart + srcLength ). | |
UBool | startsWith (const UChar *srcChars, int32_t srcLength) const |
Determine if this starts with the characters in srcChars . | |
UBool | startsWith (const UChar *srcChars, int32_t srcStart, int32_t srcLength) const |
Determine if this ends with the characters in srcChars in the range [srcStart , srcStart + srcLength ). | |
UBool | endsWith (const UnicodeString &text) const |
Determine if this ends with the characters in text . | |
UBool | endsWith (const UnicodeString &srcText, int32_t srcStart, int32_t srcLength) const |
Determine if this ends with the characters in srcText in the range [srcStart , srcStart + srcLength ). | |
UBool | endsWith (const UChar *srcChars, int32_t srcLength) const |
Determine if this ends with the characters in srcChars . | |
UBool | endsWith (const UChar *srcChars, int32_t srcStart, int32_t srcLength) const |
Determine if this ends with the characters in srcChars in the range [srcStart , srcStart + srcLength ). | |
int32_t | indexOf (const UnicodeString &text) const |
Locate in this the first occurrence of the characters in text , using bitwise comparison. | |
int32_t | indexOf (const UnicodeString &text, int32_t start) const |
Locate in this the first occurrence of the characters in text starting at offset start , using bitwise comparison. | |
int32_t | indexOf (const UnicodeString &text, int32_t start, int32_t length) const |
Locate in this the first occurrence in the range [start , start + length ) of the characters in text , using bitwise comparison. | |
int32_t | indexOf (const UnicodeString &srcText, int32_t srcStart, int32_t srcLength, int32_t start, int32_t length) const |
Locate in this the first occurrence in the range [start , start + length ) of the characters in srcText in the range [srcStart , srcStart + srcLength ), using bitwise comparison. | |
int32_t | indexOf (const UChar *srcChars, int32_t srcLength, int32_t start) const |
Locate in this the first occurrence of the characters in srcChars starting at offset start , using bitwise comparison. | |
int32_t | indexOf (const UChar *srcChars, int32_t srcLength, int32_t start, int32_t length) const |
Locate in this the first occurrence in the range [start , start + length ) of the characters in srcChars , using bitwise comparison. | |
int32_t | indexOf (const UChar *srcChars, int32_t srcStart, int32_t srcLength, int32_t start, int32_t length) const |
Locate in this the first occurrence in the range [start , start + length ) of the characters in srcChars in the range [srcStart , srcStart + srcLength ), using bitwise comparison. | |
int32_t | indexOf (UChar c) const |
Locate in this the first occurrence of the code unit c , using bitwise comparison. | |
int32_t | indexOf (UChar32 c) const |
Locate in this the first occurrence of the code point c , using bitwise comparison. | |
int32_t | indexOf (UChar c, int32_t start) const |
Locate in this the first occurrence of the code unit c starting at offset start , using bitwise comparison. | |
int32_t | indexOf (UChar32 c, int32_t start) const |
Locate in this the first occurrence of the code point c starting at offset start , using bitwise comparison. | |
int32_t | indexOf (UChar c, int32_t start, int32_t length) const |
Locate in this the first occurrence of the code unit c in the range [start , start + length ), using bitwise comparison. | |
int32_t | indexOf (UChar32 c, int32_t start, int32_t length) const |
Locate in this the first occurrence of the code point c in the range [start , start + length ), using bitwise comparison. | |
int32_t | lastIndexOf (const UnicodeString &text) const |
Locate in this the last occurrence of the characters in text , using bitwise comparison. | |
int32_t | lastIndexOf (const UnicodeString &text, int32_t start) const |
Locate in this the last occurrence of the characters in text starting at offset start , using bitwise comparison. | |
int32_t | lastIndexOf (const UnicodeString &text, int32_t start, int32_t length) const |
Locate in this the last occurrence in the range [start , start + length ) of the characters in text , using bitwise comparison. | |
int32_t | lastIndexOf (const UnicodeString &srcText, int32_t srcStart, int32_t srcLength, int32_t start, int32_t length) const |
Locate in this the last occurrence in the range [start , start + length ) of the characters in srcText in the range [srcStart , srcStart + srcLength ), using bitwise comparison. | |
int32_t | lastIndexOf (const UChar *srcChars, int32_t srcLength, int32_t start) const |
Locate in this the last occurrence of the characters in srcChars starting at offset start , using bitwise comparison. | |
int32_t | lastIndexOf (const UChar *srcChars, int32_t srcLength, int32_t start, int32_t length) const |
Locate in this the last occurrence in the range [start , start + length ) of the characters in srcChars , using bitwise comparison. | |
int32_t | lastIndexOf (const UChar *srcChars, int32_t srcStart, int32_t srcLength, int32_t start, int32_t length) const |
Locate in this the last occurrence in the range [start , start + length ) of the characters in srcChars in the range [srcStart , srcStart + srcLength ), using bitwise comparison. | |
int32_t | lastIndexOf (UChar c) const |
Locate in this the last occurrence of the code unit c , using bitwise comparison. | |
int32_t | lastIndexOf (UChar32 c) const |
Locate in this the last occurrence of the code point c , using bitwise comparison. | |
int32_t | lastIndexOf (UChar c, int32_t start) const |
Locate in this the last occurrence of the code unit c starting at offset start , using bitwise comparison. | |
int32_t | lastIndexOf (UChar32 c, int32_t start) const |
Locate in this the last occurrence of the code point c starting at offset start , using bitwise comparison. | |
int32_t | lastIndexOf (UChar c, int32_t start, int32_t length) const |
Locate in this the last occurrence of the code unit c in the range [start , start + length ), using bitwise comparison. | |
int32_t | lastIndexOf (UChar32 c, int32_t start, int32_t length) const |
Locate in this the last occurrence of the code point c in the range [start , start + length ), using bitwise comparison. | |
UChar | charAt (int32_t offset) const |
Return the code unit at offset offset . | |
UChar | operator[] (int32_t offset) const |
Return the code unit at offset offset . | |
UChar32 | char32At (int32_t offset) const |
Return the code point that contains the code unit at offset offset . | |
int32_t | getChar32Start (int32_t offset) const |
Adjust a random-access offset so that it points to the beginning of a Unicode character. | |
int32_t | getCharStart (int32_t offset) const |
Same as getChar32Start(). | |
int32_t | getChar32Limit (int32_t offset) const |
Adjust a random-access offset so that it points behind a Unicode character. | |
int32_t | getCharLimit (int32_t offset) const |
Same as getChar32Limit(). | |
int32_t | moveIndex32 (int32_t index, int32_t delta) const |
Move the code unit index along the string by delta code points. | |
void | extract (int32_t start, int32_t length, UChar *dst, int32_t dstStart=0) const |
Copy the characters in the range [start , start + length ) into the array dst , beginning at dstStart . | |
int32_t | extract (UChar *dest, int32_t destCapacity, UErrorCode &errorCode) const |
Copy the contents of the string into dest. | |
void | extract (int32_t start, int32_t length, UnicodeString &target) const |
Copy the characters in the range [start , start + length ) into the UnicodeString target . | |
void | extractBetween (int32_t start, int32_t limit, UChar *dst, int32_t dstStart=0) const |
Copy the characters in the range [start , limit ) into the array dst , beginning at dstStart . | |
virtual void | extractBetween (int32_t start, int32_t limit, UnicodeString &target) const |
Copy the characters in the range [start , limit ) into the UnicodeString target . | |
int32_t | extract (int32_t start, int32_t startLength, char *target, const char *codepage=0) const |
Copy the characters in the range [start , start + length ) into an array of characters in a specified codepage. | |
int32_t | extract (int32_t start, int32_t startLength, char *target, uint32_t targetLength, const char *codepage=0) const |
Copy the characters in the range [start , start + length ) into an array of characters in a specified codepage. | |
int32_t | extract (char *dest, int32_t destCapacity, UConverter *cnv, UErrorCode &errorCode) const |
Convert the UnicodeString into a codepage string using an existing UConverter. | |
int32_t | length (void) const |
Return the length of the UnicodeString object. | |
int32_t | countChar32 (int32_t start=0, int32_t length=0x7fffffff) const |
Count Unicode code points in the length UChar code units of the string. | |
UBool | isEmpty (void) const |
Determine if this string is empty. | |
UBool | empty (void) const |
Determine if this string is empty. | |
int32_t | getCapacity (void) const |
Return the capacity of the internal buffer of the UnicodeString object. | |
int32_t | hashCode (void) const |
Generate a hash code for this object. | |
UBool | isBogus (void) const |
Determine if this string is still valid. | |
UnicodeString & | operator= (const UnicodeString &srcText) |
Assignment operator. | |
UnicodeString & | operator= (UChar ch) |
Assignment operator. | |
UnicodeString & | operator= (UChar32 ch) |
Assignment operator. | |
UnicodeString & | setTo (const UnicodeString &srcText, int32_t srcStart, int32_t srcLength) |
Set the text in the UnicodeString object to the characters in srcText in the range [srcStart , srcStart + srcLength ). | |
UnicodeString & | setTo (const UnicodeString &srcText) |
Set the text in the UnicodeString object to the characters in srcText . | |
UnicodeString & | setTo (const UChar *srcChars, int32_t srcLength) |
Set the characters in the UnicodeString object to the characters in srcChars . | |
UnicodeString & | setTo (UChar srcChar) |
Set the characters in the UnicodeString object to the code unit srcChar . | |
UnicodeString & | setTo (UChar32 srcChar) |
Set the characters in the UnicodeString object to the code point srcChar . | |
UnicodeString & | setTo (UBool isTerminated, const UChar *text, int32_t textLength) |
Aliasing setTo() function, analogous to the readonly-aliasing UChar* constructor. | |
UnicodeString & | setTo (UChar *buffer, int32_t buffLength, int32_t buffCapacity) |
Aliasing setTo() function, analogous to the writable-aliasing UChar* constructor. | |
void | setToBogus () |
Make this UnicodeString object invalid. | |
UnicodeString & | setCharAt (int32_t offset, UChar ch) |
Set the character at the specified offset to the specified character. | |
UnicodeString & | operator+= (UChar ch) |
Append operator. | |
UnicodeString & | operator+= (UChar32 ch) |
Append operator. | |
UnicodeString & | operator+= (const UnicodeString &srcText) |
Append operator. | |
UnicodeString & | append (const UnicodeString &srcText, int32_t srcStart, int32_t srcLength) |
Append the characters in srcText in the range [srcStart , srcStart + srcLength ) to the UnicodeString object at offset start . | |
UnicodeString & | append (const UnicodeString &srcText) |
Append the characters in srcText to the UnicodeString object at offset start . | |
UnicodeString & | append (const UChar *srcChars, int32_t srcStart, int32_t srcLength) |
Append the characters in srcChars in the range [srcStart , srcStart + srcLength ) to the UnicodeString object at offset start . | |
UnicodeString & | append (const UChar *srcChars, int32_t srcLength) |
Append the characters in srcChars to the UnicodeString object at offset start . | |
UnicodeString & | append (UChar srcChar) |
Append the code unit srcChar to the UnicodeString object. | |
UnicodeString & | append (UChar32 srcChar) |
Append the code point srcChar to the UnicodeString object. | |
UnicodeString & | insert (int32_t start, const UnicodeString &srcText, int32_t srcStart, int32_t srcLength) |
Insert the characters in srcText in the range [srcStart , srcStart + srcLength ) into the UnicodeString object at offset start . | |
UnicodeString & | insert (int32_t start, const UnicodeString &srcText) |
Insert the characters in srcText into the UnicodeString object at offset start . | |
UnicodeString & | insert (int32_t start, const UChar *srcChars, int32_t srcStart, int32_t srcLength) |
Insert the characters in srcChars in the range [srcStart , srcStart + srcLength ) into the UnicodeString object at offset start . | |
UnicodeString & | insert (int32_t start, const UChar *srcChars, int32_t srcLength) |
Insert the characters in srcChars into the UnicodeString object at offset start . | |
UnicodeString & | insert (int32_t start, UChar srcChar) |
Insert the code unit srcChar into the UnicodeString object at offset start . | |
UnicodeString & | insert (int32_t start, UChar32 srcChar) |
Insert the code point srcChar into the UnicodeString object at offset start . | |
UnicodeString & | replace (int32_t start, int32_t length, const UnicodeString &srcText, int32_t srcStart, int32_t srcLength) |
Replace the characters in the range [start , start + length ) with the characters in srcText in the range [srcStart , srcStart + srcLength ). | |
UnicodeString & | replace (int32_t start, int32_t length, const UnicodeString &srcText) |
Replace the characters in the range [start , start + length ) with the characters in srcText . | |
UnicodeString & | replace (int32_t start, int32_t length, const UChar *srcChars, int32_t srcStart, int32_t srcLength) |
Replace the characters in the range [start , start + length ) with the characters in srcChars in the range [srcStart , srcStart + srcLength ). | |
UnicodeString & | replace (int32_t start, int32_t length, const UChar *srcChars, int32_t srcLength) |
Replace the characters in the range [start , start + length ) with the characters in srcChars . | |
UnicodeString & | replace (int32_t start, int32_t length, UChar srcChar) |
Replace the characters in the range [start , start + length ) with the code unit srcChar . | |
UnicodeString & | replace (int32_t start, int32_t length, UChar32 srcChar) |
Replace the characters in the range [start , start + length ) with the code point srcChar . | |
UnicodeString & | replaceBetween (int32_t start, int32_t limit, const UnicodeString &srcText) |
Replace the characters in the range [start , limit ) with the characters in srcText . | |
UnicodeString & | replaceBetween (int32_t start, int32_t limit, const UnicodeString &srcText, int32_t srcStart, int32_t srcLimit) |
Replace the characters in the range [start , limit ) with the characters in srcText in the range [srcStart , srcLimit ). | |
virtual void | handleReplaceBetween (int32_t start, int32_t limit, const UnicodeString &text) |
Replace a substring of this object with the given text. | |
virtual void | copy (int32_t start, int32_t limit, int32_t dest) |
Copy a substring of this object, retaining attribute (out-of-band) information. | |
UnicodeString & | findAndReplace (const UnicodeString &oldText, const UnicodeString &newText) |
Replace all occurrences of characters in oldText with the characters in newText. | |
UnicodeString & | findAndReplace (int32_t start, int32_t length, const UnicodeString &oldText, const UnicodeString &newText) |
Replace all occurrences of characters in oldText with characters in newText in the range [start , start + length ). | |
UnicodeString & | findAndReplace (int32_t start, int32_t length, const UnicodeString &oldText, int32_t oldStart, int32_t oldLength, const UnicodeString &newText, int32_t newStart, int32_t newLength) |
Replace all occurrences of characters in oldText in the range [oldStart , oldStart + oldLength ) with the characters in newText in the range [newStart , newStart + newLength ) in the range [start , start + length ). | |
UnicodeString & | remove (void) |
Remove all characters from the UnicodeString object. | |
UnicodeString & | remove (int32_t start, int32_t length=(int32_t) INT32_MAX) |
Remove the characters in the range [start , start + length ) from the UnicodeString object. | |
UnicodeString & | removeBetween (int32_t start, int32_t limit=(int32_t) INT32_MAX) |
Remove the characters in the range [start , limit ) from the UnicodeString object. | |
UBool | padLeading (int32_t targetLength, UChar padChar=0x0020) |
Pad the start of this UnicodeString with the character padChar . | |
UBool | padTrailing (int32_t targetLength, UChar padChar=0x0020) |
Pad the end of this UnicodeString with the character padChar . | |
UBool | truncate (int32_t targetLength) |
Truncate this UnicodeString to the targetLength . | |
UnicodeString & | trim (void) |
Trims leading and trailing whitespace from this UnicodeString. | |
UnicodeString & | reverse (void) |
Reverse this UnicodeString in place. | |
UnicodeString & | reverse (int32_t start, int32_t length) |
Reverse the range [start , start + length ) in this UnicodeString. | |
UnicodeString & | toUpper (void) |
Convert the characters in this to UPPER CASE following the conventions of the default locale. | |
UnicodeString & | toUpper (const Locale &locale) |
Convert the characters in this to UPPER CASE following the conventions of a specific locale. | |
UnicodeString & | toLower (void) |
Convert the characters in this to lower case following the conventions of the default locale. | |
UnicodeString & | toLower (const Locale &locale) |
Convert the characters in this to lower case following the conventions of a specific locale. | |
UnicodeString & | toTitle (BreakIterator *titleIter) |
Titlecase this string, convenience function using the default locale. | |
UnicodeString & | toTitle (BreakIterator *titleIter, const Locale &locale) |
Titlecase this string. | |
UnicodeString & | foldCase (uint32_t options=0) |
Case-fold the characters in this string. | |
UChar * | getBuffer (int32_t minCapacity) |
Get a read/write pointer to the internal buffer. | |
void | releaseBuffer (int32_t newLength=-1) |
Release a read/write buffer on a UnicodeString object with an "open" getBuffer(minCapacity). | |
const UChar * | getBuffer () const |
Get a read-only pointer to the internal buffer. | |
UnicodeString () | |
Construct an empty UnicodeString. | |
UnicodeString (int32_t capacity, UChar32 c, int32_t count) | |
Construct a UnicodeString with capacity to hold capacity UChars. | |
UnicodeString (UChar ch) | |
Single UChar (code unit) constructor. | |
UnicodeString (UChar32 ch) | |
Single UChar32 (code point) constructor. | |
UnicodeString (const UChar *text) | |
UChar* constructor. | |
UnicodeString (const UChar *text, int32_t textLength) | |
UChar* constructor. | |
UnicodeString (UBool isTerminated, const UChar *text, int32_t textLength) | |
Readonly-aliasing UChar* constructor. | |
UnicodeString (UChar *buffer, int32_t buffLength, int32_t buffCapacity) | |
Writable-aliasing UChar* constructor. | |
UnicodeString (const char *codepageData, const char *codepage=0) | |
char* constructor. | |
UnicodeString (const char *codepageData, int32_t dataLength, const char *codepage=0) | |
char* constructor. | |
UnicodeString (const char *src, int32_t srcLength, UConverter *cnv, UErrorCode &errorCode) | |
char * / UConverter constructor. | |
UnicodeString (const UnicodeString &that) | |
Copy constructor. | |
~UnicodeString () | |
Destructor. | |
int32_t | numDisplayCells (int32_t start=0, int32_t length=INT32_MAX, UBool asian=TRUE) const |
Returns the number of display cells occupied by the range [start , length ). | |
UCharReference | operator[] (int32_t pos) |
Return a modifiable reference to a code unit of the string. | |
UnicodeString | unescape () const |
Unescape a string of characters and return a string containing the result. | |
UChar32 | unescapeAt (int32_t &offset) const |
Unescape a single escape sequence and return the represented character. | |
Protected Member Functions | |
virtual int32_t | getLength () const |
Implement Replaceable::getLength() (see jitterbug 1027). | |
virtual UChar | getCharAt (int32_t offset) const |
The change in Replaceable to use virtual getCharAt() allows UnicodeString::charAt() to be inline again (see jitterbug 709). | |
virtual UChar32 | getChar32At (int32_t offset) const |
The change in Replaceable to use virtual getChar32At() allows UnicodeString::char32At() to be inline again (see jitterbug 709). | |
Friends | |
class | UnicodeConverter |
class | StringCharacterIterator |
class | StringThreadTest |
It is a concrete implementation of the abstract class Replaceable (for transliteration).
In ICU, strings are stored and used as UTF-16. This means that a string internally consists of 16-bit Unicode code units.
UTF-16 is a variable-length encoding: A Unicode character may be stored with either one code unit which is the most common case or with a matched pair of special code units ("surrogates"). The data type for code units is UChar.
For single-character handling, a Unicode character code point is a scalar value in the range 0..0x10ffff. ICU uses the UChar32 type for code points.
Indexes and offsets into and lengths of strings always count code units, not code points. This is the same as with multi-byte char* strings in traditional string handling. Operations on partial strings typically do not test for code point boundaries. If necessary, the user needs to take care of such boundaries by testing for the code unit values or by using functions like UnicodeString::getChar32Start() and UnicodeString::getChar32Limit() (or, in C, the equivalent macros UTF_SET_CHAR_START() and UTF_SET_CHAR_LIMIT(), see utf.h).
UnicodeString uses four storage models:
|
Construct an empty UnicodeString.
|
|
Construct a UnicodeString with capacity to hold
|
|
Single UChar (code unit) constructor.
|
|
Single UChar32 (code point) constructor.
|
|
UChar* constructor.
|
|
UChar* constructor.
|
|
Readonly-aliasing UChar* constructor. The text will be used for the UnicodeString object, but it will not be released when the UnicodeString is destroyed. This has copy-on-write semantics: When the string is modified, then the buffer is first copied into newly allocated memory. The aliased buffer is never modified. In an assignment to another UnicodeString, the text will be aliased again, so that both strings then alias the same readonly-text.
|
|
Writable-aliasing UChar* constructor. The text will be used for the UnicodeString object, but it will not be released when the UnicodeString is destroyed. This has write-through semantics: For as long as the capacity of the buffer is sufficient, write operations will directly affect the buffer. When more capacity is necessary, then a new buffer will be allocated and the contents copied as with regularly constructed strings. In an assignment to another UnicodeString, the buffer will be copied. The extract(UChar *dst) function detects whether the dst pointer is the same as the string buffer itself and will in this case not copy the contents.
|
|
char* constructor.
|
|
char* constructor.
|
|
char * / UConverter constructor. This constructor uses an existing UConverter object to convert the codepage string to Unicode and construct a UnicodeString from that. The converter is reset at first. If the error code indicates a failure before this constructor is called, or if an error occurs during conversion or construction, then the string will be bogus. This function avoids the overhead of opening and closing a converter if multiple strings are constructed.
|
|
Copy constructor.
|
|
Destructor.
|
|
Append the code point
|
|
Append the code unit
|
|
Append the characters in
|
|
Append the characters in
|
|
Append the characters in
|
|
Append the characters in
|
|
Compare two strings case-insensitively using full case folding. This is equivalent to this->foldCase(options).compare(srcChars.foldCase(options)).
|
|
Compare two strings case-insensitively using full case folding. This is equivalent to this->foldCase(options).compare(srcChars.foldCase(options)).
|
|
Compare two strings case-insensitively using full case folding. This is equivalent to this->foldCase(options).compare(srcChars.foldCase(options)).
|
|
Compare two strings case-insensitively using full case folding. This is equivalent to this->foldCase(options).compare(srcText.foldCase(options)).
|
|
Compare two strings case-insensitively using full case folding. This is equivalent to this->foldCase(options).compare(srcText.foldCase(options)).
|
|
Compare two strings case-insensitively using full case folding. This is equivalent to this->foldCase(options).compare(text.foldCase(options)).
|
|
Compare two strings case-insensitively using full case folding. This is equivalent to this->foldCase(options).compareBetween(text.foldCase(options)).
|
|
Return the code point that contains the code unit at offset
Reimplemented from Replaceable. |
|
Return the code unit at offset
Reimplemented from Replaceable. |
|
Compare the characters bitwise in the range [
|
|
Compare the characters bitwise in the range [
|
|
Compare the characters bitwise in this UnicodeString with the first
|
|
Compare the characters bitwise in the range [
|
|
Compare the characters bitwise in the range [
|
|
Compare the characters bitwise in this UnicodeString to the characters in
|
|
Compare the characters bitwise in the range [
|
|
Compare two Unicode strings in code point order. This is different in UTF-16 from how compare(), operator==, startsWith() etc. work if supplementary characters are present: In UTF-16, supplementary characters (with code points U+10000 and above) are stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff, which means that they compare as less than some other BMP characters like U+feff. This function compares Unicode strings in code point order. If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
|
|
Compare two Unicode strings in code point order. This is different in UTF-16 from how compare(), operator==, startsWith() etc. work if supplementary characters are present: In UTF-16, supplementary characters (with code points U+10000 and above) are stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff, which means that they compare as less than some other BMP characters like U+feff. This function compares Unicode strings in code point order. If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
|
|
Compare two Unicode strings in code point order. This is different in UTF-16 from how compare(), operator==, startsWith() etc. work if supplementary characters are present: In UTF-16, supplementary characters (with code points U+10000 and above) are stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff, which means that they compare as less than some other BMP characters like U+feff. This function compares Unicode strings in code point order. If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
|
|
Compare two Unicode strings in code point order. This is different in UTF-16 from how compare(), operator==, startsWith() etc. work if supplementary characters are present: In UTF-16, supplementary characters (with code points U+10000 and above) are stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff, which means that they compare as less than some other BMP characters like U+feff. This function compares Unicode strings in code point order. If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
|
|
Compare two Unicode strings in code point order. This is different in UTF-16 from how compare(), operator==, startsWith() etc. work if supplementary characters are present: In UTF-16, supplementary characters (with code points U+10000 and above) are stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff, which means that they compare as less than some other BMP characters like U+feff. This function compares Unicode strings in code point order. If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
|
|
Compare two Unicode strings in code point order. This is different in UTF-16 from how compare(), operator==, startsWith() etc. work if supplementary characters are present: In UTF-16, supplementary characters (with code points U+10000 and above) are stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff, which means that they compare as less than some other BMP characters like U+feff. This function compares Unicode strings in code point order. If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
|
|
Compare two Unicode strings in code point order. This is different in UTF-16 from how compare(), operator==, startsWith() etc. work if supplementary characters are present: In UTF-16, supplementary characters (with code points U+10000 and above) are stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff, which means that they compare as less than some other BMP characters like U+feff. This function compares Unicode strings in code point order. If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
|
|
Copy a substring of this object, retaining attribute (out-of-band) information. This method is used to duplicate or reorder substrings. The destination index must not overlap the source range.
Implements Replaceable. |
|
Count Unicode code points in the length UChar code units of the string. A code point may occupy either one or two UChar code units. Counting code points involves reading all code units. This functions is basically the inverse of moveIndex32().
|
|
Determine if this string is empty. This function was renamed to isEmtpy() because it caused confusion. If you need to determine if a string is empty, then use isEmpty(). If you want to remove a string's contents, then call truncate(0).
|
|
Determine if this ends with the characters in
|
|
Determine if this ends with the characters in
|
|
Determine if this ends with the characters in
|
|
Determine if this ends with the characters in
|
|
Convert the UnicodeString into a codepage string using an existing UConverter. The output string is NUL-terminated if possible. This function avoids the overhead of opening and closing a converter if multiple strings are extracted.
|
|
Copy the characters in the range [
This function does not write any more than
|
|
Copy the characters in the range [ The output string is NUL-terminated.
|
|
Copy the characters in the range [
|
|
Copy the contents of the string into dest. This is a convenience function that checks if there is enough space in dest, extracts the entire string if possible, and NUL-terminates dest if possible. If the string fits into dest but cannot be NUL-terminated (length()==destCapacity) then the error code is set to U_STRING_NOT_TERMINATED_WARNING. If the string itself does not fit into dest (length()>destCapacity) then the error code is set to U_BUFFER_OVERFLOW_ERROR.
If the string aliases to
|
|
Copy the characters in the range [
If the string aliases to
|
|
Copy the characters in the range [ Replaceable API.
Implements Replaceable. |
|
Copy the characters in the range [
|
|
Replace all occurrences of characters in oldText in the range [
|
|
Replace all occurrences of characters in oldText with characters in newText in the range [
|
|
Replace all occurrences of characters in oldText with the characters in newText.
|
|
Case-fold the characters in this string. Case-folding is locale-independent and not context-sensitive, but there is an option for whether to include or exclude mappings for dotted I and dotless i that are marked with 'I' in CaseFolding.txt. The result may be longer or shorter than the original.
|
|
Get a read-only pointer to the internal buffer. This can be called at any time on a valid UnicodeString. It returns 0 if the string is bogus, or during an "open" getBuffer(minCapacity). It can be called as many times as desired. The pointer that it returns will remain valid until the UnicodeString object is modified, at which time the pointer is semantically invalidated and must not be used any more. The capacity of the buffer can be determined with getCapacity(). The part after length() may or may not be initialized and valid, depending on the history of the UnicodeString object.
The buffer contents is (probably) not NUL-terminated. You can check if it is with The buffer may reside in read-only memory. Its contents must not be modified.
|
|
Get a read/write pointer to the internal buffer. The buffer is guaranteed to be large enough for at least minCapacity UChars, writable, and is still owned by the UnicodeString object. Calls to getBuffer(minCapacity) must not be nested, and must be matched with calls to releaseBuffer(newLength). If the string buffer was read-only or shared, then it will be reallocated and copied. An attempted nested call will return 0, and will not further modify the state of the UnicodeString object. The actual capacity of the string buffer may be larger than minCapacity. getCapacity() returns the actual capacity. For many operations, the full capacity should be used to avoid reallocations. While the buffer is "open" between getBuffer(minCapacity) and releaseBuffer(newLength), the following applies:
|
|
Return the capacity of the internal buffer of the UnicodeString object. This is useful together with the getBuffer functions. See there for details.
|
|
Adjust a random-access offset so that it points behind a Unicode character. The offset that is passed in points behind any code unit of a code point, while the returned offset will point behind the last code unit of the same code point. In UTF-16, if the input offset points behind the first surrogate (i.e., to the second surrogate) of a surrogate pair, then the returned offset will point behind the second surrogate (i.e., to the first surrogate).
|
|
Adjust a random-access offset so that it points to the beginning of a Unicode character. The offset that is passed in points to any code unit of a code point, while the returned offset will point to the first code unit of the same code point. In UTF-16, if the input offset points to a second surrogate of a surrogate pair, then the returned offset will point to the first surrogate.
|
|
Same as getChar32Limit(). This original function name (without "32") was meant to look like UTF_SET_CHAR_LIMIT, but since most code point-related function names in C++ APIs contain a "32", this caused confusion. Adjust a random-access offset so that it points behind a Unicode character. The offset that is passed in points behind any code unit of a code point, while the returned offset will point behind the last code unit of the same code point. In UTF-16, if the input offset points behind the first surrogate (i.e., to the second surrogate) of a surrogate pair, then the returned offset will point behind the second surrogate (i.e., to the first surrogate).
|
|
Same as getChar32Start(). This original function name (without "32") was meant to look like UTF_SET_CHAR_START, but since most code point-related function names in C++ APIs contain a "32", this caused confusion. Adjust a random-access offset so that it points to the beginning of a Unicode character. The offset that is passed in points to any code unit of a code point, while the returned offset will point to the first code unit of the same code point. In UTF-16, if the input offset points to a second surrogate of a surrogate pair, then the returned offset will point to the first surrogate.
|
|
Replace a substring of this object with the given text.
Implements Replaceable. |
|
Generate a hash code for this object.
|
|
Locate in this the first occurrence of the code point This function finds code points, which differs for BMP code points from indexOf(UChar c, ...) only for surrogates: While indexOf(UChar c, ...) finds any surrogate code units in a string, indexOf(UChar32 c, ...) finds only unmatched surrogate code points, i.e., only those that do not combine with an adjacent surrogate to form a supplementary code point. For example, in a string "\ud800\udc00" indexOf(UChar c, ...) will find code units U+d800 at 0 and U+dc00 at 1, but indexOf(UChar32 c, ...) will find neither because they combine to the code point U+10000. Either function will find U+d800 in "a\ud800b". This behavior ensures that char32At(indexOf(UChar32 c))==c.
|
|
Locate in this the first occurrence of the code unit
|
|
Locate in this the first occurrence of the code point This function finds code points, which differs for BMP code points from indexOf(UChar c, ...) only for surrogates: While indexOf(UChar c, ...) finds any surrogate code units in a string, indexOf(UChar32 c, ...) finds only unmatched surrogate code points, i.e., only those that do not combine with an adjacent surrogate to form a supplementary code point. For example, in a string "\ud800\udc00" indexOf(UChar c, ...) will find code units U+d800 at 0 and U+dc00 at 1, but indexOf(UChar32 c, ...) will find neither because they combine to the code point U+10000. Either function will find U+d800 in "a\ud800b". This behavior ensures that char32At(indexOf(UChar32 c))==c.
|
|
Locate in this the first occurrence of the code unit
|
|
Locate in this the first occurrence of the code point This function finds code points, which differs for BMP code points from indexOf(UChar c, ...) only for surrogates: While indexOf(UChar c, ...) finds any surrogate code units in a string, indexOf(UChar32 c, ...) finds only unmatched surrogate code points, i.e., only those that do not combine with an adjacent surrogate to form a supplementary code point. For example, in a string "\ud800\udc00" indexOf(UChar c, ...) will find code units U+d800 at 0 and U+dc00 at 1, but indexOf(UChar32 c, ...) will find neither because they combine to the code point U+10000. Either function will find U+d800 in "a\ud800b". This behavior ensures that char32At(indexOf(UChar32 c))==c.
|
|
Locate in this the first occurrence of the code unit
|
|
Locate in this the first occurrence in the range [
|
|
Locate in this the first occurrence in the range [
|
|
Locate in this the first occurrence of the characters in
|
|
Locate in this the first occurrence in the range [
|
|
Locate in this the first occurrence in the range [
|
|
Locate in this the first occurrence of the characters in
|
|
Locate in this the first occurrence of the characters in
|
|
Insert the code point
|
|
Insert the code unit
|
|
Insert the characters in
|
|
Insert the characters in
|
|
Insert the characters in
|
|
Insert the characters in
|
|
Determine if this string is still valid.
|
|
Determine if this string is empty.
|
|
Locate in this the last occurrence of the code point This function finds code points, which differs for BMP code points from lastIndexOf(UChar c, ...) only for surrogates: While lastIndexOf(UChar c, ...) finds any surrogate code units in a string, lastIndexOf(UChar32 c, ...) finds only unmatched surrogate code points, i.e., only those that do not combine with an adjacent surrogate to form a supplementary code point. For example, in a string "\ud800\udc00" lastIndexOf(UChar c, ...) will find code units U+d800 at 0 and U+dc00 at 1, but lastIndexOf(UChar32 c, ...) will find neither because they combine to the code point U+10000. Either function will find U+d800 in "a\ud800b". This behavior ensures that char32At(lastIndexOf(UChar32 c))==c.
|
|
Locate in this the last occurrence of the code unit
|
|
Locate in this the last occurrence of the code point This function finds code points, which differs for BMP code points from lastIndexOf(UChar c, ...) only for surrogates: While lastIndexOf(UChar c, ...) finds any surrogate code units in a string, lastIndexOf(UChar32 c, ...) finds only unmatched surrogate code points, i.e., only those that do not combine with an adjacent surrogate to form a supplementary code point. For example, in a string "\ud800\udc00" lastIndexOf(UChar c, ...) will find code units U+d800 at 0 and U+dc00 at 1, but lastIndexOf(UChar32 c, ...) will find neither because they combine to the code point U+10000. Either function will find U+d800 in "a\ud800b". This behavior ensures that char32At(lastIndexOf(UChar32 c))==c.
|
|
Locate in this the last occurrence of the code unit
|
|
Locate in this the last occurrence of the code point This function finds code points, which differs for BMP code points from lastIndexOf(UChar c, ...) only for surrogates: While lastIndexOf(UChar c, ...) finds any surrogate code units in a string, lastIndexOf(UChar32 c, ...) finds only unmatched surrogate code points, i.e., only those that do not combine with an adjacent surrogate to form a supplementary code point. For example, in a string "\ud800\udc00" lastIndexOf(UChar c, ...) will find code units U+d800 at 0 and U+dc00 at 1, but lastIndexOf(UChar32 c, ...) will find neither because they combine to the code point U+10000. Either function will find U+d800 in "a\ud800b". This behavior ensures that char32At(lastIndexOf(UChar32 c))==c.
|
|
Locate in this the last occurrence of the code unit
|
|
Locate in this the last occurrence in the range [
|
|
Locate in this the last occurrence in the range [
|
|
Locate in this the last occurrence of the characters in
|
|
Locate in this the last occurrence in the range [
|
|
Locate in this the last occurrence in the range [
|
|
Locate in this the last occurrence of the characters in
|
|
Locate in this the last occurrence of the characters in
|
|
Return the length of the UnicodeString object. The length is the number of characters in the text.
Reimplemented from Replaceable. |
|
Move the code unit index along the string by delta code points. Interpret the input index as a code unit-based offset into the string, move the index forward or backward by delta code points, and return the resulting index. The input index should point to the first code unit of a code point, if there is more than one. Both input and output indexes are code unit-based as for all string indexes/offsets in ICU (and other libraries, like MBCS char*). If delta<0 then the index is moved backward (toward the start of the string). If delta>0 then the index is moved forward (toward the end of the string). This behaves like CharacterIterator::move32(delta, kCurrent). Examples: // s has code points 'a' U+10000 'b' U+10ffff U+2029 UnicodeString s=UNICODE_STRING("a\\U00010000b\\U0010ffff\\u2029", 31).unescape();
// initial index: position of U+10000 int32_t index=1;
// the following examples will all result in index==4, position of U+10ffff
// skip 2 code points from some position in the string index=s.moveIndex32(index, 2); // skips U+10000 and 'b'
// go to the 3rd code point from the start of s (0-based) index=s.moveIndex32(0, 3); // skips 'a', U+10000, and 'b'
// go to the next-to-last code point of s index=s.moveIndex32(s.length(), -2); // backward-skips U+2029 and U+10ffff
|
|
Returns the number of display cells occupied by the range [
This function is designed for Asian text and properly takes into account halfwidth and fullwidth variants of various CJK characters and the combining behavior of the Hangul Jamo characters (with some limitations; see documentation for Unicode::getCellWidth()).
|
|
Inequality operator. Performs only bitwise comparison.
|
|
Append operator.
Append the characters in
|
|
Append operator.
Append the code point
|
|
Append operator.
Append the code unit
|
|
Less than operator. Performs only bitwise comparison.
|
|
Less than or equal operator. Performs only bitwise comparison.
|
|
Assignment operator.
Replace the characters in this UnicodeString with the code point
|
|
Assignment operator.
Replace the characters in this UnicodeString with the code unit
|
|
Assignment operator.
Replace the characters in this UnicodeString with the characters from
|
|
Equality operator. Performs only bitwise comparison.
|
|
Greater than operator. Performs only bitwise comparison.
|
|
Greater than or equal operator. Performs only bitwise comparison.
|
|
Return a modifiable reference to a code unit of the string.
|
|
Return the code unit at offset
|
|
Pad the start of this UnicodeString with the character If the length of this UnicodeString is less than targetLength, length() - targetLength copies of padChar will be added to the beginning of this UnicodeString.
|
|
Pad the end of this UnicodeString with the character If the length of this UnicodeString is less than targetLength, length() - targetLength copies of padChar will be added to the end of this UnicodeString.
|
|
Release a read/write buffer on a UnicodeString object with an "open" getBuffer(minCapacity). This function must be called in a matched pair with getBuffer(minCapacity). releaseBuffer(newLength) must be called if and only if a getBuffer(minCapacity) is "open". It will set the string length to newLength, at most to the current capacity. If newLength==-1 then it will set the length according to the first NUL in the buffer, or to the capacity if there is no NUL. After calling releaseBuffer(newLength) the UnicodeString is back to normal operation.
|
|
Remove the characters in the range [
|
|
Remove all characters from the UnicodeString object.
|
|
Remove the characters in the range [
|
|
Replace the characters in the range [
|
|
Replace the characters in the range [
|
|
Replace the characters in the range [
|
|
Replace the characters in the range [
|
|
Replace the characters in the range [
|
|
Replace the characters in the range [
|
|
Replace the characters in the range [
|
|
Replace the characters in the range [
|
|
Reverse the range [
|
|
Reverse this UnicodeString in place.
|
|
Set the character at the specified offset to the specified character.
|
|
Aliasing setTo() function, analogous to the writable-aliasing UChar* constructor. The text will be used for the UnicodeString object, but it will not be released when the UnicodeString is destroyed. This has write-through semantics: For as long as the capacity of the buffer is sufficient, write operations will directly affect the buffer. When more capacity is necessary, then a new buffer will be allocated and the contents copied as with regularly constructed strings. In an assignment to another UnicodeString, the buffer will be copied. The extract(UChar *dst) function detects whether the dst pointer is the same as the string buffer itself and will in this case not copy the contents.
|
|
Aliasing setTo() function, analogous to the readonly-aliasing UChar* constructor. The text will be used for the UnicodeString object, but it will not be released when the UnicodeString is destroyed. This has copy-on-write semantics: When the string is modified, then the buffer is first copied into newly allocated memory. The aliased buffer is never modified. In an assignment to another UnicodeString, the text will be aliased again, so that both strings then alias the same readonly-text.
|
|
Set the characters in the UnicodeString object to the code point
|
|
Set the characters in the UnicodeString object to the code unit
|
|
Set the characters in the UnicodeString object to the characters in
|
|
Set the text in the UnicodeString object to the characters in
|
|
Set the text in the UnicodeString object to the characters in
|
|
Make this UnicodeString object invalid. The string will test TRUE with isBogus(). This is used to indicate that an operation failed, and that the result string is "bogus" - which can be tested with isBogus(). This utility function is used throughout the UnicodeString implementation, and may be used in other functions, especially but not exclusively when such functions do not take a UErrorCode for simplicity. A "bogus" string is essentially empty, and getBuffer() const will return 0. The string object can be "revived" by assigning (operator=) another string, or by using one of the other setToXYZ functions, or simply by modifying it (which will work like with an empty string).
|
|
Determine if this ends with the characters in
|
|
Determine if this starts with the characters in
|
|
Determine if this starts with the characters in
|
|
Determine if this starts with the characters in
|
|
Convert the characters in this to lower case following the conventions of a specific locale.
|
|
Convert the characters in this to lower case following the conventions of the default locale.
|
|
Titlecase this string. Casing is locale-dependent and context-sensitive. Titlecasing uses a break iterator to find the first characters of words that are to be titlecased. It titlecases those characters and lowercases all others. The titlecase break iterator can be provided to customize for arbitrary styles, using rules and dictionaries beyond the standard iterators. It may be more efficient to always provide an iterator to avoid opening and closing one for each string. The standard titlecase iterator for the root locale implements the algorithm of Unicode TR 21. This function uses only the first() and next() methods of the provided break iterator.
|
|
Titlecase this string, convenience function using the default locale. Casing is locale-dependent and context-sensitive. Titlecasing uses a break iterator to find the first characters of words that are to be titlecased. It titlecases those characters and lowercases all others. The titlecase break iterator can be provided to customize for arbitrary styles, using rules and dictionaries beyond the standard iterators. It may be more efficient to always provide an iterator to avoid opening and closing one for each string. The standard titlecase iterator for the root locale implements the algorithm of Unicode TR 21. This function uses only the first() and next() methods of the provided break iterator.
|
|
Convert the characters in this to UPPER CASE following the conventions of a specific locale.
|
|
Convert the characters in this to UPPER CASE following the conventions of the default locale.
|
|
Trims leading and trailing whitespace from this UnicodeString.
|
|
Truncate this UnicodeString to the
|
|
Unescape a string of characters and return a string containing the result. The following escape sequences are recognized: 4 hex digits; h in [0-9A-Fa-f] 8 hex digits 1-2 hex digits 1-3 octal digits; o in [0-7] as well as the standard ANSI C escapes:
=> U+0007, => U+0008, => U+0009, Anything else following a backslash is generically escaped. For example, "[a\-z]" returns "[a-z]". If an escape sequence is ill-formed, this method returns an empty string. An example of an ill-formed sequence is "\u" followed by fewer than 4 hex digits. This function is similar to u_unescape() but not identical to it. The latter takes a source char*, so it does escape recognition and also invariant conversion.
|
|
Unescape a single escape sequence and return the represented character. See unescape() for a listing of the recognized escape sequences. The character at offset-1 is assumed (without checking) to be a backslash. If the escape sequence is ill-formed, or the offset is out of range, (UChar32)0xFFFFFFFF is returned.
|