Andreea S
Andreea S

Reputation: 1

c# special characters compare strings

I have a problem with these two special characters from romanian language: ț and ș.

Example:
String s = "ștrumf";

The result is ?trumf when I write the string to console. Does anyone know what may be the reason?

Upvotes: 0

Views: 371

Answers (3)

Anar Iskenderov
Anar Iskenderov

Reputation: 46

You, should set Console.OutputEncoding as UTF8

    static void Main(string[] args)
    {
        Console.OutputEncoding = System.Text.Encoding.UTF8;
        String s = "ștrumf";
        Console.WriteLine(s);
        Console.ReadLine();
    }

Upvotes: 1

Tahsin Gül
Tahsin Gül

Reputation: 118

Try using this before sending output:

Console.OutputEncoding = System.Text.Encoding.UTF8;

Checkout this Reference

Upvotes: 1

Kemal Güler
Kemal Güler

Reputation: 614

Try this

Console.OutputEncoding = Encoding.UTF8;

Upvotes: 1

Related Questions