0

I've made a telegram bot using Java with rubenlagus/TelegramBots library. And when I'm going to send a Persian message to the user, the message gets all changed into nonsense like this : enter image description here

real message : به پنل ادمین خوش آمدید

I'm using IntelliJ IDEA as my IDE

Mori
  • 41
  • 5

1 Answers1

0

The problem was encoding in java, which I soled it with this piece of code :

public static String stringWrapper(String str) throws UnsupportedEncodingException {
    String result = "";
    result = new String(str.getBytes() , "UTF-8");
    return result;
}
Mori
  • 41
  • 5
  • This worked, but it did not solve the root of the problem. Strings always have the same charset (UTF-16). The original message was not created correctly. – VGR Oct 27 '21 at 18:44
  • Yes and unfortunately I couldn't find the answer for that. And the solution I found was a little buggy around some characters like ( ف ) – Mori Oct 28 '21 at 21:44