******************** wx.EncodingConverter ******************** Inheritance diagram for `wx.EncodingConverter`: | .. inheritance-diagram:: wx.EncodingConverter | Description =========== This class is capable of converting strings between two 8-bit encodings/charsets. It can also convert from/to Unicode (but only if you compiled wxWidgets with ``wx.USE_WCHAR_T`` set to 1). Only a limited subset of encodings is supported by wx.EncodingConverter: ``wx.FONTENCODING_ISO8859_1..15``, ``wx.FONTENCODING_CP1250..1257`` and ``wx.FONTENCODING_KOI8``. .. seealso:: `wx.FontMapper `_ Derived From ^^^^^^^^^^^^^ * `wx.Object `_ Methods Summary ^^^^^^^^^^^^^^^ * `__init__ <#__init__>`_ * `CanConvert <#CanConvert>`_ * `Convert <#Convert>`_ * `GetAllEquivalents <#GetAllEquivalents>`_ * `GetPlatformEquivalents <#GetPlatformEquivalents>`_ * `Init <#Init>`_ Class API ========= Methods ^^^^^^^ .. method:: __init__() `No docstrings available for this method.` -------- .. method:: CanConvert(encIn, encOut) Returns ``True`` if (any text in) multibyte encoding `encIn` can be converted to another one (`encOut`) losslessly. Do not call this method with ``wx.FONTENCODING_UNICODE`` as either parameter, it doesn't make sense (always works in one sense and always depends on the text to convert in the other). **Parameters:** * `encIn` (int) * `encOut` (int) | **Returns:** `bool` -------- .. method:: Convert(input) Convert string and return new string object. **Parameters:** * `input` (string) | **Returns:** `string` -------- .. method:: GetAllEquivalents(enc) Similar to `GetPlatformEquivalents <#GetPlatformEquivalents>`_, but this one will return **ALL** equivalent encodings, regardless of the platform, and including itself. This platform's encodings are before others in the array. And again, if `enc` is in the array, it is the very first item in it. **Parameters:** * `enc` (int) | **Returns:** `list of integers` -------- .. method:: GetPlatformEquivalents(enc, platform=wx.PLATFORM_CURRENT) Return equivalents for given font that are used under given platform. Supported platforms are: * ``wx.PLATFORM_UNIX`` * ``wx.PLATFORM_WINDOWS`` * ``wx.PLATFORM_OS2`` * ``wx.PLATFORM_MAC`` * ``wx.PLATFORM_CURRENT`` ``wx.PLATFORM_CURRENT`` means the platform this binary was compiled for. Equivalence is defined in terms of convertibility: two encodings are equivalent if you can convert text between them without losing information (it may - and will - happen that you lose special chars like quotation marks or em-dashes but you shouldn't lose any diacritics and language-specific characters when converting between equivalent encodings). Remember that this function does **NOT** check for presence of fonts in system. It only tells you what are most suitable encodings. (It usually returns only one encoding.) **Parameters:** * `enc` (int) * `platform` (int) | **Returns:** `list of integers` .. note:: Please note the following: * Note that argument `enc` itself may be present in the returned array, so that you can, as a side-effect, detect whether the encoding is native for this platform or not. * `Convert <#Convert>`_ is not limited to converting between equivalent encodings, it can convert between two arbitrary encodings. * If `enc` is present in the returned array, then it is **always** the first item of it. * The returned array may contain no items at all. -------- .. method:: Init(input_enc, output_enc, method=wx.CONVERT_STRICT) Initialize conversion. Both output or input encoding may be ``wx.FONTENCODING_UNICODE``, but only if ``wx.USE_ENCODING`` is set to 1. All subsequent calls to `Convert <#Convert>`_ will interpret its argument as a string in `input_enc` encoding and will output string in `output_enc` encoding. You must call this method before calling `Convert`. You may call it more than once in order to switch to another conversion. `method` affects behaviour of `Convert()` in case input character cannot be converted because it does not exist in output encoding: ============================ =============================== Methods Description ============================ =============================== ``wx.CONVERT_STRICT`` follow behaviour of GNU Recode - just copy unconvertible characters to output and don't change them (its integer value will stay the same) ``wx.CONVERT_SUBSTITUTE`` try some (lossy) substitutions - e.g. replace unconvertible latin capitals with acute by ordinary capitals, replace en-dash or em-dash by '-' etc... ============================ =============================== Both modes guarantee that output string will have same length as input string. **Parameters:** * `input_enc` (int) * `output_enc` (int) * `method` (int) | **Returns:** `bool`