Unicode problem

Carey Evans careye at spamcop.net
Sun Jun 10 06:18:55 EDT 2001


"Shaun Pen" <jinushaun at hotmail.com> writes:

> From the unicode website, I find that the character code for the
> hiragana "NA" is "306a" (JIS). I know it outputs as な (JIS).
> 
> **So how do I get from "306a" to な ??? **

Python doesn't currently come with the necessary codecs for Japanese,
including Shift-JIS.  You can download them from:

    http://pseudo.grad.sccs.chukyo-u.ac.jp/~kajiyama/python/

Once you have them, you can encode the Unicode character as a
Shift-JIS bytestream:

>>> na = u'\u306a'
>>> na.encode('japanese.shift_jis')
'\202\310'
>>> print na.encode('japanese.shift_jis')
な

OK, I made the last line up - my xterm is configured for ISO-8859-1,
not Shift JIS.

-- 
	 Carey Evans  http://home.clear.net.nz/pages/c.evans/

	    "Quiet, you'll miss the humorous conclusion."



More information about the Python-list mailing list