are.ehibou.com

March 29, 2006

Encoding Preamble (mystic bytes at the begining of the utf-8,utf-16,utf-7 encoded stream)

Filed under: C#.NET — admin @ 3:19 pm

Faced a problem with detecting file encoding when file is with no encoding preamble Bytes FE and FF (0xFE,0xFF) encoded useing given encoding. The problem was that flash movie, which uses xml data source as input parameter was not able to detect the encoding of the source. (.NET web form) I’ve solved this problem by writeing the preamble in the begining of the Http Response. I think problems of this kind hapens to many programmers.

I used C# code to solve the problem:

byte[] sign=Encoding.UTF8.GetPreamble();
Response.OutputStream.Write(sign,0,sign.Length);
  • Share/Bookmark

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress