<font>> <span style="font-family:courier new,monospace">I would think that that depends on where you get the value for<br>
> ForceDirectories(UTF8) from.<br>
> If this vale is obtained from any widget (OpenDialog, TEdit, etc.) the<br>
> encoding of the value is in UTF-8.<br>
> If however you get the value as a commandline parameter, then it is in<br>
> system-encoding if you use ParamStr(), but in UTF-8 if you use<br>
> ParamStrUTF8().<br><br>That's what I guessed, so Instead of using UTF8 version I would use this to ensure cross platform correctness:<br><br>
Path := SelectDirectoryDialog1.FileName;<br>ForceDirectories(UTF8Decode(Path));<br><br>Right? Yesterday I found in this post (which t<font>riggered me to <font>ask the question initially)</font></font>:<br></span><br><a href="http://lists.lazarus.freepascal.org/pipermail/lazarus/2012-April/073170.html">http://lists.lazarus.freepascal.org/pipermail/lazarus/2012-April/073170.html</a><br>
</font><pre><font><span style="color:rgb(0,0,153)">Such problems may (should) go away with the new Unicode- and AnsiString
types, where AnsiString contains an Encoding field. Then the conversion
between UTF-8 and the system codepage are done automatically, whenever
required, and the xyUTF8 functions can be dropped then.<br></span><br>If so, we shall avoid using **UTF8 functions at all.</font><br></pre><br><div class="gmail_quote">2013/3/3 Bart <span dir="ltr"><<a href="mailto:bartjunk64@gmail.com" target="_blank">bartjunk64@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 3/2/13, Xiangrong Fang <<a href="mailto:xrfang@gmail.com">xrfang@gmail.com</a>> wrote:<br>
<br>
> In order to write cross platform programs, shall I use ForceDirectories or<br>
> ForceDirectoriesUTF8? I would like to:<br>
<br>
</div>I would think that that depends on where you get the value for<br>
ForceDirectories(UTF8) from.<br>
If this vale is obtained from any widget (OpenDialog, TEdit, etc.) the<br>
encoding of the value is in UTF-8.<br>
If however you get the value as a commandline parameter, then it is in<br>
system-encoding if you use ParamStr(), but in UTF-8 if you use<br>
ParamStrUTF8().<br>
<br>
So you would use:<br>
<br>
Path := ParamStr(1);<br>
ForceDirectories(Path);<br>
<br>
or<br>
<br>
Path := SelectDirectoryDialog1.FileName;<br>
ForceDirectoriesUtf8(Path);<br>
<br>
You need to be sure which encoding a string has when you pass it on to<br>
such procedures/functions.<br>
<span class="HOEnZb"><font color="#888888"><br>
Bart<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
--<br>
_______________________________________________<br>
Lazarus mailing list<br>
<a href="mailto:Lazarus@lists.lazarus.freepascal.org">Lazarus@lists.lazarus.freepascal.org</a><br>
<a href="http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus" target="_blank">http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus</a><br>
</div></div></blockquote></div><br>