Sam Sam - 1 year ago 91 Question

How to write Unicode characters to the console?

I was wondering if it was possible, in a console application, to write characters like

using .NET. When I try to write this character, the console outputs a question mark.

Answer Source

It's likely that your output encoding is set to ASCII. Try using this (MSDN link) before sending output:

Console.OutputEncoding = System.Text.Encoding.Unicode

and here's a little console test app you may find handy:


using System;
using System.Text;

public static class MyClass {
    public static void Main() {
        Console.OutputEncoding = System.Text.Encoding.UTF8;
        for (var i = 0; i <= 1000; i++) {
            if (i % 50 == 0) { // break every 50 chars


imports Microsoft.VisualBasic
imports System

public module MyModule
    Sub Main()
        Console.OutputEncoding = System.Text.Encoding.UTF8
        dim i as integer
        for i = 0 to 1000
            if i mod 50 = 0 'break every 50 chars 
            end if
    End Sub
end module

It's also possible that your choice of Console font does not support that particular character. Click on the Windows Toolbar Menu (icon like C:.) and select Properties -> Font. Try some other fonts to see if they display your character properly:

picture of console font edit