3 Replies Latest reply on May 23, 2008 8:55 AM by normblue

    Special chars from XML

    Pop_Clingwrap Level 1
      I am trying to load text from an XML file and display it in an HTML text field, the xml is UTF-8 encoded and the text is contained in CDATA tags.
      Everything is fine except that I am having difficulty displaying a TM character. I used &#153; and this works on my Mac but not on a PC, I have tried &trade; but this does not display at all and embedding fonts displays nothing as well. <b> and <br> tags are picked up fine so the text field is processing HTML ok.

      I'm stumped. Any suggestions?

      Cheers
        • 1. Re: Special chars from XML
          Level 7
          The unicode value for TM is \u2122. If your XML is UTF-8 encoded, you can
          use the character instead of an HTML entity.


          • 2. Re: Special chars from XML
            Pop_Clingwrap Level 1
            I tried \u2122 and it just displayed as a string so I then just entered the character straight in and and embedded it in the field using the 'include these charaters' field and it displayed fine on both systems but random characters from the rest of the text where not displayed.
            At the suggestion of another developer I put an unused dynamic text field of to one side of the stage and embedded all relevant characters and this seems to have fixed the problem.
            It feels like a bit of a hack but the problem itself feels like a bug. I would be interested to hear if anyone can explain the whys and wherefores of this issue.

            • 3. Special chars from XML
              normblue
              Ran into this same issue with character code 153 for Trademark in XML read by Flash and rendered in Dynamic Text Field. At least in Flash 9 AS 3 it seems like it will accept &#8482; in the XML and render the TM character (I still need to verify this on a Mac).

              If you have characters in your XML with character code 153 you will need to translate it to character code 8482.

              In ActionScript 3.0 the code is simply the following (assumes txtFromXml is a String):

              // TRANSLATE TRADEMARK CHARACTER 153 TO TRADEMARK CHARACTER 8482
              txtFromXml = txtFromXml .replace(String.fromCharCode(153), String.fromCharCode(8482));

              NOTE: ActionScript 2 code would look a little different as it doesn't have a "String.replace(...)" function.

              For some weird reason you have to do the translation twice if you have &#153; in your XML:

              // TRANSLATE TRADEMARK CHARACTER 153 TO TRADEMARK CHARACTER 8482
              txtFromXml = txtFromXml .replace(String.fromCharCode(153), String.fromCharCode(8482));
              txtFromXml = txtFromXml .replace(String.fromCharCode(153), String.fromCharCode(8482));

              -Norm