[fpc-devel] bug report 20473: Please add a directive to define string=utf8string
Jonas Maebe
jonas.maebe at elis.ugent.be
Fri Oct 14 17:36:24 CEST 2011
On 13 Oct 2011, at 20:51, Craig Peterson wrote:
> BTW, I wanted to point out, to anyone arguing for full Delphi compatibility, that on OS X Delphi's DefaultSystemCodePage and AnsiString(0) are *not* the system encoding _or_ UTF-8. They're the Windows ANSI codepages that correspond to the system's locale (so, 1252 for US/UK versions). It's a weird gotcha, and means it's not safe to rely on AnsiString to communicate with system functions anymore.
My guess is that this is because of Delphi's behaviour to assume that the source code has been saved in the locale's default code page unless specified otherwise. If they'd changed the default code page to UTF-8 for all locales on Mac OS X, lots of Delphi source code would probably not compile correctly on Mac OS X without explicitly specifying the code page.
They could of course have changed this only in their compiler rather than also for end-user programs, but
a) that would be bad from a maintenance/dog food point of view
b) it would have resulted in run time code page conversions for all string constants on the developer's own system, since the compiler would have stored the constants in cp1252 or the like (the specific "compiler"-determined code page) and at run time they'd all be converted into UTF-8 (the actual "ansi" code page of the system)
Jonas
More information about the fpc-devel
mailing list