Console doesn’t display Arabic

The command prompt doesn’t have support of bidi languages. Therefore the components that run from the command line need not support Bidi languages. This is a limitation of Windows, which doesn’t support Bidi code pages in the console. So what should we do? Basically we have to fallback to another locale that is supported in the console. Basically we need to use GetConsoleFallbackUICulture and set this culture for our console application.

The code:

using System.Globalization;

        static void Main(string[] args)

        {

            // Set the Current

            System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo("ar-EG");

            // Show the Culture Info

            Console.WriteLine("Culture native name: {0}", CultureInfo.CurrentUICulture.NativeName);

            Console.WriteLine("Console fallback UI: {0}", CultureInfo.CurrentUICulture.GetConsoleFallbackUICulture().Name);

            // Change the UI Culture to the Console Fallback UI

            System.Threading.Thread.CurrentThread.CurrentUICulture =

                                  CultureInfo.CurrentUICulture.GetConsoleFallbackUICulture();

            Console.WriteLine("New UI Culture: {0}", CultureInfo.CurrentUICulture.NativeName);

        }

The expected output:

Culture native name: ??????? (???)

Console fallback UI: en

New UI Culture: English

 

The important line is to set the UI Culture properly at the beginning to load the correct resources:

System.Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo.CurrentUICulture.GetConsoleFallbackUICulture();