The conversion to/from WideString
on OSX doesn't work for me.
In a large program, all string
s are assumed to be UTF-8 and everything works fine. Recently, a library using WideString
has been added and it works nicely on Linux, but fails on OSX. All non-ASCII chars get replaced by question marks (not by some strange chars, but exactly by U+003F), no matter what direction gets used. I could extract the problem into the following snippet:
VAR s: String; ws: WideString;
...
s := 'Maß'; // A string with some non-ASCII character
ws := LazUTF8.UTF8ToUTF16(s); // Works fine.
// ws := s; // *** Uncomment this and fail.
s := LazUTF8.UTF16ToUTF8(ws); // Works fine.
// s := ws; // *** Uncomment this and fail.
IF Pos('?', s) > 0 THEN RAISE Exception.Create('Blown!');
Uncommenting one or both lines marked with ***
leads to an exception. It looks like some default ASCII-only conversion gets used, but I have no idea why as OSX is said to always use UTF-8.
Including cwstring changes nothing at all. There's /usr/lib/libiconv.2.4.0.dylib
installed there. Adding it via -liconv
explicitly changes nothing either.
It's Lazarus 1.2.6 und FPC 2.6.4 on OSX 10.8. Any way to make the automated conversion work?