[Lazarus] Lazarus (UTF8) and Windows: SysToUTF8, UTF8ToSys... Is there a better solution?

Marcos Douglas md at delfire.net
Thu Dec 19 23:04:15 CET 2013


On Thu, Dec 19, 2013 at 2:33 PM, Jürgen Hestermann
<juergen.hestermann at gmx.de> wrote:
> Am 2013-12-18 02:16, schrieb Marcos Douglas:
>
>> On Tue, Dec 17, 2013 at 4:15 PM, Jürgen Hestermann
>> <juergen.hestermann at gmx.de> wrote:
>>> I am just writing a file manager for Windows (hopefully can port it to
>>> Linux
>>> later)
>>> and I don't see any performance problems by using UTF8 in my program
>>> while
>>> the API is UTF16.
>>> Most (if not all) things that I do with files take much longer than the
>>> string conversion so it does not matter much.
>> Ok. But how do you work, using SysToUTF8 / UTF8ToSys?
>
> I use the following:
>
> ---------------------------
> var X,Path : UTF8String;
>     FW     : Win32_Find_DataW;
>
> H := FindFirstFileW(pwidechar(UTF8Decode(WinAPIPathName(Path))),FW);
> ...
> X := UTF8Encode(UnicodeString(FW.cFileName));
> ---------------------------
>
> where WinAPIPathName just prepends the "\\?\" string to the pathname to
> overcome the 255 char length limitation.
> Path is the UTF8 string for the file search and X holds the found file
> name(s) in UTF8 notation.
> When I later need an API-call I convert back:
>
> ---------------------------
> ...
> Windows.DeleteFileW(pwidechar(UTF8Decode(WinAPIPathName(AppendDir(Pfad,X)))))
> ---------------------------

Well, the same problem...
If there is no solution (for now), I prefer using SysToUTF8/ UTF8ToSys
because is more simpler than use WideString API and conversion to
UnicodeString, UTF8Decode, etc. Don't you think?

Marcos Douglas




More information about the Lazarus mailing list