D
D
Danya  2020-08-29 00:02:23
Python
Danya  , 2020-08-29 00:02:23

TelegramBOT Python encoding how to fix?

How to fix encoding in python/telebot?
The code:

elif message.text == "Вкл.":
    comma = os.popen('ping 8.8.8.8').read()
    bot.send_message(message.chat.id, str(comma))


When I run it, I get this in response (The bot sends this text to the user):
ЋЎ¬Ґ­ Ї ЄҐв ¬Ё б 8.8.8.8 Ї® б 32 Ў ©в ¬Ё ¤ ­­ле:
ЋвўҐв ®в 8.8.8.8: зЁб«® Ў ©в=32 ўаҐ¬п=26¬б TTL=120
ЋвўҐв ®в 8.8.8.8: зЁб«® Ў ©в=32 ўаҐ¬п=26¬б TTL=120
ЋвўҐв ®в 8.8.8.8: зЁб«® Ў ©в=32 ўаҐ¬п=27¬б TTL=120
ЋвўҐв ®в 8.8.8.8: зЁб«® Ў ©в=32 ўаҐ¬п=26¬б TTL=120

‘в вЁбвЁЄ  Ping ¤«п 8.8.8.8:
    Џ ЄҐв®ў: ®вЇа ў«Ґ­® = 4, Ї®«г祭® = 4, Ї®вҐап­® = 0
    (0% Ї®вҐам)
ЏаЁЎ«Ё§ЁвҐ«м­®Ґ ўаҐ¬п ЇаЁҐ¬ -ЇҐаҐ¤ зЁ ў ¬б:
    ЊЁ­Ё¬ «м­®Ґ = 26¬бҐЄ, Њ ЄбЁ¬ «м­®Ґ = 27 ¬бҐЄ, ‘।­ҐҐ = 26 ¬бҐЄ


How can I fix this and is it even possible?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
shurshur, 2020-08-29
@shurshur

This is cp866 encoded text, it needs to be converted to utf-8.
Example on ru.stackoverflow.com/a/497719/23044

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question