Created 2011-10-14 20:36:00
Updated 2020-01-02 23:23:40
Vim or vi in a Lenny Debian Linux session is configured in a native way on ISO-Latin1 charset. Until today, Unix OS in general, as well as other console programs like MsDos, MySQL native client (mysql.exe) are not yet intrinsically in Unicode. It's not easy to visualize UTF-8 text for multi-byte files such as chinese writings.
The webmasters manage their Debian Linux Server at distance via a SSH session by PuTTY program from Windows 7 system, for example.
But a Chinese Windows is not required to show chinese ideograms, we can do it under Occidental Windows, French or English version.
One must install UTF-8 locales, the chinese fonts and modify the configuration ~/.vmimrc.
# dpkg-reconfigure locales.
ttf-arphic-gbsn00lp (AR PL SungtiL GB)
ttf-arphic-gkai00mp (AR PL KaitiM GB)
ttf-arphic-bsmi00lp (AR PL Mingti2L Big5)
ttf-arphic-bkai00mp (AR PL KaitiM Big5)
# apt-get install ttf-arphic-bkai00mp ttf-arphic-bsmi00lp ttf-arphic-gbsn00lp ttf-arphic-gbsn00lp. This will create files bkai00mp.ttf bsmi00lp.ttf gbsn00lp.ttf under the folder /usr/share/fonts/truetype/arphic, they are sufficient to display the simplified chinese characters.
# vi utf8sample.txthere is the chinese text: We observe that there is still something blocking, the chinese ideograms in Unicode sent by SSH Linux are shown by Windows in ASCII Latin-1.
The modern Windows is by default conforming to the UTF-8 norm, one has nothing to do for UTF-8 Locales under Windows. Nor for the character fonts, since the UTF-8 font is installed by default: Arial under Windows Microsoft. The Arial font can fill the role, even though it is nor ideal, since this font is not of constant pitch for every alphabet, this is not favorable to coding in programming, in English, in French for example. But for the first step, it's sufficient.
Now you are connected to your Linux host at distance.
# printf "\xc3\xa9\n"It would show é on a Unicode terminal. On a Latin-1 terminal, it would give Ã©.
# localeThe LANG is not predefined, so selected by default by Linux.
# vi utf8sample.txthere is the chinese text so desired: Another test file utf8bomsample.txt on UTF-8 with BOM (Byte Order Mark) will give the same display result. Please be quiet to the dos file format indication, since the chinese text has been input under Windows by NJStar and saved in the local PC.
The ordre of the configuration has no importance. You can start by the Linux side, or by the Windows 7 side. Moreover, to simply display chinese ideograms on vim, you have no need to define the accurate locale by yourselves, the genuin Linux does it for you.
If you would like to also have a Chinese vim interface, you must define the locale via the global Shell variable $LANG among the following possibilities:
Please note that for each locale separated by a space, the only first part is the valid locale name, for example, here is a good declaration:
# export LANG="zh_CN.UTF-8"
With this setting, the SHELL interface is also in the language zh_CN.UTF-8, who shows the system messages in Chinese. Here are some test commands run and ressults shown:
# date # df # ls nonexistent.file.
This setting is also valid for the native client of MySQL /usr/bin/mysql. To display contents stocked in Simplified chinese in a table, you run mysql by
# mysql --default-character-set=utf8 -u<unsername> -p<password> <your_dbname>Or you launch mysql without the option --default-character-set, then under the MySQL console, do a special definition query
mysql> SET NAMES 'utf8' COLLATE utf8_general_ci;. And then under the MySQL console, launch the query like
mysql> SELECT NameCn FROM products WHERE (ID=358);. The Chinese characters will be displayed in the result.
It's impossible to show UTF-8 Chinese in the MySQL native client mysql.exe, since it's launched by the Shell, here cmd32.exe or MS-DOS. MS-DOS does not accept Asian UTF-8 fonts for the standard terminal, no matter it is FangSong, SimSun... MySQL is so limited to Ms-DOS terminal fonts approved by Microsoft: Raster Terminal, TrueType Lucida Console, Consolas that offer no chinese ideogram. Even if one modifies Windows Register, there is any effect for the Chinese Fonts. And changing the Code Page as Unicode: After all this hard work, in the MySQL console, the chinese ideograms still appear in Hollow Square. This means that the font is Unicode, which supports the encoding of Chinese characters, but in which the glyphs, here the chinese ideograms are not drawn by the creator of the loaded font. To show Simplified Chinese contents stored in a MySQL table, you should use MySQL GUI Administrator Tools that is a FreeWare MySQL GUI Administrator Tools. Or by PHPMyAdmin via a Browser.