General XMetaL Discussion
lerche May 21, 2018 at 10:01 am
XMetaL Developer: MCR-File with UTF-8 EncodingMay 21, 2018 at 10:01 amParticipants 2Replies 3Last Activity 4 years, 4 months ago
Currently I have problems with letters like ä, ö, ü or ß. These letters are converted into cryptic characters.
My Question relates to the following system:
XMetaL(R) Author Enterprise 12.0.0.077
XMetaL(R) Developer Version 12.0.0.077
Visual Studio 2015 (Community Edition) Update 3
OS: Windows 10 Pro, English
Thank you for your help!
Renétonys May 21, 2018 at 9:53 pm
Reply to: XMetaL Developer: MCR-File with UTF-8 EncodingMay 21, 2018 at 9:53 pm
To change the encoding of an XML file:
- open it in XMetaL
- switch to plain text mode
- edit the encoding=”…” in the XML declaration
- save the file
To change to UTF-8 you can just remove the encoding, since UTF-8 is the default.
When you open a .mcr file in XMetaL it will probably ask you to locate macros.dtd – this can be found in the Author/Rules folder.Derek Read May 25, 2018 at 11:24 pm
Reply to: XMetaL Developer: MCR-File with UTF-8 EncodingMay 25, 2018 at 11:24 pm
It looks like even when a .JS file is created in an XMetaL Developer 12 project and saved using the correct encoding (in this case UTF-8) when you build the project the MCR file that is generated can be encoded using UTF-16 LE for some reason.
At this point I don't know why this occurs, whether this is a Visual Studio issue, or whether XMetaL Developer can be made to control this.
The main issue is not the encoding however. XMetaL Author is capable of reading UTF-16 encoded MCR files or UTF-8 encoded MCR files. The issue is that for whatever reason, some characters are encoded incorrectly into the MCR file(in your example these include ä, ö, ü or ß). As far as I can tell the file is being written out as UTF-16 but the encoding for these characters is actually appears to be Latin1 for some reason.
The only immediate solution I can think of (unfortunately) is to build the MCR file as usual then open it directly in a text editor and replace incorrectly encoded characters before resaving the file (either as UTF-16 or UTF-8). Seems really painful.Derek Read May 25, 2018 at 11:56 pm
Reply to: XMetaL Developer: MCR-File with UTF-8 EncodingMay 25, 2018 at 11:56 pm
OK, so here's my fix:
1. Open your .JS file in XMetaL Developer's script editor (double click on it in the Project window).
2. In the Visual Studio main menu open File and select Save As.
3. In the Save As dialog save using the same filename and path (to overwrite the file) but change the encoding (using the little arrow on the Save button) to “Unicode – Codepage 1200”. This is Microsoft's equivalent of UTF-16.
Note that this assumes your file contains the correct characters (if not fix them before step 3).
Now when you build the project the MCR file will be encoded to UTF-16 (which you cannot change) and because this .JS input file is in the same encoding (also UTF-16) there won't be any character encoding issues.
Why building a project doesn't trigger a proper encoding change from UTF-8 (or whatever other encoding you might have the .JS file in) into UTF-16 for the MCR file I don't know, but I don't know that it is worth looking into if the fix is this simple.
- You must be logged in to reply to this topic.