Skip to content

Instantly share code, notes, and snippets.

@dogancelik
Created May 23, 2012 21:11
Show Gist options
  • Save dogancelik/2777851 to your computer and use it in GitHub Desktop.
Save dogancelik/2777851 to your computer and use it in GitHub Desktop.
(Python) Convert ShiftJIS to UTF-8
#!/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