TextEncoder
from panda3d.core import TextEncoder
- class TextEncoder
Bases:
DTOOL_SUPER_BASE
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.
Inheritance diagram
- ECp437 = 3
- EIso8859 = 0
- EUnicode = 2
- EUtf16be = 2
- EUtf8 = 1
- E_cp437 = 3
- E_iso8859 = 0
- E_unicode = 2
- E_utf16be = 2
- E_utf8 = 1
- __init__(*args, **kwargs)
- appendText()
C++ Interface: append_text(const TextEncoder self, object text)
- /**
Appends the indicates string to the end of the stored text.
*/
- appendUnicodeChar()
C++ Interface: append_unicode_char(const TextEncoder self, 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.
*/
- appendWtext()
C++ Interface: append_wtext(const TextEncoder self, unicode text)
- /**
Appends the indicates string to the end of the stored wide-character text.
*/
- append_text()
C++ Interface: append_text(const TextEncoder self, object text)
- /**
Appends the indicates string to the end of the stored text.
*/
- append_unicode_char()
C++ Interface: append_unicode_char(const TextEncoder self, 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.
*/
- append_wtext()
C++ Interface: append_wtext(const TextEncoder self, unicode text)
- /**
Appends the indicates string to the end of the stored wide-character text.
*/
- clearText()
C++ Interface: clear_text(const TextEncoder self)
- /**
Removes the text from the TextEncoder.
*/
- clear_text()
C++ Interface: clear_text(const TextEncoder self)
- /**
Removes the text from the TextEncoder.
*/
- decodeText()
C++ Interface: decode_text(TextEncoder self, object text) decode_text(object text, int encoding)
- decode_text()
C++ Interface: decode_text(TextEncoder self, object text) decode_text(object text, int encoding)
- default_encoding = 1
- encodeWchar()
C++ Interface: encode_wchar(int ch, int encoding)
- /**
Encodes a single Unicode character into a one-, two-, three-, or four-byte
string, according to the given encoding system.
*/
- encodeWtext()
C++ Interface: encode_wtext(TextEncoder self, unicode wtext) encode_wtext(unicode wtext, int encoding)
- encode_wchar()
C++ Interface: encode_wchar(int ch, int encoding)
- /**
Encodes a single Unicode character into a one-, two-, three-, or four-byte
string, according to the given encoding system.
*/
- encode_wtext()
C++ Interface: encode_wtext(TextEncoder self, unicode wtext) encode_wtext(unicode wtext, int encoding)
- getDefaultEncoding()
C++ Interface: get_default_encoding()
- /**
Specifies the default encoding to be used for all subsequently created
TextEncoder objects. See set_encoding().
*/
- getEncodedChar()
C++ Interface: get_encoded_char(TextEncoder self, int index) get_encoded_char(TextEncoder self, int index, int encoding)
- getEncoding()
C++ Interface: get_encoding(TextEncoder self)
- /**
Returns the encoding by which the string set via set_text() is to be
interpreted. See set_encoding().
*/
- getNumChars()
C++ Interface: get_num_chars(TextEncoder self)
- /**
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().
*/
- getText()
C++ Interface: get_text(TextEncoder self) get_text(TextEncoder self, int encoding)
- getTextAsAscii()
C++ Interface: get_text_as_ascii(TextEncoder self)
- /**
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().
*/
- getUnicodeChar()
C++ Interface: get_unicode_char(TextEncoder self, 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().
*/
- getWtext()
C++ Interface: get_wtext(TextEncoder self)
- /**
Returns the text associated with the TextEncoder, as a wide-character
string.
*/
- getWtextAsAscii()
C++ Interface: get_wtext_as_ascii(TextEncoder self)
- /**
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.
*/
- get_default_encoding()
C++ Interface: get_default_encoding()
- /**
Specifies the default encoding to be used for all subsequently created
TextEncoder objects. See set_encoding().
*/
- get_encoded_char()
C++ Interface: get_encoded_char(TextEncoder self, int index) get_encoded_char(TextEncoder self, int index, int encoding)
- get_encoding()
C++ Interface: get_encoding(TextEncoder self)
- /**
Returns the encoding by which the string set via set_text() is to be
interpreted. See set_encoding().
*/
- get_num_chars()
C++ Interface: get_num_chars(TextEncoder self)
- /**
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().
*/
- get_text()
C++ Interface: get_text(TextEncoder self) get_text(TextEncoder self, int encoding)
- get_text_as_ascii()
C++ Interface: get_text_as_ascii(TextEncoder self)
- /**
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().
*/
- get_unicode_char()
C++ Interface: get_unicode_char(TextEncoder self, 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().
*/
- get_wtext()
C++ Interface: get_wtext(TextEncoder self)
- /**
Returns the text associated with the TextEncoder, as a wide-character
string.
*/
- get_wtext_as_ascii()
C++ Interface: get_wtext_as_ascii(TextEncoder self)
- /**
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.
*/
- isWtext()
C++ Interface: is_wtext(TextEncoder self)
- /**
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()).
*/
- is_wtext()
C++ Interface: is_wtext(TextEncoder self)
- /**
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()).
*/
- lower()
C++ Interface: lower(str source) lower(str source, int encoding)
- makeLower()
C++ Interface: make_lower(const TextEncoder self)
- /**
Adjusts the text stored within the encoder to all lowercase letters
(preserving accent marks correctly).
*/
- makeUpper()
C++ Interface: make_upper(const TextEncoder self)
- /**
Adjusts the text stored within the encoder to all uppercase letters
(preserving accent marks correctly).
*/
- make_lower()
C++ Interface: make_lower(const TextEncoder self)
- /**
Adjusts the text stored within the encoder to all lowercase letters
(preserving accent marks correctly).
*/
- make_upper()
C++ Interface: make_upper(const TextEncoder self)
- /**
Adjusts the text stored within the encoder to all uppercase letters
(preserving accent marks correctly).
*/
- reencodeText()
C++ Interface: reencode_text(str text, int from, int 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.
*/
- reencode_text()
C++ Interface: reencode_text(str text, int from, int 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.
*/
- setDefaultEncoding()
C++ Interface: set_default_encoding(int encoding)
- /**
Specifies the default encoding to be used for all subsequently created
TextEncoder objects. See set_encoding().
*/
- setEncoding()
C++ Interface: set_encoding(const TextEncoder self, int 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.
This affects only future calls to set_text(); it does not change text that
was set previously.
*/
- setText()
C++ Interface: set_text(const TextEncoder self, object text) set_text(const TextEncoder self, object text, int encoding)
- /**
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.
*/
- /**
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().
*/
- setUnicodeChar()
C++ Interface: set_unicode_char(const TextEncoder self, 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().
*/
- setWtext()
C++ Interface: set_wtext(const TextEncoder self, unicode wtext)
// Direct support for wide-character strings. Now publishable with the new // wstring support in interrogate.
- /**
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.
*/
- set_default_encoding()
C++ Interface: set_default_encoding(int encoding)
- /**
Specifies the default encoding to be used for all subsequently created
TextEncoder objects. See set_encoding().
*/
- set_encoding()
C++ Interface: set_encoding(const TextEncoder self, int 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.
This affects only future calls to set_text(); it does not change text that
was set previously.
*/
- set_text()
C++ Interface: set_text(const TextEncoder self, object text) set_text(const TextEncoder self, object text, int encoding)
- /**
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.
*/
- /**
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().
*/
- set_unicode_char()
C++ Interface: set_unicode_char(const TextEncoder self, 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().
*/
- set_wtext()
C++ Interface: set_wtext(const TextEncoder self, unicode wtext)
// Direct support for wide-character strings. Now publishable with the new // wstring support in interrogate.
- /**
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.
*/
- text
- unicodeIsalpha()
C++ Interface: unicode_isalpha(int character)
- /**
Returns true if the indicated character is an alphabetic letter, false
otherwise. This is akin to ctype’s isalpha(), extended to Unicode.
*/
- unicodeIsdigit()
C++ Interface: unicode_isdigit(int character)
- /**
Returns true if the indicated character is a numeric digit, false
otherwise. This is akin to ctype’s isdigit(), extended to Unicode.
*/
- unicodeIslower()
C++ Interface: unicode_islower(int character)
- /**
Returns true if the indicated character is a lowercase letter, false
otherwise. This is akin to ctype’s islower(), extended to Unicode.
*/
- unicodeIspunct()
C++ Interface: unicode_ispunct(int character)
- /**
Returns true if the indicated character is a punctuation mark, false
otherwise. This is akin to ctype’s ispunct(), extended to Unicode.
*/
- unicodeIsspace()
C++ Interface: unicode_isspace(int character)
- /**
Returns true if the indicated character is a whitespace letter, false
otherwise. This is akin to ctype’s isspace(), extended to Unicode.
*/
- unicodeIsupper()
C++ Interface: unicode_isupper(int character)
- /**
Returns true if the indicated character is an uppercase letter, false
otherwise. This is akin to ctype’s isupper(), extended to Unicode.
*/
- unicodeTolower()
C++ Interface: unicode_tolower(int character)
- /**
Returns the uppercase equivalent of the given Unicode character. This is
akin to ctype’s tolower(), extended to Unicode.
*/
- unicodeToupper()
C++ Interface: unicode_toupper(int character)
- /**
Returns the uppercase equivalent of the given Unicode character. This is
akin to ctype’s toupper(), extended to Unicode.
*/
- unicode_isalpha()
C++ Interface: unicode_isalpha(int character)
- /**
Returns true if the indicated character is an alphabetic letter, false
otherwise. This is akin to ctype’s isalpha(), extended to Unicode.
*/
- unicode_isdigit()
C++ Interface: unicode_isdigit(int character)
- /**
Returns true if the indicated character is a numeric digit, false
otherwise. This is akin to ctype’s isdigit(), extended to Unicode.
*/
- unicode_islower()
C++ Interface: unicode_islower(int character)
- /**
Returns true if the indicated character is a lowercase letter, false
otherwise. This is akin to ctype’s islower(), extended to Unicode.
*/
- unicode_ispunct()
C++ Interface: unicode_ispunct(int character)
- /**
Returns true if the indicated character is a punctuation mark, false
otherwise. This is akin to ctype’s ispunct(), extended to Unicode.
*/
- unicode_isspace()
C++ Interface: unicode_isspace(int character)
- /**
Returns true if the indicated character is a whitespace letter, false
otherwise. This is akin to ctype’s isspace(), extended to Unicode.
*/
- unicode_isupper()
C++ Interface: unicode_isupper(int character)
- /**
Returns true if the indicated character is an uppercase letter, false
otherwise. This is akin to ctype’s isupper(), extended to Unicode.
*/
- unicode_tolower()
C++ Interface: unicode_tolower(int character)
- /**
Returns the uppercase equivalent of the given Unicode character. This is
akin to ctype’s tolower(), extended to Unicode.
*/