Return code point of characters in C#

后端 未结 6 1284
梦谈多话
梦谈多话 2020-12-10 01:52

How can I return the Unicode Code Point of a character? For example, if the input is \"A\", then the output should be \"U+0041\". Ideally, a solution should take care of sur

6条回答
  •  时光取名叫无心
    2020-12-10 02:21

    public static string ToCodePointNotation(char c)
    {
    
        return "U+" + ((int)c).ToString("X4");
    }
    
    Console.WriteLine(ToCodePointNotation('a')); //U+0061
    

提交回复
热议问题