Created
May 23, 2012 21:11
-
-
Save dogancelik/2777851 to your computer and use it in GitHub Desktop.
(Python) Convert ShiftJIS to UTF-8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: UTF-8 -*- | |
# Convert ShiftJIS to UTF-8 | |
# Usage: cat ShiftJIS.txt | ./convert.py > UTF8.txt | |
# Alternative method: cat ShiftJIS.txt | iconv -f shift_jis -t utf8 > UTF8.txt | |
import sys | |
import codecs | |
ustdout = codecs.getwriter('utf_8')(sys.stdout) | |
jstdin = codecs.getreader('shift_jis')(sys.stdin) | |
for line in jstdin.readlines(): | |
ustdout.write(line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment