About the author
While working on the Android2DelphiImport tool, I had to get strings converted into the PAnsiChar format.
A little known record, TMarshaller, in System.SysUtils helped. It has various methods to deal with string conversions and memory allocation, and when your method exits, it cleans up the memory for you as well.
Here's how I got my PAnsiChar.
var
M: TMarshaller;
P:
Pointer
;
begin
...
P := M
.
AsAnsi(
'We are about to be converted into a PChar'
).ToPointer;
// P is now a PAnsiChar
// Similarly, to get a UTF8String, M.AsUtf8('Use the source!').ToPointer;
end
Thanks that helped me! Keep posting, it really helps !