Пример #1
0
def decode_utf16le_with_hypua(bytes):
    ''' decode utf-16le encoded bytes with Hanyang-PUA codes into a unicode
    string with Hangul Jamo codes

    :param bytes: utf-16le encoded bytes with Hanyang-PUA codes
    :returns: a unicode string with Hangul Jamo codes
    '''
    from hypua2jamo import codes2unicode
    codes = decode_uint16le_array(bytes)
    return codes2unicode(codes.tolist())
Пример #2
0
def decode_utf16le_with_hypua(bytes):
    ''' decode utf-16le encoded bytes with Hanyang-PUA codes into a unicode
    string with Hangul Jamo codes

    :param bytes: utf-16le encoded bytes with Hanyang-PUA codes
    :returns: a unicode string with Hangul Jamo codes
    '''
    from hypua2jamo import codes2unicode
    codes = decode_uint16le_array(bytes)
    return codes2unicode(codes.tolist())
Пример #3
0
    def test_codes2unicode_composed(self):
        from hypua2jamo import codes2unicode

        jamo_string = codes2unicode(
            list(ord(ch) for ch in Fixtures.HunMinPreface.pua_string),
        )
        self.assertEqual(
            Fixtures.HunMinPreface.composed_jamo_string,
            jamo_string,
        )
Пример #4
0
        for pos in ('left', 'right', 'top', 'bottom'):
            yield '-'.join([name, pos]), xmlattrval(value.get(pos))
    elif t is COLORREF:
        yield name, xmlattrval(t(value))
    elif t is VERSION:
        yield name, '.'.join(str(x) for x in value)
    elif t in (HWPUNIT, SHWPUNIT, HWPUNIT16):
        yield name, str(value)
    elif t is WCHAR:
        if value == 0:
            yield name, u''
        else:
            if value in PUA_SYMBOLS:
                yield name, PUA_SYMBOLS[value]
            else:
                yield name, codes2unicode([value])
    elif t is BinStorageId:
        yield name, 'BIN%04X' % value
    else:
        yield name, xmlattrval(value)


# TODO: arbitrary assignment; not based on any standards
PUA_SYMBOLS = {
    0xF046: u'☞',  # U+261E WHITE RIGHT POINTING INDEX
    0xF06C: u'●',  # U+25CF BLACK CIRCLE
    # F06C: u'⚫',  # U+26AB MEDIUM BLACK CIRCLE
    0xF09F: u'•',  # U+2022 BULLET = black small circle
    0xF0A1: u'○',  # U+25CB WHITE CIRCLE
    # F0A1: u'⚪',  # U+26AA MEDIUM WHITE CIRCLE
    # F0A1: u'⚬',  # U+26AC MEDIUM SMALL WHITE CIRCLE
Пример #5
0
        for pos in ('left', 'right', 'top', 'bottom'):
            yield '-'.join([name, pos]), xmlattrval(value.get(pos))
    elif t is COLORREF:
        yield name, xmlattrval(t(value))
    elif t is VERSION:
        yield name, '.'.join(str(x) for x in value)
    elif t in (HWPUNIT, SHWPUNIT, HWPUNIT16):
        yield name, str(value)
    elif t is WCHAR:
        if value == 0:
            yield name, u''
        else:
            if value in PUA_SYMBOLS:
                yield name, PUA_SYMBOLS[value]
            else:
                yield name, codes2unicode([value])
    elif t is BinStorageId:
        yield name, 'BIN%04X' % value
    else:
        yield name, xmlattrval(value)


# TODO: arbitrary assignment; not based on any standards
PUA_SYMBOLS = {
    0xF046: u'☞',  # U+261E WHITE RIGHT POINTING INDEX
    0xF06C: u'●',  # U+25CF BLACK CIRCLE
    # F06C: u'⚫',  # U+26AB MEDIUM BLACK CIRCLE
    0xF09F: u'•',  # U+2022 BULLET = black small circle
    0xF0A1: u'○',  # U+25CB WHITE CIRCLE
    # F0A1: u'⚪',  # U+26AA MEDIUM WHITE CIRCLE
    # F0A1: u'⚬',  # U+26AC MEDIUM SMALL WHITE CIRCLE