Quantcast
Channel: Active questions tagged utf-8 - Stack Overflow
Viewing all articles
Browse latest Browse all 1154

c++ can't get "wcout" to print unicode, and leave "cout" working

$
0
0

can't get "wcout" to print unicode string in multiple code pages, together with leaving "cout" to work

please help me get these 3 lines to work together.

std::wcout<<"abc "<<L'\u240d'<<" defg "<<L'א'<<" hijk"<<std::endl;std::cout<<"hello world from cout! \n";std::wcout<<"hello world from wcout! \n";

output:

abc hello world from cout!

i tried:

#include <io.h> #include <fcntl.h>_setmode(_fileno(stdout), _O_U8TEXT);

problem:"wcout" failed

tried:

std::locale mylocale("");std::wcout.imbue(mylocale);

and:

SetConsoleOutputCP(1251);

and

setlocale(LC_ALL, "");

and

SetConsoleCP(CP_UTF8)

Nothing worked


Viewing all articles
Browse latest Browse all 1154

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>