Esempio n. 1
0
def utf32_to_utf8(ch):
    """ Convert a UTF-32 character to UTF-8.

        ch  -- the character to convert
    """
    _lib.caca_utf32_to_utf8.argtypes = [ctypes.c_char_p, ctypes.c_uint32]
    _lib.caca_utf32_to_utf8.restype  = ctypes.c_int

    buf = ctypes.c_buffer(7)
    _lib.caca_utf32_to_utf8(buf, ch)

    return buf.raw.rstrip('\x00')
Esempio n. 2
0
def utf32_to_utf8(ch):
    """ Convert a UTF-32 character to UTF-8.

        ch  -- the character to convert
    """
    _lib.caca_utf32_to_utf8.argtypes = [ctypes.c_char_p, ctypes.c_uint32]
    _lib.caca_utf32_to_utf8.restype = ctypes.c_int

    buf = ctypes.c_buffer(7)
    _lib.caca_utf32_to_utf8(buf, ch)

    if _PYTHON3:
        return _bytes_to_str(buf.raw).replace('\x00', '')
    else:
        return buf.raw.replace('\x00', '')
Esempio n. 3
0
def utf32_to_utf8(ch):
    """ Convert a UTF-32 character to UTF-8.

        ch  -- the character to convert
    """
    _lib.caca_utf32_to_utf8.argtypes = [ctypes.c_char_p, ctypes.c_uint32]
    _lib.caca_utf32_to_utf8.restype  = ctypes.c_int

    buf = ctypes.c_buffer(7)
    _lib.caca_utf32_to_utf8(buf, ch)

    if _PYTHON3:
        return _bytes_to_str(buf.raw).replace('\x00', '')
    else:
        return buf.raw.replace('\x00', '')