UTF8 Encoding with vCards in Windows
Asked Answered
B

5

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");
Bilinear answered 23/12, 2011 at 14:59 Comment(5)
Your header is a bit smelly, have you tried Content-type: text/x-vcard; charset="utf-8"Arsenide
@EugenRieck still a typo: text/x-vcard; charset=utf-8Nullify
Thanks Eugen and Joop. Unfortunately this didn't help. As you can see in my question this is one of the things I have already tried. I added the used headers to the question.Bilinear
According to Wikipedia, the correct MIME type for VCards is "text/vcard"...Transduction
Your code and the header() function, are those in Java or PHP or ASP or another language?Excessive
A
11

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

Acrylonitrile answered 17/3, 2017 at 14:5 Comment(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 @Acrylonitrile , this is really not that obvious!Cord
T
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.

Trolly answered 10/2, 2012 at 4:15 Comment(1)
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.Bilinear
H
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

Hummingbird answered 20/7, 2014 at 22:11 Comment(1)
does not work for me (outlook 2013). Can you provide a full vcard that I could use for reference?Gaberdine
V
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.

Vaden answered 2/2, 2014 at 22:11 Comment(4)
What version are you using? I'm using version 3.0 with windows 8 and it doesn't workProletarian
I'm using 3.0, see 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)Vaden
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.Proletarian
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.Vaden
B
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.

Bilinear answered 27/12, 2011 at 14:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.