aspose file tools*
The moose likes Java in General and the fly likes Escape all special characters in HTML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Escape all special characters in HTML" Watch "Escape all special characters in HTML" New topic
Author

Escape all special characters in HTML

Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3697
    
    5

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


My Blog: Down Home Country Coding with Scott Selikoff
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29261
    
140

Scott,
Have you looked at Apache Commons. Not built in, but reusable. It sounds like StringEscapeUtils has what you want.

[edited to fix typo]


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3697
    
    5

Thanks! I'll give it a shot and see.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Escape all special characters in HTML
 
Similar Threads
Escaping HTML Text
Problem with escape chars...
cancel button problem
"Could not create task of type: echo"
backslash is removed from the parameter when javascript function get the parameter from java call