My Opera is closing 3rd of March
photo of Yunt

云一样的梦…

只是当时已惘然

Subscribe to RSS feed

寻找字码

刚才看了李果正大侠的Unicode 中文部首起始碼位找尋字碼
以及Jserv大侠用用 Cairo 写那个unichart
着重看了看那个找尋字碼那个程序,用的是Ruby写的,可是这东西我机器上没有也没学过,
可是我懂python,所以也写个类似的程序,那个工具只支持Big-5 及 UTF-8环境,
我这个可以支持更多的环境……bigsmile

#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# vim:ts=8 sw=8 et
# uscchar.py : 将输入的字符转换成 ucs2/ucs4 hex.
# Yunt (05/17/06)

import sys
import locale

if __name__ == "__main__":
        if len(sys.argv) < 2:
                print 'Usage %s <Char>' % sys.argv[0]
        else:
                enc = locale.getdefaultlocale()[1]
                if enc != '':
                        c = unicode(sys.argv[1], enc )
                        print '0x%x' % ord(c)
                else:
                        print "\nNot support yet!"
                        print "\nTry to add code by yourself.\n"