Completely solves the problem of garbled Chinese flash loading in Flash

Source: Internet
Author: User
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
    1. <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

  1. response. addheader ("Content-Type", "text/XML");
  2. string S = system. io. file. readalltext (S, system. text. encoding. utf8);
  3. 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

    1. 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

  1. response. addheader ("Content-Type", "text/XML");
  2. string S = system. io. file. readalltext (S, system. text. encoding. utf8);
  3. // ---- Add the following code ******************
  4. byte [] BOM = {239,187,191 };
  5. response. binarywrite (BMM);
  6. Response. Write (s );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.