3 Replies Latest reply on Feb 8, 2016 11:10 AM by cwodwrth

    Inserting an apostrophe (char code '==39)

    cwodwrth Level 1

      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:




      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 >