How to emit UTF-8 from console mode program?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?U2llZ2ZyaWVkIEhlaW50emU=?=

    #1

    How to emit UTF-8 from console mode program?

    The following perl program prints the russian alphabet in Cryllic when I use
    the urxvt console from cygwin. It seems to understand UTF-8 better than
    cmd.exe.

    perl -wle "binmode STDOUT, q[:utf8]; print chr() for 0x410 .. 0x430;"

    How can I translate this program to C# and write a console mode C# program
    that emits UTF-8 and displays the proper Cryllic glyphs? I don't care what
    console it works with, cmd.exe or urxvt are fine.


  • Marc Gravell

    #2
    Re: How to emit UTF-8 from console mode program?

    I don't know how I would check it, but you could try changing the
    Console.OutputE ncoding. However, I suspect you might need to
    OpenStandardOut put() and write directly to the Stream; something like:

    using (StreamWriter writer = new StreamWriter(
    Console.OpenSta ndardOutput(),
    new UTF8Encoding(fa lse))) // no BOM
    {
    // write your glyphs to "writer"
    }

    Marc

    Comment

    • =?Utf-8?B?QWxoYW1icmEgRWlkb3MgRGVzYXJyb2xsbw==?=

      #3
      Re: How to emit UTF-8 from console mode program?

      using (StreamWriter writer = new StreamWriter(
      Console.OpenSta ndardOutput(),
      new UTF8Encoding(fa lse))) // no BOM
      {
      // write your glyphs to "writer"
      }
      What differences UTF-8 without BOM and with BOM ??

      Thanks.

      Comment

      Working...