PHP 8.2.30
Preview: kanji-data.js Size: 1.55 KB
//proc/thread-self/root/home/byroehnu/.trash/node_modules11/qrcode/lib/core/kanji-data.js

const Mode = require('./mode')
const Utils = require('./utils')

function KanjiData (data) {
  this.mode = Mode.KANJI
  this.data = data
}

KanjiData.getBitsLength = function getBitsLength (length) {
  return length * 13
}

KanjiData.prototype.getLength = function getLength () {
  return this.data.length
}

KanjiData.prototype.getBitsLength = function getBitsLength () {
  return KanjiData.getBitsLength(this.data.length)
}

KanjiData.prototype.write = function (bitBuffer) {
  let i

  // In the Shift JIS system, Kanji characters are represented by a two byte combination.
  // These byte values are shifted from the JIS X 0208 values.
  // JIS X 0208 gives details of the shift coded representation.
  for (i = 0; i < this.data.length; i++) {
    let value = Utils.toSJIS(this.data[i])

    // For characters with Shift JIS values from 0x8140 to 0x9FFC:
    if (value >= 0x8140 && value <= 0x9FFC) {
      // Subtract 0x8140 from Shift JIS value
      value -= 0x8140

    // For characters with Shift JIS values from 0xE040 to 0xEBBF
    } else if (value >= 0xE040 && value <= 0xEBBF) {
      // Subtract 0xC140 from Shift JIS value
      value -= 0xC140
    } else {
      throw new Error(
        'Invalid SJIS character: ' + this.data[i] + '\n' +
        'Make sure your charset is UTF-8')
    }

    // Multiply most significant byte of result by 0xC0
    // and add least significant byte to product
    value = (((value >>> 8) & 0xff) * 0xC0) + (value & 0xff)

    // Convert result to a 13-bit binary string
    bitBuffer.put(value, 13)
  }
}

module.exports = KanjiData

Directory Contents

Dirs: 0 × Files: 22

Name Size Perms Modified Actions
2.93 KB lrw-r--r-- 2026-02-27 09:44:58
Edit Download
1.78 KB lrw-r--r-- 2026-02-27 09:44:58
Edit Download
719 B lrw-r--r-- 2026-02-27 09:44:58
Edit Download
1.47 KB lrw-r--r-- 2026-02-27 09:44:58
Edit Download
675 B lrw-r--r-- 2026-02-27 09:45:00
Edit Download
3.33 KB lrw-r--r-- 2026-02-27 09:45:00
Edit Download
893 B lrw-r--r-- 2026-02-27 09:45:00
Edit Download
599 B lrw-r--r-- 2026-02-27 09:45:00
Edit Download
1.10 KB lrw-r--r-- 2026-02-27 09:45:00
Edit Download
1.85 KB lrw-r--r-- 2026-02-27 09:45:00
Edit Download
1.55 KB lrw-r--r-- 2026-02-27 09:45:00
Edit Download
5.96 KB lrw-r--r-- 2026-02-27 09:45:00
Edit Download
3.89 KB lrw-r--r-- 2026-02-27 09:45:00
Edit Download
1.18 KB lrw-r--r-- 2026-02-27 09:45:00
Edit Download
1.55 KB lrw-r--r-- 2026-02-27 09:45:00
Edit Download
14.77 KB lrw-r--r-- 2026-02-27 09:45:00
Edit Download
1.59 KB lrw-r--r-- 2026-02-27 09:45:00
Edit Download
1.06 KB lrw-r--r-- 2026-02-27 09:45:02
Edit Download
9.11 KB lrw-r--r-- 2026-02-27 09:45:02
Edit Download
1.58 KB lrw-r--r-- 2026-02-27 09:45:04
Edit Download
268 B lrw-r--r-- 2026-02-27 09:45:04
Edit Download
4.81 KB lrw-r--r-- 2026-02-27 09:45:04
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).