📜 ⬆️ ⬇️

Flash XML parsing: win vs mac

Simple and clear code:
package {
import flash.display.Sprite;

public class XCDATATest extends Sprite {
public function XCDATATest() {
var node:XML = <format>
<![CDATA[<b>ds3 - CSV Settings:</b>
ignore_first_row=<b> true </b>
columns_separator=<b>;</b>
rows_separator=<b>\n</b>]]>
</format>;
trace (String(node));
}
}
}


* This source code was highlighted with Source Code Highlighter .

It can lead to very "funny" consequences of different work of swf-ki under different systems.

Source file for those who want to try: anychart.com/batsuev/habrahabr/xml-win-mac/XCDATATest.as
Actually who will open the file with the code - immediately guess what's the matter.
(copy-paste from the article will not achieve this)

And the fun itself is that the trace under the poppy will give the following:
<b>ds3 - CSV Settings:</b>
ignore_first_row=<b> true </b>
columns_separator=<b>;</b>
rows_separator=<b>\n</b>


* This source code was highlighted with Source Code Highlighter .


And under Win it will be like this:
<b>ds3 - CSV Settings:</b>
ignore_first_row=<b> true </b>
columns_separator=<b>;</b>
rows_separator=<b>\n</b>


* This source code was highlighted with Source Code Highlighter .

')
This difference in the work of the 10th Flash Player under Win and Mac is that the magic character with the code 0xA0 (better known as nbsp) is ignored outside of CDATA under Win, but is perceived as significant by Mac.

Be careful with invisible characters.

PS : XML with this magic symbol issued by Visual Studio after autoformatting

Source: https://habr.com/ru/post/89905/


All Articles