Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Write Hebrew Characters on Console Window, C# [duplicate]

How can the user be able to write Hebrew Characters in console window which appears now to show question marks, This is what I Have:

        Encoding hebrewEncoding = Encoding.GetEncoding("Windows-1255");
        Console.InputEncoding = Encoding.GetEncoding("Windows-1255");
        Console.WriteLine("Write your input:");
        string Input = Console.ReadLine();
like image 828
Mayer Spitz Avatar asked May 17 '17 20:05

Mayer Spitz


2 Answers

Simply changed InputEncoding to OutputEncoding:

Console.OutputEncoding = Encoding.GetEncoding("Windows-1255");
like image 131
Mayer Spitz Avatar answered Nov 14 '22 21:11

Mayer Spitz


First make sure you set the registry like explained here : איך אפשר לראות עברית ב

run -> regedit --rightclick choose new string.

After that Try this instead :

     Console.OutputEncoding = new UTF8Encoding();
     Console.InputEncoding = new UTF8Encoding();
       Console.WriteLine("Write your input:");
            string Input = Console.ReadLine();

If you want output only :

//It will display hebrew letter to console 
  Console.OutputEncoding = new UTF8Encoding();
       Console.WriteLine("\u05D0\u05D1");
        Console.WriteLine("אריאל");
        Console.WriteLine(new string("אריאל".Reverse().ToArray()));
like image 38
napi15 Avatar answered Nov 14 '22 22:11

napi15