Skip to main content
TᴀW
Legend
January 19, 2012
Question

Search document for SpecialCharacters Enumerator

  • January 19, 2012
  • 2 replies
  • 7372 views

Hi,

I've placed a Word document that has loads of irritating Unicode markers

(left-to-right etc.)

There is no way that I can see of using the UI to search and delete

these characters.

The unicode value of these markers is: 0x200E as it appears from the

Info palette, but that Unicode value is shared by various things.

Selecting a marker and get its contents (app.selection[0].contents)

returns the number: 1399616109. This is in fact the number for

SpecialCharacters.LEFT_TO_RIGHT_MARK.

To cut a long story short and make a specific question general:

How do you search for a SpecialCharacter that doesn't have an escape

code in the GREP find/replace?

What I've done so far is looped through all the characters in the

document and compared their contents to 1399616109. But this is very

slow, and is also causing InDesign to crash.

Is there a better way?

Thanks,

Ariel

This topic has been closed for replies.

2 replies

Marc Autret
Legend
January 19, 2012

To complete my previous post:

1) Given a Character myChar whose contents property returns a SpecialCharacter enumerator, you can still retrieve the Unicode codepoint using myChar.texts[0].contents instead of myChar.contents:

alert( myChar.texts[0].contents.charCodeAt(0).toString(16) ); // => Unicode CP (hexa)

2) Since ID CS5 the Enumeration objects (Locale, SpecialCharacters, etc.) describe a set of Enumerator objects rather than a set of numbers. An Enumerator is a special native object which converts itself into either a String or a Number depending on the context:

// ID CS5+

alert( SpecialCharacters.emDash ); // => EM_DASH (string)

alert( +SpecialCharacters.emDash ); // => 1397058884 (number)

In fact, these respectively correspond to myEnumerator.toString() and myEnumerator.valueOf():

// ID CS5+

var myEnumerator = SpecialCharacters.emDash;

alert( myEnumerator.toString() ); // => EM_DASH (string)

alert( myEnumerator.valueOf() ); // => 1397058884 (number)

But every Enumerator has its == and === operators overriden so as we can still compare it with a number:

alert( SpecialCharacters.emDash==1397058884 ); // => true

alert( SpecialCharacters.emDash===1397058884 ); // => true

Also, an Enumeration object see both the camelcase and the uppercase name of an enumerator as a regular own property:

// ID CS5+

alert( SpecialCharacters.hasOwnProperty('emDash') ); // => true

alert( SpecialCharacters.hasOwnProperty('EM_DASH') ); // => true

Both are [[enumerable]] but the for-in loop only collects the uppercase forms ('EM_DASH', etc.).

@+

Marc

Trevor:
Legend
July 8, 2012

Hi Marc or anybody else who knows

Is there a way of getting the full Enumeration string, i.e. SpecialCharacters.EM_DASH and not just EM_DASH ?

Regards

Trevor

Harbs.
Legend
July 8, 2012

Huh?

I'm not sure what you are asking...

Marc Autret
Legend
January 19, 2012

Hi Ariel,

Use the Unicode code point in the GREP F/R field this way:

\x{200E}

See also:

http://www.indiscripts.com/post/2009/07/idcs4-special-characters

@+

Marc

TᴀW
TᴀWAuthor
Legend
January 19, 2012

Hi Marc,

Thank you. I couldn't find that documented anywhere.

Ariel

id-extras.com | InDesign tools & scripts for typesetters, form designers, and translators