+ 1
Unicode Characters in Code Playground
Hi! :) Got this error: UnicodeEncodeError: 'charmap' codec can't encode character Any chance to use unicode characters in my python code in sololearn. I have some escape sequences in my code. The program runs without a problem on my linux box, but I know character encoding can be a bit tricky.
8 Respuestas
+ 4
You can try fiddling with the codepage and you might chance upon one with acceptable output:
https://code.sololearn.com/c6NQFsmNHz82/?ref=app
+ 4
(Actually, there might be a solution to this now if you're still around; not escape sequences but unicode)
+ 4
Add these two lines to the top of your program:
import sys, codecs
sys.stdout = codecs.getwriter('utf_16')(sys.stdout.buffer, 'strict')
and then use any of these to get unicode chars:
"\u0000 \U00000000"
chr(9000) chr(0x590)
...or just paste the chars directly:
print("🌠")
Not all characters will be supported on all devices and I'm not sure if strings like u"..." are required (I didn't need them).
I have this code trying to be a block-by-block browser if you like:
https://code.sololearn.com/csTae6tX7D4l/?ref=app
Disable / comment addTestChars...line 16 if you just want the table.
+ 3
In sololearn code playground context, not all unicode characters are well handled, unfortunatly... The reason is maybe in the limitation due to the way of script execution are handled in sololearn : by buffering in/output and executing/compiling code on server side ^^
+ 1
Thanks for your answers! I think my codesnippet won't work in sololearn. But I learned some new things about character encoding now. :)
+ 1
Hi Kirk, still around, still interested :)
+ 1
Thanks Kirk! I will give it a try.