I am writting a simple C++ programm and I want to generate outputs to the console but with the functions 'fwrite' and 'printf'. However, I can't print special characters like 'á', 'é', ... Here is a simple code:

printf("Special character: 'ñ'");

Were the output was ±
I found that those characters are printed as ascii but they were encoded in Utf8. I don't know how to make this output visible correctly, I'm using the Microsoft Visual Studio. Any help?

Recommended Answers

All 3 Replies

This thread might help

I already tried SetConsoleOutputCP(65001); but nothing happended. I also tried WideCharToMultiByte(codepage, 0, unicode, lenW, 0, 0, NULL, NULL); but it wrote 2 characters for each one.

On my system the console seems to use ASCII for output as well. I'm not sure if there is a class that will convert the characters, but you could use the Character Map(Programs/Accessories/SystemTools), and set the character set to DOS and the language of your omputer. That will give you the hex number for the ASCII code.

wChar_t c = 0x99;
wcout << c;

will output Ö on my system.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.