aic007 Posted May 12, 2009 Share Posted May 12, 2009 Hi allI have written code to generate av vcf card when clicking on a button, but I have a small problem. The problem is that it cannot take norwegian letters like: Æ, Ø and Å. (Norwegian is a western European and Scandinavian language). If my name is Bjørn, it will show as Bjørn on the card. I have tried many different values on the "response.Charset=" in my code, but without success. I have also tried this without success as theese variables are read only: stringWrite.Encoding.BodyName = "iso-8859-1";stringWrite.Encoding.CodePage = "1252";stringWrite.Encoding.EncodingName = "Western European";htmlWrite.Encoding.EncodingName = "iso-8859-1";This is my code. Please let me know if you know how to fix my problem private void VCard(HttpResponse response) { nameFirst = result.Rows[0]["Fornavn"].ToString(); nameLast = result.Rows[0]["Etternavn"].ToString(); company = "Company Æ, Ø, Å"; uRL = "www.whatever.no"; profession = result.Rows[0]["Tittel"].ToString(); telephone = result.Rows[0]["Telefon]ToString(); mobile = result.Rows[0]["Mobil"].ToString(); streetName ="Nationaltheateret"; city = "1517 OSLO"; response.Clear(); response.Charset = "1252"; response.ContentType = "text/x-vCard"; //create a string writer System.IO.StringWriter stringWrite = new System.IO.StringWriter(); //stringWrite.Encoding.BodyName = "iso-8859-1"; //stringWrite.Encoding.CodePage = "1252"; //stringWrite.Encoding.EncodingName = "Western European"; //create an htmltextwriter which uses the stringwriter System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); //htmlWrite.Encoding.EncodingName = "iso-8859-1"; //vCard Begin stringWrite.WriteLine("BEGIN:VCARD"); stringWrite.WriteLine("VERSION:2.1"); //Name stringWrite.WriteLine("N:" + nameFirst + ";" + nameLast); //Full Name // stringWrite.WriteLine("FN:" + nameFirst + " " + nameLast); stringWrite.WriteLine("FN:" +nameFirst + " " + nameLast); //Organisation stringWrite.WriteLine("ORG:" + company); //URL stringWrite.WriteLine("URL;WORK:" + uRL); //Title stringWrite.WriteLine("TITLE:" + nameTitle); //Profession stringWrite.WriteLine("ROLE:" + profession); //Telephone stringWrite.WriteLine("TEL;WORK;VOICE:" + telephone); //Fax stringWrite.WriteLine("TEL;WORK;FAX:" + fax); //Mobile stringWrite.WriteLine("TEL;CELL;VOICE:" + mobile); //Email stringWrite.WriteLine("EMAIL;PREF;INTERNET:" + email); //Address stringWrite.WriteLine("ADR;WORK;ENCODING=QUOTED-PRINTABLE:" + ";" + office + ";" + addressTitle + "=0D" + streetName + ";" + city + ";" + region + ";" + postCode + ";" + country); //Revision Date //Not needed //stringWrite.WriteLine("REV:" + DateTime.Today.Year.ToString() + //vCard End stringWrite.WriteLine("END:VCARD"); response.Write(stringWrite.ToString()); response.End(); } Link to comment Share on other sites More sharing options...
jesh Posted May 12, 2009 Share Posted May 12, 2009 I've never created a vcf card before and have never seen the MIME type "text/x-vCard" either. However have you tried "utf-8" for the character set instead of "1252"? response.Clear();response.Charset = "utf-8"; Link to comment Share on other sites More sharing options...
aic007 Posted May 13, 2009 Author Share Posted May 13, 2009 I've never created a vcf card before and have never seen the MIME type "text/x-vCard" either. However have you tried "utf-8" for the character set instead of "1252"?response.Clear();response.Charset = "utf-8"; Yes, tried with both "utf-8", "8859-1" and "iso-8859-1". No luck Link to comment Share on other sites More sharing options...
aic007 Posted May 13, 2009 Author Share Posted May 13, 2009 HiI got it right. I had to write this response.Charset = "Unicode";response.ContentEncoding = Encoding.GetEncoding(1252); Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.