diff options
| author | AlexGeller1 <87009702+AlexGeller1@users.noreply.github.com> | 2021-10-21 18:10:28 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-21 18:10:28 +0300 |
| commit | 2e22d09479daf204b24ef57d939c0a78a5fe9769 (patch) | |
| tree | 9aada3260bd1f9d0670e72c7e68cc269b54f01e6 /core/src/test/java | |
| parent | c729abe393b9ace4beefe83b52add392853072c3 (diff) | |
| download | zxing-2e22d09479daf204b24ef57d939c0a78a5fe9769.tar.xz | |
Compact QR-Code: Support more character sets (in particular cp1256 (Arabic) and Shift-JIS) (#1453)
* - added code to suppress the terminator if the capacity of the version is less than 4 bit
- added test case
* - Removed code in MinimalEncoder that added Mode.TERMINATOR (is taken care of in Encoder.terminateBits)
- Removed the corresponding test case
* Updated test cases
* Improved documentation
* Changed documentation to not use an example with an unsupported character encoding
* Improved wording of comment
* - Simplified code
- Added space after comma in several places
* Added support for more character sets supported by CharacterSetECI
* Syntactic enhancements
* Changed instantiation of generic types to diamond style
* Updated documentation of the QR_COMPACT hint to explain the impact of setting the CHARACTER_SET hint .
* Changed whitespace
* Removed comment
* Fixed typos in comments
* Added text cases for KANJI and Shift_JS encoding
* Improved comments on Japanese language test cases
Diffstat (limited to 'core/src/test/java')
| -rw-r--r-- | core/src/test/java/com/google/zxing/qrcode/encoder/EncoderTestCase.java | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/core/src/test/java/com/google/zxing/qrcode/encoder/EncoderTestCase.java b/core/src/test/java/com/google/zxing/qrcode/encoder/EncoderTestCase.java index 9c1cd73d8..b76ef3840 100644 --- a/core/src/test/java/com/google/zxing/qrcode/encoder/EncoderTestCase.java +++ b/core/src/test/java/com/google/zxing/qrcode/encoder/EncoderTestCase.java @@ -882,6 +882,29 @@ public final class EncoderTestCase extends Assert { true); } + @Test + public void testMinimalEncoder42() throws Exception { + // test halfwidth Katakana character (they are single byte encoded in Shift_JIS) + verifyMinimalEncoding("Katakana:\uFF66\uFF66\uFF66\uFF66\uFF66\uFF66", "ECI(Shift_JIS),BYTE(Katakana:......)", null + , false); + } + + @Test + public void testMinimalEncoder43() throws Exception { + // The character \u30A2 encodes as double byte in Shift_JIS so KANJI is more compact in this case + verifyMinimalEncoding("Katakana:\u30A2\u30A2\u30A2\u30A2\u30A2\u30A2", "BYTE(Katakana:),KANJI(......)", null, + false); + } + + @Test + public void testMinimalEncoder44() throws Exception { + // The character \u30A2 encodes as double byte in Shift_JIS but KANJI is not more compact in this case because + // KANJI is only more compact when it encodes pairs of characters. In the case of mixed text it can however be + // that Shift_JIS encoding is more compact as in this example + verifyMinimalEncoding("Katakana:\u30A2a\u30A2a\u30A2a\u30A2a\u30A2a\u30A2", "ECI(Shift_JIS),BYTE(Katakana:.a.a.a" + + ".a.a.)", null, false); + } + static void verifyMinimalEncoding(String input, String expectedResult, Charset priorityCharset, boolean isGS1) throws Exception { MinimalEncoder.ResultList result = MinimalEncoder.encode(input, null, priorityCharset, isGS1, |
