Does somebody know how to print out wild character with unicode value greater than 255

J

jackie

Here is my prolem: i try to output wstring with unicode value greater
than 255(for each wchar_t) to a file such as test.tmp. Here is my code:

wofstream outdata("test.tmp");
wstring s;
long l1=256;
long l2=250;
wchar_t c1=(wchar_t)l1;
wchar_t c2=(wchar_t)l2;
s+=l1;
s+=l2;
outdata<<s<<endl;
outdata.close();

However, there is nothing showes in the output file. But if i assign
any positive value less than 256 to l1 such as: long l1=255, it works
fine.
could someone please tell me what is wrong with my code and the
solution for it?
thanks!
 
R

Ron Natalie

jackie said:
Here is my prolem: i try to output wstring with unicode value greater
than 255(for each wchar_t) to a file such as test.tmp. Here is my code:

wofstream outdata("test.tmp");
wstring s;
long l1=256;
long l2=250;
wchar_t c1=(wchar_t)l1;
wchar_t c2=(wchar_t)l2;
s+=l1;
s+=l2;
Don't you want c1 and c2 here?
outdata<<s<<endl;
outdata.close();

Did you examine the output file with something that can inspect the
characters? Maybe your font doesn't have anything in those positions.
250 I don't even know what it should be. 256 is an A with a flat bar
over it...not a common character.
 
E

E. R. Jacobson

jackie said:
Here is my prolem: i try to output wstring with unicode value greater
than 255(for each wchar_t) to a file such as test.tmp.

Is it actually writing some characters to the file or is the file totally
empty?

If the former, you might try explicity opening the file as binary. If you
open it as text, your characters may converted to unreadble
ASCII.characters.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,830
Latest member
HeleneMull

Latest Threads

Top