Copy link to clipboard
Copied
Maybe my newness to Javascript has me thinking down the wrong path, but I thought I could just take a text string and run:
calloutText = calloutText.replace(/"/g, "\'");
and replace a double quote with a single quote. This works for simple quotes, but not for typographer's quotes. Is the manner of addressing curly quotes so obscure and variable that one must resort to the find object for handling this? I haven't seen this particular discussion in the forum.
calloutText = c.replace(/(“|”)/g, "'");
If you want to find quotes, you have to type them in the 1st parameter -- Alt+147 and Alt+148 characters (on Windows) -- instead of double quotes. In the 2nd parameter, you don't need escape the single quote inside the double quotes.
Kasyan
Copy link to clipboard
Copied
calloutText = c.replace(/(“|”)/g, "'");
If you want to find quotes, you have to type them in the 1st parameter -- Alt+147 and Alt+148 characters (on Windows) -- instead of double quotes. In the 2nd parameter, you don't need escape the single quote inside the double quotes.
Kasyan
Copy link to clipboard
Copied
-- The reason for this is that InDesign's Find & Change translates between straight double quotes and curly quotes, just for your convenience, but your code uses native Javascript and that doesn't do the auto-translate.
Kasyan's Find string contains the actual characters you should be searching for.
(On that note: I had a spot of trouble trying to use Unicode notation in a GREP string inside a Javascript -- I should look it up, but from memory I think \uXXXX didn't work. Is that because regexp-inside-js is another language altogether?)
Copy link to clipboard
Copied
Thanks, Kasyan, that was the clue I needed. I found that on my keyboard (Windoze) I have to make the key code four digits to show the correct quote, i.e.:
alt+ 0147: “ = left curly double quote
alt+ 0148: ” = right curly double quote
alt+ 0149: • = bullet character
alt+ 0145: ‘ = left curly single quote
alt+ 0146: ’ = right curly single quote, etc.
I wonder if there's a convenient reference to these key codes somewhere. I did a bit of searching and didn't find it. The ID CS4 manual lists all keyboard shortcuts, but has next to nothing on these key codes. No doubt they vary depending on the font's character set...
Thanks for your observations as well, Jongware. I'd like to see the answer to your question as well.
Copy link to clipboard
Copied
I wonder if there's a convenient reference to these key codes somewhere.
I use Character Map application to find Alt key numeric codes. I am sure in Google you can find a lot of such references -- here is my first hit.
Kasyan
Copy link to clipboard
Copied
> I use *Character Map* application to find Alt key numeric codes.
Excellent, Kasyan, thanks. Turns out my machine didn't have Character
Map installed, but it does now. It's always a marvel how much difference it
makes to have the precise terminology.
Daniel
Find more inspiration, events, and resources on the new Adobe Community
Explore Now