can anybody explain this to me? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

18th Dec 2017, 12:43 PM
Rabee Abbas
Rabee Abbas - avatar
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
18th Dec 2017, 2:19 PM
Zephyr Koo
Zephyr Koo - avatar
+ 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 Ã
18th Dec 2017, 1:53 PM
Dave
Dave - avatar
+ 2
@Dave that's right thank u
18th Dec 2017, 1:59 PM
Rabee Abbas
Rabee Abbas - avatar