question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Codepoints above 127 not rendering on Windows

See original GitHub issue

DrawText as implemented in Raylib-cs only supports codepoints up to 127 in Windows – all characters above that gets rendered as “?”. This is kind of annoying, as I’m a swedish programming teacher, and we have a few special extended ascii-characters; å, ä and ö are part of a lit of swedish words.

Things I’ve tried:

  • DrawText and DrawTextEx. Same result.
  • Loading different fonts, with or without explicit inclusion of codepoints up to 255. Same result.
  • Getting the latest Raylib-cs from the github page. Same result as with the nuget package.
  • Running the same code but in a virtual Debian machine. THIS WORKS, so issue seems to be in Windows.
  • Asking a friend who’s proficient in C/C++ to try using åäö using Raylib in C++. THIS WORKS, so the issue seems to be specific to Raylib-cs, even though it’s just a wrapper?
  • DrawTextCodepoint. THIS WORKS, which means that for some reason the issue is specific to the DrawText methods (and InitWindow). Raylib is supposed to be Unicode-capable, and this proves that at least in theory, it is.

Here’s my simple test code (just writes out characters 0-255):

static void Main(string[] args)
{
  int font_size = 10;
  Raylib.InitWindow(800, font_size * 64, "åäö");
  while (!Raylib.WindowShouldClose())
  {
    Raylib.BeginDrawing();
    Raylib.ClearBackground(Color.BEIGE);
    for (int i = 0; i < 255; i++)
    {
      int col = i / 64;
      int x = col * 200;
      int y = (i % 64) * font_size;
      string text = i.ToString() + " | " + ((char)i).ToString();

      Raylib.DrawText(text, x, y, font_size, Color.BLACK);
    }
    Raylib.EndDrawing();
  }
}

It works fine in Debian, as stated, but in Windows columns 3 and 4 are filled with ?😒 and the window titlebar is also just ???.

An nice fellow on StackOverflow, who definitely deems to know more than me about these kind of things, had this to say:

The way the library imports DrawText is faulty; its default behavior “marshals” string values to fit a legacy character encoding, not necessarily UTF-8: github.com/ChrisDill/Raylib-cs/blob/… . (Specifying CharSet=Unicode probably won’t help because the DrawText function doesn’t use wide-character strings, but rather ordinary char* pointers interpreted as UTF-8.)

(Peter O)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
krankcommented, Jan 15, 2021

Thanks, @ChrisDill, can confirm both workarounds work here as well! I’ll pass the first one on to my students immediately.

Very grateful for fast & helpful response; I’ll be using this as an example in the classroom on how git/github, open source and issue tracking is supposed to work =)

0reactions
SWCreeperKingcommented, Jun 7, 2021

I’m trying to display the pi character (π, U+03C0), but no matter what I do, all I get are underline characters. Is there any way to draw it to the screen? It seems to be at least somewhat related to this issue.

I’m using the NuGet package for Raylib-cs 3.7.0.

I believe its the same issue, I tried drawing text with a 127 unicode and it drew an underscore. I am also using Raylib-cs 3.7.0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CP437 "low ASCII" characters not working in the v2 console
Apps trying to render ANSI-art should simply #define UNICODE and use proper code-point anyway as box-drawings and block-elements might not map ...
Read more >
Different codepoints for same character in MacOS and ...
1 Answer 1 · Thanks for explaining why 195 is returned on windows. · "I tired java -Dfile. · It seems like the...
Read more >
UTF-8, Extended ASCII, Character Set Encoding, Collisions
It recognizes the Extended ASCII character set to be ISO-8859-1 and converts the single-byte characters above code point 127 into UTF-8 multibyte characters....
Read more >
Windows Command-Line: Unicode and UTF-8 Output Text ...
One problem, for example, is that because UCS-2 is a fixed-width 16-bit encoding, it is unable to represent all Unicode codepoints. Another ...
Read more >
Is it possible to delete ANSI characters such as Ââ in ...
hello, I have a lots of ANSI characters such as Â|â in multiple UTF-8 files. How to delete them? With notepad++, I try...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found