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

消息乱码 #4

Open
sbbbb-com opened this issue Aug 21, 2021 · 2 comments
Open

消息乱码 #4

sbbbb-com opened this issue Aug 21, 2021 · 2 comments

Comments

@sbbbb-com
Copy link

在使用此过程运行后,使用项目中的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

@Karlatemp
Copy link
Member

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

@sbbbb-com
Copy link
Author

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

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

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

2 participants