Unicode filenames in C++?

I'm trying to figure out how to support Unicode or atleast an unsigned char in the d_name of struct dirent

The problem i'm facing is that I'm checking file names for special characters and obviously the "char d_name" doesn't like it. I'm looping through the directory and getting the file names/folder names

"doesn't like it"? What do you mean?

You can easily cast a pointer to a char * into an unsigned char *.

I wrote this a while ago to read UTF-8 from strings, converting multibyte chars into their glyph numbers. (and single-byte ones too, trivial that might be. ;p)

thank you for this, I didn't know how to proceed on getting multibyte chars :slight_smile: the masks are a good thing 2 know

The masks are just a way of checking if characters have certain combinations of higher and lower bits set and cleared. octet_masks contains what bits should be checked, octet_res contains what the bits being checked should actually be. If it matches, it's the right encoding. Single-byte encoding is easy, octet_masks[0] is binary 10000000 and octet_res[0] is binary 00000000: Check bit 8, if it's clear, it's encoded single-byte. If not, add another char and check the next mask, etc, etc, until either one of them matches what it should be or you run out of masks to check and declare the first char to be an error. I could have done it with massive if-else-then chains but I hate those.