Pythonについて0から教えてください
■ このスレッドは過去ログ倉庫に格納されています
0609デフォルトの名無しさん
2006/03/23(木) 16:47:14>>> unicodedata.name(u"\u017f")
'LATIN SMALL LETTER LONG S'
この文字は EUC-JP では表すことのできない多数の文字のひとつ。
result.encode("euc-jp", "ignore") として無視するか、
result.encode("euc-jp", "replace") として所定の置換文字に置き換えるか、
def replace_by_name(exc):
c = exc.object[exc.start:exc.end]
u = "[U+%04X %s]" % (ord(c), unicodedata.name(c))
return unicode(u), len(c)
codecs.register_error("replacebyname", replace_by_name)
result.encode("euc-jp", "replacebyname") のように置換方法を定義して用いるのが良かろう。
■ このスレッドは過去ログ倉庫に格納されています