Can the command line display unicode characters?

For instance:

cout << "δ½ ε₯½" << endl; 
+2
source share
5 answers

It depends on the platform and on the command line encoding.

However, you may have more luck with

 std::wcout << L"δ½ ε₯½" << std::endl; 
+3
source

Since you are talking about Windows, you are talking about console windows.

Windows console windows are based on Unicode, more specifically UCS-2 (the basic multilingual plane, essentially the original 16-bit Unicode).

Contrary to what was suggested in the other answers, you can no longer do more. results with std::wcout than with std::cout . Standard widescreen streams simply translate to the character encoding of a single byte of the program. By default, Windows uses OEM character encoding (which can be configured using an undocumented registry key).

But you can output Unicode through the console functions of the Windows API.

Note. It is not recommended to install console windows in UTF-8 . Then the command interpreter [cmd.exe] simply silently ignores most commands. At least in Windows XP and earlier.

Me I just installed OEM in Windows ANSI Western (via the mentioned undocumented registry key), and it works for most purposes, but not for Chinese, of course. This is code page 1252. Alternatively, you can do this manually using the chcp 1252 command in each instance of the command interpreter, as well as in other ways.

Cheers and hth.,

+2
source

Depends on the operating system and implementation. Currently, the active C ++ standard does not even talk about Unicode.

On Windows, I believe that you can use wide versions of characters. Then your code should be:

 std::wcout << L"ni3 hao3" << std::endl; 

However, you may have to enter Unicode character codes, because the code you use to write your C ++ source may not be Unicode.

+1
source

It all depends on the console / shell used.

Some shells can be configured to use UTF-8 (I did this once upon a time), so this can be done, but I forgot the details.

Before anyone can be more specific, we need to know the shell you are using and what platform the shell is running on (with full information about the versions of each of them).

+1
source

The Windows console partially supports Unicode. It does not support, for example, languages ​​from right to left.

Your cout example does not output unicode. Use wcout . Or use WriteConsoleW

+1
source

All Articles