1

I'm having trouble running this code. I have a file Program.cs with the following line

Console.WriteLine("\u280B"); // Braile dots: ⠋

I'm on Windows 10 running .NET 7 in PowerShell Core. When I dotnet run it, it just outputs ?. If I change the encoding to UTF8 I get a box with a question mark (if I copy it here, it shows the real icon). I'm just trying to create a little spinner à la node.js. I also cannot print a character like "℃", but I can print special characters like "âäçàî".

I have tried the following, mostly from from this answer:

  • Setting Console.OutputEncoding to UTF8 (and Unicode and every other value)
  • Changing my console Font (JetBrains Mono, Consolas - these fonts render the correct unicode character in the IDE
  • Using the string literal instead of the unicode escape
  • Using cmd.exe and git bash instead of pwsh
  • Running the .exe instead of dotnet run

When I run this on an online compiler like .NET Fiddle it works.

Adam
  • 817
  • 8
  • 16
  • Could you please [edit] the question to confirm that you *can* print "℃" (or some similar characters) and have problem with just "\u280B"? (Realistically it should be duplicate of the linked question, and you should put bounty on that... but you are expected to say "f$$$$ you downvoting elitists" - so keeping it open) – Alexei Levenkov Apr 19 '23 at 16:45
  • 1
    Extrapolating how an IDE (or other GUI) displays text for given font doesn't tell you much about how a console will display text using the same font, because an IDE or other GUI may do font fallback, but the console not (depends on which console). – Paul Dempsey Apr 20 '23 at 00:11
  • Likely duplicate of https://stackoverflow.com/questions/38533903/set-c-sharp-console-application-to-unicode-output – Paul Dempsey Apr 20 '23 at 00:11
  • @AlexeiLevenkov I edited the question (I _cannot_ print that) – Adam Apr 20 '23 at 19:19
  • @PaulDempsey I think you solved it - I tried pasting it into Word which refused to change the font, likely due to fallback. If you'd like to post your answer as a response I'll accept it. I would not consider it a duplicate as basically every question I've seen on this suggests things I've tried. I'll rephrase the title to mention specifically braille because that's the sticking point here. I'll need a better spinner :shrug: – Adam Apr 20 '23 at 19:37
  • I would want to provide a good portable way to test whether a font contains a given character, but I can't think of something that's reliable. I usually use Windows charmap utility, which will only show characters actually in the font, but unfortunately stopped at approx Unicode 3.1, so doesn't cover newer code points. – Paul Dempsey Apr 21 '23 at 18:47
  • Does this answer your question? [Set C# console application to Unicode output](https://stackoverflow.com/questions/38533903/set-c-sharp-console-application-to-unicode-output) – E_net4 Apr 23 '23 at 15:25

1 Answers1

0

In this case, the font did not natively support the braille characters. The IDE was fooling me into believing that the character set was supported by using fallback.

I know this question and answer are similar to others posted, however none of the top answers in other posts seem to mention fallback, and I believe it may be useful for others to see a question which explicitly states the asker has tried all the other suggestions.

Adam
  • 817
  • 8
  • 16