Java mail problem with Turkish characters

和自甴很熟 提交于 2019-12-01 23:27:49

It looks like ISO-8859-9 should be able to handle your Turkish letters alright. Is it possible that the text is decoded somewhere else with the wrong character encoding? For example, if the body of the email contains text from a web request, another email, or a file, perhaps the wrong decoder is specified at that point.

One way to check would be to print the numeric value of the Unicode code points in the String:

for (int idx = 0; idx < str.length(); ++idx) {
  System.out.println(Integer.toHexString(str.charAt(idx)));
}

If you see fffd, that is the "replacement character" and means that the decoding used when the String was created could not map a byte (or byte sequence) to a character. If you see 3f, that is a '?' character, and means that the text was corrupted even farther back.

Use UTF-8, here's a good overview of encoding: http://www.joelonsoftware.com/articles/Unicode.html

You can find the solution here:

http://www.serkankonakci.com/Project/wordpress/2009/02/04/java-mail-ile-mail-gonderme-ornegi/

even with this code, you can send with attachment or single mail in Turkish. And you can find other Turkish charset problem, just search there.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!