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

Support unicode characters in standard output #76

Closed

Conversation

treyhunner
Copy link

This prints out ! © ⌚ 🌈 ! (which includes 2-byte, 3-byte, and 4-byte UTF-8 characters as well as the 1-byte ! marks).

print("!  \u00a9  \u231a  \U0001f308  !")

Currently it looks like this:

image

After this pull request it looks like this:

image

I only implemented this fix for standard output, but a similar fix could be done for standard error as well.

@pmp-p
Copy link
Contributor

pmp-p commented Apr 23, 2022

hi, what's the difference with #74 which applies to stdin/stderr ?

@treyhunner
Copy link
Author

One thing I noticed in testing my solution is that grapheme clusters don't seem to render correctly. A rainbow flag and US flag show up as an overlapping white flag and rainbow and an overlapping U and S:

image

I'm not sure whether xterm.js, the font being used, or something else is causing that behavior. With the version of this code I'm using on the Python Morsels pastebin site, grapheme clusters show up properly merged (https://pym.dev/p/23qza/):
image

@treyhunner
Copy link
Author

hi, what's the difference with #74 which applies to stdin/stderr ?

I honestly hadn't seen that pull request before starting this one. If #74 works, it looks like it may be an even simpler solution.

@pmp-p
Copy link
Contributor

pmp-p commented Apr 23, 2022

it looks like it may be an even simpler solution.

please confirm because i use a different xterm (with sixel) and i don't have same extended font installed on it. the last two chars appear as squares on my setup so i can't be sure.

@treyhunner
Copy link
Author

@pmp-p I just tried #74 and it didn't seem to work on my machine (running in Google Chrome):

image

@pmp-p
Copy link
Contributor

pmp-p commented Apr 23, 2022

nvm found the font, #74 works fine for me

>>>                                                                            ┌───────────────┐
>>>                                                                            │22:38:37 ☢ 99% │
>>>                                                                            └───────────────┘
>>> print("!  \u00a9  \u231a  \U0001f308  !")
!  ©  ⌚  🌈  !
>>> 

maybe not all xterm.js versions react the same vs browser that could be a problem. ( my setup is here https://pmp-p.github.io/pygame-wasm/python311.html )

@treyhunner
Copy link
Author

Closing this in favor of #77.

@treyhunner treyhunner closed this Apr 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants