私は Unicode データ文字を扱っていますが、一部の文字が unicodedata に名前がないのはなぜでしょうか? 確認できるサンプルコードは次のとおりです。< unknown >
ユニコードデータベース内のすべての文字に名前が付けられていると思いましたが、ところで、同じカテゴリのすべてがあります[Cc] Other, Control
.
別の質問: どうすれば Unicode コード ポイントの値を取得できますか? それord(unicodechar)
はトリックを行いますか?
また、ファイルをここに置きます(エンコーディングは奇妙なことなので)。これは、「見えない」文字を使用したカット アンド ペーストが失われる可能性があるためです。
#!/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