[Lazarus] Unicode on Windows

Mattias Gaertner nc-gaertnma at netcologne.de
Mon Apr 9 20:31:16 CEST 2012


On Mon, 09 Apr 2012 19:18:15 +0200
Jürgen Hestermann <juergen.hestermann at gmx.de> wrote:

> Marcos Douglas schrieb:
>  > For the Lazarus sources yes, but not for RTL.
>  > I still think about:
>  > DirectoryExists or DirectoryExistsUTF8
>  > ForceDirectoriesUTF8 or ForceDirectories
>  > Pos or UTF8Pos
>  > etc
>  > Depends what part of code you are...
> 
> 
> Yes, it's a real pain. I once used the Windows API function "CopyFile" 
> and because I knew that this API function uses Ansi coding I prepared my 
> code like this. But after some months my program suddenly crashed 
> because someone named a file my program reads with german umlauts. I 
> then discovered that a CopyFile function exists within the LCL too! 

CopyFile was added 2002-12-23 to the LCL FileCtrl with two string
parameters. The Windows CopyFile takes two PChar and one boolean, so
there was no chance to use the wrong one.
In 2004-09-27 an overloaded CopyFile was added to the LCL to
preserve time. This can indeed be misused when passing two constants as
file names. I never saw a bug report/note about it, so I guess this is
not a common case.


> Who 
> did build this trap? You cannot use the same name for an existing API 
> function and then silently convert it to UTF8 in the background (not 
> even mention this on 
> http://lazarus-ccr.sourceforge.net/docs/lcl/fileutil/copyfile.html ). 

The change of all LCL strings to UTF-8 was all but silent.

> This kind of issue hits me very often.

Where else?

Mattias




More information about the Lazarus mailing list