|

楼主 |
发表于 2005-11-12 10:15:03
|
显示全部楼层
iconv 很好用。我自己写了一个角本来自动将eucJP-WIN的编码改为UTF8的编码。
现在有一点不好,就是虽然编码转换好了,但日文显示还是有问题。有很多字符无法正常显示。scim的日文输入法法也是一样的问题。包括debian linux下的所有可以显示日文的编辑器也是。我想应该是没有更好的字体的原因。但是不知道怎么解决。
把我编码转换用的角本放在这里,给有用的兄弟。
______________________________________
#! /bin/sh
##file transDir.sh
##author:xlinlover(www.linuxsir.cn)
##Usage: transDir.sh [DIRname|FILEname]
##Function:
##Traverse the directory
##&& Convert the .txt .h .c file from eucJP-WIN encoding to UTF-8 encoding
##Note:Your text should be eucJP-WIN encoding
##&& Your system should have iconv installed
if [ "$#" -ne 1 ] ; then
echo "Usage: $0 DIRname "
exit
fi
reEnter(){
local i L
[ "${1:0:1}" = "/" ] && L="$1" || L="$PWD/$1"
echo "Current directory $L"
if [ -d "${L}" ] ; then
cd "${L}" ## Must use "" to prevent blank
echo "Enter in $L"
local fn="$(ls | tr '\n' "
old_IFS="$IFS"
IFS=:
for i in $fn ; do
if [ -f "$i" ]; then ##If is a file,do some work
if [ "`echo $i|egrep '\.c'`" -o "`echo $i|egrep '\.h'`" -o "`echo $i|egrep '\.txt'`" ]; then
cp "$i" "$i~"
iconv -f EUCJP-MS -t UTF8 "$i~" -o "$i~~"
cp "$i~~" "$i"
rm -f "$i~"
rm -f "$i~~"
echo " $i "
fi
fi
if [ -d "$i" ]; then ##If is a directory ,enter the directory recursively
reEnter "$i"
fi
done
cd ..
fi
return
}
reEnter "$1"
IFS=old_IFS ;
______________________________________ |
|