Forum in READ ONLY mode! All questions and discussions on Discord official server, invite link: https://discord.gg/VxsGzJ7

Fail on Unicode

Post Reply
Vlek
Neophyte
Neophyte
Posts: 21
Joined: 03.10.2014 1:15

Fail on Unicode

Post by Vlek »

An annoying issue I'm having with unicode characters is not being able to use them. I can't print them to system journal, nor can I print them in game even if UO can handle them. I have seen in the Russian forums that this has been an issue for a few people already in the Asian community, and I was not able to figure out whether it was addressed. It seems that, when stealth attempts to use what's passed into the functions UOSay or AddToSystemJournal, it attempts to encode it using ASCII. When that fails, it either causes stealth to crash or complain.

I believe this issue may also shed some light on PartySay and how it is horribly mangled. Instead of using ASCII, it seems to want to encode the passed string as something completely different which causes it to bug out. I'll have to investigate it further and make a post specifically about that though.

This is the code I'm using:

Code: Select all

import stealth

stealth.UOSay(u'\u2660')
This is the error I'm getting:

Code: Select all

(file path) line 3, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2660' in position 0: ordinal not in range(128)
User avatar
Vizit0r
Developer
Developer
Posts: 3958
Joined: 24.03.2005 17:05
Contact:

Re: Fail on Unicode

Post by Vizit0r »

really, thats python error, not stealth.

try use stealth.UOSay(u'\2660');
"Пишите код так, как будто сопровождать его будет склонный к насилию психопат, который знает, где вы живете". (с) Макконнелл, "Совершенный код".
Vlek
Neophyte
Neophyte
Posts: 21
Joined: 03.10.2014 1:15

Re: Fail on Unicode

Post by Vlek »

I tried that, and I get the same error message:

Code: Select all

(file location) line 3, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character u'\xb6' in position 0: ordinal not in range(128)
I swear it's a problem with how stealth handles strings. It's trying to encode or deal with them like they are ASCII encoded.
User avatar
Vizit0r
Developer
Developer
Posts: 3958
Joined: 24.03.2005 17:05
Contact:

Re: Fail on Unicode

Post by Vizit0r »

thats python raise you error. At this moment Stealth handles nothing - he didnt receive string from Py.


Seems like need to use unicode Py 3.X or unicode modules (in 2.7) - i dont know.
"Пишите код так, как будто сопровождать его будет склонный к насилию психопат, который знает, где вы живете". (с) Макконнелл, "Совершенный код".
Post Reply