How to write Unicode characters to the console?

后端 未结 5 1855
无人及你
无人及你 2020-11-22 00:27

I was wondering if it was possible, in a console application, to write characters like using .NET. When I try to write this character, the console outputs a q

5条回答
  •  执念已碎
    2020-11-22 01:04

    I found some elegant solution on MSDN

    System.Console.Write('\uXXXX') //XXXX is hex Unicode for character
    

    This simple program writes ℃ right on the screen.

    using System;
    
    public class Test
    {
        public static void Main()
        {
            Console.Write('\u2103'); //℃ character code
        }
    }
    

提交回复
热议问题