Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MS "VCard" french specials chars

I'm trying to create VCard on the fly for a site. I simply open a "real" VCard once create with Outlook with Notepad++ and saw what I need into it to create one on the fly. Everything works fine and I'm able to add anything I need, where I need. Instead one point :

  • All french caracters such as É, À, Ê, Ç, etc showing like : Simon Dugré.

I've add everything suggested by the Outlook created one who's proposing to add : "CHARSET=Windows-1252:" in front of my string entry (also tryied ISO-8859-1, UTF8, UTF7, UTF-8, UTF-7) and none of those are working.

Any suggestion?

EDIT (After Alexandre C.'s answer)
Here is the VCard source. Please note that the source shows it correctly, but when I open it with Outlook, I still have the accent problem :

BEGIN:VCARD VERSION:2.1
N;LANGUAGE=fr-ca;CHARSET=UTF-8:Dugré;Simon
ORG;CHARSET=utf-8:CompanyNameéàêâç
TEL;WORK;VOICE:5555555555
X-MS-OL-DEFAULT-POSTAL-ADDRESS:0
EMAIL;PREF;INTERNET:[email protected]
X-MS-OL-DESIGN;CHARSET=utf-8:[VCard HTML Format]
REV:20110404T135700
END:VCARD

like image 993
Simon Dugré Avatar asked Apr 04 '11 13:04

Simon Dugré


2 Answers

You should write CHARSET=utf-8 and not CHARSET=UTF-8.

vCard specs suggest that character set should be case independent, but Outlook does not care.

like image 106
GiG Avatar answered Oct 21 '22 08:10

GiG


Here is the good line:

currentPage.Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0} {1}.vcf", this.FirstName, this.LastName));
currentPage.Response.ContentType = "text/x-vcard";
currentPage.Response.ContentEncoding = System.Text.Encoding.GetEncoding("ISO-8859-1"); // THIS LINE
currentPage.Response.Write(content);
currentPage.Response.End();

Instead of :

currentPage.Response.Charset = "ISO-8859-1";
like image 1
Simon Dugré Avatar answered Oct 21 '22 07:10

Simon Dugré