Martin schrieb:
On 11/10/2011 02:46, Marco van de Voort wrote:
In our previous episode, Martin said:
Now my question.
Is there (or going to be) an encoding, that is "unknown" and will never
be converted. but can be assigned to any of the types?
Afaik, there is no such thing in Delphi.
Slight change in topic:
What encoding does a pchar have? Or rather what does it get, when for
example assigned to a rawbytestring?
Good question. Delphi claims that AnsiChar corresponds to the first 256
Unicode characters, but this may not always hold :-(
what happens (or is intended to happen), if I cast a string to pchar,
before handing it over as param?
procedure foo(a: Utf8String);
.....
var s: string;
foo(pchar(s));
This will work only when "string" is UTF-16, since PChar is a pointer to
Unicode. You can try figure out what copies and conversions the compiler
may insert, in order to match the given casts and argument types.
or
foo(pchar(@s[2]));
In all cases a temporary UTF8string will be used, matching the strong
argument type of foo.
See also: ms-help://embarcadero.rs_xe/vcl/System.PAnsiChar.html
DoDi
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel