0

Simple Task: I want to find out how the Windows explorer is sorting

for that purpose I want to create folders with a single unicode chars as name, but i dont get how you print all unicode characters ...

via '\u0xxx' my compiler says i can't use them for the base charset.

im pretty sure there has to be a simple answer but im not gettin it.

kxc0re
  • 25
  • 6
  • Possible duplicate: [How to print unicode character in C++?](http://stackoverflow.com/questions/12015571/how-to-print-unicode-character-in-c) – JBentley Jan 10 '14 at 13:18
  • 1
    Do you really want to print *all* Unicode characters? There are currently over 100,000 code points assigned to characters (some of which are by definition non-printable). – Jukka K. Korpela Jan 10 '14 at 13:40
  • well at least the printable ones i thought it would be easier to just skip them with an error then gettin the needed ranges by hand – kxc0re Jan 10 '14 at 14:18
  • 1
    Regarding explorer, what if it's using the "sorting intuitively" feature? – Chris O Jan 10 '14 at 15:05

2 Answers2

0
for(WCHAR i = 0; i < WCHAR_MAX; ++i)
    create_directory_somehow(i);

(You may need to #include "wchar.h")

But I also think it's not a good idea - the file system may not like it...

Maciek
  • 148
  • 6
0

Okay I solved it with the help of Macieks comment :D

for(WCHAR i = 0; i < WCHAR_MAX; ++i)
{
    LPCWSTR lpcChar = &wcChar;
    CreateDirectoryW(lpcChar,NULL);
}

Thanks a lot i knew it has to be some easy way to do this

kxc0re
  • 25
  • 6
  • 3
    This won't print out all Unicode characters. It will only print the first 65,536 characters (some of which aren't actually valid Unicode characters), while Unicode v6.3 supports 110,187 different characters. – ntoskrnl Jan 10 '14 at 21:34
  • 1
    You need to null-terminate the string you pass to `CreateDirectoryW()`. You can use a `WCHAR[2]` array for that. – Remy Lebeau Jan 11 '14 at 16:32
  • 1
    Windows is based on UTF-16, and `wchar_t` is 16-bit on Windows. Your example only covers codepoints in the BMP. It does not cover codepoints that use surrogate pairs in UTF-16. Windows supports surrogates, even in file/folder names. If you really want to loop through ALL codepoints then loop using an `int` from 0 to 0x10FFFF, converting each value to a UTF-16 sequence as needed, and then using that sequence as the folder name. – Remy Lebeau Jan 11 '14 at 16:35