UtfString
|
Represents a Unicode character in an encoding-neutral way. More...
#include <UnicodeChar.h>
Public Member Functions | |
UnicodeChar () | |
Initializes an empty UnicodeChar. | |
UnicodeChar (const UnicodeChar &character) | |
Initializes an instance of UnicodeChar using another instance of UnicodeChar. More... | |
UnicodeChar (const Utf16Char &character) | |
Initializes an instance of UnicodeChar using an instance of Utf16Char. More... | |
UnicodeChar (const Utf8Char &character) | |
Initializes an instance of UnicodeChar using an instance of Utf8Char. More... | |
virtual | ~UnicodeChar () |
The destructor. More... | |
bool | operator== (const UnicodeChar &otherCharacter) const |
Compares the value of this character to the value of another character and tests whether the two character values are the same. More... | |
bool | operator== (const Utf8Char &character) const |
Compares the value of this character to the value of a UTF-8 character and tests whether the two character Unicode values are the same. More... | |
bool | operator== (const Utf16Char &character) const |
Compares the value of this character to the value of a UTF-16 character and tests whether the two character Unicode values are the same. More... | |
bool | operator== (const UnicodeCharReference &characterReference) const |
Compares the value of this character to the value of a character reference and tests whether the two character values are the same. More... | |
bool | operator== (const Utf8CharReference &characterReference) const |
Compares the value of this character to the value of a UTF-8 character reference and tests whether the two character Unicode values are the same. More... | |
bool | operator== (const Utf16CharReference &characterReference) const |
Compares the value of this character to the value of a UTF-16 character reference and tests whether the two character Unicode values are the same. More... | |
bool | operator!= (const UnicodeChar &otherCharacter) const |
Compares the value of this character to the value of another character and tests whether the two character values are the different. More... | |
bool | operator!= (const Utf8Char &character) const |
Compares the value of this character to the value of a UTF-8 character and tests whether the two character Unicode values are the different. More... | |
bool | operator!= (const Utf16Char &character) const |
Compares the value of this character to the value of a UTF-16 character and tests whether the two character Unicode values are the different. More... | |
bool | operator!= (const UnicodeCharReference &characterReference) const |
Compares the value of this character to the value of a character reference and tests whether the two character values are the different. More... | |
bool | operator!= (const Utf8CharReference &characterReference) const |
Compares the value of this character to the value of a UTF-8 character reference and tests whether the two character Unicode values are the different. More... | |
bool | operator!= (const Utf16CharReference &characterReference) const |
Compares the value of this character to the value of a UTF-16 character reference and tests whether the two character Unicode values are the different. More... | |
UnicodeChar & | operator= (const UnicodeChar &character) |
Assigns the contents of a UnicodeChar object to this object. More... | |
UnicodeChar & | operator= (const Utf8Char &character) |
Assigns the contents of a Utf8Char object to this object. More... | |
UnicodeChar & | operator= (const Utf16Char &character) |
Assigns the contents of a Utf16Char object to this object. More... | |
UnicodeChar & | operator= (const Utf8CharReference &characterReference) |
Assigns the contents of a Utf8CharReference object to this object. More... | |
UnicodeChar & | operator= (const Utf16CharReference &characterReference) |
Assigns the contents of a Utf16CharReference object to this object. More... | |
operator Utf16Char () const | |
Converts this object to a Utf16Char object. More... | |
operator Utf8Char () const | |
Converts this object to a Utf8Char object. More... | |
void | clear () |
Clears the contents of the character, making it an empty character. | |
bool | empty () const |
Indicates whether this character is an empty character. More... | |
bool | is_valid () const |
Indicates whether this character is a valid Unicode character. More... | |
const UtfEncoding | internal_encoding () const |
Indicates the internal encoding used by this character. More... | |
UInt32 | to_utf_32 () const |
Converts this character to a UTF-32 code point. More... | |
Represents a Unicode character in an encoding-neutral way.
The class acts as a thin wrapper that can contain a UTF-8 or UTF-16 character to facilitate an easier handling of characters when dealing with characters in an encoding-neutral fashion.
Since this is an encoding-neutral class, code units cannot be accessed directly. In order to access the individual code units, an instance of this class must be cast to an encoding- specific class, such as Utf8Char or Utf16Char. An instance of this class holds a copy of a character. Changing the value of an instance of this class will not cause anything to be changed anywhere else.
This object can be freely assigned and converted to or from a number of encoding-specific data types. Since a Unicode character must be encoded in some form or another in order to be stored. We could always store the character one particular encoding, but in order avoid the inefficiency of multiple encoding conversions (original character is UTF-16 -> stored as UTF-8 -> converted back to UTF-16), this class will store the character in its original encoding. If you wish to avoid unnecessary encoding conversions, you get the internal encoding by calling GetInternalEncoding().
UtfString::UnicodeChar::UnicodeChar | ( | const UnicodeChar & | character) |
Initializes an instance of UnicodeChar using another instance of UnicodeChar.
This is a copy constructor, and sets the constructed instance to be the same as the UnicodeChar instance passed in as a parameter
[in] | character | A character to use in initializing this character |
UtfString::UnicodeChar::UnicodeChar | ( | const Utf16Char & | character) |
Initializes an instance of UnicodeChar using an instance of Utf16Char.
[in] | character | A character to use in initializing this character |
UtfString::UnicodeChar::UnicodeChar | ( | const Utf8Char & | character) |
Initializes an instance of UnicodeChar using an instance of Utf8Char.
[in] | character | A character to use in initializing this character |
|
virtual |
The destructor.
The destructor will clean up the encoding-specific string contained within this object
bool UtfString::UnicodeChar::empty | ( | ) | const |
Indicates whether this character is an empty character.
An empty character is one that doesn't contain any encoding-specific character data. This happens when an instance is not initialized with character data or clear() is called.
const UtfEncoding UtfString::UnicodeChar::internal_encoding | ( | ) | const |
Indicates the internal encoding used by this character.
The internal encoding of a UnicodeChar depends on what data is used to initialize the character or what data is assigned to the character when it is empty. If a UnicodeChar is initialized with a UTF-8 character, the internal encoding will be UTF-8. The opposite is the case when a UnicodeCharacter is initialized with a UTF-16 character. This is done to keep encoding conversions to a minimum. If an application is dealing primarily with one encoding, and a character in that encoding is put in a UnicodeString, we avoid the conversion to a specific internal encoding and then the conversion back to the original encoding.
bool UtfString::UnicodeChar::is_valid | ( | ) | const |
Indicates whether this character is a valid Unicode character.
If this object is able to convert the code units given to it during initialization to a Unicode character, this character will be considered valid.
If this character is an empty character, false will be returned.
UtfString::UnicodeChar::operator Utf16Char | ( | ) | const |
UtfString::UnicodeChar::operator Utf8Char | ( | ) | const |
bool UtfString::UnicodeChar::operator!= | ( | const UnicodeChar & | otherCharacter) | const |
Compares the value of this character to the value of another character and tests whether the two character values are the different.
[in] | otherCharacter | The character to be compared with this character |
bool UtfString::UnicodeChar::operator!= | ( | const Utf8Char & | character) | const |
Compares the value of this character to the value of a UTF-8 character and tests whether the two character Unicode values are the different.
[in] | character | The UTF-8 character to be compared with this character |
bool UtfString::UnicodeChar::operator!= | ( | const Utf16Char & | character) | const |
Compares the value of this character to the value of a UTF-16 character and tests whether the two character Unicode values are the different.
[in] | character | The UTF-16 character to be compared with this character |
bool UtfString::UnicodeChar::operator!= | ( | const UnicodeCharReference & | characterReference) | const |
Compares the value of this character to the value of a character reference and tests whether the two character values are the different.
[in] | characterReference | The character reference to be compared with this character reference |
bool UtfString::UnicodeChar::operator!= | ( | const Utf8CharReference & | characterReference) | const |
Compares the value of this character to the value of a UTF-8 character reference and tests whether the two character Unicode values are the different.
[in] | characterReference | The UTF-8 character reference to be compared with this character |
bool UtfString::UnicodeChar::operator!= | ( | const Utf16CharReference & | characterReference) | const |
Compares the value of this character to the value of a UTF-16 character reference and tests whether the two character Unicode values are the different.
[in] | characterReference | The UTF-16 character reference to be compared with this character |
UnicodeChar& UtfString::UnicodeChar::operator= | ( | const UnicodeChar & | character) |
Assigns the contents of a UnicodeChar object to this object.
The contents of the other UnicodeChar object are copied to this object: they are not shared.
[in] | character | The UnicodeChar object whose contents are to be assigned to this object |
UnicodeChar& UtfString::UnicodeChar::operator= | ( | const Utf8Char & | character) |
UnicodeChar& UtfString::UnicodeChar::operator= | ( | const Utf16Char & | character) |
UnicodeChar& UtfString::UnicodeChar::operator= | ( | const Utf8CharReference & | characterReference) |
Assigns the contents of a Utf8CharReference object to this object.
[in] | characterReference | The Utf8CharReference object whose contents are to be assigned to this object |
UnicodeChar& UtfString::UnicodeChar::operator= | ( | const Utf16CharReference & | characterReference) |
Assigns the contents of a Utf16CharReference object to this object.
[in] | characterReference | The Utf16CharReference object whose contents are to be assigned to this object |
bool UtfString::UnicodeChar::operator== | ( | const UnicodeChar & | otherCharacter) | const |
Compares the value of this character to the value of another character and tests whether the two character values are the same.
[in] | otherCharacter | The character to be compared with this character |
bool UtfString::UnicodeChar::operator== | ( | const Utf8Char & | character) | const |
Compares the value of this character to the value of a UTF-8 character and tests whether the two character Unicode values are the same.
[in] | character | The UTF-8 character to be compared with this character |
bool UtfString::UnicodeChar::operator== | ( | const Utf16Char & | character) | const |
Compares the value of this character to the value of a UTF-16 character and tests whether the two character Unicode values are the same.
[in] | character | The UTF-16 character reference to be compared with this character |
bool UtfString::UnicodeChar::operator== | ( | const UnicodeCharReference & | characterReference) | const |
Compares the value of this character to the value of a character reference and tests whether the two character values are the same.
[in] | characterReference | The character reference to be compared with this character reference |
bool UtfString::UnicodeChar::operator== | ( | const Utf8CharReference & | characterReference) | const |
Compares the value of this character to the value of a UTF-8 character reference and tests whether the two character Unicode values are the same.
[in] | characterReference | The UTF-8 character reference to be compared with this character |
bool UtfString::UnicodeChar::operator== | ( | const Utf16CharReference & | characterReference) | const |
Compares the value of this character to the value of a UTF-16 character reference and tests whether the two character Unicode values are the same.
[in] | characterReference | The UTF-16 character reference to be compared with this character |
UInt32 UtfString::UnicodeChar::to_utf_32 | ( | ) | const |
Converts this character to a UTF-32 code point.
This function assumes that is_valid() is true. If empty() is true, this function will return a value of 0xFFFFFFFF.