Code Playground encoding (UTF-8) problem | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 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/

9th Mar 2018, 6:29 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
7 Réponses
+ 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 ;)
9th Mar 2018, 9:00 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 7
Thanks @!` ;)
11th Mar 2018, 12:21 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 6
@Hasan Yep, tried that, but doesn't work in SL 🤔
9th Mar 2018, 6:49 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 5
@Brains Thanks for sharing anyway :)
9th Mar 2018, 6:49 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 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 😂)
13th Mar 2018, 6:43 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 2
s = vivodships.decode('utf8').encode('latin1').decode('utf8')
9th Mar 2018, 6:43 PM
Hasan Jafarov
Hasan Jafarov - avatar
+ 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 ...
11th Mar 2018, 9:16 AM
Cépagrave
Cépagrave - avatar