Ashley Gullen (@AshleyGullen@mastodon.gamedev.place)
mastodon.gamedev.place
external-link
If you thought JavaScript was a mess, here's what it takes to pass a file path to a Windows API in C++: 🧵 - Windows uses UTF-16, but most modern software uses UTF-8 - Converting UTF-8 to UTF-16 requires calling MultiByteToWideChar twice (once for size, second to convert) - Alternatively you can set the process code page to UTF-8 and call the 'A' variant API directly, but only sometimes, and only with Windows 10 v1903+, and you might still have to change the system locale setting and reboot (1/3)

I assume this is not thr case for Linux

@AProfessional@lemmy.world
link
fedilink
English
20
edit-2
1Y

Linux APIs are 8bit, instead of 16bit, however the filesystem encoding can be anything if the user wants.

In practice we all use UTF-8 but correct software has to encode to the correct one just in case.

There is also still a max path length, but it’s longer like 4096.

Max-P
link
fedilink
7
edit-2
1Y

It’s better and worse at the same time: it just doesn’t bother with it for the most part. If you have files named with UTF-8 characters, and run it with a locale that uses an ISO-whatever charset, it just displays them wrong. As long as the byte is not a zero or an ASCII forward slash, it’ll take it.

There’s still a path length limit but it’s bigger: 255 bytes for filenames and 4096 bytes for a whole path. That’s bytes, not characters. So if you use UTF-16 like on Windows, those numbers are halved.

That said, it’s assumed to be UTF-8 these days and should be interpreted as UTF-8, nobody uses non-UTF-8 locales anymore. But you technically can.

Create a post

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person’s post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you’re posting long videos try to add in some form of tldr for those who don’t want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



  • 1 user online
  • 1 user / day
  • 1 user / week
  • 1 user / month
  • 1.11K users / 6 months
  • 1 subscriber
  • 1.21K Posts
  • 17.8K Comments
  • Modlog