[Solution] There are Chinese garbled characters in the history file preview in Github Desktop

When using the GitHub Desktop client today, the content of the file is displayed as garbled characters after adding the local warehouse.

1. Phenomenon

 As shown below:

2. Reason analysis

Later analysis revealed that it was caused by inconsistent encoding.

Specifically, I created a new test file under the Windows Chinese system, opened it with the system's own notepad, and then found that the reality on the client side was full of garbled characters.

Later, I opened the file with Notepad++ and found that the default encoding is GB2312. At this time, I used Notepad++ to convert the encoding into utf-8 to save the file.

At this time, confirm again on the client that the garbled characters have disappeared and can be displayed normally.

3. Countermeasures and suggestions

In the future, when editing files locally, you should try to use a professional text editor like Notepad++, which may avoid some unexpected problems in your work.

Here is a brief introduction to the default text files under the Windows operating system that support four encoding formats, namely ANSI, Unicode, Unicode big endian, and UTF-8.

【Right click】=》【New】text document, if you use the system’s built-in notepad to open and edit it, it is actually encoded in ANSI by default.

However, it will be automatically converted according to the language of the operating system. The conversion rules are as follows

[Chinese system]: gb2312

[Japanese system]: jis

Because  GitHub  will automatically convert the encoding method of all files when pushing the code to the remote, so  when UTF-8 you browse your  GitHub  warehouse in the web page, there will be no garbled characters in Chinese.
But locally, if you want to   see Chinese normally in the GitHub For WindowsUTF-8 client software instead of garbled characters, you have to manually convert the files containing Chinese to: encoding method. (If it is  a Windows  system, it must be converted to: Utf-8 无 BOM encoding format)

 

※If there is anything wrong, I hope everyone will give us your advice and learn from each other! ! !

Reproduced reference:

https://blog.csdn.net/github_35160620/article/details/52788419

https://www.cnblogs.com/yddzyy/p/7628037.html

Guess you like

Origin blog.csdn.net/qq_27677599/article/details/112474611