mailto 不可读的字符 - unicode
我在我的网站中使用 mailto URI 方案通过电子邮件发送当前页面.
I am using the mailto URI scheme in my website for emailing the current page.
问题是我在mailto链接中使用印地语作为主题
The problem is i use Hindi as the subject in the mailto link
示例
<a href="mailto:test@gmail.com?subject=मानक हिन्दी">Testing</a>
单击链接时,Outlook(版本 6)打开并显示一些不可读的字符作为主题而不是मानक हिन्दी",即我得到'मानकहिनà¥à¤|ी"
When the link is clicked, the Outlook(version 6) opens and it displays some unreadable characters as subject instead of "मानक हिन्दी" i.e i get "'मानक हिनà¥à¤¦à¥€"
我使用的是 PHP,所以我尝试使用 urlencode、utf8_encode 和其他类似的函数,但没有用.并且页面的默认字符集是UTF-8
I am using PHP so i tried using urlencode, utf8_encode and other similar functions and it is of no use. And the page's default character set is UTF-8
当我直接粘贴文本मानकहिन्दी时,它起作用了.
When i directly paste the text मानक हिन्दी, it works.
但我需要它作为mailto链接...有什么解决方案?
But i need it as a mailto link... What will be the solution ?
推荐答案
不幸的是,这只能在 Outlook 端修复,通过设置选项允许 UTF-8 支持 mailto: 协议".(在 2010 年,这是在选项 -> 高级 -> 国际选项下.)
Unfortunately this can only be fixed at the Outlook end, by setting the option ‘Allow UTF-8 support for the mailto: protocol’. (In 2010 this is under Options -> Advanced -> International options.)
否则,默认情况下,Outlook 将使用用户特定于语言环境的桌面默认编码(ANSI"代码页),该编码从不使用 UTF-8.这使得在 mailto: URL 中使用非 ASCII 字符非常不可靠,以至于实际上毫无用处.(甚至超过了 subject=
的正常不可靠性.)
Otherwise, and by default, Outlook will use the user's locale-specific desktop default encoding (the ‘ANSI’ code page) which is never UTF-8. This makes using non-ASCII characters in a mailto: URL so unreliable as to be effectively useless. (Even more than the normal unreliability of subject=
.)
总的来说,对非 ASCII 字符串进行 URL 编码的想法是正确的:使用像这样的 URI:
In general the idea to URL-encode the non-ASCII string was the right one: using a URI like:
<a href="mailto:test@gmail.com?subject=%E0%A4%AE%E0%A4%BE%E0%A4%A8%E0%A4%95%20%E0%A4%B9%E0%A4%BF%E0%A4%A8%E0%A5%8D%E0%A4%A6%E0%A5%80">Testing</a>
比带有原始 Unicode 的 IRI 格式更可靠.但是,这并没有解决 Outlook 问题.
Is more reliable than the IRI format with the raw Unicode. However this does not address the Outlook issue.
相关文章