aboutsummaryrefslogtreecommitdiff
path: root/hash_script/node_modules/iconv-lite/encodings/sbcs-codec.js
diff options
context:
space:
mode:
authorYuchen Pei <hi@ypei.me>2022-07-28 15:32:10 +1000
committerYuchen Pei <hi@ypei.me>2022-07-28 15:32:10 +1000
commit5b10a10743b8459f64fe83e0ff420f69da79c9a4 (patch)
treec61904d688247790181d4955a4074b8c94302c03 /hash_script/node_modules/iconv-lite/encodings/sbcs-codec.js
parentb98cb70b1bcd5b211aaa5d2675f96416911c0647 (diff)
Moving scripts and utilities into a new utilities dir
Diffstat (limited to 'hash_script/node_modules/iconv-lite/encodings/sbcs-codec.js')
-rw-r--r--hash_script/node_modules/iconv-lite/encodings/sbcs-codec.js73
1 files changed, 0 insertions, 73 deletions
diff --git a/hash_script/node_modules/iconv-lite/encodings/sbcs-codec.js b/hash_script/node_modules/iconv-lite/encodings/sbcs-codec.js
deleted file mode 100644
index 7789e00..0000000
--- a/hash_script/node_modules/iconv-lite/encodings/sbcs-codec.js
+++ /dev/null
@@ -1,73 +0,0 @@
-"use strict";
-var Buffer = require("buffer").Buffer;
-
-// Single-byte codec. Needs a 'chars' string parameter that contains 256 or 128 chars that
-// correspond to encoded bytes (if 128 - then lower half is ASCII).
-
-exports._sbcs = SBCSCodec;
-function SBCSCodec(codecOptions, iconv) {
- if (!codecOptions)
- throw new Error("SBCS codec is called without the data.")
-
- // Prepare char buffer for decoding.
- if (!codecOptions.chars || (codecOptions.chars.length !== 128 && codecOptions.chars.length !== 256))
- throw new Error("Encoding '"+codecOptions.type+"' has incorrect 'chars' (must be of len 128 or 256)");
-
- if (codecOptions.chars.length === 128) {
- var asciiString = "";
- for (var i = 0; i < 128; i++)
- asciiString += String.fromCharCode(i);
- codecOptions.chars = asciiString + codecOptions.chars;
- }
-
- this.decodeBuf = new Buffer(codecOptions.chars, 'ucs2');
-
- // Encoding buffer.
- var encodeBuf = new Buffer(65536);
- encodeBuf.fill(iconv.defaultCharSingleByte.charCodeAt(0));
-
- for (var i = 0; i < codecOptions.chars.length; i++)
- encodeBuf[codecOptions.chars.charCodeAt(i)] = i;
-
- this.encodeBuf = encodeBuf;
-}
-
-SBCSCodec.prototype.encoder = SBCSEncoder;
-SBCSCodec.prototype.decoder = SBCSDecoder;
-
-
-function SBCSEncoder(options, codec) {
- this.encodeBuf = codec.encodeBuf;
-}
-
-SBCSEncoder.prototype.write = function(str) {
- var buf = new Buffer(str.length);
- for (var i = 0; i < str.length; i++)
- buf[i] = this.encodeBuf[str.charCodeAt(i)];
-
- return buf;
-}
-
-SBCSEncoder.prototype.end = function() {
-}
-
-
-function SBCSDecoder(options, codec) {
- this.decodeBuf = codec.decodeBuf;
-}
-
-SBCSDecoder.prototype.write = function(buf) {
- // Strings are immutable in JS -> we use ucs2 buffer to speed up computations.
- var decodeBuf = this.decodeBuf;
- var newBuf = new Buffer(buf.length*2);
- var idx1 = 0, idx2 = 0;
- for (var i = 0; i < buf.length; i++) {
- idx1 = buf[i]*2; idx2 = i*2;
- newBuf[idx2] = decodeBuf[idx1];
- newBuf[idx2+1] = decodeBuf[idx1+1];
- }
- return newBuf.toString('ucs2');
-}
-
-SBCSDecoder.prototype.end = function() {
-}