#!/usr/bin/python import os import sys def file_convert_encoding(target, from_encoding, to_encoding): if os.path.isfile(target): buf = file(target, 'rb').read() buf = buf.decode(from_encoding).encode(to_encoding) file(target, 'wb').write(buf) target = sys.argv[1] file_convert_encoding(target, 'utf8', 'sjis',) os.spawnlp(os.P_WAIT, 'vi', 'vi', target) file_convert_encoding(target, 'sjis', 'utf8')