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

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

Community Expert ,
Dec 01, 2016 Dec 01, 2016

Copy link to clipboard

Copied

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

TOPICS
Scripting

Views

1.3K

Translate

Translate

Report

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
Community Expert ,
Dec 01, 2016 Dec 01, 2016

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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
Contributor ,
Dec 02, 2016 Dec 02, 2016

Copy link to clipboard

Copied

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

Thanks Stefan

Votes

Translate

Translate

Report

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
Community Expert ,
Dec 02, 2016 Dec 02, 2016

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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 ,
Dec 02, 2016 Dec 02, 2016

Copy link to clipboard

Copied

Hello Uwe,

Isn't the problem these special characters are meant to be ignored?

I have some text with a note in the middle.

Screen Shot 2016-12-02 at 13.45.52.png

P.

Votes

Translate

Translate

Report

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
Community Expert ,
Dec 02, 2016 Dec 02, 2016

Copy link to clipboard

Copied

Hi Pickory,

the matter is, if you want to find them, you can:

Two Note objects next to each other in layout and story view:

TwoNotesNextToEachOther-StoryView.png

The two characters found by TEXT Find/Change:

TwoNotesNextToEachOther-TextFind-FoundOneInstance.png

Regards,
Uwe

Votes

Translate

Translate

Report

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 ,
Dec 02, 2016 Dec 02, 2016

Copy link to clipboard

Copied

Hello Uwe,

Just because you can, doesn't mean you should.

Why are you doing it? Or, are you just testing?

P.

Votes

Translate

Translate

Report

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
Community Expert ,
Dec 02, 2016 Dec 02, 2016

Copy link to clipboard

Copied

Hi Pickory,

mainly for testing.

I have some ideas using Note objects in a special way.
And one key is to find two Notes adjacent to each other.

Since Note objects could be "anywhere"—in Stories, Bookmarks Footnotes* , Tables (nested or not), even Notes can contain Notes—I was looking for a quick way to find them. And two <FEFF> characters next to each other are likely candidates for containing two notes.

Furher testing with Text Find/Change of the UI and the search strings <FEFF> or <FEFF><FEFF> reveal some more oddities:

For example have two Notes placed next to each other in the middle of a Story, do a search for <FEFF><FEFF> and try to replace them with, let's say "N" that should stand for "Notes". The right Note of the two will be replaced with 4 times "N". The left Note is still there. Run the replacement again and another 4 "N"s are added, but one of the "N"s of the first replacement is removed, the left Note is still there…

I can only tell:

Something very strange is going on with <FEFF> special characters containing Note objects and Text Find/Change.

Regards,
Uwe

* EDIT: Meant "Footnotes" not "Bookmarks". Sorry.

Votes

Translate

Translate

Report

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 ,
Dec 03, 2016 Dec 03, 2016

Copy link to clipboard

Copied

Hello Uwe,

I think accessing those 'owned' items directly is dangerous. If you use the UI, InDesign takes care of keeping the notes intact. There are other instances of those owned items, index markers and hyperlink destinations.

P.

Votes

Translate

Translate

Report

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
Community Expert ,
Dec 03, 2016 Dec 03, 2016

Copy link to clipboard

Copied

Now that I detected the oddities around searching <FEFF> I think I can live with it.
I am able to extract a unique Note object out of a found text with Text Find/Change by its unique id number and then refer to the Note object directly. So adding text, extracting text, doing a label or removing the Note object is no problem at all.

Thanks,
Uwe

Votes

Translate

Translate

Report

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 ,
Dec 04, 2016 Dec 04, 2016

Copy link to clipboard

Copied

LATEST

Hello Uwe,

Ah, I thought you were going to try to modify the owned items / special characters.

I presume you are going to use the selection returned by your find to access the notes, clever!

P.

Votes

Translate

Translate

Report

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