Class _codecs.EncodingMap

  • All Implemented Interfaces:
    java.io.Serializable
    Enclosing class:
    _codecs

    public static class _codecs.EncodingMap
    extends PyObject
    Optimized charmap encoder mapping. Uses a trie structure instead of a dictionary; the speedup primarily comes from not creating integer objects in the process. The trie is created by inverting the encoding map.
    See Also:
    Serialized Form
    • Method Detail

      • buildEncodingMap

        public static PyObject buildEncodingMap​(PyObject string)
        Create and populate an EncodingMap from a 256 length PyUnicode char. Returns a PyDictionary if the mapping isn't easily optimized.
        Parameters:
        string - a 256 length unicode mapping
        Returns:
        an encoder mapping
      • lookup

        public int lookup​(char c)
        Lookup a char in the EncodingMap.
        Parameters:
        c - a char
        Returns:
        an int, -1 for failure