<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Dec 23, 2015 at 6:35 AM, Lubos Pintes <span dir="ltr"><<a href="mailto:lubos.pintes@gmail.com" target="_blank">lubos.pintes@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hello,<br>
I have a text in the WideString variable. I want to send this text to a SAPI5 synthesizer. I am doing this as follows:<br>
WideStr := Format('<pitch absmiddle="%d">%s</pitch>', [Pitch, Text]); </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">[...]</blockquote></div><div><br></div><div>Assuming that you tested it on Windows, you can't copy a AnsiString (FPC Format() is ansi on Windows) directly by pointing it to a WideString (your wide variable), and probably the compiler warns it with an 'Implicit string type conversion from "AnsiString" to "WideString"'. So, try it with a string type cast, something like this:</div><div><br></div><div><font face="monospace, monospace">WideStr := WideString(Format('<pitch absmiddle="%d">%s</pitch>', [Pitch, Text]));</font><br></div><div><br></div><div>Or use the SysUtils.WideFormat() function, that is wide:</div><div><br></div><div><font face="monospace, monospace">WideStr := WideFormat('<pitch absmiddle="%d">%s</pitch>', [Pitch, Text]);</font><br></div><div><br></div><div>Just for testing, I did it here and it worked fine (FPC 3.0):</div><div><div><br></div><div><div><font face="monospace, monospace">uses</font></div><div><font face="monospace, monospace"> SysUtils;</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">var</font></div><div><font face="monospace, monospace"> WideStr: WideString;</font></div><div><font face="monospace, monospace">begin</font></div><div><font face="monospace, monospace"> WideStr := WideString(Format('<pitch absmiddle="%d">%s</pitch>', [123, 'abc']));</font></div><div><font face="monospace, monospace"> WriteLn('String: ', WideStr);</font></div><div><font face="monospace, monospace"> WriteLn('Length: ', Length(BytesOf(WideStr)));</font></div><div><font face="monospace, monospace"> WideStr := '';</font></div><div><font face="monospace, monospace"> WideStr := WideFormat('<pitch absmiddle="%d">%s</pitch>', [123, 'abc']);</font></div><div><font face="monospace, monospace"> WriteLn('String: ', WideStr);</font></div><div><font face="monospace, monospace"> WriteLn('Length: ', Length(BytesOf(WideStr)));</font></div><div><font face="monospace, monospace">end.</font></div></div></div><div><br></div><div>Result:</div><div><br></div><div><div><font face="monospace, monospace">String: <pitch absmiddle="123">abc</pitch></font></div><div><font face="monospace, monospace">Length: 34</font></div><div><font face="monospace, monospace">String: <pitch absmiddle="123">abc</pitch></font></div><div><font face="monospace, monospace">Length: 34</font></div></div><div><br></div><div>However it is interesting if you send a minimal test program showing the entire problem and informing your SO, as the guys said for you.</div><div><br></div>-- <br><div><div dir="ltr"><div>Silvio Clécio</div></div></div>
</div></div>