Chinese characters in MetaTrader

There are several gotchas that need to be fixed to make it work:

  1. Select the Windows fonts with Unicode support.
  2. Set the Windows locale to Chinese.
  3. Recompile the “nquotes.mq4” file.

Step 1: Unicode fonts

The MetaTrader uses fonts specified in the Windows settings. If the font doesn’t support Chinese characters, it will be displayed as “?” or squares. MT4 uses a “Message Box” group font for menu bars and panel titles, and it uses “Icon” group font for almost anything else. For example the messages panel where the EA logs are printed uses the “Icon” font. To change it on Windows 7 you need to go to “Control Panel” - “Personalization” - “Window Color” (at the bottom), then select “Item” group and choose a “Font”:

Windows 7 font settings

“Arial Unicode MS” is selected, because it has Chinese Unicode glyphs, but some other font that has them should work as well. It should to be selected for all groups, especially “Icon” and “Message Box”.

Step 2: Chinese locale

Even with the right fonts, when you choose the Chinese language in the MT4 “View” - “Language” the labels can be garbled. MT4 uses the current Windows locale for non-Unicode programs as the UI language. To change it in Windows 7 you need to go to “Control Panel” - “Region and Language” - “Administrative” - “Change system locale”:

Windows 7 locale settings

After that restart Windows and you should get MetaTrader with the Chinese UI and messages. The MQL scripts using Print function should be working at this point.

int init() {
    Print("utf8 ru привет = \x043F\x0440\x0438\x0432\x0435\x0442");
    Print("utf8 cn 朋友你好 = \x670B\x53CB\x4F60\x597D");
    return (0);
}

Step 3: “nquotes.mq4” recompilation

Finally, the “nquotes.mq4” file needs to be recompiled. Somehow the MT4 remembers an active locale in the “nquotes.ex4” at the time it was created. To recompile it just open “nquotes.mq4” in MetaEditor and hit F7 “Compile”. This file can be found in the “Experts” folder. Alternatively right-click it in the navigator list of EAs, choose “Edit”, and then “Compile”.

In the end it works like this:

NQuotes prints Chinese characters

Those lines were printed with this C# code using NQuotes:

public override int init() {
    Print("utf8 привет = \u043F\u0440\u0438\u0432\u0435\u0442");
    Print("utf8 朋友你好 = \u670B\u53CB\u4F60\u597D");
    return 0;
}