In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article analyzes "how to convert the file encoding format under Linux". The content is detailed and easy to understand, and friends who are interested in "how to convert the file encoding format under Linux" can follow the editor's train of thought to read it in depth. I hope it will be helpful to everyone after reading. Let's follow the editor to learn more about "how to convert the file encoding format under Linux".
Often when operating files under Windows in Linux, you will encounter garbled code. Common, such as the C\ C++ program written in Visual Studio needs to be compiled on the Linux host, while the Chinese comments of the program show garbled, the more serious is due to coding reasons, the compiler on Linux reported an error.
This is because the default file format in Windows is GBK (gb2312), while Linux is generally UTF-8. So how to look at the encoding of the file in Linux and how to transcode the file?
1. Use VIM to view the file encoding
You can view file encodings directly in Vim
: set fileencoding
The file encoding format can be displayed.
2. Rewrite ~ / .vimrc file
If you just want to view files in other encoding formats or want to solve the problem of garbled viewing files with Vim, you can use the
Add the following to the ~ / .vimrc file
Set encoding=utf-8 fileencodings=ucs-bom,utf-8,cp936
In this way, you can let vim automatically identify file encodings (you can automatically identify UTF-8 or GBK encoded files), which is actually an attempt according to the coding list provided by fileencodings. If you do not find a suitable encoding, open it with latin-1 (ASCII) coding.
3. Transcoding with ICONV files
We use the iconv tool to convert the encoding of the file.
Iconv conversion. The command format of iconv is as follows:
Iconv-f encoding-t encoding inputfile
For example, convert a GBK-encoded file to UTF-8-encoded file
Iconv-f GBK-t UTF-8 file1-o file2
The meaning representation of the parameters in it
-f From some code
-t To some code
-o Export to file
4. Change the file encoding by saving notepad as
Open it with the notepad under Windows, select Save as, and change the code.
On how to carry out Linux file coding format conversion to share here, I hope that the above content can make you improve. If you want to learn more knowledge, please pay more attention to the editor's updates. Thank you for following the website!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.