• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

unicode characters and their support in java

 
Ranch Hand
Posts: 201
2
Netbeans IDE PHP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Best, forumists and everyone else!

I have a question about how to properly and or/if use html entitites in java for example in ones jlabel objects in some
html encoded string? What guidelines should you consider before you use them too frequently. As an example i am a
terrible "graphist" so instead of using images as icons for buttons or download them free somewhere i use stars, plus
and minus signs and etc, encoded in html strings. There is a good page for entities i use often and like very much,
fileformat.info. I am shortly above a beginners grade in java and my english might have a few remarks in its grammar.
But gladely post comments on this topic. Is it a generally good idea to use html entities instead of graphics in
ones projects? Im just curious, not an expert. I hope this is a general question.

Best wishes,
Robert.
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Interesting question to which I don't know the answer. There will be an extra overhead involved in parsing and rendering the HTML over plain text but then there is an extra overhead for rendering images as well. I would imagine you would have to be displaying a great many components before it is likely to be a problem. You could always write a test program to display a few hundred components displaying plain text, another for HTML and a third with images and see if there is any noticeable difference for initial loading, redraws etc.
 
Sheriff
Posts: 67746
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
Why would you use HTML entities rather than the actual unicode characters? I assume you're not talking about on HTML pages.

 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As to your question, if they do what you want, why not?

Be aware that the font you use may not contain the unicode glyphs, or may render them differently from other fonts. Make sure you choose a font that contains the glyphs that you want.

More info: There are even font sets that have "graphics" as glyphs in place of "normal" characters for icons that unicode may not contain, which I find very useful for things like button icons. But I'm 100% web focused so your mileage may vary.
 
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
- in Swing (reduced for AWT) is just (valid for rest of programming languages and Native OSes) is about if concrete Font to support painting the concrete glyph

- Swing (reduced for AWT) support Html <=3.2 with reduced support for css formating

- different situation is in JavaFX8, there is Html5/css very good implemented, side effect are bugs in JavaFX Components (event, notifier)



 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've done what you're sort of asking, although HTML entities would have been the long way around. Java supports the entire Unicode character set so using the Unicode characters directly is the most straightforward way.

For example: in my Swing application, if a sighting entry has notes attached to it then I display ♫ next to it. The Java way to express that character is "\u266b", so that's what is in my code, not the HTML character escape.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic