我处理的是unicode数据字符,我想知道为什么有些字符在unicodedata中没有任何名称?下面是一个示例代码,您可以在其中检查< unknown >
我认为unicode数据库中的每个字符都是命名的,顺便说一句,它们都属于同一个类别[Cc] Other, Control
。在
另一个问题:如何获得unicode码位值?是ord(unicodechar)
起作用了吗?在
我还把文件here(因为编码是一件奇怪的事情),因为我认为我的带有“不可见”字符的剪切粘贴可能会丢失。在
#!/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
根据
unicodedata
库documentation您的两个字符将显示以下输出:
它们对应于控制点字符0x96和0x97 上面的unicode文档在the code point paragraph中规定:
我不知道如何通过
unicodedata
模块获得与unicode注释相对应的标签注释,但我认为您无法获得两个控制字符的任何名称,因为它是由unicode规范定义的。在不,控制字符没有名称,请参见UnicodeData文件
是的!在
相关问题 更多 >
编程相关推荐