The most afraid of the problem with the unthinkable to fight, to see who the cow nose. Have not been in the code for a long time have encountered obstacles, bkjia.com today incredibly met a small tea bag--php generated XML, to flash fetch is garbled. 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, bkjia.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, bkjia.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!
http://www.bkjia.com/PHPjc/486493.html www.bkjia.com true http://www.bkjia.com/PHPjc/486493.html techarticle The most afraid of the problem with the unthinkable to fight, to see who the cow nose. Have not been in the code for a long time have encountered obstacles, php100.com today actually met a small tea packet PHP generated XML, to flash get ...