It is well known that the character set encoding and regular character locator between Windows and Unix are quite different, and if passing files between different systems always brings many errors due to the differences in character set encoding and character Locator.
Here first of all, the character set encoding, in Unix, the general use of Utf-8, and in Windows in the system used more, most of the GB2312 (Chinese Simplified), BIG5 (Chinese Traditional) and so on, then if the use of the character set is incorrect, the source file will be garbled, At this time we need to use ICONV to convert the source files to suit different system environments, ICONV usage is as follows:
Usage: iconv [Options ...] [file ...] Converts the encoding of a given file. Input/Output format specification: -f, --from-code= name original text encoding -t, -- to-code= name Output code information: -l, --list Enumerate all known character sets output controls: -c ignore invalid characters from output -o, --output=FILE Output File -s, --silent Close Warning --verbose Print Progress Information -?, --help gives the system Help list --usage give a brief usage information -v, -- version Print Program version number
In this way we can write a script for the actual production environment, in general, the software installed in the system has a default installation, if not can go to the GNU website Download Source package installation, this installation is not a dependency package, installation is very simple, here do not repeat
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
There are some differences in the regular locators that are used in addition to the character set encoding between Windows and UNIX, such as the Windows-edited file in a Unix system that has a "^m" at the end of each line, which is the same as the regular locator between the two. In the end of the Windows line ending is "^m$", and in the UNIX system is "$", so we have a lot of trouble when using, then this will need to use Unix2dos dos2unix2 instructions to convert the regular locator, when using these 2 instructions, When the Yum source is configured correctly, it can be installed directly, using the following method:
[[email protected] ~]# yum-y install Unix2dos Dos2unixdos2unix and unix2dos:-k: Keep the date of the output file constant-Q: Quiet mode without prompting for any warning messages. -V: View version-C: Conversion mode, Mode: ASCII, 7bit, ISO, Mac, default is: ASCII. -O: Write to source file-N: Parameter options for writing to a new file are the same, except that Dos2unix is turning dos (that is, Windows) into UNIX format, while Unix2dos is the opposite
Usually we need to pay attention to these problems when exchanging files between different systems, so as not to cause errors
This article is from the "Technical essay" blog, please be sure to keep this source http://jim123.blog.51cto.com/4763600/1873303
Character conversions for Windows and UNIX