Copy link to clipboard
Copied
Hello,
I've got an InDesign script that adds text to a text frame like so:
myTextFrame.insertionPoints[-1].contents = ' The café...';
The problem is that InDesign renders the acute accent 'e' character incorrectly and inserts other special characters. I think I should be able to use glyphs, but I'm not sure how to do it within a script? Is there an easy way to insert that glyph character?
Many thanks in advance!
-Lloyd
Hi,
As John suggested, it is almost certainly a character encoding issue at script-editing level. I have similar troubles when I deployed my first scripts for Mac + Win platforms—there was always users who got degenerate UTF8. Since I'm not an expert in cross-OS character encoding, I decided to never use non-ASCII characters in my script. This is a radical solution, I admit, but my scripts never more displayed weird © strings and so.
Any Unicode string can be easily expressed in ASCII JavaScript
...Copy link to clipboard
Copied
Works for me. What platform and how are you running the script?
Most importantly: what does it insert instead? Post a screenshot of the "other special characters," please.
Copy link to clipboard
Copied
I think I figured it out, and I needed to use something like:
myTextFrame.insertionPoints[-1].contents = String.fromCharCode(0x00E9);
to make the special "e" character.
It seems like some of the symbols work but not others. The "other special characters" that it rendered before was this "©".
I'm using Windows 7 with CS5, but I was running the script on our development InDesign Server.
Copy link to clipboard
Copied
You should answer the questions I asked, like how you're running the script.
I suspect whatever editor you are using to save the script is not writing it in UTF-8 format.
You can certainly use that syntax, though more convenient is the \u syntax: "The caf\u00e9".
But it should not be necessary.
Copy link to clipboard
Copied
You should read my answers, like "running the script on our development InDesign Server". If you need more details, just ask.
The script is written in a process and saved on a server before getting executed on our InDesign Server, but I'm testing with Adobe's Extend Script Tool Kit, but I'm not sure if it uses the UTF-8 format or not.
Thanks for the help.
Copy link to clipboard
Copied
Indeed I did read your post, but "running the script" is not an answer to "how are you running the script."
Are you using the ESTK? Are you using the CORBA interface? Are you using the SOAP interface? Are you using one of the script-running API utillities that come with InDesign server? Are you doing something else?
How are you running the script?
The ESTK does indeed use UTF-8. Does it work properly in InDesign Desktop? Your example from the ESTK under Windows XP to InDesign Desktop works fine for me.
Copy link to clipboard
Copied
Hi,
As John suggested, it is almost certainly a character encoding issue at script-editing level. I have similar troubles when I deployed my first scripts for Mac + Win platforms—there was always users who got degenerate UTF8. Since I'm not an expert in cross-OS character encoding, I decided to never use non-ASCII characters in my script. This is a radical solution, I admit, but my scripts never more displayed weird © strings and so.
Any Unicode string can be easily expressed in ASCII JavaScript using "\xHH" or "\uHHHH"—which is simpler than String.fromCharCode(0xHHHH).
E.g.:
myTextFrame.insertionPoints[-1].contents = "The caf\xE9...";
Etc.
@+
Marc
Copy link to clipboard
Copied
Thanks for the reply, and I also agree that the ASCII Javascript is much simpler. I'll be using that solution. Thanks!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now