Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

[CS5][JS] Add Glyph for special 'e' characters?

Guest
Oct 11, 2011 Oct 11, 2011

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

TOPICS
Scripting
2.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Oct 12, 2011 Oct 12, 2011

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

...
Translate
LEGEND ,
Oct 11, 2011 Oct 11, 2011

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 11, 2011 Oct 11, 2011

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 11, 2011 Oct 11, 2011

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 11, 2011 Oct 11, 2011

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 11, 2011 Oct 11, 2011

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 12, 2011 Oct 12, 2011

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 12, 2011 Oct 12, 2011
LATEST

Thanks for the reply, and I also agree that the ASCII Javascript is much simpler. I'll be using that solution. Thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines