7

i am using the cluetip plugin and the simple use case is to to put the content in a title attribute, like below:

<a title='Top title|detail content'>Text</a>

i am now running into issues where the string that is inside "detail content' has an apostrophe inside of it and it seems to confuse cluetip plugin. Is there anyway to escape or encode an apostrophe to allow cluetip to work properly.

leora
  • 188,729
  • 360
  • 878
  • 1,366
  • 2
    In .net 4.0 System.Web.HttpUtility.HtmlEncode works, but in 3.5 for some reason it skips single apostrophes. You can use System.Security.SecurityElement.Escape if you're in 3.5. – Hardwareguy Oct 14 '11 at 19:14

3 Answers3

11

You're looking for &apos;.
See HTML entities.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • is there an method in the .net 3.5 library to take a string and convert all of these characters like apostrophe and convert them to their equivalent (' in this case) – leora May 23 '11 at 03:30
  • 5
    htmlEncode method doesn't seem to do anything to apostrophes. – leora May 23 '11 at 03:58
  • @ooo: Sorry; `HtmlAttributeEncode`. (But you also need to use double-quoted attributes) – SLaks May 23 '11 at 13:05
  • reasons for using System.Security.SecurityElement.Escape given @ http://stackoverflow.com/a/1934252/41153 – Michael Paulukonis Apr 22 '13 at 18:41
3

You'll want to use &#39; per this link since &apos; has flaky browser support. See this old post for more info.

Community
  • 1
  • 1
Quanta
  • 465
  • 5
  • 14
0

have you tried HTML escaping the apostrophe?

Mark Hosang
  • 501
  • 5
  • 21