haxeui / haxeui-hxwidgets

The hxWidgets backend of the HaxeUI framework -
http://haxeui.org
MIT License
23 stars 7 forks source link

Can not display chinese #25

Open hlizard opened 3 years ago

hlizard commented 3 years ago

image win10+Haxe 4.1.3: it's wrong ,Chinese garbled!

also https://github.com/HaxeFoundation/hxcpp/issues/842

ianharrigan commented 3 years ago

what version of haxe / hxcpp are you using?

hlizard commented 3 years ago

Haxe 4.1.3 hxcpp 4.1.15 haxeui-core 1.1.1 haxeui-hxwidgets 1.1.0 hxWidgets 1.6.0

ianharrigan commented 3 years ago

Obviously i dont speak Chinese, but would i be correct in thinking that the "trace" in your screenshot is also incorrect? If that is the case then it would seem to be a haxe issue - the issue you linked seemed to indicate there is a fix for it, though it may be in a nightly.

hlizard commented 3 years ago

Yes, "trace" is also incorrect, but there is a PR in hxcpp to "trace", but it no for GUI, may be is diff. Other, I found the neko, hashlink target of haxeui-openfl also not display Chinese(flash and html target is right), but some diff, Chinese is missing: image

Sorry, my english is poor.

also https://github.com/HaxeFoundation/hashlink/issues/406

ianharrigan commented 3 years ago

I would try that PR, or latest git version of hxcpp and see if that helps - im not too sure about OpenFL + HL.

In the meantime, could you paste some Chinese characters that i could test?

Thanks! Ian

hlizard commented 3 years ago
import haxe.ui.Toolkit;
import haxe.ui.components.Button;
import haxe.ui.containers.VBox;
import haxe.ui.core.Screen;

class Main {
    static function main() {
        trace("你好, 中国!");
        trace("你好, 中国!".length);

        Toolkit.init();

        var main = new VBox();

        var button1 = new Button();
        button1.text = "按钮 1";
        main.addComponent(button1);

        var button2 = new Button();
        button2.text = "按钮 2";
        main.addComponent(button2);

        var input = new TextField();
        main.addComponent(input);

        Screen.instance.addComponent(main);
    }
}
hlizard commented 3 years ago

Test on Linux no problem!

haxe=4.2.0 haxeui-core=1.2.2 haxeui-hxwidgets=1.2.1 haxeui_core=1.2.2 hxWidgets=1.7.1 hxcpp=4.2.1

tabris17 commented 4 months ago

This is a problem specific to Windows.

The reason for this problem is that hxwidgets uses utf-8 encoding, while the Chinese windows system uses cp936 (GBK) encoding by default.

You can refer to this article to solve the problem of Chinese garbled characters Use UTF-8 code pages in Windows apps

BTW: Should hxwidgets consider allowing users to customize UI string encoding?