2 Replies Latest reply on Nov 22, 2010 5:51 AM by liedzeit

    How to read unicode character out of XML?

    liedzeit Level 2

      I am working with some XML that I read in that contains some unicode like this: "some text\u00CCsome more text".

      If I have a string like this in the editor I can directly place it and the unicode will be interpreted.

      However with the imported string I have to use a function that finds the code in the string

      and then used the String.fromCharCode(uc) to substitute the code with the actual character. Am I missing something? Is there a better way to do it?

       

      Thanks,

      Ralf

        • 1. Re: How to read unicode character out of XML?
          Dirk Becker  Level 4

          The best would be to educate the producer of the XML about encoding, und how XML natively supports Unicode.

           

          If they are not approachable, you'd first have to decide how you're going to work with that XML.

          Will you use ExtendScript's XML class, or InDesign's import?

          With the former you'd probably use the JS String.replace method before you even parse the wannabe XML text, with the latter you maybe use an XSL, maybe even a global search&replace utilizing InDesign's text features.

           

          Dirk

          1 person found this helpful
          • 2. Re: How to read unicode character out of XML?
            liedzeit Level 2

            Thank you, Dirk.

            The provider of the XML blames Java. Says it is not possible to create text like "Helden der Nacht‰". Which is hard to believe. I guess I just have to accept it.

            Ralf