[fpc-pascal] Problem with StrMove() in a unit compilable in FPC and Delphi

silvioprog silvioprog at gmail.com
Thu Feb 25 19:31:07 CET 2016


Hello,

I want to use the StrMove() function in a unit compilable in Delphi (XE)
and FPC, but I don't know why it doesn't work on FPC.

Consider the following code:

{$IFDEF FPC}
{$codepage utf8} // I need to keep my unit in UTF-8
{$ENDIF}

var
  a: AnsiString;
  la: Integer;
  pa: PAnsiChar;
  b: Byte;
  bs: TBytes;
begin
  a := 'aã';
  pa := @a[1];
  la := strlen(pa);
  WriteLn('L: ', la);
  SetLength(bs, la);
  StrMove(@bs[0], pa, la);
  for b in bs do
    WriteLn(b);
end;

On Delphi, I get:

*L: 2*
97
227

Perfect, checking it via a character map, the 227 is the keystroke Alt+0227
that is the "ã" character, however, when I try this code in FPC (from
trunk), I get:

*L: 3*
97
195
163

And finally a get a wrong content in my final buffer.

So, is the FPC StrMove() function compatible with the Delphi one?

Thank you!

-- 
Silvio Clécio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20160225/48ff872f/attachment.html>


More information about the fpc-pascal mailing list