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

Jürgen Hestermann juergen.hestermann at gmx.de
Wed Dec 25 11:03:55 CET 2013


Am 2013-12-25 01:36, schrieb Hans-Peter Diettrich:
 > Whenever the encoding matters, most users and applications are best off
 > with their regional Ansi encoding - all used characters are single bytes.

You forget that using ANSI API functions on Windows not only has the drawback
that you cannot access all files (which have unicode characters in them)
but also that there is the limit of 255 characters for the path length
(while unicode API functions allow up to 32k characters).
So you run into problems in 2 cases:

1.) if strings (file names) contain non-ANSI unicode characters
2.) if paths are longer than 255 characters

Do you realy advice people nowadays to restrict their programs so far by using ANSI API functions?
I wouldn't. I was always wondering why so many programs fail with these 2 limitations on
Windows after an alternative has been available for such a long time.
Now you want to extent this time by yet another generation of programmers.
That's not good. Hopefully not too many programmers follow this road...

 > UTF-16 extends the range of languages whose characters can be assumed to have a fixed size,

That's not true.
You still you cannot rely on having a number of bytes for characters in UTF16 either.
Also, UTF8 would not have any BOM problem while UTF16 and UTF32 have.
So UTF16 has all drawbacks of all encodings but no benefit (except that this awfull decision is used by Windows).





More information about the Lazarus mailing list