mailto unreadable characters - unicode

好久不见. 提交于 2021-02-16 13:36:50

问题


I am using the mailto URI scheme in my website for emailing the current page.

The problem is i use Hindi as the subject in the mailto link

Example

<a href="mailto:test@gmail.com?subject=मानक हिन्दी">Testing</a>

When the link is clicked, the Outlook(version 6) opens and it displays some unreadable characters as subject instead of "मानक हिन्दी" i.e i get "'मानक हिनà¥à¤¦à¥€"

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.

But i need it as a mailto link... What will be the solution ?


回答1:


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.)

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=.)

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>

Is more reliable than the IRI format with the raw Unicode. However this does not address the Outlook issue.




回答2:


Older outlook as far as i know is using local encoding instead of Unicode for emails, so any unicode string will be scrambled - there may be an option to set encoding for mailto - but not sure




回答3:


As bobince said, Outlook has its limitations. Microsoft has published documentation that states that properly configured Outlook 2003 and 2007 attached to a properly configured Exchange server will default to supporting Unicode, but that doesn't really help you with the general public.

For reference, the "standard" you want to refer to for this is RFC 2047.

The solution that I have implemented to get around this limitation (only with European languages and accents, not with as something as exotic as Hindi) is to use a web form instead of a mailto: link. It requires more setup on the server side, but gives you a lot more control over the contact process.



来源:https://stackoverflow.com/questions/8082073/mailto-unreadable-characters-unicode

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