Skip to main content
Known Participant
January 29, 2016
Question

Inserting an apostrophe (char code '==39)

  • January 29, 2016
  • 2 replies
  • 841 views

OK here is a weird one:

I'm trying to insert a ' (single quote char code 39) into a string to display as text but it keeps showing up as a >

If I go into Photoshop and try to enter a single quote, it does the same thing (>). Yet if you copy this exact single quote char from this post and paste it into the text box, it correctly shows up as a '.

Then if I try see what the char code of that pasted ' is, it still shows up as 39, so I can't replace it using the char code value. Does anyone have any idea what is going on? I know I can replace it with another single quote char, such as 180, but it is drawn differently from 39;

If I replace the 39 with any other character it works fine, for instance:

str.replace(String.fromCharCode(39),'*');

I'm totally baffled by this. Any idea what might be happening or how I can fix this?

str.replace(String.fromCharCode(39),String.fromCharCode([WHAT GOES HERE]));

PS - I'm using Century Gothic, so I know this character exists (since I can paste it in) but it seems to happen on every font option I use if trying to type the character. I have no issue typing the ' in another other application on Windows, this is only occurring in Photoshop.

PPS - Clearly just grasping at straws here, I also tried to replace ' (39) with > (62) or to escape the apostrophe:

str.replace(String.fromCharCode(39),String.fromCharCode(62)); // results in >

str.replace(String.fromCharCode(39),'\''); // results in >

str.replace(String.fromCharCode(39),"\'"); // results in >

str.replace('\'', String.fromCharCode(39));// results in >

str.replace("\'", String.fromCharCode(39));// results in >

This topic has been closed for replies.

2 replies

pixxxelschubser
Community Expert
Community Expert
January 31, 2016

Sorry, my previous posting means the wrong forum.

Which language do you use?

In Photoshop this should work:

var str = app.activeDocument.activeLayer.textItem.contents + String.fromCharCode(0x2019)

app.activeDocument.activeLayer.textItem.contents = str;

cwodwrthAuthor
Known Participant
February 8, 2016

This solution did work, replacing with String.fromCharCode(0x2019).


Turns out the real cause of the issue was with Smart Quotes. If any one is having this issue in the future try:

Edit > Preferences > Type > Make sure 'Use Smart Quotes' is unchecked

Thank you!

pixxxelschubser
Community Expert
Community Expert
January 30, 2016

At first: check your preferences.

dictionary - simple quotation marks (not <> but ‚‘)

second

try String.fromCharCode(0x2019)