UTF8 Encoding with vCards in Windows

爱⌒轻易说出口 提交于 2019-12-06 23:44:14

问题


I have implemented a vCard on a website. Problem is though that special characters are not parsed correctly on windows.

I can get it to work fine for Mac, but as soon as I open a vcf in Windows (Windows Contacts) it gets messed up. When I open the vcf in Notepad it shows the characters normally.

I tried all vcf versions I could find (2.1,3.0,4.0). I used charset-utf-8 in my content-type header (text/x-vcard; charset: utf-8). I used N;CHARSET=utf-8: (and for the other tags).

All to no avail.

Does anyone has a solution for this? Thanks for sharing your insight.

Headers used:

header("Content-type: text/x-vcard; charset=utf-8");
header("Content-Disposition: attachment; filename=".$this->filename.".vcf");
header("Pragma: public");

回答1:


To make Outlook import UTF-8 vCards you have to open Outlook options, go to Advanced > International Options and then select UTF-8 for outgoing emails and outgoing vCards... And voila - import works!

Isn't it obvious, that one has to set export options to setup import...? Thanks Microsoft :P




回答2:


I found that instead of supplying ;CHARSET=utf-8 in the vCard field, I instead supplied ;CHARSET=windows-1252, which resulted in the vcard opening correctly in Outlook 2010.

Not a solution for everybody, but hope this helps someone.




回答3:


Compared 2 files, one working from a different service and mine. It appeared that the working version from the other service used Content-Type: text/x-vcard; charset=iso-8859-1.




回答4:


Use ISO-8859-1 and you should be fine. Just make sure every part in the chain uses that encoding (the .vcf file, the encoding declarations in the .vcf file, and your header).

Header:

Content-Type: text/x-vcard; charset=iso-8859-1

Vcard (example, must be saved with iso-8859-1 encoding):

N;CHARSET=iso-8859-1:Übermann

Tested on Windows, OS X, IOS and Android.




回答5:


for me to work with UTF-8 and being readable for Mac OS X all polish characters like ĘĄĆŻŹŃŁÓŚ ęąćżźńłóś was enough to switch to declare VERSION:3.0



来源:https://stackoverflow.com/questions/8617439/utf8-encoding-with-vcards-in-windows

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