[fpc-pascal] Assigning string constant to a WideString and the Format function
wkitty42 at windstream.net
wkitty42 at windstream.net
Thu Dec 24 15:26:17 CET 2015
On 12/24/2015 07:44 AM, Lubos Pintes wrote:
> Hello,
> Here is a minimal program, it doesn't work as I expected either because there is
> a bug somewhere in the RTL, or, more probably, I misunderstood something.
> Basically, I am reading an UTF-8 encoded text from stdin, and collecting it in a
> WideChar array. I am assigning UTF-8 string to a WideString, and then collecting
> chars from it into the mentioned array.
> Then I am using a SetString procedure to recreate the WideString from collected
> chars.
> Here is a simple program which demonstrates this:
>
> program a;
> {$mode delphi}
>
> uses SysUtils;
>
> var
> U: UTF8String;
> S, W: WideString;
>
> begin
> U := 'Hello';
> W := U;
> SetString(S, @W[1], Length(W));
> W := Format(WideString('%s'), [S]);
> Writeln(W);
> end.
Free Pascal Compiler version 3.1.1 [2015/06/13] for x86_64
Copyright (c) 1993-2015 by Florian Klaempfl and others
(1002) Target OS: Linux for x86-64
(3104) Compiling /home/myuser/tmp/project1.lpr
/home/myuser/tmp/project1.lpr(12,8) Warning: (4104) Implicit string type
conversion from "UTF8String" to "WideString"
/home/myuser/tmp/project1.lpr(14,8) Warning: (4104) Implicit string type
conversion from "AnsiString" to "WideString"
~/tmp/project1
Hel
--
NOTE: No off-list assistance is given without prior approval.
*Please keep mailing list traffic on the list* unless
private contact is specifically requested and granted.
More information about the fpc-pascal
mailing list