Last active
May 8, 2019 00:26
-
-
Save pollenjp/20b96dad35cd410f1fea75eeca92cb12 to your computer and use it in GitHub Desktop.
エンコーディング形式の変換
This file contains 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
#!/bin/bash -eux | |
# encoding形式をUTF-8(DOM無し)に変換するコード | |
FILES=$(find . -type f) | |
for FILE in ${FILES}; do | |
ENC=$(nkf --guess ${FILE}) | |
# 動画等の"BINARY"ファイルには処理を行わない. | |
if [ "${ENC}" != "BINARY" ]; then | |
# この行をコメントアウトしてどのファイルがどのエンコーディングになるかを事前に確認するとよい. | |
nkf -Lu -d -w -w80 --in-place ${FILE} | |
ENC2=$(nkf --guess ${FILE}) | |
printf "%-30s %-20s => %-20s\n" "${FILE}" "${ENC}" "${ENC2}" | |
fi | |
done |
This file contains 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
./exe EUC-JP (LF) => UTF-8 (LF) | |
./tmp.bash.sh ASCII (LF) => ASCII (LF) | |
./inc/scene.h EUC-JP (MIXED NL) => UTF-8 (LF) | |
./inc/win2d.h EUC-JP (CRLF) => UTF-8 (LF) | |
./inc/box.h EUC-JP (MIXED NL) => UTF-8 (LF) | |
./inc/attri.h EUC-JP (CRLF) => UTF-8 (LF) | |
./inc/win.h EUC-JP (MIXED NL) => UTF-8 (LF) | |
./inc/patch.h EUC-JP (CRLF) => UTF-8 (LF) | |
./inc/array.h EUC-JP (CRLF) => UTF-8 (LF) | |
./inc/scene2.h EUC-JP (MIXED NL) => UTF-8 (LF) | |
./inc/win3d.h EUC-JP (MIXED NL) => UTF-8 (LF) | |
./inc/line.h EUC-JP (MIXED NL) => UTF-8 (LF) | |
./inc/surface1.h EUC-JP (MIXED NL) => UTF-8 (LF) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment