+ 1
Unicode text characters in Python
Anyone know an easy way to use special Unicode characters in Python that works with the playground? I want to incorporate some special characters (ā„ļøā£ļøā ļøā¦ļø) to represent the suits in my card program. Any ideas? Thank you for your help.š https://code.sololearn.com/cSXviY46eQdB/?ref=app
11 Answers
+ 4
The short answer is: I don't think so (means: I have code that supports my statements). For low unprintable characters, you need MSDOS codepage 437, which if enabled in your SoloLearn programs will prevent remapping BEFORE it's sent to you, but does nothing for the Android/browser output (which doesn't support DOS CP437).
Our programs appear to be jailed / hooked so stdin/stdout/stderr are sent to sockets or pipes (which is why I/O is all batched) and whatever intercepts is probably all single-byte processors (no characters >255, possibly a good security decision). Unicode is multi-byte, which I suspect -- if not encoded in a transport-safe way -- is unsupported at the client output panel (likely an Android text fragment).
Regardless of what we send, it looks like 1-byte characters only and may be a good device-/community-support decision (varying codepages and fonts at 9 million clients).
Related code cleanup tomorrow ... thought I'd at least say something today.
+ 8
I'm afraid little more can be expected to be printed out properly in Python's Code Playground -- than this:
https://code.sololearn.com/cGh63mKrL4iT/?ref=app
+ 7
You may want to cross-reference with this thread, where I link a Python code that switches code pages for slightly better output:
https://www.sololearn.com/Discuss/1183785/?ref=app
+ 4
Jordan Monk You can check out www.codeskulptor.org for creating Python, web-based games runable online.
Check out the BlackJack Gold link under here:
https://code.sololearn.com/W2nvcMqTRi4q/?ref=app
+ 2
CopperyMarrow15 Could you share the core, please?
+ 1
Thanks @ Kuba SiekierzyÅski. Iāve never heard of code sculptor before. Iāll have to give it a try. I enjoyed your webpage and your blackjack game. Thanks for the tip! š
0
Thanks for that
0
Thanks @ Kuba SiekierzyÅski. I was able to use the ASCII set of box drawing characters for making my cards but couldnāt find the symbols for the suits available. Years ago DOS based programming had them available in the ASCII set but Iāve since only been able to find them in Unicode. Iām having trouble using them with Python in the playground.
0
Thanks @ Kirk Schafer. Before posting my question I was able to research and find the code you posted. It was very helpful. The symbols Iām trying to use are listed as numbers 2660 - 2667. Iāve tried simply āprint(ā\u2660ā)ā but of course it didnāt work. Am I going about this all wrong? Maybe someone could look at my code and let me know what they think?
https://code.sololearn.com/cSXviY46eQdB/?ref=app
0
Thanks @Kirk Schafer. That makes perfect sense to me now. My programs work on the computer at home. As useful as it is the playground has its limitations. Maybe Iāll practice making some web based applications instead.
0
@Kuba SiekierzyÅski
hmm... I tried the good ol' copy pasta with with number 178 and got...
Traceback (most recent call last):
File "..\Playground\", line 1, in <module>
\ufeffprint('\u2593')
File "..\Playground\", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2593' in position 0: character maps to <undefined>