Created
September 6, 2012 12:02
-
-
Save redraiment/3655495 to your computer and use it in GitHub Desktop.
For Chinese user, not only convert \r\n to \n, but also convert char encoding from GBK to UTF-8
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/sh | |
until [ -z $1 ]; do | |
unix2dos $1 2>/dev/null | |
iconv -f UTF-8 -t GBK $1 -o /tmp/unix2doc.tmp 2>/dev/null | |
if [ $? -eq 0 ]; then | |
mv /tmp/unix2doc.tmp $1 | |
echo "linux2win: converting file $1 to WIN format ..." | |
else | |
rm -rf /tmp/unix2doc.tmp | |
echo "linux2win: converting file $1 is not Linux format ..." | |
fi | |
shift | |
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
#!/bin/sh | |
until [ -z $1 ]; do | |
dos2unix $1 2>/dev/null | |
iconv -f GBK -t UTF-8 $1 -o /tmp/win2unix.tmp 2>/dev/null | |
if [ $? -eq 0 ]; then | |
mv /tmp/win2unix.tmp $1 | |
echo "win2linux: converting file $1 to UNIX format ..." | |
else | |
rm -rf /tmp/win2unix.tmp | |
echo "win2linux: converting file $1 is not WIN format ..." | |
fi | |
shift | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment