shmup / miniboa

An asynchronous, single-threaded, poll-based Telnet server
Apache License 2.0
61 stars 12 forks source link

utf8, python3 #31

Open iceixmud opened 4 years ago

iceixmud commented 4 years ago

i don't know if this is still being worked on or not, but if it is:

i started on grapevine support for my game that is using this, and part of that was switching the server encoding to utf8... and that caused all sorts of havoc, garbage chars everywhere

while trying to figure this out, i found this:

Python 3.8.3 (default, May 17 2020, 14:48:56) [GCC] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> test = chr(201) #gmcp
>>> bytes(test, "cp1252")
b'\xc9'
>>> bytes(test, "utf8")
b'\xc3\x89'
>>> 

it looks to me like in utf8 the control character is no longer a valid oob control character, so the client of course just displays it... but i don't know if i'm just reading that wrong, as python (and character encoding especially) is not exactly my most knowledgeable area... for all i know the above is perfectly normal and i'm chasing the wrong thing here

anyways, whatever the case: the issue is that utf8 support with this server appears to be somewhat broken and i hope someone smarter than i knows how to fix it

shmup commented 2 years ago

Give this a shot, which will specify the encoding to utf-8 instead of cp1252.

TelnetServer(encoding='utf-8')

This is the case as of the latest release, 1.0.9.