简体   繁体   中英

How can I make my visual studio support more unicode characters?

在此处输入图片说明

I have a problem with a program I made in visual studio 2019. The code itself, or the algorithm is not wrong, because it works properly as I intended.

Yet, I got a problem, as I was adding patches to support other languages. I added the Korean and Spanish versions, but the Korean version comes out well but the Spanish don't. If you can see in that photo, which is the first scene of my program, the English and Korean characters' outputs are fine but for Spanish, it is printed as "Espa?ol", which is supposed to be printed as "Español".

I believe this is some presets problem or lack of language packs (which are related to Unicode systems) or so but I couldn't find anything to fix this problem. How can I fix this problem and let the Spanish characters appear properly?

For your information, I am using C++ in VS2019 and used the "string" type for all statements.

I am requesting your help to fix this problem. Thank you for your generosity.

It seems you need two things:

  1. Setting execution character set for your VC++ project.

https://docs.microsoft.com/en-us/cpp/build/reference/execution-charset-set-execution-character-set?view=vs-2019

Basically adding compiler option /utf-8 to Configuration Properties, C/C++, Command Line.

  1. Changing the code page for the console. Visual Studio use cmd for console application, and cmd may not handle Unicode character properly. You can execute your .exe program from an independent cmd instead, using an Unicode code page:
cmd>chcp 65001
cmd>out.exe
Hello Español!

Or calling the chcp command from inside your program.

system("chcp 65001");
cout << "Hello Español!" << endl;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM