I'm dealing with unicode data characters, and I wonder why some do not have any name in unicodedata? Here is a sample code where you can check the < unknown >
I thought that every characters inside unicode database were named, BTW there are all of the same category that is [Cc] Other, Control
.
Another question: how can I get the unicode code point value? Is it ord(unicodechar)
that does the trick?
I also put the file here (as encoding is a weird thing), and because I think that my cut n' paste with 'invisible' character may be lossy.
#!/bin/env python
# -*- coding: utf-8 -*-
#extracted and licensing from here:
"""
:author: Laurent Pointal <laurent.pointal@limsi.fr> <laurent.pointal@laposte.net>
:organization: CNRS - LIMSI
:copyright: CNRS - 2004-2009
:license: GNU-GPL Version 3 or greater
:version: $Id$
"""
# Chars alonemarks:
# !?¿;,*¤@°:%|¦/()[]{}<>«»´`¨&~=#±£¥$©®"
# must have spaces around them to make them tokens.
# Notes: they may be in pchar or fchar too, to identify punctuation after
# a fchar.
# \202 is a special ,
# \226 \227 are special -
alonemarks = u"!?¿;,\202*¤@°:%|¦/()[\]{}<>«»´`¨&~=#±\226"+\
u"\227£¥$©®\""
import unicodedata
for x in alonemarks:
unicodename = unicodedata.name(x, '<unknown>')
print "\t".join(map(unicode, (x, len(x), ord(x), unicodename, unicodedata.category(x))))
# unichr(int('fd9b', 16)).encode('utf-8')
# http://stackoverflow.com/questions/867866/convert-unicode-codepoint-to-utf8-hex-in-python