【问题标题】:encoding hebrew in mailto: anchor element在 mailto 中编码希伯来语:锚元素
【发布时间】:2012-01-30 00:12:21
【问题描述】:

我在 body 参数中有一个带有希伯来文文本的 mailto 链接。

结果我开始胡言乱语了。

示例结果:

׳©׳ ׳”׳׳™׳¨׳•׳¢: 
׳׳×׳—׳™׳: 11.05.2011
׳׳¡׳×׳™׳™׳: 09.04.2014
׳”׳¢׳¨׳•׳×

我可以通过添加 requestEncoding="windows-1255" 来解决这个问题 在web config。 但这会对网站的其他部分造成不必要的副作用。

如何在邮件正文中获取正确的希伯来语文本?

【问题讨论】:

  • 可以分享一下制作的html头和mailto锚点
  • HEAD: 锚点:

标签: encoding href mailto hebrew


【解决方案1】:

您应该在发送电子邮件之前对您的希伯来语文本正文进行编码。

即:

    final MimeMessage msg = new MimeMessage(session);
    msg.setText(message, "utf-8");
    msg.setHeader("Content-Type", "text/plain; charset=UTF-8");

    MimeBodyPart mbp1 = new MimeBodyPart();
    mbp1.setDataHandler(new DataHandler(new ByteArrayDataSourcemessage.toString), "text/html")));
    mbp1.setContent(new String(message.getBytes("UTF8"),"ISO-8859-8-i"), "text/html");

    Multipart mp = new MimeMultipart();
    mp.addBodyPart(mbp1);
    msg.setContent(mp, "text/html");

对我来说很好用 :)

祝你好运!

戴夫。

【讨论】:

    【解决方案2】:

    在你的 href 中试试这个:

    mailto:?body=שם האירוע: fixing the encoding issue 27.12.11%0Aמתחיל: 11.05.2011%0Aמסתיים: 09.04.2014%0Aהערות: encoding was messed up here as well%0A&subject=fixing the encoding issue 27.12.11
    

    我玩过这个链接: http://www.unicodetools.com/unicode/convert-to-html.php

    【讨论】:

    • 谢谢你。我刚刚使用相同的头部和锚元素创建了一个新的测试网站,并且没有编码问题。网络配置中一定有什么东西,或者页面上的其他元素会导致问题。
    猜你喜欢
    • 1970-01-01
    • 2015-07-16
    • 1970-01-01
    • 1970-01-01
    • 2015-07-03
    • 2012-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多