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

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:

[code lang=”cpp”]
byte[] sign=Encoding.UTF8.GetPreamble();

Leave a Reply