Simon Dugré
Simon Dugré

Reputation: 18916

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 :

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

Upvotes: 7

Views: 4280

Answers (5)

mctl87
mctl87

Reputation: 381

I also had a problem with special characters (polish language). I am not sure if there's a problem with utf-8 encoding in Outlook or something else. After multiple approaches with utf-8:

Response.ContentType = "text/x-vcard; charset=UTF-8";

Response.HeaderEncoding = Encoding.GetEncoding("UTF-8");

Response.ContentEncoding = Encoding.GetEncoding("UTF-8");

Response.Charset = "UTF-8";

I decided to try Windows-1250 encoding, which (in my case) worked! After trying to remove unnecessary lines it turned out that the only line i need is:

Response.ContentEncoding = Encoding.GetEncoding("Windows-1250");

I also recommend vCard library which helped me a lot.

Upvotes: 0

GiG
GiG

Reputation: 96

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.

Upvotes: 8

Simon Dugré
Simon Dugré

Reputation: 18916

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";

Upvotes: 1

Darryl Braaten
Darryl Braaten

Reputation: 5231

Here is a version that works for me.

<%@ Page Language="C#"  CodePage=1252 %>
<%
Response.Charset ="windows-1252";
Response.ContentType="text/x-vcard";
Response.AddHeader("Content-Disposition", "attachment; filename=test.vcf" );
 %>
BEGIN:VCARD
VERSION:2.1
N:;Dugré;Simon
FN:Simon Dugré
ORG:CompanyNameéàêâç
TEL;WORK;VOICE:5555555555
EMAIL;PREF;INTERNET:[email protected]
REV:20110405T164322Z
END:VCARD

This loads correctly into Outlook 2003.

Upvotes: 0

Alexandre C.
Alexandre C.

Reputation: 56956

Try utf8 or utf-8 as the charset.

Upvotes: 0

Related Questions