SHARE
TWEET

jpnum_Halfwidth2Fullwidth.py

a guest May 23rd, 2014 206 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # http://cuio.blog2.fc2.com/blog-entry-2165.html
  4.  
  5. import codecs
  6.  
  7. fpath = '/Users/kmiura/20140523.txt'
  8. newfpath = fpath + 'updated.txt'
  9. f = codecs.open(fpath, encoding='utf-8')
  10. s = f.read()
  11. t = dict((0x0020 + ch, 0xff00 + ch) for ch in range(0x5f))
  12. t[0x0020] = 0x3000
  13. print s.translate(t)
  14. nf = codecs.open(newfpath, encoding='utf-8', mode='w')
  15. nf.write(s.translate(t))
  16. nf.close()
  17. f.close()
RAW Paste Data
Top