问题
I'd like to retrieve the ANSI code value of a given character. E.g. when I now get the int value of the trademark character, I get 8482. Instead I would like to get 153, which is the value of the trademark character in codepage 1252.
Some help would be appreciated.
Jurgen
回答1:
Found it myself:
Encoding ansiEncoding = Encoding.GetEncoding(1252);
byte[] bytes = ansiEncoding.GetBytes(c);
int code = bytes[0];
来源:https://stackoverflow.com/questions/12370812/c-sharp-get-ansi-code-value-of-a-character