karotte,
@karotte@chaos.social avatar

So you're developing a cross-platform library that deals with filenames as a const char * (or the equivalent thereof)? On Windows, please treat the the filenames as UTF-8 and internally convert them to UTF-16 to call the Unicode Windows APIs or only have a wchar_t* function available.

DO NOT pass the filename as-is to the ANSI Windows APIs. With char * being treated as UTF-8 encoded text, this appears to work until an umlaut or another non-ASCII character appears in a filename.

Thank you.

gsuberland,
@gsuberland@chaos.social avatar

@karotte yes; the older *A functions (e.g. CreateFileA) expect a Windows-1252 (ISO 8859-1 superset) string. that codepage does contain many accented characters, but it is not byte-compatible with UTF-8 so passing UTF-8 strings in will bite you in the ass.

use MultiByteToWideChar to convert UTF-8 to UTF-16, then call the *W suffixed API rather than the *A suffixed API.

(or mbstowcs in C++)

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • DreamBathrooms
  • magazineikmin
  • everett
  • InstantRegret
  • rosin
  • Youngstown
  • slotface
  • love
  • khanakhh
  • kavyap
  • tacticalgear
  • GTA5RPClips
  • thenastyranch
  • modclub
  • megavids
  • mdbf
  • normalnudes
  • Durango
  • ethstaker
  • osvaldo12
  • cubers
  • ngwrru68w68
  • tester
  • anitta
  • cisconetworking
  • Leos
  • provamag3
  • JUstTest
  • All magazines