Linxu Shell Iconv transcoding problem

Source: Internet
Author: User

First, view the file encoding.
When you open the file, enter: Set fileencoding
You can display the file encoding format.



Second, the file encoding conversion
1, in vim Direct conversion file encoding, such as converting a file to Utf-8 format
in the Open file, enter: Set Fileencoding=utf-8

2, using iconv conversion, the ICONV command format is as follows:

iconv-f encoding-t encoding inputfile
such as converting an encoded file into a GBK encoding.
iconv-f UTF-8-t GBK file1-o file2

usage of iconv:

usage: iconv [Options ...] [File ...]
Convert encoding of given files from one encoding to another.
input/Output format specification:
-F,--from-code=name original text encoding
-T,--to-code=name output encoding
Information:
-L,--list enumeration of all known character sets
Output Control:
-C ignores invalid characters from output
-O,--output=file output file
-S,--silent suppress warnings
--verbose Printing Progress Information
-?,--Help gives a list of the systems
--usage gives a brief usage information
-V,--version Print program version number

convert GB2312 encoded file content to UTF-8
iconv-f gb2312-t UTF-8 file-name > New-file-name

convert UTF-8 encoded file content to GB2312
iconv-f UTF-8-t GB2312 file-name > New-file-name
Note: Be sure to back up important files before converting, especially when converting the contents of a file

Third, the file name encoding conversion:

Copying files from Linux to Windows, or copying files from Windows to Linux, sometimes the Chinese file name is garbled, the reason for this problem is because the Windows FileName Chinese encoding defaults to GBK, In Linux, the default file name is encoded as UTF8, due to inconsistent encoding, so the file name garbled problem, to solve this problem requires the file name transcoding.
a tool convmv for file name encoding is provided specifically in Linux, which converts the file name from GBK to UTF-8 encoding, or from UTF-8 to GBK.

1, first look at your system is installed on the CONVMV, if not installed in the terminal input the following command installation:
sudo yum-y install CONVMV

2, the following look at the specific use of CONVMV:
convmv-f Source code-T new encoding [options] File name
Common parameters:
- R recursive processing of subfolders
--notest The actual operation, please note that by default, the file does not actually operate, but only the experiment.
--list display of all supported encodings
--unescap can be escaped, such as to turn%20 into a space
For example, we have a UTF8 encoded file name, converted to GBK encoding, the command is as follows:
convmv-f UTF-8-t GBK--notest UTF8 encoded file name

Linxu Shell Iconv transcoding problem

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.