This project is read-only.

Charset/Codepage selection. Unicode strings

Aug 20, 2013 at 3:57 PM

I recently started to work on a project based on mapwingis to be used particularly in asia. The first question that is raised is obviously character encoding. I didn't find a lot of information concerning unicode, and charset configuration about mapwingis.
So I briefly looked at the code and the different threads that talk about it and here is what i found :
1) Filepath and different strings are managed in unicode ( BSTR type is mostly used for every strings etc..)
2) Shapefile have a charset marker that is read but never used
3) A .cpg file is read by the dbfopen module, it reads a charset parameter from it but is never used.
4) The label drawing function uses : graphics.DrawString(wText, wcslen(wText) ...) that takes wchar string, and this string is converted using MultiByteToWideChar(CP_ACP, ...) with the current system codepage setting.
5) There is no way to get the codepage information of a shapefile

So in order to make mapwingis behave as expected for displaying different charset the idea is to use the charset parameter from the shapefile and the cpg file to convert the wtext used for writing to the label. This implies to have an encoding member to the label class.
and for displaying the attribute table using the charset specified in the file, retrive the shapefile charset by a method and convert it to wchar on the application side.
Another Option would be to migrate to wchar for all the strings that concerns shapefile, and make the encoding trasnlation when reading the DBF.

What do you think about those options ? Is there any work that has been done on unicode and encoding ? Or maybe is there hidden trick that i didn't see and in that case character encoding is supported for attribute table and labelling ?


Aug 21, 2013 at 10:39 AM
We are aware of the problems with unicode.
On several locations in the source code modifications need to be made to fully support unicode.
At this moment we don't have time to do so. Feel free to fix it yourself. If you provide patches we will make sure it will be merged into the source code.