LoginSignup
3
3

More than 5 years have passed since last update.

異体字セレクタを扱う

Last updated at Posted at 2014-08-10

Python(2.7)で異体字セレクタ(IVS)を扱う方法.

文字列リテラルで異体字セレクタを利用する場合, 基底文字に続けてセレクタを続ける. セレクタは16bit以上なので32bitのユニコードリテラルで表記する必要がある( https://docs.python.org/2/reference/lexical_analysis.html ).

邉の異体字(U+9089U+E0102 http://ivd.dicey.org/21549 )を扱う例. 標準出力とファイルに文字を出力する.

# -*- coding: utf-8


import codecs


z = u'\u9089\U000E0102'
print z
x = codecs.open('ivs_char.txt', 'w', 'utf-8')
x.write(z)
x.close()

実際に表示できるかは環境に依存する. Windows7以降, OSX SnowLeopard以降の主要なWebブラウザで表示可能.

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3