Lazarus

Programming => General => Topic started by: Pascal on October 12, 2018, 10:19:25 am

Title: CreateDirUTF8 vs. CreateDir and others
Post by: Pascal on October 12, 2018, 10:19:25 am
Which one should i use?
Title: Re: CreateDirUTF8 vs. CreateDir and others
Post by: Bart on October 12, 2018, 03:08:40 pm
The UFT8 file function were created to deal with unicode on Windows before fpc had codepage aware strings.

The "normal" functions from fpc should work OK, even with unicode filenames.
In Lazarus this works out of the box, because strings are encoded as UTF8 and the file functions use Windows widestring API, so conversion is lossless.

However, if you don't use Lazarus with default setting (i.e. if you define DisableUTF8RTL), or if you use plain pascal, then character encoding of strings is CP_ACP, which is one-byte codepage on Windows by default, and '€' in your sourcecode will be interpreted on the basis ofe users codepage (like it was in the "good old DOS" days, so you may get unexpected results.

Bart
TinyPortal © 2005-2018