+ 20
Code Playground encoding (UTF-8) problem
Guys, has anyone tried to remedy the encoding issue in SL and succeeded? I've been trying to do sth about it, but never managed to actually solve it. The encoding part is fine. It seems that when I try to decode and print it out, it fails, raising an exception (tough!) I recently wrote a code on retrieving new company data from the Polish business registry and of course the data there contains lots of our local letters. The output is illegible without them... https://code.sololearn.com/c83B1EYdf8MP/
7 Antworten
+ 7
@Ace, my man, thanks for the tip :) Inspired by your code, I dug a bit into this and found out it's not that simple to manipulate with system encoding (which amazingly is cp1252 instead of utf-8 in the CP).
BUT, I've taken a more elegant approach now. If I can't change it, at least I give the user a heads up ;)
+ 7
Thanks @!` ;)
+ 6
@Hasan Yep, tried that, but doesn't work in SL 🤔
+ 5
@Brains Thanks for sharing anyway :)
+ 5
@Sean-Michael My workaround kind of works for now. If I can't change the system encoding on Windows virtual machine in the Code Playground, there's little I can do inside Python there. The system will simply not produce the chars I need as it doesn't know how to handle and display them.
I remember that waaaay ago when programming in Pascal, there was a way to overwrite standard ASCII table and define your own 8x16 pixel chars replacing them (even beyond run-time). Perhaps there is a way to do it in Python, too? (although even if so, CP probably does not include this module 😂)
+ 2
s = vivodships.decode('utf8').encode('latin1').decode('utf8')
+ 2
Hi Kuba,
Because I was interested in playing with UTF-8 characters to produce AsciiArt things, I wrote about the limitations to SL dev team. They answered on February 1, 2018 :
" We are working to improve the Code Playground ",
To be continued ...