> 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 functions at all. 2013/3/3 Bart <[email protected]> > On 3/2/13, Xiangrong Fang <[email protected]> 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 > [email protected] > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus >
-- _______________________________________________ Lazarus mailing list [email protected] http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
