Skip to main content
Community Expert
December 1, 2016
Question

Text Find/Change | Syntax for two special characters <FEFF> next to each other

  • December 1, 2016
  • 1 reply
  • 1923 views

Hi all,

just found an oddity with InDesign's app.findTextPreferences.findWhat concerning special characters.


I wanted to find two special characters encoded as <FEFF> that are next to each other.

Did that with InDesign's UI Text Find/Replace function and typed <FEFF><FEFF> in the search field.

In my sample document there were two of them next to each other so the result was:
one single instance.

Now the scripting side:

app.findTextPreferences.findWhat = "<FEFF><FEFF>";

var result = app.documents[0].findText();

alert(result.length); // 2

"<FEFF><FEFF>" found two instances instead of one.

The special characters in my sample document contain one Note object each so I could read out the Note's id number and found that indeed the two notes were found twice!

My solution was to change the search string a bit:

app.findTextPreferences.findWhat = "<FEFF>"+"<FEFF>";

var result = app.documents[0].findText();

alert(result.length); // 1

That gave me the right number of results.

Tested with InDesign CS 6 v8.1.0 and CC 2017 v12.0.0.81 on OSX 10.10.5.

Did I detect a bug?

Or should special strings always be written on their own as substrings and concatenated when working with Text Find/Replace ?

Regards,
Uwe

Message was edited by: Uwe Laubender

This topic has been closed for replies.

1 reply

LaubenderCommunity ExpertAuthor
Community Expert
December 1, 2016

Did further testing with very mixed results with more sample documents.

Sometimes even "<FEFF>"+"<FEFF>" in the search string resulted in doubles.

Also the position of the special characters in a text frame seems to be of importance.

E.g. if the two characters are positioned at the beginning or at the end of a story the results would not be doubled…

Since I'd like to get Note objects, that are next to each other, I came to the conclusion, that I would better gather the notes out from the special characters and inspect their id numbers instead of processing something like

var note1 = result.notes[0];

var note2 = result.notes[1];

directly.

More on that tomorrow or at the weekend.

Regards,
Uwe

Stefan Rakete
Inspiring
December 2, 2016

FEFF are XmlTag characters. You cannot find these characters nor with the GREP UI or by scripting.

Thanks Stefan

LaubenderCommunity ExpertAuthor
Community Expert
December 2, 2016

Hi Stefan,

but you can find them. :-)

Not with GREP UI, but by using TEXT Find/Change.
And also by using the script implementation of TEXT Find/Change.

And FEFF are not only XML-Tag special characters, but also—among others—ones that carry InDesign's Note Object.

Regards,
Uwe