NinethSense oWnZ mE!: Praveen’s drawing book

Choose a Topic:

Fri
9
May '08

Encoding - converter

Here is a sample code in c# to convert a file with UTF-7 encoding to ISO-8859-1 encoding. You can change these values to make any to any converter.

 
            Encoding FromEnc =  Encoding.UTF7; // from
            Encoding ToEnc = Encoding.GetEncoding(“ISO-8859-1″); //to
            TextReader tr = new StreamReader(@“C:\from.html”, FromEnc);
            TextWriter tw = new StreamWriter(@“C:\to.html”,false, ToEnc);
            tw.Write(tr.ReadToEnd());
            tr.Close();
            tw.Close();


Make sure you imported System.IO.
The CodeProject Microsoft Developer Network Official ASP.NET Forums Microsoft .NET Framework Community Microsoft Most Valuable Professional Kidoos forums Microsoft Visual Studio Developer Home Professional Information Technology Solutions Microsoft Research Home Trivandrum Microsoft Users Group Community Website