[fpc-pascal] FileIO in FPC 3.0

Andreas Dorn adornno1 at web.de
Fri Sep 25 12:52:41 CEST 2015


On Fri, 25 Sep 2015, Michael Van Canneyt wrote:

> It uses UTF16 on windows, not a codepage aware string.
> So if you use widestring for all your filename strings, there will be no problem. No conversions will happen.
 
If I understand that correctly, it stores the filename in a string that
has been tagged as valid UTF-16.

Do I then have to be careful about any automagic conversions?
Of course anything that assumes that a conversion of an UTF-16 tagged string to an 
UTF-8 one is lossless has to be avoided.

Is it safe to pass the Filename to procedures from the RTL without risking corruption?


For me this is more a general problem when dealing with external data.
Should I tag raw external data as UTF-16/UTF-8 and be super-careful,
or should I tag it as some kind of "raw" string (which one?) and handle
any conversions manually.

For me Filenames are more a type that has some kind of affinity to an
encoding for display, but I'd rather not tag its content as valid UTF-16
- any magic internal conversion is potentially lossy.

All in all I think if everything works for filenames, everything else will follow...

(Now lets better not start about the encoding of Filenames on non-Windows OS... :-))



More information about the fpc-pascal mailing list