Author Topic: CreateDirUTF8 vs. CreateDir and others  (Read 688 times)


  • Hero Member
  • *****
  • Posts: 823
CreateDirUTF8 vs. CreateDir and others
« on: October 12, 2018, 10:19:25 am »
Which one should i use?
laz trunk - fpc trunk 32bit - Windows 10 Pro x64 (1803)


  • Hero Member
  • *****
  • Posts: 3431
    • Bart en Mariska's Webstek
Re: CreateDirUTF8 vs. CreateDir and others
« Reply #1 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.