3 Replies Latest reply on Jan 26, 2007 12:27 PM by abeall

    Special Characters in dynamic text

      I am importing text from an xml document at run time. Everything comes over ok except for a few characters. The ' does not display correctly and β (greek lower case beta symbol). Does anyone know how to import these special characters? Is there a list somewhere?

      I tried embedding the greek characters in the text field properties with out any luck. Do I need to format the xml text differently?
        • 1. Re: Special Characters in dynamic text
          abeall Level 3
          Are you assigning text via TextField.text or TextField.htmlText? If you aren't using htmlText, use that.

          Also, trace the XML data after its loaded, see if the greek beta is getting converted to an entity, like β. It probably is. In that case, I don't think htmlText will properly convert it, and you will have to do it yourself, like this:

          myText.htmlText = myLoadedText.split('β').join('β');

          I often make a function which cleans up entities(like above) that I'll be using in the project.

          • 2. Re: Special Characters in dynamic text
            weanderson Level 1
            Thanks - I seem to be following you though process, but can't seem to get it to work. I am using .html text and you were spot on with the β conversion.

            Am I correct that the split should cut out the β in the text and replace it with the β. I have not got it to work quite right. I have my text pushed into an array based on combo boxes the user selects. I then populate the field by looping through the array. Should the split - join work when looping through the array, or should I put the array info in a string "holder" and then try the split - join.

            Thanks again for the help and direction. I'll keep trying some different approaches over the weekend.

            • 3. Re: Special Characters in dynamic text
              abeall Level 3
              You are correct about split().join(). String.split() will split the text into an Array of elements, cut up at all instances of the passs ed in character. Array.join() will merge all elements as an array into a String, placing a dilimiter of choice. By doing split().join() it's effectively a find and replace. You could even do this:
              myString = myString.split().join().split().join().split().join();
              And pass in as many find.replace pairs as you want.

              If I follow your set up, you should be able to use split().join() at any point. For instance:

              myTextField_txt.htmlText = myArray[index].split('β').join('β');

              You say its not working. What isn't working about it? ie is there character not showing up at all? Is it showing up as a box? is it showing up as β ? Make sure you are using a font which has the β symbol, like Arial.

              Depending on how much you need to convert text in this way, you might want to consider making a function, like this:

              function convertEntities(str){
              return str.split('&beta').join('β').split('&someOtherEntity;').join('bla');

              Then you could just do, using the earlier example:

              myTextField_txt.htmlText = convertEntities(myArray[index]);
              anotherTextField_txt.htmlText = convertEntities(myArray[index2]);