A text in Persian language is stored in a txt file.
I want to send its contents using Python and Telebot in Telegram, but the letters are messed up in Telegram.
The file storage format is UTF-8.I changed the content to string before posting.
But the message in Telegram is still messed up. How do I solve this problem?
CODE:
import telebotbot_token = "MY_TOKEN"file_path = "C:/shr.txt"bot = telebot.TeleBot(bot_token)def send_file_content(message):with open(file_path, "r") as f: content = f.read() text_str = str(content)bot.send_message(message.chat.id,text_str)@bot.message_handler(commands=["start"])def start_command(message):send_file_content(message)bot.polling()
result in Telegram:
20%C3%98%C2%B9%C3%98%C2%B6%C3%99%E2%80%9A%20%C3%99%CB%86%C3%98%C2%B1%C3%98%C2%B2%C3%9B%C5%92%C3%98%C2%AF%C3%99%E2%80%A0%0A%0Ai%20love%20you%0A%0A