No UNICODE in console?

I

Immortal Nephi

My source code is in UNICODE format text. Why didn’t wcout display
UNICODE to the console screen properly under Windows XP?
The message reads “6 <= 10”, but ‘<=’ is truly \x2264.

For example

wstring msg = L“6 \x2264 10”; // wstring holds UNICODE

wcout << msg << endl;

The screen only displays “6 “ and the rest characters do not
display. I think that wcout checks for null terminator before \x2264
and it stops to display.

Any clue?
 
G

Goran

        My source code is in UNICODE format text.  Why didn’t wcout display
UNICODE to the console screen properly under Windows XP?
        The message reads “6 <= 10”, but ‘<=’ is truly \x2264.

For example

        wstring msg = L“6 \x2264 10”; // wstring holds UNICODE

        wcout << msg << endl;

        The screen only displays “6 “ and the rest characters do not
display.  I think that wcout checks for null terminator before \x2264
and it stops to display.

wcout failed. Debug to see why. Try e.g. this:

std::wcout << L'\x2264';
if (!std::wcout)
{
int wtf=errno;
}

Goran.
 
I

Immortal Nephi

wcout failed. Debug to see why. Try e.g. this:

  std::wcout << L'\x2264';
  if (!std::wcout)
  {
    int wtf=errno;
  }

Goran.

It reports 42 to errno as EILSEQ. It is not C++ standard. Perhaps,
it means that \x2264 is an illegal character to UNICODE character.
 
J

James Kanze

My source code is in UNICODE format text. Why didn’t wcout
display UNICODE to the console screen properly under Windows
XP?
The message reads “6 <= 10”, but ‘<=’ is truly \x2264..
For example
wstring msg = L“6 \x2264 10”; // wstring holds UNICODE
wcout << msg << endl;
The screen only displays “6 “ and the rest characters do not
display. I think that wcout checks for null terminator before
\x2264 and it stops to display.

Regardless of the OS: for starters, a window can only display
characters present in the font it is using. Also, the encoding
used by the window (or its font) must correspond to that implied
by the embedded locale. Otherwise, it's highly likely that
problems will ensue.

With regards to MS-Windows: at least in western Europe, the
default codepage used by a console window does not contain a <=
character in its font.
 
J

James Kanze

It reports 42 to errno as EILSEQ. It is not C++ standard.
Perhaps, it means that \x2264 is an illegal character to
UNICODE character.

More likely it means that there is no equivalent character in
the imbued target narrow character translation.
 
S

Sprechen sie von C++

I have a cast for wchar_t to std::string that I have come to adore. No more
annoying problems.
 

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,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top