[Lazarus] ForceDirectoriesUTF8
Bart
bartjunk64 at gmail.com
Sun Mar 3 00:37:39 CET 2013
On 3/2/13, Xiangrong Fang <xrfang at gmail.com> 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
More information about the Lazarus
mailing list