The best way is to use WideString.
For several reasons.
- It is Unicode and works up to D2009
- Memory management is carried out in ole32.dll, therefore there is no dependence on the Delphi memory manager or CLR GC.
- .
Oxygene :
type
Sample = static class
private
[UnmanagedExport]
method StringTest([MarshalAs(UnmanagedType.BStr)]input : String;
[MarshalAs(UnmanagedType.BStr)]out output : String);
end;
implementation
method Sample.StringTest(input : String; out output : String);
begin
output := input + "ä ~ î 暗";
end;
"MarshalAs" CLR, . Ansi (PAnsiChar), , , , .
Delphi:
procedure StringTest(const input : WideString; out output : WideString);
stdcall; external 'OxygeneLib';
var
input, output : WideString;
begin
input := 'A b c';
StringTest(input, output);
Writeln(output);
end.
, , .
PChar DLL. , , D7 D2009 ( dev)