• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Escape all special characters in HTML

 
Scott Selikoff
author
Saloon Keeper
Posts: 4010
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Is there a simple (built-in) method in java for escaping a string containing special characters to HTML? I came across this page which is useful but not complete. There's a couple hundred in this table that I would like to add. Right now, my only solution is to manually edit the text of the first page to include more of the codes of the second, but I feel like I'm re-inventing the wheel.

Is there a better way to do this?

-Scott
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34210
341
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Scott,
Have you looked at Apache Commons. Not built in, but reusable. It sounds like StringEscapeUtils has what you want.

[edited to fix typo]
 
Scott Selikoff
author
Saloon Keeper
Posts: 4010
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks! I'll give it a shot and see.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic