mirai-hello-world icon indicating copy to clipboard operation
mirai-hello-world copied to clipboard

消息乱码

Open sbbbb-com opened this issue 3 years ago • 2 comments

在使用此过程运行后,使用项目中的Java代码 此org.example.mirai.JavaMain 调用发送消息出现乱码。

Friend friend = bot.getFriend(好友QQ号);
        String s = new String("测试消息".getBytes("GBK"), "GBK");
        String s2 = new String("测试消息".getBytes("UTF8"), "UTF8");
        friend.sendMessage(s);
        friend.sendMessage(s2);

好友接收到为: image

sbbbb-com avatar Aug 21 '21 14:08 sbbbb-com

将 IDEA, Gradle设置 等 调整至 UTF-8 编码

Karlatemp avatar Aug 24 '21 03:08 Karlatemp

谢谢楼上,虽然没有什么用嘿嘿,我的解决办法: //在发送消息时更改字符编码为gbk bot.getFriend(3555824873l).sendMessage(new String("测试".getBytes("GBK")));

测试开发语言是 Java,其他项目也参考下

sbbbb-com avatar Aug 25 '21 00:08 sbbbb-com