Context
Frequently requested across multiple QR code libraries:
Description
The QR code spec (ISO/IEC 18004) defines a Kanji encoding mode that efficiently encodes Shift JIS characters using 13 bits per character, significantly more compact than byte mode for Japanese text. This is one of the four core encoding modes alongside numeric, alphanumeric, and byte.
Current Status in etiket
The types and mode indicators exist (kanji is in EncodingMode, MODE_INDICATOR.kanji = 0b1000), but the encoder throws an error:
case "kanji":
throw new Error("Kanji encoding mode is not yet supported. Use byte mode for non-ASCII text.");
Byte mode works for UTF-8 text but produces larger QR codes for Japanese content.
Proposed Solution
- Implement Shift JIS encoding for Kanji mode in
src/encoders/qr/mode.ts
- Add Kanji character detection to
selectMode() in src/encoders/qr/version.ts
- Update the segment optimizer to consider Kanji mode switching
- Add ECI (Extended Channel Interpretation) mode support for specifying character sets beyond the default (ISO 8859-1)
Context
Frequently requested across multiple QR code libraries:
Description
The QR code spec (ISO/IEC 18004) defines a Kanji encoding mode that efficiently encodes Shift JIS characters using 13 bits per character, significantly more compact than byte mode for Japanese text. This is one of the four core encoding modes alongside numeric, alphanumeric, and byte.
Current Status in etiket
The types and mode indicators exist (
kanjiis inEncodingMode,MODE_INDICATOR.kanji=0b1000), but the encoder throws an error:Byte mode works for UTF-8 text but produces larger QR codes for Japanese content.
Proposed Solution
src/encoders/qr/mode.tsselectMode()insrc/encoders/qr/version.ts