Skip to content

Commit

Permalink
Replacing non ISO-8859-1 characters in PDF417 input with '?' (#1514)
Browse files Browse the repository at this point in the history
* Replacing non ISO-8859-1 characters in input with '?' when neither a character set nor multi-eci encoding is selected.

* Changed code to raise an exception for characters not encodeable in ISO-8859-1
  • Loading branch information
AlexGeller1 committed Apr 27, 2022
1 parent 8265242 commit 5f20b8d
Showing 1 changed file with 9 additions and 0 deletions.
Expand Up @@ -171,6 +171,15 @@ private PDF417HighLevelEncoder() {
static String encodeHighLevel(String msg, Compaction compaction, Charset encoding, boolean autoECI)
throws WriterException {

if (encoding == null && !autoECI) {
for (int i = 0; i < msg.length(); i++) {
if (msg.charAt(i) > 255) {
throw new WriterException("Non-encodable character detected: " + msg.charAt(i) + " (Unicode: " +
(int) msg.charAt(i) +
"). Consider specifying EncodeHintType.PDF417_AUTO_ECI and/or EncodeTypeHint.CHARACTER_SET.");
}
}
}
//the codewords 0..928 are encoded as Unicode characters
StringBuilder sb = new StringBuilder(msg.length());

Expand Down

0 comments on commit 5f20b8d

Please sign in to comment.