imagine these line:

cout << "glória vitória"; //glory vitory

why instead print 'ó', prints '3/4'(the ascii char)???
changing the console font name, can resolve it?

Edited by cambalinho

3 Years
Discussion Span
Last Post by cambalinho

The good news is you can do it. The bad news is you have little choice but to use a platform dependent method to set the console into a wide character mode. For example:

#include <iostream>
#include <fcntl.h>
#include <io.h>

using namespace std;

int main()
    _setmode(_fileno(stdout), _O_U16TEXT);

    wcout << L"glória vitória\n";

sorry i get these error:
"error: converting to execution character set: Illegal byte sequence"


That's an issue with your code editor. If you can set the character set to something like Unicode, you should be good to go.

#include <clocale>
#include <iostream>

using namespace std;

int main() 
    setlocale(LC_ALL, "");//these is the important line
    cout << "úçéûi"; // yes the cout works too;)
    return 0;

thanks too all


The istream and ostream classes work with chars, rather than wchar_ts, and won't interpret wide chars correctly. However, changing them to work with wchar_t would break a large amount of existing code, so they have to be retained for backwards compatibility. Naturally, the standards commitee wanted to provide a portable solution to this, and to this end, the standard now defines wistream and wostream classes, and mirror objects for the standard input and output: wcin and wcout. To work with wide chars, you will want to use those instead of cin and cout.

Edited by Schol-R-LEA


after more search i found it ;)
here i use 'en_US.UTF-8' string option, but we can change it for other types

setlocale(LC_ALL, "en_US.UTF-8");

about it:

> The setlocale function installs the specified system locale or its portion as the new C locale. The modifications remain in effect and influences the execution of all locale-sensitive C library functions until the next call to setlocale. If locale is a null pointer, setlocale queries the current C locale without modifying it.
> Parameters
> category  -   locale category identifier, one of the LC_xxx macros. May be 0.
> locale    -   system-specific locale identifier. Can be "" for the user-preferred locale or "C" for the minimal locale
> Return value
> Pointer to a narrow null-terminated string identifying the C locale after applying the changes, if any, or null pointer on failure.

heres the page about it:

thansk for all... thanks

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.