Encode single quote into &#x27; instead of &apos;

&apos; does not appear in HTML.
http://www.w3.org/TR/xhtml1/#C_16

My browser, for example, latest Chrome does not understand `&apos;` and renders the text as is. I have not tested on other browsers but, in any case, this small change will make the escaped entity work on pretty much every browser.