[ 2 posts ]

Levan

  • Username: levancho
  • Joined: Thu Sep 17, 2009 3:29 am
  • Posts: 129
  • Location: New York, NY
  • Twitter: dlevancho
  • GitHub: levancho
  • Gists: levancho
  • Offline
  • Profile

how to add html entities

Post Posted: Thu Jun 17, 2010 6:28 am
+0-
I tried:

Code:
tcDiv.text(" ");


but it generates:

Code:
<div class="ct">&amp;nbsp;</div>

Eric Ferraiuolo

YUI Developer

  • Username: ericf
  • Joined: Mon Jan 12, 2009 8:26 pm
  • Posts: 380
  • Location: Boston, MA
  • Twitter: ericf
  • GitHub: ericf
  • Gists: ericf
  • IRC: eric_f
  • YUI Developer
  • Offline
  • Profile

Re: how to add html entities

Post Posted: Thu Jun 17, 2010 7:15 am
+0-
Interesting question.

The text method is calling document.createTextNode
http://github.com/yui/yui3-gallery/blob ... out.js#L79

createTextNode takes a DOMString which is encoded using UTF-16
http://www.w3.org/TR/2000/REC-DOM-Level ... #DOMString

Looks like you're getting doubled encoding. Could you just do: tcDiv.text(" "); with a literal space char?
  [ 2 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum