Closed l4npro closed 2 years ago
Hi @l4npro,
I need some extra info from you to solve the issue:
I hope this method is suitable. There weren't any problems with encoding before updating, so I think that's not my code's fault.
UTF-8. Btw i tried to switch through some encodings, it worked only for russian words directly in code, not for text from VK messages.
Try to set UTF-8
encoding right before running your app:
chcp 65001
java -jar your-jar-file.jar
Is result the same?
Ok, It worked in console. But there is other problem: bot still don't understand this commands, cos it's getting wrong encoded message. How can I fix it?
For example: I have a text button named "Подтвердить"
So, when I'm pressing this button, I send message:
Bot getting it:
And returns this:
Try to set UTF-8
encoding in your pom.xml
and rebuild your app:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
Is result the same?
Yep, the same.
Please try this workaround:
byte[] encoded = message.getText().getBytes(StandardCharsets.UTF_8);
String decoded = new String(encoded, StandardCharsets.UTF_8);
Is it working?
It's a waste of time. Maybe I should try to downgrade through versions of your API to find where this problem occurs?
Please try this command:
chcp 65001
java -Dfile.encoding=UTF-8 -jar your-jar-file.jar
I will be grateful if you let me know the result. :worried:
Thanks, it worked!
Hm, so, is this is nessesary option from now on, am I right?
I see that HTTP response is read without explicit encoding specified. So the actual encoding depends on what Charset.defaultCharset()
retuns in runtime. Most probably I should specify UTF-8
explicitily to InputStreamReader
.
Will investigate and update further in next 1-2 days.
So please use -Dfile.encoding=UTF-8
option as workaround for now.
Okay, thanks a lot! I'll check for your updates!
UTF-8
encoding was explicitily set to InputStreamReader
while reading HTTP response.
Fixed in version 3.2.10
.
Got an issue with encoding after updating from 2.1.7 to 3.2.9.
This message is "меню", but the result is (first line):