Linux screen window Chinese garbled problem

  
 

Target: The terminal uses the commands less/more/grep to correctly display the contents of the GBK encoded file. vim correctly displays the GBK encoded file Chinese characters

Symptoms:

1. The system comes with gnome-terminal After setting the terminal code to GBK, the target can be achieved.

2. Using xshell When setting the terminal encoding to default on the Windows platform, ssh logs in to CentOS and can achieve the goal.

3. In the screen command window, regardless of the terminal or vim, Chinese is displayed as garbled and cannot reach the target.

Workaround: In ~/.screenrc, add the following two sentences:

defencoding GBKencoding UTF-8 GBK

My guess is xshell, gnome-terminal, etc. The ability to pass its own code to the system, so the system can automatically transcode the output. The screen belongs to the terminal in the terminal, and its own encoding is not GBK, which causes the output to be transcoded after being transmitted to the system. After setting the encoding and conversion rules for screen, it will be OK.

Copyright © Windows knowledge All Rights Reserved