Skip to content

Instantly share code, notes, and snippets.

@kosugi
Created May 7, 2013 05:33
Show Gist options
  • Select an option

  • Save kosugi/5530466 to your computer and use it in GitHub Desktop.

Select an option

Save kosugi/5530466 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
# ホームディレクトリにあったスクリプト.
# 何に使ったんだっけか.
#
# ファイル名から推測するに,
# 古い Gnumeric で日本語が EUC-JP で保存されていたものをサルベージしたか何か.
import sys
import re
pat_ncr = re.compile(r'&#(\d+);')
def refn_ncr2chr(m):
return chr(int(m.group(1)))
if __name__ == '__main__':
sys.stdout.write(pat_ncr.sub(refn_ncr2chr, sys.stdin.read()).decode('EUC-JP').encode('UTF-8'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment