Skip to content

Support Kanji encoding mode in QR codes #1

@productdevbook

Description

@productdevbook

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

  1. Implement Shift JIS encoding for Kanji mode in src/encoders/qr/mode.ts
  2. Add Kanji character detection to selectMode() in src/encoders/qr/version.ts
  3. Update the segment optimizer to consider Kanji mode switching
  4. Add ECI (Extended Channel Interpretation) mode support for specifying character sets beyond the default (ISO 8859-1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestfrom-competitorFeature inspired by competitor libraries

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions