Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
30 Views

Escaped unicode characters

So here's a silly issue that I can't seem to find a good answer to after a frustrating attempt and search of the net/forums.

I have some simple code, that wants to print some unicode characters (sample drastically reduced):

cout << "hi " << "\\u2596" << " there" << endl ;


And it works just fine in gcc:
hi there

But icc spits a warning:
warning #27: character value is out of range
cout << "hi " << "\\u2596" << " there" << endl ;
^
And then doesn't print the correct character:
hi \\uffff there

I can work around it by doing:
char qux[] = {0xe2, 0x96, 0x96, 0x00};
cout << "hi " << qux << " there" << endl;

Where the sequence of characters is the internal representation of the symbol, and it ends up printing the right thing for both compilers, but depends on the terminal doing the right thing. It feels awful to do, though, and means destructing any unicode symbols we're using.

Clearly it doesn't seem like the correct workaround, but I'm at a loss for anything else to try. I've use casting, wcout (still produces a warning, and no output), L"\\u..." (still invalid symbol), and various combinations, all to no avail. Any other smart ideas out there?

Thanks in advance.
0 Kudos
3 Replies
Highlighted
Beginner
30 Views

*bump* Any ideas?
0 Kudos
Highlighted
Employee
30 Views

It looks like a bug :-)
We have entered this into our bug database and I'll let you know when we have a fix. If we come up with a better workaround, I'll let you know.
Sorry for the inconvenience.
Dale
0 Kudos
Highlighted
Moderator
30 Views

This is an old thread, but I'd like to add a note here to bring everyone to the same page: this issue has been fixed a while back from 13.1 and later.

Thanks,

Jennifer

0 Kudos