Home > Mobile >  Printing a sharp sign character
Printing a sharp sign character

Time:03-21

I am trying to print this Unicode character(and many others) but the Console displays a ?. It should print the sharp sign https://unicode-table.com/en/266F/ Could you please help me? "kjfnv" is in UTF-16BE, I have tried it in UTF-16LE too (6F 26), but it does not work

char kjfnv = '\u6F26';

CodePudding user response:

I am trying to print this Unicode character(and many others) but the Console displays a '?'.

The problem is not with the character, but it's the console not being configured the correct font to display this character.

You can manually set a console's Font, here's a tutorial on how to do it. I don't know of a way to set it programmatically (yet).

https://www.tenforums.com/tutorials/93961-change-console-window-font-font-size-windows.html

Here's a .net Fiddle: https://dotnetfiddle.net/xLvRq2

using System;
                    
public class Program
{
    public static void Main()
    {
        char kjfnv = '\u266F';
        Console.WriteLine(kjfnv);
    }
}

Output:


Update:

my personal set of applicable fonts in the console is very limited - meaning: I am not able to display the character.

However, the .net fiddle proves the methodology is correct - meaning: changing your console host, or find a way to make use of the correct font in Console should do the trick.

Here's a article on how to change fonts in powershell. Possibly a similar thing exists for the default console host: https://community.idera.com/database-tools/powershell/powertips/b/tips/posts/adding-more-fonts-to-powershell-console


@EricMovsessian: wasn't able to get this working without seriously needing to change some default values. For me this is not worth further investigation.

Keep in mind Console graphic capabilities are very limited, perhaps you want to consider an alternative technique, or just use the number sign # as a substitute

  •  Tags:  
  • c#
  • Related