This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Rust Web Development and have Bastian Gruber on-line!
See this thread for details.
Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Easy way to convert text characters to html?

 
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am writing servlets with text in them. Every time I have a comma, apostrophe, ampersand or similar characters I have to use the html special characters. Is there some easier way to do this other than me manually searching for the character and replacing with the html code equivalent? If I don't convert the characters an ampersand becomes a question mark ect . ..

Thanks!
 
Ranch Hand
Posts: 820
IntelliJ IDE VI Editor Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Peter Bergoff wrote:Hi,

I am writing servlets with text in them. Every time I have a comma, apostrophe, ampersand or similar characters I have to use the html special characters. Is there some easier way to do this other than me manually searching for the character and replacing with the html code equivalent? If I don't convert the characters an ampersand becomes a question mark ect . ..

Thanks!



please see http://stackoverflow.com/questions/655746/is-there-a-jdk-class-to-do-html-encoding-but-not-url-encoding
 
Sheriff
Posts: 67618
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Peter Bergoff wrote: I am writing servlets with text in them. Every time I have a comma, apostrophe, ampersand or similar characters I have to use the html special characters.


No, you don't. The ampersand, yes, you must use & because it is in the introducer for HTML entities, but commas and most other characters do not need to be HTML-encoded.

Obviously, the angle brackets need to be encoded into HTML entities.
 
Peter Bergoff
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bear and Tim - You guys rock. Thanks.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic