Thu
17
May '07
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;

Leave a passing comment »