Example #1
0
def store(conn):
    with open(BASE + '/build/NamesList.txt') as f:
        for line in f.readlines():
            m = re_line.match(line)
            if not m:
                continue
            code, name = m.groups()
            if name in ('<control>', '<not a character>'):
                continue
            conn.execute('''insert into a (code, name) values (?, ?)''', (parse_codepoint(code), name))
Example #2
0
def store(conn):
    with open(BASE + '/build/NamesList.txt') as f:
        for line in f.readlines():
            m = re_line.match(line)
            if not m:
                continue
            code, name = m.groups()
            if name in ('<control>', '<not a character>'):
                continue
            conn.execute('''insert into a (code, name) values (?, ?)''',
                         (parse_codepoint(code), name))
Example #3
0
def do(query):
    try:
        codepoint = parse_codepoint(query)
        s = codepoint2unichr(codepoint)
    except:
        return make_xml(False, query, query, u'Type hexadecimal unicode codepoint')

    try:
        name = call_with_cursor([codepoint], get_name_by_code)
    except:
        return make_xml(False, query, query, u'Bad or unsuitable codepoint')
    else:
        return make_xml(True, s, u'{0}: {1}'.format(query, s), u'U+{0:04X}: {1}'.format(codepoint, name))
Example #4
0
def do_one(query):

    if query.strip() == '':
        return make_item(None,
                         'Type hexadecimal unicode codepoint',
                         '',
                         dummy=True)

    try:
        codepoint = parse_codepoint(query)
        s = codepoint2unichr(codepoint)
        name = call_with_cursor([codepoint], get_name_by_code)
    except:
        return make_item(None,
                         query,
                         'Bad or unsuitable codepoint',
                         dummy=True)
    else:
        return make_item(s, u'{0}: {1}'.format(query, s),
                         u'U+{0:04X}: {1}'.format(codepoint, name))