Sven Barth schrieb:
> There is a difference between "String" being a "PChar" and having internal type conversions between "String" and "PChar".
> The former is never the case while the second one is true.
> "String" is defined as either being "AnsiString", "ShortString" or "UnicodeString" depending on the used compiler and settings. > Then again "PChar" is assignment compatible to "AnsiString", "ShortString" and "UnicodeString" and thus also to "String", > as "String" is one of those three types. This does not mean though that "String" is a "PChar".

Yes, ok. I see now what you mean.
In the end it all seems to be some missunderstanding when Felipe wrote:

----------------------------------
It would be a huge duplication of documentation to write in every
single Lazarus function that uses string that it expects UTF-8.

It would be like writing in every function that string means
longstring (aka ansistring), that the routine is not using a
shortstring ... well, this is obvious.
----------------------------------

where I answered:

----------------------------------
String is generic so it can be pchar, shortstring or ansistring or ....
----------------------------------

because I think that it is quite irrelevant what type of string (ShortString, AnsiString, pchar) is used for the parameter.
My concern was the encoding of the string (UTF-8, ANSI, UTF-16 or ...).
And you wrote:

----------------------------------
Please note that String can NEVER be PChar (though there is assignment compatibility between the two to some extent). The possible types for String are ShortString, AnsiString and maybe in the future (and in Delphi 2009+) UnicodeString.
----------------------------------

I only wanted to point out that there is no relation between these two types of information about string parameters in functions:

1.) If a parameter is defined as STRING it can be fed with (nearly) any type of string like shortstring, ansistring, pchar or whatever. It will be converted automatically. There is no fundamental need for the programmer to know which type is actually used internally by the function.

2.) The expected encoding of a parameter. If no encoding is documented then an essential information is missing for the programmer.

So I don't understand Felipe when he says that giving information 2.) is like giving information 1.). They are not related and of very different importance.


--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to