In the previous article, when loading xml configuration files in flash, there was a solution that could not load Chinese characters. The flash garbled problem that flash often encountered during encoding was analyzed in a simple way. After half a year, the original Code Garbled again
This occurs when you modify the globalization in the. NET configuration file web. config. The original configuration is
- <Globalization requestencoding = "gb2312" responseencoding = "gb2312"/>
Now it is to change the responseencoding encoding to the UTF-8, the results of flash in all the aspx file output XML structure call there is a garbled problem. Thanks to common sense, calling the UTF-8 encoding structure in Flash is a perfect match. How can we see garbled characters?
During the test, a strange problem was found occasionally. Flash did not find garbled Characters During the test in the local file system, and the performance was normal. After comparing the row files, although it is the same file with the same encoding structure, the output results are a little different.
Original Program
- response. addheader ("Content-Type", "text/XML");
- string S = system. io. file. readalltext (S, system. text. encoding. utf8);
- Response. Write (s );
This seems to be a simple code, and the output code is correct.
First, let's take a look at the modified
Understand the structure of the UTF-8 file at a glance to see the problem, the first two 0d0a, it is obviously a carriage return line, this is also part of the HTTP protocol, but followed by three more bytes
- Efbbbf // the content of the XML file is later.
This illustrates a problem that flash will first detect the BOM of the UTF-8 when reading the external UTF-8 file, the solution code is also very simple
- response. addheader ("Content-Type", "text/XML");
- string S = system. io. file. readalltext (S, system. text. encoding. utf8);
- // ---- Add the following code ******************
- byte [] BOM = {239,187,191 };
- response. binarywrite (BMM);
- Response. Write (s );