[Lazarus] ForceDirectoriesUTF8
Jürgen Hestermann
juergen.hestermann at gmx.de
Sun Mar 3 13:12:30 CET 2013
I have had the same problem with all the different string encodings arround:
Windows API-function can have ANSI or UTF16 encoding.
FPC-RTL file functions are restricted to 255 characters (so only ANSI file names are possible).
Linux seems to have UTF8.
The LCL is UTF8 and the IDE can have different encodings (UTF8 as default).
So I see no way to avoid the hassle to learn all the string encodings of all libraries you use.
I am now trying to use UTF8 encoded strings in my programs as much as possible.
The LCL expects this encoding and I can have it in the IDE editor too (so no conversion is needed for constant strings).
Then I wrote procedures/functions for all cases where a conversion is needed which take UTF8 strings as parameters
and convert them to UFT16 or ANSI internally if needed.
Also, when reading file names on Windows I capsulate this in a procedure,
use UTF16 API functions if possible (to avoid the 255 characters limit)
and convert them to UTF8 immediately.
So the conversion part is isolated in these small routines and the overall general
encoding stays UTF8. UTF8 is a good compromise because it's not so memory waisting as UTF16 is.
More information about the Lazarus
mailing list