Results 1 to 3 of 3
Hello,
I have been playing with utf32 characters and I cannot get the following working:
Code:
#include <iostream>
using namespace std;
int main(int argnum, char *argstr[])
{
wprintf(L"test\n");
setlocale(LC_CTYPE,"th_TH");
wchar_t ...
- 03-01-2010 #1Just Joined!
- Join Date
- Jan 2008
- Posts
- 19
c++ wchar_t
Hello,
I have been playing with utf32 characters and I cannot get the following working:
The problem is thatCode:#include <iostream> using namespace std; int main(int argnum, char *argstr[]) { wprintf(L"test\n"); setlocale(LC_CTYPE,"th_TH"); wchar_t c=0xe5b;//L'ข'; unsigned long test = (unsigned long)c; wcout<<L"value "<<test<<endl; wprintf(L"hex: %lc %x\n",c,test); return 0; }always returns "hex: ? e5b" (the question mark is the issue).Code:wprintf(L"hex: %lc %x\n",c,test);
Can anybody please tell me what is incorrect in my code?
thanks in advance,
Regards Meereck
- 03-01-2010 #2Just Joined!
- Join Date
- Aug 2007
- Posts
- 7
Hi,
Two things jump out at me.
1. The size of wchar_t is implementation dependent. On all of the platforms I've worked with, wchar_t is actually 16 bits, not 32bits.
2. Just because you can specify a unicode character by hex value, doesn't mean your OS actually has anything to map it to. Do you have that language installed on your machine? If not that may explain the question mark.
- 03-13-2010 #3Just Joined!
- Join Date
- Jan 2008
- Posts
- 19
Hi,
I think it is 32bit on my Ubuntu 9.10 32bit:
Returns 4Code:wchar_t c=0xe5b;//L'ข'; wcout <<L"size:"<<sizeof(c)<<endl;
2) Hmm, you are right, I think that is the cause
Thank you
Regards Meereck


Reply With Quote