haxeui-hxwidgets icon indicating copy to clipboard operation
haxeui-hxwidgets copied to clipboard

Can not display chinese

Open hlizard opened this issue 5 years ago • 8 comments
trafficstars

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

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

hlizard avatar Aug 05 '20 04:08 hlizard

what version of haxe / hxcpp are you using?

ianharrigan avatar Aug 05 '20 05:08 ianharrigan

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

hlizard avatar Aug 05 '20 08:08 hlizard

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.

ianharrigan avatar Aug 05 '20 19:08 ianharrigan

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

hlizard avatar Aug 06 '20 01:08 hlizard

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

ianharrigan avatar Aug 06 '20 05:08 ianharrigan

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 avatar Aug 06 '20 08:08 hlizard

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

hlizard avatar Feb 26 '21 02:02 hlizard

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?

tabris17 avatar Feb 21 '24 03:02 tabris17