4 Replies Latest reply on Mar 30, 2012 8:15 AM by [Jongware]

    How To Insert Special Characters

    Zoffix222 Level 1

      Hey,

       

      I can't figure out how to insert special characters into a paragraph (the "Indent to Here" in this case).

       

      I tried text_frame.paragraphs[0].contents +=  SpecialCharacters.INDENT_HERE_TAB;  but all I get is "1397319796" instead of the actual character.

       

      How to insert special characters instead of those numbers?

        • 1. Re: How To Insert Special Characters
          Zoffix222 Level 1

          People viewing but no one know this one?

           

          Only with Adobe's creation could you have a full language manual and a forum, and still have no clue how to do the simplests of things...

          • 2. Re: How To Insert Special Characters
            [Jongware] Most Valuable Participant

            Zoffix222 wrote:

             

            People viewing but no one know this one?

             

            What, you mean that in the 5 minutes since you posted it no-one answered? Shocking indeed.

             

            As you aleady found out by yourself, "contents" is the wrong type of object to stuff "SpecialCharacters" in. "contents" is the contents of text, translated into a plain Javascript string. Only when you change a single 'character', you can use "SpecialCharacters", because at that point Extendscript will see you don't want to change the "entire" string?

            • 3. Re: How To Insert Special Characters
              Zoffix222 Level 1
              What, you mean that in the 5 minutes since you posted it no-one answered? Shocking indeed.

               

              No, that 50 people who were curious enough to read the message didn't know the answer. And that language reference doesn't provide a single shred of info on how to use those special characters. That's what's shocking.

               

              As you aleady found out by yourself, "contents" is the wrong type of object to stuff "SpecialCharacters" in. "contents" is the contents of text, translated into a plain Javascript string. Only when you change a single 'character', you can use "SpecialCharacters", because at that point Extendscript will see you don't want to change the "entire" string?

               

              Thanks. What I found is that if I use assignment, instead of +=, then the special character is added without replacing the string.

              • 4. Re: How To Insert Special Characters
                [Jongware] Most Valuable Participant

                Zoffix222 wrote:

                 

                Thanks. What I found is that if I use assignment, instead of +=, then the special character is added without replacing the string.

                 

                Ah, yes, that was the term I was looking for. With your "contents += ..", the entire contents are 'read', converted into a Javascript string, and at that point you cannot insert the SpecialCharacters anymore. With a straight assignment, one at a time, it works.

                 

                The biggest downside of this method is that you can only add one special character at a time. I guess that's just the price you have to pay for this method, working around Unicode. You'll also have the same problem if you try to read a contents string back that contains any special character ...