tags:

views:

177

answers:

2

Hi,

I want to write a java program to print Unicode characters. I want to detect and not print Unknown/Unassigned CHaracters (which are shown by a rectangular). I have tried "isDefined" and "isISOControl" from "Character" class, but it does not work. Does anybody know the solution? it will be a big help for me.

Thanks.

+3  A: 

The characters that are shown as a rectangle (on Windows) are ones that aren't available in the font you're using. While you could filter out a lot of them by filtering out undefined and control characters, it's entirely possible that the problem you're running into is that your font doesn't support certain ranges of valid characters (which is typical -- very few fonts define glyphs for all defined Unicode characters).

If your goal is really to remove characters that render as a rectangle, you can use the canDisplay method in Font.

Laurence Gonsalves
A: 

Dear Laurence,

Thank you so much for your answer. Do you know any way to realize each character is supported by which font? as I said I want to print all Unicode characters. I have studied Unicode consortium font page. However, it was not very useful for me. Could you please guide me?

Thank you.

Shadi
A note about stackoverflow usage: instead of posting an answer you really should have posted a comment on the answer I'd posted. By posting a separate answer you both risk getting downvoted (because this isn't really an answer), and also it's only by luck that I even saw this answer, while a comment on my answer would have notified me.
Laurence Gonsalves
To answer your followup question: I'm not really sure what you're asking. What exactly is the input you expect and the output you want to see in response?
Laurence Gonsalves
Thank you. I wanted to add a comment, however, I could not have found the "Add comment" button.In my code, I want to print glyphs of Unicode characters. I think for each (group) of them, I should change the font. my first problem is that setting the font for each character is difficult, I am looking for an easiest way to set the appropriate font for each character.and my second problem, I do not know what is the appropriate font for some characters (a large number of them). Is there any API/way that tells me what is the appropriate font for a character? Thanks.
Shadi