How to make XRC resources to support east asia language?

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Legol
Earned a small fee
Earned a small fee
Posts: 18
Joined: Sat Jan 15, 2005 11:56 am

How to make XRC resources to support east asia language?

Post by Legol »

wxWidgets xrc system is based on expat. expat do not support east asia language, such as Chinese, Korean...

For example, if using a Chinese string as a button caption in resource file,when the resource file was parsed and corresponding button was displayed, the Chinese string was changed into some un-recognizable characters.

How to fix this?

Many thanks!
Avi
Super wx Problem Solver
Super wx Problem Solver
Posts: 398
Joined: Mon Aug 30, 2004 9:27 pm
Location: Tel-Aviv, Israel

Post by Avi »

I have a bit offtopic question, if you use wxWidgets (and therefor xrc as well) in Unicode mode, would it still not support east asian languages? I mean, doesn't Unicode natively supports all these languages?
Legol
Earned a small fee
Earned a small fee
Posts: 18
Joined: Sat Jan 15, 2005 11:56 am

Post by Legol »

Avi wrote:I have a bit offtopic question, if you use wxWidgets (and therefor xrc as well) in Unicode mode, would it still not support east asian languages? I mean, doesn't Unicode natively supports all these languages?
yes,I'm using Unicode mode.
It looks as if expat or xrc system has done something "special" to change the characters,but obviously this special things is not welcomed by asian language. I don't know what expat or wxWidgets xrc system has done under the table, for I havn't dug into their source codes yet. I just hope I can find a solution here :), then I havn't need to study their long long codes...
naef_wy
In need of some credit
In need of some credit
Posts: 2
Joined: Fri Sep 02, 2005 3:17 am

I succeed used chinese string in xrc file

Post by naef_wy »

First: Convert the xrc file from ASCII to UTF-8;
Second: Replaced the first line of the XRC file with"<?xml version="1.0" encoding="UTF-8"?>" (or only change the encoding)
Three: either the normal or the unicode compile is ok.

Good Luck!
lowjoel
Part Of The Furniture
Part Of The Furniture
Posts: 1511
Joined: Sun Jun 19, 2005 11:37 am
Location: Singapore
Contact:

Post by lowjoel »

OK this sounds PARTIALLY weird, but just so you know (because I come from Web programming background aswell) there are escape codes to get your characters - look carefully for those that start with &xxxx; where xxxx is a code to represent your character.

If expat is coded to specification, it should know what the escape code means...
GeraldG
Experienced Solver
Experienced Solver
Posts: 85
Joined: Mon May 16, 2005 12:30 pm

Post by GeraldG »

I think you must call

wxXmlResource::Get()->SetFlags(0);

before wxXmlResource::Get()->Load(...) because you must disable the wxXRC_USE_LOCALE flag if non US-Ascii is used in xrc-file.

See:
http://www.wxwidgets.org/faqcmn.htm#xrclocale
Last edited by GeraldG on Mon Sep 05, 2005 1:08 pm, edited 2 times in total.
naef_wy
In need of some credit
In need of some credit
Posts: 2
Joined: Fri Sep 02, 2005 3:17 am

Post by naef_wy »

I apologize to lowjoel for my mistakes,"Replaced the first line of the XRC file with""" should be "Replaced the first line of the XRC file with"

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
"(I tried on my machine:xp pro cn, vc 71 cn, wxwidgets 2.6.0) ;
BTW:I tried "wxXmlResource::Get()->SetFlags(0); " before , but it seem to no effort to me.
waterj
Earned a small fee
Earned a small fee
Posts: 21
Joined: Mon Nov 07, 2005 8:39 am

Post by waterj »

naef_wy wrote:I apologize to lowjoel for my mistakes,"Replaced the first line of the XRC file with""" should be "Replaced the first line of the XRC file with"

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
"(I tried on my machine:xp pro cn, vc 71 cn, wxwidgets 2.6.0) ;
BTW:I tried "wxXmlResource::Get()->SetFlags(0); " before , but it seem to no effort to me.
I do things as you said. but wxWidgets xrc still can't handle Chinese words right. Are you sure you sample works?
waterj
Earned a small fee
Earned a small fee
Posts: 21
Joined: Mon Nov 07, 2005 8:39 am

Post by waterj »

naef_wy wrote:I apologize to lowjoel for my mistakes,"Replaced the first line of the XRC file with""" should be "Replaced the first line of the XRC file with"

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
"(I tried on my machine:xp pro cn, vc 71 cn, wxwidgets 2.6.0) ;
BTW:I tried "wxXmlResource::Get()->SetFlags(0); " before , but it seem to no effort to me.
I've dug into the wxXmlResource code, and i found that wxXmlResource::Get()->SetFlags(0) together with naef_wy's way works.
Post Reply