+ 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 Respostas
+ 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>