C # - How did input ctrl + A turn into a smiley face?

After learning about Console.ReadLine () in depth, I found something very peculiar.

I wrote the following code in the main method in a console application in C #

string str = Console.ReadLine();
Console.WriteLine(str);
Console.WriteLine(str.Trim());
Console.ReadLine();

When I ran the code, I gave input as ctrl + A and hit enter. I see emoticons (I can’t send an image because I don’t have permission yet to do this).

I want to understand how he shows the emoticon ? If it does not show ^ A or empty / empty (empty, because when I tried to debug it, it showed the string value a "".)

+4
source share
2 answers

If you look at this encoding used by Console, you will see that it is used by IBM437.

: http://en.wikipedia.org/wiki/Code_page_437

, 1 .

ctrl + A, 1.

, .

        string str = Console.ReadLine();            
        Console.WriteLine((int)str[0]);  // Integer value of character.
        // Console.OutputEncoding ( to get further detail)
        Console.ReadLine();
+4

- , U + 0001 ( ) - , , -, , Ctrl-A... , Ctrl-G, U + 0007 ().

.NET, Windows ( , ) - Java, .

+3

Source: https://habr.com/ru/post/1568099/


All Articles