I have one excel export module on a project which will output UTF7 encoded text. That is because the requirement included unicode characters (German, French etc.). I am able to test those files with Microsoft Excel XP, 2000 etc. But after I install Microsoft Office 2007, it stopped working. It was time consuming for me to go to the other developer’s machine and test. So I wrote a quick c# windows application to do the job. Since I have html data with tables, I used the webbrowser control to display the contents. Here is the code:

Stream inputstream = new FileStream(filename, FileMode.Open, FileAccess.Read);

byte[] bytes = new byte[inputstream.Length];
int outputlength = inputstream.Read(bytes, 0, int.Parse(inputstream.Length.ToString()));

char[] chars = Encoding.UTF7.GetChars(bytes, 0, outputlength);

string contents = new string(chars);
webBrowser1.DocumentText = contents;

VN:F [1.1.6_502]
Rating: 0.0/5 (0 votes cast)
Share:
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • DotNetKicks
  • LinkedIn
  • Live
  • MySpace
  • StumbleUpon
  • Technorati

Related posts:

  1. ASP.NET - Download as ZIP
  2. System.IO.Compression.GZipStream
  3. Encoding - converter
  4. MD5 encryption with c#
  5. Reverse text as you type