In a recent project, I wanted to load the Unicode values for special characters from an external XML file to add a special characters panel to the RichTextEditor. I wanted these values to show up in a label or text box using something like label.htmlText =”\u00A9″, which would produce the copyright symbol. However, when I loaded the values from a external XML file, the resulting label showed the literal value”\u00A9″ instead of the copyright symbol.
I created a test application and found that locally created XML vars work and local strings work, but not loaded values from the external XML file. In my test application I was using this XML code:
<character> <data>\\u00A9</data> <label>Inverted Exclamation Mark</label> </character>
However, Gordon Smith from the Flex Coders forum pointed out that “\u00A9” is ActionScript syntax and that Flex E4X apparently has a bug which will not treat the \u as an escape sequence in an XML literal (this is Gordon’s lingo, not mine, hehe). Gordon suggested that I use the XML entity syntax:
<character> <data>©</data> <label>Inverted Exclamation Mark</label> </character>
I updated my XML with the new syntax and everything worked great. I doubt I could have tracked this issue down myself, it was literally driving me nuts. I am not sure if I have discovered a bug in E4X, but I certainly hope others don’t run into this same issue. Many thanks to Gordon Smith on Flex Coders for all his help. You can view my test application and source code here and the Flex Coder discussion at this link.