views:

96

answers:

2

I could have sworn I used a chr() function 40 minutes ago but can't find the file. I know it can go up to 256 so I use this:

std::string chars = "";
chars += (char) 42; //etc

So that's alright, but I really want to access unicode characters. Can I do (w_char) 512? Or maybe something just like the unichr() function in python, I just can't find a way to access any of those characters.

+2  A: 

The Unicode character type is probably wchar_t in your compiler. Also, you will want to use std::wstring to hold a wide string.

std::wstring chars = L"";
chars += (wchar_t) 442; //etc
Greg Hewgill
+2  A: 

Why would you ever want to do that instead of just 'x' or whatever the character is? L'x' for wide characters.

However, if you have a desperate need, you can do (wchar_t)1004. wchar_t can be 16bit (normally Visual Studio) or 32bit(normally GCC). C++0x comes with char16_t and char32_t, and std::u16string.

DeadMG