The other thread was about a conversion bug in C#. This particular problem
happens because iText relies on Java to do the charset conversion otherwise
a lot of tables would have to be included. Some JDK treat chars outside the
codepage as '?' and others miss them entirely. In the second case
charExists() will work correctly.
 
Paulo
 


From: [EMAIL PROTECTED] on behalf of Jan Bentzen
Sent: Fri 24-Mar-06 16:50
To: [email protected]
Subject: [iText-questions] charExists(char) not reliable?

Hi all

 

Using HELVETICA with CP1252 I am seeing a problem similar (yet opposite) in nature to what was discussed in a previous thread: http://sourceforge.net/mailarchive/message.php?msg_id=14106085 (CharExists returning false for Arial Unicode and IDENTITY_H  )

 

When checking if certain characters exists using baseFont.charExists(char), I’m getting true returned for some characters (Hebrew, Japanese, Thai) that the font cannot represent. It ends up as all ‘?’s.

The code that I’m using is equivalent to:

 

BaseFont baseFont = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED);

                                                      

           if (baseFont.charExists(character)) {

                      return baseFont;

           }

 

1)       I seem to remember seeing a list of which built in fonts supported which encodings, and this being a valid combination. I haven’t been able to find that info again, though…. Do such a list exist?

2)       I noticed that the BaseFont.charExist(char) implementation ends up calling String.getBytes(“Cp1250”) on a string containing the input character. Part of the javadoc for this method states: “The behavior of this method when this string cannot be encoded in the given charset is unspecified”. This makes me a little worried..? What am I missing please?

 

Thanks for any guidance.

/jan

Reply via email to