• 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:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

Embedding Special Character in a Java String

 
Ranch Hand
Posts: 493
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This may be an easy one for someone here but is driving me crazy. I am trying to create a java String (note create not Print as in System.out.println(...)) which uses special characters. More specifically, I need to create a string which says 349 degrees where degrees should be replaced by that little circle symbol that appears to the right hand top corner of 9. I will be concatinating other characters to this string and then output the eventual string on a JSP page. I know that I can do it using HTML but I don't want to do that. I would rather create a compound Java String that has all such embedded characters and then let the JSP simply output it. Does anyone know how to create a String that has a non keyboard character such as the degrees symbol discussed above?
Thanks in advance.
Bharat
 
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For one thing (char)0x00B0 would work. I'm sure there's a better way to specify a literal by the Unicode code but I don't know what it is off the top of my head.
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not two minutes later I remember. You can use \uxxxx in any string or charactger literal. So you would want to use "\u00B0" or '\u00B0'.
 
Bharat Ruparel
Ranch Hand
Posts: 493
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ken. This is precisely what I needed. It works.
 
What are your superhero powers? Go ahead and try them on this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic