gpt4 book ai didi

java - 如何对javamail中的日语字符进行编码

转载 作者:行者123 更新时间:2023-12-01 22:17:35 28 4
gpt4 key购买 nike

所以基本上我正在尝试发送一封包含日语字符的电子邮件,例如“𥹖𥹖𥹖”,然后我收到“???”我应该做什么来编码这个?我研究了很多解决方案,但没有一个能帮助我解决这个问题。

这是我一直在尝试进行编码的方法:

public String encoding(String str) throws UnsupportedEncodingException{
String Encoding = "Shift_JIS";
return this.changeCharset(str, Encoding);
}
public String changeCharset(String str, String newCharset) throws UnsupportedEncodingException {
if (str != null) {
byte[] jis = str.getBytes("Shift_JIS");
return new String(bs, newCharset);
}
return null;
}

最佳答案

你把事情搞得太复杂了......

首先,确保使用正确的 Unicode 字符将日语文本存储在正确的 Java String 对象中。

然后,使用 this method 设置正文部分的内容:

htmlPart.setText(japaneseString, "Shift_JIS", "html");

关于java - 如何对javamail中的日语字符进行编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58614579/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com