Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to Open Chinese txt File in Ubuntu16.04 LTS

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to open the Chinese txt file in Ubuntu16.04 LTS, which is very detailed and has certain reference value. Interested friends must finish reading it!

Preface

As we all know, the Chinese support of the Ubuntu system is still relatively friendly, except that there is a problem with the recognition of TEXT file coding.

Gedit directly opens the Chinese txt file

The reason for this problem is that txt files are generated in Windows environment, and text readers such as vim and gedit under Ubuntu can not automatically recognize the file encoding format.

Here are several possible solutions.

File format conversion

Use commands such as dos2unix unix2dos unix2mac to convert txt files from the source operating system to the target operating system.

If these commands do not exist, use the following command to install.

Sudo apt install dos2unix sudo apt install unix2dos

Use the following command for format conversion:

Dos2unix [options] [FILE...] [- n INFILE OUTFILE...] Unix2dos [options] [FILE...] [- n INFILE OUTFILE...]

This conversion will change some of the attributes of the original file, such as generation time, and so on. This solution is not appropriate if files need to be accessed from two different operating systems.

.VIMRC sets the default encoding format

This solution is suitable for vim enthusiasts like me.

VIM opens the garbled code.

The solution to the problem is to modify the / etc/vim/vimrc or / etc/vim/vimrc.local file as shown below.

/ etc/vim/vimrc.local is called in / etc/vim/vimrc. You can modify either of the two. It is recommended to modify / etc/vim/vimrc.local.

Vimrc modification

Then use vim to open the same file again, bingo, done.

Vim opens files normally

Gedit Force qualify Encoding on

Gedit is a powerful text editing software under Ubuntu. Directly using gedit to open Chinese txt files is the most attractive solution.

In fact, this solution is simpler.

First use chardet3 to detect the encoding format of the file.

Summary of regular expressions commonly used in chardet3. Txt

The result of running shows that the encoding format of the file is GB2312:

Summary of commonly used regular expressions. Txt: GB2312 with confidence 0.99

Once you know the encoding format, you can add the encoding option when running gedit, as follows

Gedit-- A summary of regular expressions commonly used by encoding GB2312. Txt

You can also open the txt file normally, as shown in the following figure.

The above is all the contents of the article "how to Open Chinese txt Files in Ubuntu16.04 LTS". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report