Answer the question
In order to leave comments, you need to log in
Is it possible to use Japanese characters in the console?
Good day to all! Thank you. that drew attention to this issue. What is the problem:
I have an array whose values come from a file:
string[] Symbols = File.ReadAllLines("Symbols.txt");
Answer the question
In order to leave comments, you need to log in
You need to set the encoding for what is output to the console, and switch the console itself to display code page 932.
public class Program
{
[DllImport("kernel32.dll", SetLastError = true)]
private static extern bool SetConsoleOutputCP(uint wCodePageID);
[DllImport("kernel32.dll", SetLastError = true)]
private static extern bool SetConsoleCP(uint wCodePageID);
private static void Main(string[] args)
{
SetConsoleOutputCP(932);
SetConsoleCP(932);
Console.OutputEncoding = Encoding.Unicode;
Console.WriteLine(@"一 人 七 八 九 十 入 二 三 上
下 大 女 万 土 山 千 川 子 小
口 手 五 日 六 分 中 円 月 午");
}
}
The file contains Japanese characters. And when a character is output to the console, instead of a character, it shows a question mark.
System.Console.OutputEncoding = Encoding.UTF8;
chcp 65001
. Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question