Recent

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

Pascal

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

Bart

  • Hero Member
  • *****
  • Posts: 5275
    • 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.

Bart

 

TinyPortal © 2005-2018