Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Change text encoding in UTFGrid driver to work with Windows #5342
The use of the ICONV encoding "UCS-4LE" in the maputfgrid.cpp encoding causes junk output on Windows.
Changing this to "UCS-2LE" produces the correct output on Windows. I'm not sure if this also works
The only other place the encoding is specified is in the Windows-only MS SQL driver which uses "UCS-2LE"
I'm not sure of the exact difference between the two encodings. The most detailed descriptions I could find were:
"UCS2LE is a direct byte encoding of the first plane in which the low byte comes first"
"UCS4LE is a four byte direct encodings of of ISO-10646. UCS4LE puts the low byte first. "
Looking at https://www.gnu.org/software/libc/manual/html_node/iconv-Examples.html, I'd suggest trying "WCHAR_T" although I'm not sure. I found elsewhere that wchar_t on Windows was only 2 bytes wide, whereas it is 4 bytes on Unix systems, hence "UCS-4LE" is indeed inappropriate for Windows and wchar_t.
@rouault thanks for the comment. I have tried the "WCHAR_T" encoding, as UCS-2LE broke the Linux tests on Travis.
A couple more links I found that might be relevant: http://stackoverflow.com/a/40150716/179520
This link says WCHAR_T doesn't work correctly on OSX, and the best approach is to use macros.