• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to convert special character registered trademark ® to number code & # 174;

 
chaohua wang
Ranch Hand
Posts: 62
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Folks,

I need to convert special character ® to number code &# 174;

http://www.webmonkey.com/2010/02/special_characters/

is there any java API method which can do convert?
Thank you
Chwang
 
Michael Dunn
Ranch Hand
Posts: 4632
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you mean like this?

javax.swing.JOptionPane.showMessageDialog(null, "\u00ae");
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or an HTML escaping utility, but I don't know if it would escape it to a named entity or the number. Apache Commons Lang has such utilities.

(And no, I don't think displaying it in an option pane is really converting it to an entity.)
 
Rob Spoor
Sheriff
Pie
Posts: 20372
44
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The 174 is the int representation of the character; 00ae is hexadecimal for 174. So just cast your char into an int, then wrap it in &# and ;
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic