开发者

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:55开发者_Python百科55555555

X-MS-OL-DEFAULT-POSTAL-ADDRESS:0

EMAIL;PREF;INTERNET:hello@world.com

X-MS-OL-DESIGN;CHARSET=utf-8:[VCard HTML Format]

REV:20110404T135700

END:VCARD


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.


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


Try utf8 or utf-8 as the charset.


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:hello@world.com
REV:20110405T164322Z
END:VCARD

This loads correctly into Outlook 2003.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜