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

MAC Unique Code Issue

Contributor ,
Nov 15, 2021 Nov 15, 2021

Copy link to clipboard

Copied

Hi Everyone,

 

I tried to replace the bulletin content using unicode but the space after the unicode was not getting deducted... I'm using mac with bigsir os.

What to do with this?????

//bulletin unicode with space 
scriptCode.Append(" app.findTextPreferences.findWhat = '\\u2022    '; ");  //not working
scriptCode.Append(" app.changeTextPreferences.changeTo ='\\u2022 '; ");
scriptCode.Append(" app.activeDocument.changeText();")

//bulletin unicode without space
scriptCode.Append(" app.findTextPreferences.findWhat = '\\u2022'; ");  //working
scriptCode.Append(" app.changeTextPreferences.changeTo ='\\u2022'; ");
scriptCode.Append(" app.activeDocument.changeText();")

by,

-Jo

TOPICS
Bug , Scripting , SDK

Views

465

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

correct answers 1 Correct answer

Community Expert , Nov 15, 2021 Nov 15, 2021

Use \\x{2022}, not \\u2022

And use just one space after the code. " +" means 'one or more spaces'. So:

scriptCode.Append(" app.findGrepPreferences.findWhat = '\\x{2022}\\K +'; ");

Votes

Translate

Translate
Community Expert ,
Nov 15, 2021 Nov 15, 2021

Copy link to clipboard

Copied

Hi Jo, if I understand you right, please try this:

app.findGrepPreferences = NothingEnum.NOTHING;
app.changeGrepPreferences = NothingEnum.NOTHING;
app.findGrepPreferences.properties = ({ findWhat: '\u2022 ' });
app.changeGrepPreferences.properties = ({ changeTo: '\u2022' });
app.activeDocument.changeGrep();

- Mark 

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 ,
Nov 15, 2021 Nov 15, 2021

Copy link to clipboard

Copied

Mark -- You need the \x{....} format in Grep searches, so here you'd need \\x{2022}

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 ,
Nov 21, 2021 Nov 21, 2021

Copy link to clipboard

Copied

LATEST

Thanks Peter, I've a lot to learn about indesign grep, but in this case I just used a literal extendscript string—no escaped backslash. It worked for me on Mac, by the way, but apparently not for Jo, so maybe we can't specify literal extendscript string with unicode on Windows? No need to answer. You're answer is far better. Thanks again.

- Mark

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 ,
Nov 15, 2021 Nov 15, 2021

Copy link to clipboard

Copied

Hi mlb,

 

I tried your solution but it doesn't work is there any other way to fix it....

What i'm trying to do is to find the "\\u2022    " followed by four space and to replace it as "\\u2022 " followed by one space........

For windows what i have done here is working there but in mac it was not working.....

jothipriya_0-1636976757211.png

 

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 ,
Nov 15, 2021 Nov 15, 2021

Copy link to clipboard

Copied

Your code works only if \u2022 is followed by four or more spaces. A Grep replacement in this case is much more flexible than a Text replament:

 

 

scriptCode.Append(" app.findTextPreferences.findWhat = '\\x{2022} \\K +'; ");  //not working
scriptCode.Append(" app.changeTextPreferences.changeTo = ''; ");
scriptCode.Append(" app.activeDocument.changeText();")

 

 

This reads as 'look for multiple apces preceded by a bulletpoint+space and delete those spaces'.

P.

 

(edit: Mark beat me to it)

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 ,
Nov 15, 2021 Nov 15, 2021

Copy link to clipboard

Copied

It's not working peter...

Kindly refer to the screenshot attached here

 

jothipriya_0-1636975308436.pngjothipriya_1-1636975330769.png

 

Thanks,

-Jo

 

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 ,
Nov 15, 2021 Nov 15, 2021

Copy link to clipboard

Copied

Sorry, findTextPreferences should be findGrepPreferences. And changeTextPreferences should be changeGrepPreferences.

 

By the way, out of curiosity, why do you use scriptCode.Append ()? 

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 ,
Nov 15, 2021 Nov 15, 2021

Copy link to clipboard

Copied

Tried that also but nothing works peter is there any other way????

jothipriya_0-1636980853929.png

 

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 ,
Nov 15, 2021 Nov 15, 2021

Copy link to clipboard

Copied

Use \\x{2022}, not \\u2022

And use just one space after the code. " +" means 'one or more spaces'. So:

scriptCode.Append(" app.findGrepPreferences.findWhat = '\\x{2022}\\K +'; ");

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 ,
Nov 15, 2021 Nov 15, 2021

Copy link to clipboard

Copied

FWIW: That's the syntax for Text Find/Replace:

 

 

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

 

 

You can see that in the UI as well:

FindTextUniCodeCodePoint.PNG

 

 

Regards,
Uwe Laubender

( ACP )

 

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 ,
Nov 16, 2021 Nov 16, 2021

Copy link to clipboard

Copied

Thanks all,

 

Now my problem is solved..

 

Thanks,

-Jo

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