Click here to Skip to main content
15,029,715 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have a test source code in VS 2019 in C language and it has Japanese character.
C++
#include<stdio.h>
#include<math.h>
int main()
{
printf_s("私はグエンチヴィエンです.京都情報大学院大学の新入生です\n");
printf_s("ベトナムの出身です");
int a = 2;
int b = 3;
int c = pow(a, 3) + pow(b, 4);
printf_s("%d", c);

When I compiled it it didn't show the Japanese message path. Instead it show the "?" all along the message.
I know this is called " Garbled Character" errors but don't know how to fix it
Can anyone suggest a solution for me?
Thank you very much!

What I have tried:

I have checked the "support Unicode UTF-8 for world wide language" in the Administrative language setting but it didn't work out for me
Posted
Updated 26-Apr-21 0:13am
v2
Comments
den2k88 26-Apr-21 5:02am
   
You are using CRT functions, those use the system locale to print characters. Check if you are using the en_US locale instead of ja_JP.

Refer to your Operating System documentation for how to change your locale.
Member 14629414 26-Apr-21 6:32am
   
@den2k88 I'm using en_US not ja_JP. Even when I changed my locale it still not work

1 solution

There is no C locale information compatible with printf, so your characters don't "know" what to print like, and the default font is no use.
Have a look here: Unicode in C and C++ - Cprogramming.com[^] - I haven't tried it, but it looks like it may help solve your problem.
   
Comments
Member 14629414 26-Apr-21 6:45am
   
@OriginalGriff Thank you for the info!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900