Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Below is the string that needs to be passed into the javascript function as i do not want to do the replace , i need to display the original subject string without any modification in the String value.

 String subject="The apostrophe ( ’ or ' ) < is a punctuation mark,";
 <td style="border: none"><a>href="javascript:showPopUpMsg('<%=subject%>')</a></td>

can you please suggest me how to parse these special characters.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
296 views
Welcome To Ask or Share your Answers For Others

1 Answer

Escape ' character with backslash ():

String subject="The apostrophe ( ’ or ' ) < is a punctuation mark,";
 <td style="border: none"><a>href="javascript:showPopUpMsg('<%=subject%>')</a></td>

Also you can use String.replace ( see String.replace method, for more info)

String subject="The apostrophe ( ’ or ' ) < is a punctuation mark,";
subject.replace("'", "'");

href="javascript:showPopUpMsg('<%=subject%>')


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...