Skip to content

Instantly share code, notes, and snippets.

@hikalium
Last active May 12, 2017 22:43
Show Gist options
  • Save hikalium/6b78979187a32a88215716278a011eb0 to your computer and use it in GitHub Desktop.
Save hikalium/6b78979187a32a88215716278a011eb0 to your computer and use it in GitHub Desktop.
Shift-JISのC言語ソースをUTF-8に一括置換する
  • Shift-JISのC言語ソースをUTF-8に一括置換する(Macで確認済み)
  • オリジナルファイルは.orgとして残る
  • 何度実行しても大丈夫

ソース

  • sjis2utf8.sh
echo $1
LANG=C file $1 | grep -v -q "UTF-8" && \
	cp $1 $1.org && \
	iconv -f shift-jis -t utf-8 $1.org | \
	sed -e 's/‾/~/g' | \
	sed -e 's/¥/\\/g' > $1
  • sjis2utf8all.sh
find . -name "*.c" -o -name "*.h" | xargs -n 1 ./sjis2utf8.sh 

実行

./sjis2utf8all.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment