What encoding does the Alt + Numpad keys generate?

In short:

For this code:

Encoding.ASCII.GetBytes("‚")

I want the output to be 130, but that gives me 63.

I am typing a line using Alt + 0130.

+3
source share
2 answers

In my setup:

Encoding.ASCII.GetBytes("‚"); // 63
Encoding.Default.GetBytes("‚"); // 130

Of course, "default" may well be environment dependent ...

+2
source

If you try to encode a string using ASCII encoding, it will be converted to a question mark, since there is no such character in the ASCII character set. The character code for the question mark is 63.

You need to use an encoding that supports the character in order to get its actual character code.

Encoding.Default , . , , .

- 8218, int:

int characterCode = (int)'‚';

- , , .

+2

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


All Articles