I have a function to convert a string to a Unicode string:
private string UnicodeString(string text)
{
return Encoding.UTF8.GetString(Encoding.ASCII.GetB
private string UnicodeString(string text)
{
return text;
}
The string text
is already in Unicode. All internal C# strings are Unicode. When you convert it to ASCII you lose characters. That is why you get ????? ????.
Just do plain simple Console.WriteLine("добры дзень");
no need for any conversion.
First, change the output encoding to UTF8:
Console.OutputEncoding = Encoding.UTF8;
Console.WriteLine("добры дзень");
Now you'll still see question marks. The reason is that the default console's font doesn't support Cyrillic letters. Change the font of the console:
If you're lucky, you should find a different font with Unicode support:
Change the font, and you should be able to see your text:
In the general case, if you want to display all Unicode characters reliably, the Console is probably not right for you. See also: C# console font (the comments are interesting too)