mui.CreateObject and umlauts

Discuss GUI programming with the MUI Royale plugin here
Post Reply
evil
Posts: 177
Joined: Mon Jun 14, 2010 1:38 pm

mui.CreateObject and umlauts

Post by evil »

Hello!

I have prolems with mui.createobject and german umlauts (I think, the problem will occur with other languages special letters,too).
As an exmple I take your MUI-Royale Example Dynamic1.hws
I replaced the wort "two" in line 7 of dynamic.xml to "zwö".
When I now display Dynamic1.hws, It will start correctly,as the gui will be opened with mui.creategui.
But when I click on "Newwindow", I will get an error message:
Error parsing XML: not well-formed (invalid token) (Line: 7)
File Dynamic1.hws (current line: 76 - In Function: CreateObject)

A Bug??

Merry Christmas!

George
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: mui.CreateObject and umlauts

Post by airsoftsoftwair »

No, it's not a bug. If you don't specify an encoding, XML will fall back to UTF-8 and "ö" is not a valid UTF-8 character, thus causing an error. So you either have to pass the correct UTF-8 code for "ö" or simply set the encoding to ISO 8859-1 by always starting your XML declarations with the following header:

Code: Select all

<?xml version="1.0" encoding="iso-8859-1"?>
Then it will work fine.
evil
Posts: 177
Joined: Mon Jun 14, 2010 1:38 pm

Re: mui.CreateObject and umlauts

Post by evil »

Okay.

My program will be localised.
It creates the xml-file in realtime while startup up.
That means, Artbase creates a new file and uses 1000s of WriteLine() to write a complete XML-file.
( there were other problems, which treated me to do it this way...).
This file contains the localised strings (about 350) for each supported language.
For german, I could use 8859-1. Does this encoding also run for polish chars (8859-2)??
If not, is there a workaround?
Would it be better, to change those strings later (after creation) with mui.set (id,contents)??
How would this work with "shorthelp"-strings?
Is there any other way to localise xml-files

Regars

George
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: mui.CreateObject and umlauts

Post by airsoftsoftwair »

evil wrote:It creates the xml-file in realtime while startup up.
That means, Artbase creates a new file and uses 1000s of Writeline() to write a complete XML-file.
( there were other problems, which treated me to do it this way...).
You don't have to use a file for this. You can just create it in a string and then pass this string to mui.CreateObject(). Many people wrongly assume that the XML definition has to be external because all my examples do it that way. But it's perfectly ok to create them in a string.
This file contains the localised strings (about 350) for each supported language.
For german, I could use 8859-1. Does this encoding also run for polish chars (8859-2)??
If not, is there a workaround?
No, MUI Royale only supports ISO 8859-1 and UTF-8 in its XML files. So if you need Eastern European characters, you have to use UTF-8.
Would it be better, to change those strings later (after creation) with mui.set (id,contents)??
How would this work with "shorthelp"-strings?
Changing the strings at runtime can be problematic because AFAIK MUI always uses the system's default charset and there's currently no way of passing UTF-8 to MUI directly. That's why you are better of doing as much as possible at creation time.
evil
Posts: 177
Joined: Mon Jun 14, 2010 1:38 pm

Re: mui.CreateObject and umlauts

Post by evil »

You don't have to use a file for this. You can just create it in a string and then pass this string to mui.CreateObject(). Many people wrongly assume that the XML definition has to be external because all my examples do it that way. But it's perfectly ok to create them in a string.
I know, but the whole xml-file is about 400kb in size. Its easier for me to put it into a file, first.
Also as it is localised, it would get more comples when adding hundreds of "..cat$[x].." into the string...
No, MUI Royale only supports ISO 8859-1 and UTF-8 in its XML files. So if you need Eastern European characters, you have to use UTF-8.
So I use ISO 8859-1 at the moment. My polish translator uses 8859-2 for cataloging. Does he see the correct letters inside ArtBase then??
Or are those "polish-specific" letters displayed wrong on his system???
Changing the strings at runtime can be problematic because AFAIK MUI always uses the system's default charset and there's currently no way of passing UTF-8 to MUI directly. That's why you are better of doing as much as possible at creation time.
Ok. So I will do it the standard way... as before....

Thanx!

George
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: mui.CreateObject and umlauts

Post by airsoftsoftwair »

So I use ISO 8859-1 at the moment. My polish translator uses 8859-2 for cataloging. Does he see the correct letters inside ArtBase then??
Or are those "polish-specific" letters displayed wrong on his system???
Yes, he should. He should provide the translated texts as UTF-8 and then you include them in an XML that uses UTF-8 encoding. Then everything should be displayed correctly on Polish systems (but not on your machine since your machine uses ISO 8859-1.... but you can test it on your machine, too, by simply switching language and charset to Polish temporarily).
evil
Posts: 177
Joined: Mon Jun 14, 2010 1:38 pm

Re: mui.CreateObject and umlauts

Post by evil »

Quite confusing at all...
Well, I will let him test the actual version and we will see....

Thanx for explanation!!

Best regards

George
Post Reply