+ 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

26th Apr 2018, 6:28 PM
Jordan Monk
Jordan Monk - avatar
11 Respuestas
+ 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.
28th Apr 2018, 2:42 AM
Kirk Schafer
Kirk Schafer - avatar
+ 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
26th Apr 2018, 7:46 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 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
26th Apr 2018, 6:45 PM
Kirk Schafer
Kirk Schafer - avatar
+ 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
28th Apr 2018, 2:33 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 2
CopperyMarrow15 Could you share the core, please?
14th Oct 2019, 7:35 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 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! 😀
28th Apr 2018, 7:03 PM
Jordan Monk
Jordan Monk - avatar
0
Thanks for that
26th Apr 2018, 7:14 PM
Joe Mabbort
Joe Mabbort - avatar
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.
27th Apr 2018, 12:59 AM
Jordan Monk
Jordan Monk - avatar
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
27th Apr 2018, 1:07 AM
Jordan Monk
Jordan Monk - avatar
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.
28th Apr 2018, 1:46 PM
Jordan Monk
Jordan Monk - avatar
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>
14th Oct 2019, 1:44 PM
CopperyMarrow15
CopperyMarrow15 - avatar