29th Apr 2021, 6:26 PM
Atul [Inactive]
5 ответов
+ 2
Console.OutputEncoding = Encoding.Unicode; What is the meaning of this line?
30th Apr 2021, 4:58 AM
Atul [Inactive]
+ 1
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { Console.OutputEncoding = Encoding.Unicode; Console.WriteLine("x²"); } } }
29th Apr 2021, 6:38 PM
RKK
RKK - avatar
+ 1
From the syntax itself, it should be clear that that line is encoding some characters that couldn't be found in ASCII. Basically, it's the taking char and converting/encoding to unicode. Why do we need encoding? character encoding provides a key to unlock (ie. crack) the code. It is a set of mappings between the bytes in the computer and the characters in the character set. Without the key, the data looks like garbage(like in your case a question mark?)
30th Apr 2021, 5:21 AM
RKK
RKK - avatar
+ 1
I'm not sure maybe Microsoft .net works differently. Well, you can research that yourself and have fun. :)
30th Apr 2021, 5:29 PM
RKK
RKK - avatar
0
So Console. OutputEncoding=Encoding.Unicode is an inbuilt method in java strings
30th Apr 2021, 10:15 AM
Atul [Inactive]