Character encoding issues with PHP generated vCards in Outlook

character-encoding, php, vcf-vcard

Solution

Your solution didn't work for me, I still got funny characters on Windows.

What worked for me was using ISO-8859-1 instead. You can convert UTF8 to ISO-8859-1 in PHP using utf8-decode() , and by using `ENCODING=iso-8859-1` in the Vcard for the relevant fields makes it work on most UTF-8 based clients I have tested on.

Header:

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

Vcard example:

N;CHARSET=iso-8859-1:Göteborg

Tested on Windows, OS X, IOS and Android.

Problem

We're encountering character encoding issues trying to create vcards in PHP. In Outlook names that use special characters are distorted, like "é" becomes "é". We updated the header and the FN and N sections for Windows character encoding, but the issue remains. Grateful for any suggestions. Vcard excerpt: ``` BEGIN:VCARD VERSION:3.0 REV:2013-03-27 19:37:46 FN;CHARSET=Windows-1252:Namé S. Nameé N;CHARSET=Windows-1252:Namé;Namé;;; TITLE:Associate ORG:Company EMAIL;TYPE=internet,pref:name@abc.com TZ:-0400 END:VCARD ``` PHP Header for Vcard: ``` header("Content-type: text/x-vcard; charset=windows-1252;"); header("Content-Length: ".strlen($vc->card)); header("Content-Disposition: attachment; filename=".$vcard_name.".vcf"); header("Pragma: public"); ```

Original source