1

I am using Visual Studio 2010 and I want to print Unicode characters in it console mode (Bengali Unicode Characters).

I am compressing database content in console, and I need to print it in console to test my exact compressed/decompressed data. But the output is three garbage characters:

enter image description here

Here's the code. I also tried (Console.OutputEncoding = Encoding.UTF8).

using System;
using System.Text;
namespace Unicode_Printing_in_console
{
    class Program
    {
        static void Main(string[] args)
        {
            char ch = 'আ';// hex value=0985
            Console.WriteLine(ch);
        }
    }
}

Here is the output of this program:

enter image description here

Muhammad Ashikuzzaman
  • 3,075
  • 6
  • 29
  • 53
  • What's the result so far? Did u get any errors? – Ghasem Sep 09 '14 at 09:16
  • The answer is a question mark(?). But I need to see the character. For my compressed or decompressed data to be tested. @AlexJolig Help me please. – Muhammad Ashikuzzaman Sep 09 '14 at 09:19
  • possible duplicate of [Displaying Arabic characters in C# console application](http://stackoverflow.com/questions/21751827/displaying-arabic-characters-in-c-sharp-console-application) Note that this question refers to Arabic characters, and the LTR writing direction issues do not apply, but the solution is generally the same. – J... Sep 09 '14 at 09:34
  • @Muhammad - for binary data, you usually [Hex Encode](https://en.wikipedia.org/wiki/Hexadecimal) it when you want to view/dump it. So the byte 0x12 is printed as the two-character ASCII string "12". – jww Sep 09 '14 at 10:06

1 Answers1

2

The primary issue with Unicode languages in the Windows console is that font support is limited (among other things) to monospace fonts. This answer details the steps to installing a new font for availability in the Windows Console :

https://stackoverflow.com/a/21753872/327083

Specific to this question is the content of Bengali characters. For full coverage, downloading and installing something like GNU Unifont would give 100% coverage of the Bengali block.

GNU Unifont

Community
  • 1
  • 1
J...
  • 30,968
  • 6
  • 66
  • 143
  • Arial Unicode MS is neither a Windows font (it belongs to Office), nor is it monospaced, so you shouldn't really use it in the console. Furthermore, Arial Unicode MS is a *fallback* font, intended to show *something* when no useful font exists. It has severe issues with several languages. – Joey Sep 09 '14 at 13:47
  • @Joey My mistake. I must have glanced at Arial's type foundry (which is named "Monospace") and got my wires crossed. MS = Microsoft, not MonoSpaced. The GNU font is probably the better choice in any case, and it is monospaced. – J... Sep 09 '14 at 15:35