Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UTF8 Encoding with vCards in Windows

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");
like image 852
hphoeksma Avatar asked Dec 23 '11 14:12

hphoeksma


5 Answers

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

like image 67
andilabs Avatar answered Nov 01 '22 05:11

andilabs


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

like image 45
user808667 Avatar answered Nov 01 '22 06:11

user808667


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.

like image 6
Kris Koskelin Avatar answered Nov 01 '22 05:11

Kris Koskelin


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.

like image 2
Patrick Fabrizius Avatar answered Nov 01 '22 06:11

Patrick Fabrizius


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.

like image 1
hphoeksma Avatar answered Nov 01 '22 05:11

hphoeksma