Closed sakkyoi closed 2 months ago
So you tested with relevant characters on MacOS? But not on Windows?
I apologize for my incomplete explanation. I initially noticed this issue on Windows, so I fixed it. However, I also noticed that Windows handles this differently compared to Linux and macOS. I tested it on macOS, and it showed that macOS can natively handle Unicode character input perfectly.
Took me a while to get the Japanese keyboard to work on windows, but here is what I found:
This seems to mostly work as expected. Linux is fine as is, as you have found with Mac:
windows work for all characters I tested, but breaks on emojis for some reason:
After my investigation, it appears that some emojis are encoded using UTF-8 surrogates, which may appear as two characters in the terminal (you can observe this if you select them with your cursor). This is related to the issue of "surrogates not allowed." Perhaps you could use a try-except block to handle UnicodeEncodeError, as this error is raised by getwchar().
I might have found a solution, so please stay tuned.
After my investigation, it appears that some emojis are encoded using UTF-8 surrogates, which may appear as two characters in the terminal
Still strang that it works fine on linux
Linux works fine without this issue.
this seems to be a good solution, but I would prefer that code in the readkey()
function, as it handles identically to the combined key-presses. Surrogates are also made up of two chars that don't make sense on their own.
I will implement that now
I tested it on macOS without any issues. The original problem seems to occur only on Windows.