+ 1
can anybody explain this to me?
in the following code there are two casting operations from integer to char first one : 65 casted to char gives A second one : 195 casted to char gives A again. is that possible or something is wrong with the code? https://code.sololearn.com/cMBO53oP0oNR/?ref=app
3 Answers
+ 9
Interesting! After a quick finding online I found that by default C# console always use the machine's default encoding, in this case, SBCSCodePageEncoding which have limited support of extended ASCII.
You may use the following statement to determine it:-
Console.WriteLine(Console.OutputEncoding);
Besides, the output is dependent on the font used for the console as well. I'm able to display the expected character in my machine with Consolas after setting the encoding to UTF8 but not SoloLearn's online compiler.
Console.OutputEncoding = Encoding.UTF8;
Here's an interesting read I found @ Stack Overflow. đ
https://stackoverflow.com/q/3948089
+ 3
195 means Ă in extended ascii char sets,i think the compiler or the compier output must have not being supported the Ă symbol,so it think it must have returned A instead of Ă
+ 2
@Dave that's right thank u