Flash Player 10 official download PHP generated XML with Flash get as garbled ultimate solution

Source: Internet
Author: User
Finally resolved through exploration. Documented, and by the way, a general-purpose solution was recorded. If you also encounter Xml<->flash garbled situation, you can quickly check:
1. The case that there is absolutely no problem with XML:
First, the flash read XML garbled involves system.usecodepage this static property property
Official description: "A Boolean value that tells Flash Player which code page to interpret external text files." The default is False.
If we use UTF8 encoded external text file, php100.com do not have to control it, use non-UTF8 encoded text file and text characters, you need to set it to true to let Flash read out the characters are not garbled.
AS3 can import Flash.system.System first, then set system.usecodepage=true;
2. Want PHP to generate UTF-8 encoded XML:
To have Chinese characters in XML, it is best to use UTF-8 encoding. Declared as $dom_xml = new DomDocument (' 1.0′, ' utf-8′) before using the DOM to create XML, the second parameter corresponds to the encoding value of the XML Document declaration section. But note: This is just the code of the Declaration, finally using $dom_xml->savexml (), the actual generated XML file is the same as the PHP script source file encoding format, that is, "What is your PHP code, the resulting file is what encoding." ”
3. XML file declaration encoded as UTF-8, in Flash, regardless of whether the value of usecodepage is read or garbled
This is often the case, usually because: although the declaration part is UTF-8, the file itself is not UTF-8 (I myself am ANSI-encoded, Khan).
That will lead to a serious problem: the Firefox browser can interpret the XML normally, but IE (including the TT and other IE kernel browser) hints that there are wrong characters, Flash also shows garbled!
There are two ways to deal with this situation:
Change the XML declaration part to non-UTF-8, such as GB2312, then set the Flash usecodepage=true;
Open the XML in Notepad and save it as UTF-8 using the "Save as" command
That is, the code declaration and the file itself code matching, not the name does not match the actual.
4. PHP source files are not UTF8 encoded, how to generate XML to let flash support Chinese characters? The situation I encountered:
PHP is ANSI-saved, XML generated using the DOM is naturally also ANSI, php100.com this encoded XML file contains Chinese characters, even if the declaration is encoded as UTF-8, can not be read correctly.
In this premise, to flash the correct read XML does not appear garbled, you must set encoding to GB2312.
and PHP Dom incredibly can not use GB2312 write Chinese characters (puzzled, please the talent pointing maze)? If new DomDocument (' 1.0′, ' gb2312′), the XML will be saved with an error: "Output conversion failed due to conv error, bytes 0xCE 0xd2 0x5d 0x5d". That is to say, I this ANSI PHP can only generate a declaration as UTF-8 and actually ANSI XML file, this file of course Flash read out garbled (refer to 3rd).
My solution:
After PHP has generated XML with the UTF-8 declaration, it adds one more step: Open the XML file to overwrite the header declaration and replace the UTF-8 with GB2312. Hey, flash,ie,ff are not wrong!

The above describes the Flash Player 10 official download PHP generated XML to flash for the ultimate solution of garbled, including the Flash Player 10 official download content, I hope to be interested in PHP tutorial friends helpful.

  • Related Article

    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.