12

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");
hphoeksma
  • 220
  • 1
  • 2
  • 11

5 Answers5

10

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

Dev-iL
  • 23,742
  • 7
  • 57
  • 99
user808667
  • 333
  • 3
  • 11
  • 1
    This is easy and works great with a german Outlook 2016 on a german Windows 10 with UTF-8 vCards. The only option I had to change was the "export/outgoing" option for vCard to "Unicode (UTF-8)". And you are right @user808667 , this is really not that obvious! – PeterCo Sep 21 '17 at 12:29
7

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.

Mike Mackintosh
  • 13,917
  • 6
  • 60
  • 87
  • 2
    In my case the content was encoded with utf-8 enforcing a utf-8 header in the end. Now I check for windows OS -> then iso content encoding, else utf-8 encoding. Works well. – hphoeksma Feb 10 '12 at 07:41
6

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

andilabs
  • 22,159
  • 14
  • 114
  • 151
2

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.

  • 1
    What version are you using? I'm using version 3.0 with windows 8 and it doesn't work – Marcio Oliveira Aug 13 '14 at 12:28
  • I'm using 3.0, see http://pastebin.com/HBW9LgJi for an example. Tested on my clients Outlook (unknown version) on Windows 8. Did you make sure that the actual data is also in ISO-8859-1? I'm using utf8_decode() in my script (PHP) – Patrick Fabrizius Aug 18 '14 at 17:20
  • actually I'm using node.js. Anyway, for windows, iso-8859-1 or utf-8 is the same (doesn't work), but if I read that same card with Android, then it's fine. Hope they fix this bug.. I'm also using version 3.0 of vCard. – Marcio Oliveira Aug 19 '14 at 11:13
  • Sounds like you have UTF-8 somewhere, don't forget that the source data itself must be ISO-8859-1, f eg database, source code etc. – Patrick Fabrizius Aug 20 '14 at 12:34
1

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.

hphoeksma
  • 220
  • 1
  • 2
  • 11