nuintun / qrcode

A pure JavaScript QRCode encode and decode library.
https://nuintun.github.io/qrcode
MIT License
198 stars 26 forks source link

GB2312 编码 #333

Closed nuintun closed 6 months ago

nuintun commented 6 months ago
function getGB2312Codes(content: string): Uint8Array {
  const bytes: number[] = [];

  for (const character of content) {
    let code = GB2312_MAPPING.get(character);

    // If not found, push "?".
    code = code != null ? code : 41919;

    // Write with big endian.
    bytes.push((code >> 8) & 0xff, code & 0xff);
  }

  return new Uint8Array(bytes);
}