[fpc-pascal] WideStringReplace bug?

Lubos Pintes lubos.pintes at gmail.com
Tue Mar 28 11:22:07 CEST 2017

I am developing a console program which receives input in UTF-8, but it 
is converted to WideString for communication with COM.
I found a weird behaviour of the WideStringReplace, and I extracted the 
small program below:
program a;
{$apptype console}

uses SysUtils;

   U: UTF8String;
   W: WideString;

   U := 'left[*]paren';
   W := WideStringReplace(WideString(U), WideString('[*]'), WideString(' 
'), [rfReplaceAll]);

It seems to me that the output is garbaged, and it is not a problem of 
writeln, because I also obtained the weird result which was sent to SAPI.

More information about the fpc-pascal mailing list