How to create Unicode characters in iTextSharp?
I am trying to create the Greek character phi in iTextSharp along with a number of other characters. I managed to do this by outputing:
Convert.ToChar(593)
When I look at the Wikipedia reference though, phi can be represented by
U+03A6 (934 decimal)
U+03C6 (966 decimal)
U+03D5 (965 decimal)
U+0278 (632 decimal)
However when I try
Convert.ToChar(934)
Convert.ToChar(966)
Convert.ToChar(965)
Convert.ToChar(632)
I get blanks.
How do I output these Unicode characters?开发者_如何学Go
I strongly suspect that the problem isn't the character value, but the encoding of the font[s] used to display that character.
If a given font/encoding cannot display a given character, you get a blank. When in doubt, use BaseFont.IDENTITY_H encoding. If that character (well... "glyph" really) exists in that font, you'll have access to it. You can even ask a BaseFont if it can display a given character (IIRC taking its glyphs and encoding into account) with myBaseFont.charExists(int)
.
精彩评论