Mac OSはiconvを使用してgb 18030符号化テキストをutf-8形式テキストに変換する
Mac OS X comes with iconv utility that can convert text between encodings. Run the following command in Terminal to convert a gb2312 chinese text file to utf-8:
To list the encodings that iconv supports:
転載先:http://notepad2.blogspot.com/2012/07/mac-os-x-convert-gb2312gbkgb18030.html
以下はshellを使用してファイルディレクトリの下のファイルフォーマットをutf-8フォーマットに再帰的に変換するスクリプトです.
iconv -f cp936 -t utf-8 chinese-gb2312.txt > chinese-utf8.txt
To list the encodings that iconv supports:
iconv -l
転載先:http://notepad2.blogspot.com/2012/07/mac-os-x-convert-gb2312gbkgb18030.html
以下はshellを使用してファイルディレクトリの下のファイルフォーマットをutf-8フォーマットに再帰的に変換するスクリプトです.
#!/bin/bash
function encode()
{
iconv -f cp936 -t utf-8 "$1" > test
# iconv -f iso8859-15 -t utf8 "$1" > test;
cat test > "$1";
}
function walk()
{
for file in `ls $1`
do
local path=$1"/"$file
if [ -d $path ]
then
echo "DIR $path"
walk $path
else
echo "FILE $path"
encode $path
fi
done
}
if [ $# -ne 1 ]
then
echo "USAGE: $0 TOP_DIR"
else
walk $1
fi