Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

COMMON: Add string encoding API with more informative error behavior #4017

wants to merge 1 commit into
base: master
Choose a base branch


Copy link

@elasota elasota commented Jun 19, 2022

This updates the string encode API to return a status code indicating whether the encoding completely succeeded, or if it contains errors.

Currently, unmappable characters are just silently encoded as "?" so there is no way to determine if a Unicode code point is valid on a particular code page other than seeing if it comes out as "?" when the input character wasn't "?" which is a pretty gnarly hack.

The mTropolis engine needs this to filter out keystrokes that don't map to a valid character.

Copy link

@athrxx athrxx commented Jun 19, 2022

I am not sure if I understand the description correctly, but it seems that you're assuming that the keyboard events from our event manager are Unicode. They're not. At least the ports based on SDL send the keyboard events encoded as ISO 8859-1. You'll then have to know the codepage used by your game and its fonts and use that for re-encoding. There is no multibyte support for the keyboard input (only the ISO 8859-1), so you can't really find out experimentally by looking for empty codepoints or error chars. In the range from 128 to 255, you'll just get wrong characters if you use the wrong codepage, no error chars.

Copy link
Contributor Author

@elasota elasota commented Jun 20, 2022

edit: Nevermind, misinterpreted. So no way to get the actual Unicode code point right now either...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet
2 participants