[fpc-pascal] Summary of Unicode Strings Debate

Michael Van Canneyt michael at freepascal.org
Wed May 11 16:44:59 CEST 2016



On Wed, 11 May 2016, Mazo Winst wrote:

> Hello,
>
> A summary of what i learned from the Unicode String debate:
>
> 1 - FPC 3 introduces code page aware strings
>
> 2 - FPC 3 updates the RTL to provide a better support for code page aware
> strings
>
> 3 - The dynamic behavior of the string type regarding to the platform was
> not introduced by FPC 3. In the previous versions of FPC, the string type
> depends on the platform too.

The string type does not depend on the platform.

The only thing that depends on the platform is the default encoding used in an AnsiString.

But that was true in FPC 2.6.4 as well: 
On windows that would have been CP_ACP, on unix UTF8. Now this is simply settable.

(Jonas can confirm/deny this)

> 4 - However, there is a key difference among FPC 3 and the previous
> versions: in the FPC 3, the compiler do perform automatic conversions in
> certain circumstances (two ansistring variables with diferent codepages). I
> think these automatic conversions can potentially be the source of
> unexpected data corruption.

In such cases the codepage is determined by the declared code page of the
result string. (Jonas should be able to confirm/deny this).

If the codepages cannot be converted correctly, then the data may be corrupted.

> 5 - The automatic conversion is a desirable feature. IMHO, the definitive
> solution would be to stop the unpredictable dynamic behavior of the String
> type following the same path that Delphi followed: addopt the same unicode
> string code page on all platforms.
>
> 6 - A workaround when developing a cross-platform app is to use the Lazarus
> Unicode Support
> <http://wiki.freepascal.org/Better_Unicode_Support_in_Lazarus>;

Huh ? What kind of statement is this ?
What do you think Lazarus uses under the hood ? 
Last I looked, it was FPC :-)

It seems to me that most people simply do not understand fully what is
happening, and as a result, a lot of misunderstandings are abound.

Michael.



More information about the fpc-pascal mailing list