Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encoding problem #1359

Closed
HuDeez opened this issue May 18, 2024 · 1 comment
Closed

Encoding problem #1359

HuDeez opened this issue May 18, 2024 · 1 comment

Comments

@HuDeez
Copy link

HuDeez commented May 18, 2024

When sending a message using Cyrillic characters, hieroglyphs are sent. And not only with Cyrillic, with any other characters except the Latin alphabet, there is such a problem. How fix it? I am using the latest version of library.

package bot;

import org.telegram.telegrambots.client.okhttp.OkHttpTelegramClient;
import org.telegram.telegrambots.longpolling.util.LongPollingSingleThreadUpdateConsumer;
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
import org.telegram.telegrambots.meta.api.objects.Update;
import org.telegram.telegrambots.meta.exceptions.TelegramApiException;
import org.telegram.telegrambots.meta.generics.TelegramClient;


public class Bot implements LongPollingSingleThreadUpdateConsumer {
    private final String token = System.getProperty("TELEGRAM_TOKEN");
    private final TelegramClient telegramClient = new OkHttpTelegramClient(token);

    @Override
    public void consume(Update update) {
        if (update.hasMessage() && update.getMessage().hasText()) {
            String text = update.getMessage().getText();
            if (text.equals("/help")) {
                SendMessage sendMessage = new SendMessage(update.getMessage().getChatId().toString(), "Тест кириллицы");
                try {
                    telegramClient.execute(sendMessage);
                } catch (TelegramApiException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    public String getToken() {
        return token;
    }
}
@HuDeez
Copy link
Author

HuDeez commented May 20, 2024

The problem was in the IDE encoding itself, fixed by adding an option.
Help -> Edit Custom VM Options

-Dfile.encoding=UTF-8

@HuDeez HuDeez closed this as completed May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant