Show quoted text 7 lines
I would think that that depends on where you get the value for
ForceDirectories(UTF8) from.
If this vale is obtained from any widget (OpenDialog, TEdit, etc.) the
encoding of the value is in UTF-8.
If however you get the value as a commandline parameter, then it is in
system-encoding if you use ParamStr(), but in UTF-8 if you use
ParamStrUTF8().
That's what I guessed, so Instead of using UTF8 version I would use this to ensure cross platform correctness:
Path := SelectDirectoryDialog1.FileName;
ForceDirectories(UTF8Decode(Path));
Right? Yesterday I found in this post (which triggered me to ask the question initially):
http://lists.lazarus.freepascal.org/pipermail/lazarus/2012-April/073170.html
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.
If so, we shall avoid using **UTF8 /3/3 Bart
Show quoted text 35 lines
On 3/2/13, Xiangrong Fang wrote:
> In order to write cross platform programs, shall I use ForceDirectories
or
> ForceDirectoriesUTF8? I would like to:
I would think that that depends on where you get the value for
ForceDirectories(UTF8) from.
If this vale is obtained from any widget (OpenDialog, TEdit, etc.) the
encoding of the value is in UTF-8.
If however you get the value as a commandline parameter, then it is in
system-encoding if you use ParamStr(), but in UTF-8 if you use
ParamStrUTF8().
So you would use:
Path := ParamStr(1);
ForceDirectories(Path);
or
Path := SelectDirectoryDialog1.FileName;
ForceDirectoriesUtf8(Path);
You need to be sure which encoding a string has when you pass it on to
such procedures/functions.
Bart
--
_______________________________________________
Lazarus mailing list
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130303/0385d72d/attachment.html>