Jump to content

Problems With Encoding


aic007
 Share

Recommended Posts

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();		}

Edited by aic007
Link to comment
Share on other sites

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...