mailto特殊字符 [英] mailto special characters

查看:202
本文介绍了mailto特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法让电子邮件客户端(Outlook)接受来自HTML中mailto链接的特殊字符?我试图在体内使用与德文字符的mailto链接,但在Outlook中我只能看到奇怪的字符。



谢谢

解决方案

我刚刚花了2天时间调查这个问题。我们的问题是,如果subject =字符串包含非ascii字符,例如挪威字符,那么我们utf-8编码的网页上的mailto:链接对Outlook用户不起作用。一个例子是:
mailto:mail@coretrek.no?subject =julegløggogfårikål



从我迄今为止所了解的情况来看,Outlook根本就没有处理ASCII和iso-8859-1字符以外的任何内容。所以当试图点击上面的mailto链接(无论是从IE还是Firefox)时,Outlook都无法解码字符,导致主题被破坏并包含怪异字符。

所以下一步就是尝试对ISO-8859-1中的页面进行重新编码。我们所做的是用utf-8页面上的原始mailto链接替换为email-to-iso服务的链接,如下所示:

< a href =http://url.com/service.php?service=util.mailtoencode&mailto=mail%40coretrek.no%3Fsubject%3Demne+%C3%B8%C3%A6%C3%A5+emne = noreferrer> http://url.com/service.php?service=util.mailtoencode&mailto=mail%40coretrek.no%3Fsubject%3Demne+%C3%B8%C3%A6%C3%A5+emne



此页面将把mailto字符转换为iso-8859-1,然后在iso-8859-1中输出整个页面内容。包含location.href ='mailto:...'的页面上的JavaScript被用于自动打开客户端的电子邮件客户端。



到目前为止,一切都很顺利。这实际上适用于Internet Explorer,Thunderbird和Outlook(在使用Outlook Express和TB 2的WinXP上的IE7上进行测试)。

但现在的问题实际上是Firefox。似乎Firefox无法解码包含仅在ISO-8859-1中找到的字符的url编码的url,但不是以ASCII码(如挪威语å,编码时由%E5表示)。如果页面编码是utf-8,则相同的处理是正确的,但似乎Firefox开发人员已经忘记了与ISO-8859-1字符集一起测试特殊字符。
结果是,Firefox向电子邮件客户端传递未解码的字符串(仍包含%E5)。令人惊讶的是,这是由Outlook(它管理解码字符串本身)正确处理,但不是由Thunderbird,它可能与Firefox相同的错误。如果您不对网址进行网址编码,则该字符串会正确传递给Thunderbird,但不会传递给Outlook。 我们也一直在尝试其他的编码方法,比如php的htmlentities,htmlspecialchars,base64编码等,但是它们都失败了。

所以,总结:

使用utf-8编码的页面:

IE总是失败

- > Thunderbird:OK
$ b FF - > Outlook: FAIL



在ISO-8859-1中编码的页面:

IE:OK

FF - > Thunderbird:失败如果主题是网址编码,如果不是)


$ b

FF - > Outlook:失败,如果主题不是网址编码,确定如​​果编码)
(这是Windows,在Ubuntu Linux FF和TB工作正常)。



希望这有助于其他人也有同样的问题。

Is there a way to make the email client ( Outlook ) accept special characters coming from the mailto link in html? I'm trying to have a mailto link with german characters in the body, but in Outlook I get only strange characters.

Thanks

解决方案

I just spent 2 days investigation this issue. Our issue was that mailto: links on our utf-8 encoded web pages did not work for Outlook users if the subject= string contained non-ascii characters, like e.g Norwegian characters. An example is: "mailto:mail@coretrek.no?subject=julegløgg og fårikål"

From what I have learned so far, Outlook simply does not handle anything other than ASCII and iso-8859-1 characters. So when trying to click on the above mailto link (either from IE or Firefox), Outlook fails to decode the characters, leaving the subject broken and containing "weird" characters.

So the next step was to try to re-encode the pages in ISO-8859-1. What we did was to replace the original mailto link on the utf-8 page with a link to a "email-to-iso"-service, like this:

http://url.com/service.php?service=util.mailtoencode&mailto=mail%40coretrek.no%3Fsubject%3Demne+%C3%B8%C3%A6%C3%A5+emne

This page would convert the mailto characters to iso-8859-1 and then output the entire page content in iso-8859-1. A javascript on the page, containing "location.href='mailto:...'" was used to open the client's email client automatically.

So far everything seemed ok. This actually works in Internet Explorer, both with Thunderbird and Outlook (tested on IE7 on WinXP with Outlook express and TB 2).

BUT the problem now is actually Firefox. It seems like Firefox is unable to decode url-encoded urls containing characters found only in ISO-8859-1 but not in ASCII (like the norwegian å, represented by %E5 when encoded). The same å is handled correct if the page encoding is utf-8, but it seems like the Firefox developers have forgotten to test special characters together with the ISO-8859-1 charset. The result is that Firefox passes an un-decoded string (still containing %E5 intstead of å) to the email client. And, amazingly, this is handled correct by Outlook (which manages to decode the string itself), but NOT by Thunderbird, which probably has the same bug as Firefox. If you DON't url encode the subject, the string is passed correctly to Thunderbird, but not to Outlook.

We have also been trying other encoding methods, like php's htmlentities, htmlspecialchars, base64 encoding etc, but all of them fails one way or the other.

So, summarized:

Pages encoded in utf-8:

IE fails always

FF -> Thunderbird: OK

FF -> Outlook: FAIL

Pages encoded in iso-8859-1:

IE: OK

FF -> Thunderbird: Fails if subject is url encoded, ok if not)

FF -> Outlook: Fails if subject is not url encoded, ok if encoded) (this is Windows, on Ubuntu Linux FF and TB works OK always).

Hoping this was helpful for others having the same problem.

这篇关于mailto特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆