6

As it is shown in below examples, i have tried various techniques to display tamil text by parsing its unicode content to the output window and it doesn't work. Please suggest as where i'm going wrong?

private static void PrintInTamil1()
{
    const string str = "தமிழ்"; // this is already a unicode string.

    byte[] stringBytes = Encoding.Unicode.GetBytes(str);
    char[] stringChars = Encoding.Unicode.GetChars(stringBytes);

    foreach (var chr in stringChars)
    {
        // unicode character code
        var unicoded = ((int)chr).ToString();

        // hex character code
        var hexcoded = @"\u" + ((int)chr).ToString("X4").ToLower();

        Console.OutputEncoding = Encoding.UTF8;
        // print to VS output window
        Console.WriteLine(chr + "     " + unicoded + "     " + hexcoded);
    }
}

private static void PrintInTamil2()
{
    byte[] unicodeBytes = new byte[]
    {0x61, 0x70, 0x70, 0x6C, 0x69, 0x63, 0x61,
     0x74, 0x69, 0x6F, 0x6E, 0x2F, 0x70, 0x63,
     0x61, 0x70};

    string unicodeString = Encoding.UTF8.GetString(unicodeBytes);

    Console.WriteLine(unicodeString);
}        

private static void PrintInTamil()
{
    string str = "தமிழ்";
    var myarray2 = Encoding.UTF8.GetBytes(str);
    string unicodeString = Encoding.UTF8.GetString(myarray2);
    Console.WriteLine(unicodeString);
}
CSDev
  • 3,177
  • 6
  • 19
  • 37
Manoj
  • 61
  • 4
  • 3
    `Console.OutputEncoding = Encoding.UTF8\Unicode;` then you will need a font that can display those characters, set the console property page to that font. which i think is going to be the hard part. none of the fonts i had could display those charcters – TheGeneral Nov 03 '18 at 06:39
  • Try installing Office 2013 or lower. It comes with Ariel Unicode. – Aron Nov 03 '18 at 07:07
  • Possible duplicate of [How to write Unicode characters to the console?](https://stackoverflow.com/questions/5750203/how-to-write-unicode-characters-to-the-console) – GSerg Apr 27 '19 at 12:01

0 Answers0