[Lazarus] Beyond Compare 4 built with Lazarus 1.2

Michael Van Canneyt michael at freepascal.org
Tue Dec 31 15:04:50 CET 2013



On Tue, 31 Dec 2013, Jürgen Hestermann wrote:

> There it says:
>
> ---------------------
> function SysErrorMessage(
>  ErrorCode: Integer
> ):;
> SysErrorMessage returns a string that describes the operating system error 
> code ErrorCode.
> ---------------------
>
> Yet another documentation bug?

All appearances of string were 'annihilated' in the 2.6.2 release due to a bug in fpdoc.

> What kind of string is given back?
> But even if it would say "string" it would  be of no use for me.
> Which encoding?

Ansistring = The system encoding.

> How should a user find out what he has to do in his program
> to display a correct string in a ShowMessage() or whatever?
> This is a real mess.
> Actually I found out by trial and error that
>
>      ShowMessage(Trim(SysToUTF8(SysErrorMessage(GetLastError))));
>
> is required to get a correct string (Trim is needed because trailing spaces 
> and tabs may appear).

Simple logic would have told you this in about 30 seconds.

>
> I would expect that for all these functions where stings are involved at 
> least a link
> to the encoding is added that tells the user that he will get back an
> AnsiString with System-ANSI-encoding (or whatever he will get back on other 
> OS's).
> How else should a user find out about this?

Simple: an object pascal programmer should know that

String = Ansistring

Or he must stop programming Object Pascal at once.

Additionally, from this, BY DEFINITION, it follows that the encoding is system encoding.

The FPC 2.6.x RTL uses ansistring everywhere and therefor supports system encoding only.

It's really this simple rule:

String = Ansistring => System encoding.

Michael.


More information about the Lazarus mailing list