This class can be used to convert text between multiple representations, e.g.
More...
|
| __init__ () |
|
| __init__ (const TextEncoder copy) |
|
| appendText (object text) |
|
| appendUnicodeChar (char32_t character) |
| Appends a single character to the end of the stored text.
|
|
| appendWtext (str text) |
| Appends the indicates string to the end of the stored wide-character text.
|
|
| clearText () |
| Removes the text from the TextEncoder.
|
|
object | decodeText (object text) |
|
object | encodeWtext (str wtext) |
| Encodes a wide-text string into a single-char string, according to the current encoding.
|
|
str | getEncodedChar (int index) |
| Returns the nth char of the stored text, as a one-, two-, or three-byte encoded string.
|
|
str | getEncodedChar (int index, TextEncoder::Encoding encoding) |
| Returns the nth char of the stored text, as a one-, two-, or three-byte encoded string.
|
|
TextEncoder::Encoding | getEncoding () |
| Returns the encoding by which the string set via set_text() is to be interpreted.
|
|
int | getNumChars () |
| Returns the number of characters in the stored text.
|
|
object | getText () |
| Returns the current text, as encoded via the current encoding system.
|
|
object | getText (TextEncoder::Encoding encoding) |
| Returns the current text, as encoded via the indicated encoding system.
|
|
str | getTextAsAscii () |
| Returns the text associated with the node, converted as nearly as possible to a fully-ASCII representation.
|
|
int | getUnicodeChar (int index) |
| Returns the Unicode value of the nth character in the stored text.
|
|
str | getWtext () |
| Returns the text associated with the TextEncoder, as a wide-character string.
|
|
str | getWtextAsAscii () |
| Returns the text associated with the node, converted as nearly as possible to a fully-ASCII representation.
|
|
bool | hasText () |
|
bool | isWtext () |
| Returns true if any of the characters in the string returned by get_wtext() are out of the range of an ASCII character (and, therefore, get_wtext() should be called in preference to get_text()).
|
|
| makeLower () |
| Adjusts the text stored within the encoder to all lowercase letters (preserving accent marks correctly).
|
|
| makeUpper () |
| Adjusts the text stored within the encoder to all uppercase letters (preserving accent marks correctly).
|
|
| setEncoding (TextEncoder::Encoding encoding) |
| Specifies how the string set via set_text() is to be interpreted.
|
|
| setText (object text) |
|
| setText (object text, TextEncoder::Encoding encoding) |
|
| setUnicodeChar (int index, char32_t character) |
| Sets the Unicode value of the nth character in the stored text.
|
|
| setWtext (str wtext) |
| Changes the text that is stored in the encoder.
|
|
|
static object | decodeText (object text, TextEncoder::Encoding encoding) |
|
static object | encodeWchar (char32_t ch, TextEncoder::Encoding encoding) |
| Encodes a single Unicode character into a one-, two-, three-, or four-byte string, according to the given encoding system.
|
|
static object | encodeWtext (str wtext, TextEncoder::Encoding encoding) |
| Encodes a wide-text string into a single-char string, according to the given encoding.
|
|
static TextEncoder::Encoding | getDefaultEncoding () |
| Specifies the default encoding to be used for all subsequently created TextEncoder objects.
|
|
static str | lower (str source) |
| Converts the string to lowercase, assuming the string is encoded in the default encoding.
|
|
static str | lower (str source, TextEncoder::Encoding encoding) |
| Converts the string to lowercase, assuming the string is encoded in the indicated encoding.
|
|
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.
|
|
static | setDefaultEncoding (TextEncoder::Encoding encoding) |
| Specifies the default encoding to be used for all subsequently created TextEncoder objects.
|
|
static bool | unicodeIsalpha (char32_t character) |
| Returns true if the indicated character is an alphabetic letter, false otherwise.
|
|
static bool | unicodeIsdigit (char32_t character) |
| Returns true if the indicated character is a numeric digit, false otherwise.
|
|
static bool | unicodeIslower (char32_t character) |
| Returns true if the indicated character is a lowercase letter, false otherwise.
|
|
static bool | unicodeIspunct (char32_t character) |
| Returns true if the indicated character is a punctuation mark, false otherwise.
|
|
static bool | unicodeIsspace (char32_t character) |
| Returns true if the indicated character is a whitespace letter, false otherwise.
|
|
static bool | unicodeIsupper (char32_t character) |
| Returns true if the indicated character is an uppercase letter, false otherwise.
|
|
static int | unicodeTolower (char32_t character) |
| Returns the uppercase equivalent of the given Unicode character.
|
|
static int | unicodeToupper (char32_t character) |
| Returns the uppercase equivalent of the given Unicode character.
|
|
static str | upper (str source) |
| Converts the string to uppercase, assuming the string is encoded in the default encoding.
|
|
static str | upper (str source, TextEncoder::Encoding encoding) |
| Converts the string to uppercase, assuming the string is encoded in the indicated encoding.
|
|
This class can be used to convert text between multiple representations, e.g.
UTF-8 to UTF-16. 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().
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 in their original form.
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.
This affects only future calls to set_text(); it does not change text that was set previously.