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.
Dňa 23. 12. 2015 o 17:29 Mark Morgan Lloyd napísal(a):
Lubos Pintes wrote:
Hello Mark,The result isthe same, I tried it before I wrote my
message.I even tried to temporarily write ordinal codes of characters,
it seems that a string is not automatically converted to a WideString
when assigned, there wereno zeros, like H#0e#0l#0, etc.
Dňa 23. 12. 2015 o 11:07 Mark Morgan Lloyd napísal(a):> Lubos Pintes
wrote:>> Hello,>> I have a text in the WideString variable. I want to
send this text to>> a SAPI5 synthesizer. I am doing this as follows:>>
WideStr := Format('<pitch absmiddle="%d">%s</pitch>', [Pitch,
Text]);>> Pitch is integer, Text is WideString.>> The result is
incorrect, only a half of the Text contents is copied to>> the
result.>> Tested with Free Pascal Compiler version 3.1.1 [2015/11/14]
for i386>> Thanks>> What happens if the format string is put into a
temporary widestring?>
I suggest posting a *minimal* test program would be appropriate, and
telling us exactly what OS etc. you've got.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal