This class can be used to convert text between multiple representations, e.g. utf-8 to Unicode. You may use it as a static class object, passing the encoding each time, or you may create an instance and use that object, which will record the current encoding and retain the current string.
More...
|
| __init__ () |
|
| __init__ (const TextEncoder copy) |
|
| appendText (str text) |
| Appends the indicates string to the end of the stored text. More...
|
|
| appendUnicodeChar (int character) |
| Appends a single character to the end of the stored text. This may be a wide character, up to 16 bits in Unicode. More...
|
|
| appendWtext (str text) |
| Appends the indicates string to the end of the stored wide-character text. More...
|
|
| clearText () |
| Removes the text from the TextEncoder. More...
|
|
str | decodeText (str text) |
| Returns the given wstring decoded to a single-byte string, via the current encoding system. More...
|
|
str | encodeWtext (str wtext) |
| Encodes a wide-text string into a single-char string, according to the current encoding. More...
|
|
str | getEncodedChar (int index) |
| Returns the nth char of the stored text, as a one-, two-, or three-byte encoded string. More...
|
|
str | getEncodedChar (int index, TextEncoder::Encoding encoding) |
| Returns the nth char of the stored text, as a one-, two-, or three-byte encoded string. More...
|
|
TextEncoder::Encoding | getEncoding () |
| Returns the encoding by which the string set via set_text() is to be interpreted. See set_encoding(). More...
|
|
int | getNumChars () |
| Returns the number of characters in the stored text. This is a count of wide characters, after the string has been decoded according to set_encoding(). More...
|
|
str | getText () |
| Returns the current text, as encoded via the current encoding system. More...
|
|
str | getText (TextEncoder::Encoding encoding) |
| Returns the current text, as encoded via the indicated encoding system. More...
|
|
str | getTextAsAscii () |
| Returns the text associated with the node, converted as nearly as possible to a fully-ASCII representation. This means replacing accented letters with their unaccented ASCII equivalents. More...
|
|
int | getUnicodeChar (int index) |
| Returns the Unicode value of the nth character in the stored text. This may be a wide character (greater than 255), after the string has been decoded according to set_encoding(). More...
|
|
str | getWtext () |
| Returns the text associated with the TextEncoder, as a wide-character string. More...
|
|
str | getWtextAsAscii () |
|
bool | hasText () |
|
bool | isWtext () |
|
| makeLower () |
|
| makeUpper () |
|
| setEncoding (TextEncoder::Encoding encoding) |
| Specifies how the string set via set_text() is to be interpreted. The default, E_iso8859, means a standard string with one-byte characters (i.e. ASCII). Other encodings are possible to take advantage of character sets with more than 256 characters. More...
|
|
| setText (str text) |
| Changes the text that is stored in the encoder. The text should be encoded according to the method indicated by set_encoding(). Subsequent calls to get_text() will return this same string, while get_wtext() will return the decoded version of the string. More...
|
|
| setText (str text, TextEncoder::Encoding encoding) |
| The two-parameter version of set_text() accepts an explicit encoding; the text is immediately decoded and stored as a wide-character string. Subsequent calls to get_text() will return the same text re-encoded using whichever encoding is specified by set_encoding(). More...
|
|
| setUnicodeChar (int index, int character) |
| Sets the Unicode value of the nth character in the stored text. This may be a wide character (greater than 255), after the string has been decoded according to set_encoding(). More...
|
|
| setWtext (str wtext) |
| Changes the text that is stored in the encoder. Subsequent calls to get_wtext() will return this same string, while get_text() will return the encoded version of the string. More...
|
|
|
static str | decodeText (str text, TextEncoder::Encoding encoding) |
|
static str | encodeWchar (wchar_t ch, TextEncoder::Encoding encoding) |
|
static str | encodeWtext (str wtext, TextEncoder::Encoding encoding) |
|
static TextEncoder::Encoding | getDefaultEncoding () |
| Specifies the default encoding to be used for all subsequently created TextEncoder objects. See set_encoding(). More...
|
|
static str | lower (str source) |
| Converts the string to lowercase, assuming the string is encoded in the default encoding. More...
|
|
static str | lower (str source, TextEncoder::Encoding encoding) |
| Converts the string to lowercase, assuming the string is encoded in the indicated encoding. More...
|
|
static str | reencodeText (str text, TextEncoder::Encoding from, TextEncoder::Encoding to) |
| Given the indicated text string, which is assumed to be encoded via the encoding "from", decodes it and then reencodes it into the encoding "to", and returns the newly encoded string. This does not change or affect any properties on the TextEncoder itself. More...
|
|
static | setDefaultEncoding (TextEncoder::Encoding encoding) |
| Specifies the default encoding to be used for all subsequently created TextEncoder objects. See set_encoding(). More...
|
|
static bool | unicodeIsalpha (int character) |
| Returns true if the indicated character is an alphabetic letter, false otherwise. This is akin to ctype's isalpha(), extended to Unicode. More...
|
|
static bool | unicodeIsdigit (int character) |
| Returns true if the indicated character is a numeric digit, false otherwise. This is akin to ctype's isdigit(), extended to Unicode. More...
|
|
static bool | unicodeIslower (int character) |
| Returns true if the indicated character is a lowercase letter, false otherwise. This is akin to ctype's islower(), extended to Unicode. More...
|
|
static bool | unicodeIspunct (int character) |
| Returns true if the indicated character is a punctuation mark, false otherwise. This is akin to ctype's ispunct(), extended to Unicode. More...
|
|
static bool | unicodeIsspace (int character) |
| Returns true if the indicated character is a whitespace letter, false otherwise. This is akin to ctype's isspace(), extended to Unicode. More...
|
|
static bool | unicodeIsupper (int character) |
| Returns true if the indicated character is an uppercase letter, false otherwise. This is akin to ctype's isupper(), extended to Unicode. More...
|
|
static int | unicodeTolower (int character) |
| Returns the uppercase equivalent of the given Unicode character. This is akin to ctype's tolower(), extended to Unicode. More...
|
|
static int | unicodeToupper (int character) |
| Returns the uppercase equivalent of the given Unicode character. This is akin to ctype's toupper(), extended to Unicode. More...
|
|
static str | upper (str source) |
| Converts the string to uppercase, assuming the string is encoded in the default encoding. More...
|
|
static str | upper (str source, TextEncoder::Encoding encoding) |
| Converts the string to uppercase, assuming the string is encoded in the indicated encoding. More...
|
|
This class can be used to convert text between multiple representations, e.g. utf-8 to Unicode. You may use it as a static class object, passing the encoding each time, or you may create an instance and use that object, which will record the current encoding and retain the current string.
This class is also a base class of TextNode, which inherits this functionality.
Returns the text associated with the node, converted as nearly as possible to a fully-ASCII representation. This means replacing accented letters with their unaccented ASCII equivalents.
It is possible that some characters in the string cannot be converted to ASCII. (The string may involve symbols like the copyright symbol, for instance, or it might involve letters in some other alphabet such as Greek or Cyrillic, or even Latin letters like thorn or eth that are not part of the ASCII character set.) In this case, as much of the string as possible will be converted to ASCII, and the nonconvertible characters will remain encoded in the encoding specified by set_encoding().