Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

unicode characters and their support in java  RSS feed

 
Robert Ingmarsson
Greenhorn
Posts: 27
Java Netbeans IDE PHP
  • Mark post as helpful
  • send pies
  • 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.
 
Tony Docherty
Bartender
Posts: 3205
78
  • Mark post as helpful
  • send pies
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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.
 
m Korbel
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • 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)



 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!