I believe it was possible to show Arabic characters on a console application 13+ years ago, since the days of Windows ME.
Now i am using Visual Studio 2013, On a Windows 8, and the following code shows:
????? ??
Console.OutputEncoding = System.Text.Encoding.Unicode;
Console.WriteLine("مرحبا بك");
Is there anyway to show Arabic characters in the console output?
There are several issues to resolve to get this to work.
See KB : Necessary criteria for fonts to be available in a command window
The font must be a fixed-pitch font. The font cannot be an italic font. The font cannot have a negative A or C space. If it is a TrueType font, it must be FF_MODERN. If it is not a TrueType font, it must be OEM_CHARSET.
For testing, I used DejaVu Mono, which is one of the few that supports Arabic. Arabic is a tough language to make a monotype font with since the aesthetics of the language do not work well with a fixed width for each character. Nevertheless, this font makes an honest effort. For other possible alternatives, see :
complete, monospaced Unicode font?
The font must be installed in the normal way for your version of Windows (in Vista/7/8 this is right-click, Install
on the .ttf file). Once this is done, you have to follow the directions in the KB.
000
" with the value DejaVu Sans Mono
Once you've rebooted, you can change the font in the console by selecting "Properties" from the console menu and changing the font in the "Font" tab.
Result.
... so after all that, we discover that the console does not support Right-To-Left languages. I guess you could use a function like :
static string Reverse(string text)
{
if (text == null) return null;
char[] array = text.ToCharArray();
Array.Reverse(array);
return new String(array);
}
and then do
Console.OutputEncoding = System.Text.Encoding.Unicode;
Console.WriteLine(Reverse("مرحبا بك"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With