Projektstart
This commit is contained in:
6
backend/node_modules/encoding-japanese/src/banner.js
generated
vendored
Normal file
6
backend/node_modules/encoding-japanese/src/banner.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/*!
|
||||
* <%= pkg.name %> v<%= pkg.version %> - <%= pkg.description %>
|
||||
* Copyright (c) 2012 <%= pkg.author %>
|
||||
* <%= pkg.homepage %>
|
||||
* @license <%= pkg.license %>
|
||||
*/
|
||||
139
backend/node_modules/encoding-japanese/src/config.js
generated
vendored
Normal file
139
backend/node_modules/encoding-japanese/src/config.js
generated
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
var util = require('./util');
|
||||
var EncodingTable = require('./encoding-table');
|
||||
|
||||
// Fallback character when a character can't be represented
|
||||
exports.FALLBACK_CHARACTER = 63; // '?'
|
||||
|
||||
var HAS_TYPED = exports.HAS_TYPED = typeof Uint8Array !== 'undefined' && typeof Uint16Array !== 'undefined';
|
||||
|
||||
// Test for String.fromCharCode.apply
|
||||
var CAN_CHARCODE_APPLY = false;
|
||||
var CAN_CHARCODE_APPLY_TYPED = false;
|
||||
|
||||
try {
|
||||
if (String.fromCharCode.apply(null, [0x61]) === 'a') {
|
||||
CAN_CHARCODE_APPLY = true;
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
if (HAS_TYPED) {
|
||||
try {
|
||||
if (String.fromCharCode.apply(null, new Uint8Array([0x61])) === 'a') {
|
||||
CAN_CHARCODE_APPLY_TYPED = true;
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
exports.CAN_CHARCODE_APPLY = CAN_CHARCODE_APPLY;
|
||||
exports.CAN_CHARCODE_APPLY_TYPED = CAN_CHARCODE_APPLY_TYPED;
|
||||
|
||||
// Function.prototype.apply stack max range
|
||||
exports.APPLY_BUFFER_SIZE = 65533;
|
||||
exports.APPLY_BUFFER_SIZE_OK = null;
|
||||
|
||||
var EncodingNames = exports.EncodingNames = {
|
||||
UTF32: {
|
||||
order: 0
|
||||
},
|
||||
UTF32BE: {
|
||||
alias: ['UCS4']
|
||||
},
|
||||
UTF32LE: null,
|
||||
UTF16: {
|
||||
order: 1
|
||||
},
|
||||
UTF16BE: {
|
||||
alias: ['UCS2']
|
||||
},
|
||||
UTF16LE: null,
|
||||
BINARY: {
|
||||
order: 2
|
||||
},
|
||||
ASCII: {
|
||||
order: 3,
|
||||
alias: ['ISO646', 'CP367']
|
||||
},
|
||||
JIS: {
|
||||
order: 4,
|
||||
alias: ['ISO2022JP']
|
||||
},
|
||||
UTF8: {
|
||||
order: 5
|
||||
},
|
||||
EUCJP: {
|
||||
order: 6
|
||||
},
|
||||
SJIS: {
|
||||
order: 7,
|
||||
alias: ['CP932', 'MSKANJI', 'WINDOWS31J']
|
||||
},
|
||||
UNICODE: {
|
||||
order: 8
|
||||
}
|
||||
};
|
||||
|
||||
var EncodingAliases = {};
|
||||
exports.EncodingAliases = EncodingAliases;
|
||||
|
||||
exports.EncodingOrders = (function() {
|
||||
var aliases = EncodingAliases;
|
||||
|
||||
var names = util.objectKeys(EncodingNames);
|
||||
var orders = [];
|
||||
var name, encoding, j, l;
|
||||
|
||||
for (var i = 0, len = names.length; i < len; i++) {
|
||||
name = names[i];
|
||||
aliases[name] = name;
|
||||
|
||||
encoding = EncodingNames[name];
|
||||
if (encoding != null) {
|
||||
if (encoding.order != null) {
|
||||
orders[orders.length] = name;
|
||||
}
|
||||
|
||||
if (encoding.alias) {
|
||||
// Create encoding aliases
|
||||
for (j = 0, l = encoding.alias.length; j < l; j++) {
|
||||
aliases[encoding.alias[j]] = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
orders.sort(function(a, b) {
|
||||
return EncodingNames[a].order - EncodingNames[b].order;
|
||||
});
|
||||
|
||||
return orders;
|
||||
}());
|
||||
|
||||
function init_JIS_TO_UTF8_TABLE() {
|
||||
if (EncodingTable.JIS_TO_UTF8_TABLE === null) {
|
||||
EncodingTable.JIS_TO_UTF8_TABLE = {};
|
||||
|
||||
var keys = util.objectKeys(EncodingTable.UTF8_TO_JIS_TABLE);
|
||||
var i = 0;
|
||||
var len = keys.length;
|
||||
var key, value;
|
||||
|
||||
for (; i < len; i++) {
|
||||
key = keys[i];
|
||||
value = EncodingTable.UTF8_TO_JIS_TABLE[key];
|
||||
if (value > 0x5F) {
|
||||
EncodingTable.JIS_TO_UTF8_TABLE[value] = key | 0;
|
||||
}
|
||||
}
|
||||
|
||||
EncodingTable.JISX0212_TO_UTF8_TABLE = {};
|
||||
keys = util.objectKeys(EncodingTable.UTF8_TO_JISX0212_TABLE);
|
||||
len = keys.length;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
key = keys[i];
|
||||
value = EncodingTable.UTF8_TO_JISX0212_TABLE[key];
|
||||
EncodingTable.JISX0212_TO_UTF8_TABLE[value] = key | 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.init_JIS_TO_UTF8_TABLE = init_JIS_TO_UTF8_TABLE;
|
||||
1681
backend/node_modules/encoding-japanese/src/encoding-convert.js
generated
vendored
Normal file
1681
backend/node_modules/encoding-japanese/src/encoding-convert.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
502
backend/node_modules/encoding-japanese/src/encoding-detect.js
generated
vendored
Normal file
502
backend/node_modules/encoding-japanese/src/encoding-detect.js
generated
vendored
Normal file
@@ -0,0 +1,502 @@
|
||||
/**
|
||||
* Binary (exe, images and so, etc.)
|
||||
*
|
||||
* Note:
|
||||
* This function is not considered for Unicode
|
||||
*/
|
||||
function isBINARY(data) {
|
||||
var i = 0;
|
||||
var len = data && data.length;
|
||||
var c;
|
||||
|
||||
for (; i < len; i++) {
|
||||
c = data[i];
|
||||
if (c > 0xFF) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((c >= 0x00 && c <= 0x07) || c === 0xFF) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
exports.isBINARY = isBINARY;
|
||||
|
||||
/**
|
||||
* ASCII (ISO-646)
|
||||
*/
|
||||
function isASCII(data) {
|
||||
var i = 0;
|
||||
var len = data && data.length;
|
||||
var b;
|
||||
|
||||
for (; i < len; i++) {
|
||||
b = data[i];
|
||||
if (b > 0xFF ||
|
||||
(b >= 0x80 && b <= 0xFF) ||
|
||||
b === 0x1B) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
exports.isASCII = isASCII;
|
||||
|
||||
/**
|
||||
* ISO-2022-JP (JIS)
|
||||
*
|
||||
* RFC1468 Japanese Character Encoding for Internet Messages
|
||||
* RFC1554 ISO-2022-JP-2: Multilingual Extension of ISO-2022-JP
|
||||
* RFC2237 Japanese Character Encoding for Internet Messages
|
||||
*/
|
||||
function isJIS(data) {
|
||||
var i = 0;
|
||||
var len = data && data.length;
|
||||
var b, esc1, esc2;
|
||||
|
||||
for (; i < len; i++) {
|
||||
b = data[i];
|
||||
if (b > 0xFF || (b >= 0x80 && b <= 0xFF)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (b === 0x1B) {
|
||||
if (i + 2 >= len) {
|
||||
return false;
|
||||
}
|
||||
|
||||
esc1 = data[i + 1];
|
||||
esc2 = data[i + 2];
|
||||
if (esc1 === 0x24) {
|
||||
if (esc2 === 0x28 || // JIS X 0208-1990/2000/2004
|
||||
esc2 === 0x40 || // JIS X 0208-1978
|
||||
esc2 === 0x42) { // JIS X 0208-1983
|
||||
return true;
|
||||
}
|
||||
} else if (esc1 === 0x26 && // JIS X 0208-1990
|
||||
esc2 === 0x40) {
|
||||
return true;
|
||||
} else if (esc1 === 0x28) {
|
||||
if (esc2 === 0x42 || // ASCII
|
||||
esc2 === 0x49 || // JIS X 0201 Halfwidth Katakana
|
||||
esc2 === 0x4A) { // JIS X 0201-1976 Roman set
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
exports.isJIS = isJIS;
|
||||
|
||||
/**
|
||||
* EUC-JP
|
||||
*/
|
||||
function isEUCJP(data) {
|
||||
var i = 0;
|
||||
var len = data && data.length;
|
||||
var b;
|
||||
|
||||
for (; i < len; i++) {
|
||||
b = data[i];
|
||||
if (b < 0x80) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (b > 0xFF || b < 0x8E) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (b === 0x8E) {
|
||||
if (i + 1 >= len) {
|
||||
return false;
|
||||
}
|
||||
|
||||
b = data[++i];
|
||||
if (b < 0xA1 || 0xDF < b) {
|
||||
return false;
|
||||
}
|
||||
} else if (b === 0x8F) {
|
||||
if (i + 2 >= len) {
|
||||
return false;
|
||||
}
|
||||
|
||||
b = data[++i];
|
||||
if (b < 0xA2 || 0xED < b) {
|
||||
return false;
|
||||
}
|
||||
|
||||
b = data[++i];
|
||||
if (b < 0xA1 || 0xFE < b) {
|
||||
return false;
|
||||
}
|
||||
} else if (0xA1 <= b && b <= 0xFE) {
|
||||
if (i + 1 >= len) {
|
||||
return false;
|
||||
}
|
||||
|
||||
b = data[++i];
|
||||
if (b < 0xA1 || 0xFE < b) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
exports.isEUCJP = isEUCJP;
|
||||
|
||||
/**
|
||||
* Shift-JIS (SJIS)
|
||||
*/
|
||||
function isSJIS(data) {
|
||||
var i = 0;
|
||||
var len = data && data.length;
|
||||
var b;
|
||||
|
||||
while (i < len && data[i] > 0x80) {
|
||||
if (data[i++] > 0xFF) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (; i < len; i++) {
|
||||
b = data[i];
|
||||
if (b <= 0x80 ||
|
||||
(0xA1 <= b && b <= 0xDF)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (b === 0xA0 || b > 0xEF || i + 1 >= len) {
|
||||
return false;
|
||||
}
|
||||
|
||||
b = data[++i];
|
||||
if (b < 0x40 || b === 0x7F || b > 0xFC) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
exports.isSJIS = isSJIS;
|
||||
|
||||
/**
|
||||
* UTF-8
|
||||
*/
|
||||
function isUTF8(data) {
|
||||
var i = 0;
|
||||
var len = data && data.length;
|
||||
var b;
|
||||
|
||||
for (; i < len; i++) {
|
||||
b = data[i];
|
||||
if (b > 0xFF) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (b === 0x09 || b === 0x0A || b === 0x0D ||
|
||||
(b >= 0x20 && b <= 0x7E)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (b >= 0xC2 && b <= 0xDF) {
|
||||
if (i + 1 >= len || data[i + 1] < 0x80 || data[i + 1] > 0xBF) {
|
||||
return false;
|
||||
}
|
||||
i++;
|
||||
} else if (b === 0xE0) {
|
||||
if (i + 2 >= len ||
|
||||
data[i + 1] < 0xA0 || data[i + 1] > 0xBF ||
|
||||
data[i + 2] < 0x80 || data[i + 2] > 0xBF) {
|
||||
return false;
|
||||
}
|
||||
i += 2;
|
||||
} else if ((b >= 0xE1 && b <= 0xEC) ||
|
||||
b === 0xEE || b === 0xEF) {
|
||||
if (i + 2 >= len ||
|
||||
data[i + 1] < 0x80 || data[i + 1] > 0xBF ||
|
||||
data[i + 2] < 0x80 || data[i + 2] > 0xBF) {
|
||||
return false;
|
||||
}
|
||||
i += 2;
|
||||
} else if (b === 0xED) {
|
||||
if (i + 2 >= len ||
|
||||
data[i + 1] < 0x80 || data[i + 1] > 0x9F ||
|
||||
data[i + 2] < 0x80 || data[i + 2] > 0xBF) {
|
||||
return false;
|
||||
}
|
||||
i += 2;
|
||||
} else if (b === 0xF0) {
|
||||
if (i + 3 >= len ||
|
||||
data[i + 1] < 0x90 || data[i + 1] > 0xBF ||
|
||||
data[i + 2] < 0x80 || data[i + 2] > 0xBF ||
|
||||
data[i + 3] < 0x80 || data[i + 3] > 0xBF) {
|
||||
return false;
|
||||
}
|
||||
i += 3;
|
||||
} else if (b >= 0xF1 && b <= 0xF3) {
|
||||
if (i + 3 >= len ||
|
||||
data[i + 1] < 0x80 || data[i + 1] > 0xBF ||
|
||||
data[i + 2] < 0x80 || data[i + 2] > 0xBF ||
|
||||
data[i + 3] < 0x80 || data[i + 3] > 0xBF) {
|
||||
return false;
|
||||
}
|
||||
i += 3;
|
||||
} else if (b === 0xF4) {
|
||||
if (i + 3 >= len ||
|
||||
data[i + 1] < 0x80 || data[i + 1] > 0x8F ||
|
||||
data[i + 2] < 0x80 || data[i + 2] > 0xBF ||
|
||||
data[i + 3] < 0x80 || data[i + 3] > 0xBF) {
|
||||
return false;
|
||||
}
|
||||
i += 3;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
exports.isUTF8 = isUTF8;
|
||||
|
||||
/**
|
||||
* UTF-16 (LE or BE)
|
||||
*
|
||||
* RFC2781: UTF-16, an encoding of ISO 10646
|
||||
*
|
||||
* @link http://www.ietf.org/rfc/rfc2781.txt
|
||||
*/
|
||||
function isUTF16(data) {
|
||||
var i = 0;
|
||||
var len = data && data.length;
|
||||
var pos = null;
|
||||
var b1, b2, next, prev;
|
||||
|
||||
if (len < 2) {
|
||||
if (data[0] > 0xFF) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
b1 = data[0];
|
||||
b2 = data[1];
|
||||
if (b1 === 0xFF && // BOM (little-endian)
|
||||
b2 === 0xFE) {
|
||||
return true;
|
||||
}
|
||||
if (b1 === 0xFE && // BOM (big-endian)
|
||||
b2 === 0xFF) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (; i < len; i++) {
|
||||
if (data[i] === 0x00) {
|
||||
pos = i;
|
||||
break;
|
||||
} else if (data[i] > 0xFF) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (pos === null) {
|
||||
return false; // Non ASCII
|
||||
}
|
||||
|
||||
next = data[pos + 1]; // BE
|
||||
if (next !== void 0 && next > 0x00 && next < 0x80) {
|
||||
return true;
|
||||
}
|
||||
|
||||
prev = data[pos - 1]; // LE
|
||||
if (prev !== void 0 && prev > 0x00 && prev < 0x80) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
exports.isUTF16 = isUTF16;
|
||||
|
||||
/**
|
||||
* UTF-16BE (big-endian)
|
||||
*
|
||||
* RFC 2781 4.3 Interpreting text labelled as UTF-16
|
||||
* Text labelled "UTF-16BE" can always be interpreted as being big-endian
|
||||
* when BOM does not founds (SHOULD)
|
||||
*
|
||||
* @link http://www.ietf.org/rfc/rfc2781.txt
|
||||
*/
|
||||
function isUTF16BE(data) {
|
||||
var i = 0;
|
||||
var len = data && data.length;
|
||||
var pos = null;
|
||||
var b1, b2;
|
||||
|
||||
if (len < 2) {
|
||||
if (data[0] > 0xFF) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
b1 = data[0];
|
||||
b2 = data[1];
|
||||
if (b1 === 0xFE && // BOM
|
||||
b2 === 0xFF) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (; i < len; i++) {
|
||||
if (data[i] === 0x00) {
|
||||
pos = i;
|
||||
break;
|
||||
} else if (data[i] > 0xFF) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (pos === null) {
|
||||
return false; // Non ASCII
|
||||
}
|
||||
|
||||
if (pos % 2 === 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
exports.isUTF16BE = isUTF16BE;
|
||||
|
||||
/**
|
||||
* UTF-16LE (little-endian)
|
||||
*/
|
||||
function isUTF16LE(data) {
|
||||
var i = 0;
|
||||
var len = data && data.length;
|
||||
var pos = null;
|
||||
var b1, b2;
|
||||
|
||||
if (len < 2) {
|
||||
if (data[0] > 0xFF) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
b1 = data[0];
|
||||
b2 = data[1];
|
||||
if (b1 === 0xFF && // BOM
|
||||
b2 === 0xFE) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (; i < len; i++) {
|
||||
if (data[i] === 0x00) {
|
||||
pos = i;
|
||||
break;
|
||||
} else if (data[i] > 0xFF) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (pos === null) {
|
||||
return false; // Non ASCII
|
||||
}
|
||||
|
||||
if (pos % 2 !== 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
exports.isUTF16LE = isUTF16LE;
|
||||
|
||||
/**
|
||||
* UTF-32
|
||||
*
|
||||
* Unicode 3.2.0: Unicode Standard Annex #19
|
||||
*
|
||||
* @link http://www.iana.org/assignments/charset-reg/UTF-32
|
||||
* @link http://www.unicode.org/reports/tr19/tr19-9.html
|
||||
*/
|
||||
function isUTF32(data) {
|
||||
var i = 0;
|
||||
var len = data && data.length;
|
||||
var pos = null;
|
||||
var b1, b2, b3, b4;
|
||||
var next, prev;
|
||||
|
||||
if (len < 4) {
|
||||
for (; i < len; i++) {
|
||||
if (data[i] > 0xFF) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
b1 = data[0];
|
||||
b2 = data[1];
|
||||
b3 = data[2];
|
||||
b4 = data[3];
|
||||
if (b1 === 0x00 && b2 === 0x00 && // BOM (big-endian)
|
||||
b3 === 0xFE && b4 === 0xFF) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (b1 === 0xFF && b2 === 0xFE && // BOM (little-endian)
|
||||
b3 === 0x00 && b4 === 0x00) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (; i < len; i++) {
|
||||
if (data[i] === 0x00 && data[i + 1] === 0x00 && data[i + 2] === 0x00) {
|
||||
pos = i;
|
||||
break;
|
||||
} else if (data[i] > 0xFF) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (pos === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// The byte order should be the big-endian when BOM is not detected.
|
||||
next = data[pos + 3];
|
||||
if (next !== void 0 && next > 0x00 && next <= 0x7F) {
|
||||
// big-endian
|
||||
return data[pos + 2] === 0x00 && data[pos + 1] === 0x00;
|
||||
}
|
||||
|
||||
prev = data[pos - 1];
|
||||
if (prev !== void 0 && prev > 0x00 && prev <= 0x7F) {
|
||||
// little-endian
|
||||
return data[pos + 1] === 0x00 && data[pos + 2] === 0x00;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
exports.isUTF32 = isUTF32;
|
||||
|
||||
/**
|
||||
* JavaScript Unicode array
|
||||
*/
|
||||
function isUNICODE(data) {
|
||||
var i = 0;
|
||||
var len = data && data.length;
|
||||
var c;
|
||||
|
||||
for (; i < len; i++) {
|
||||
c = data[i];
|
||||
if (c < 0 || c > 0x10FFFF) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
exports.isUNICODE = isUNICODE;
|
||||
4
backend/node_modules/encoding-japanese/src/encoding-table.js
generated
vendored
Normal file
4
backend/node_modules/encoding-japanese/src/encoding-table.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
exports.UTF8_TO_JIS_TABLE = require('./utf8-to-jis-table');
|
||||
exports.UTF8_TO_JISX0212_TABLE = require('./utf8-to-jisx0212-table');
|
||||
exports.JIS_TO_UTF8_TABLE = require('./jis-to-utf8-table');
|
||||
exports.JISX0212_TO_UTF8_TABLE = require('./jisx0212-to-utf8-table');
|
||||
593
backend/node_modules/encoding-japanese/src/index.js
generated
vendored
Normal file
593
backend/node_modules/encoding-japanese/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,593 @@
|
||||
var config = require('./config');
|
||||
var util = require('./util');
|
||||
var EncodingDetect = require('./encoding-detect');
|
||||
var EncodingConvert = require('./encoding-convert');
|
||||
var KanaCaseTable = require('./kana-case-table');
|
||||
var version = require('../package.json').version;
|
||||
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
|
||||
var Encoding = {
|
||||
version: version,
|
||||
|
||||
/**
|
||||
* Encoding orders
|
||||
*/
|
||||
orders: config.EncodingOrders,
|
||||
|
||||
/**
|
||||
* Detects character encoding
|
||||
*
|
||||
* If encodings is "AUTO", or the encoding-list as an array, or
|
||||
* comma separated list string it will be detected automatically
|
||||
*
|
||||
* @param {Array.<number>|TypedArray|string} data The data being detected
|
||||
* @param {(Object|string|Array.<string>)=} [encodings] The encoding-list of
|
||||
* character encoding
|
||||
* @return {string|boolean} The detected character encoding, or false
|
||||
*/
|
||||
detect: function(data, encodings) {
|
||||
if (data == null || data.length === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (util.isObject(encodings) && !util.isArray(encodings)) {
|
||||
encodings = encodings.encoding;
|
||||
}
|
||||
|
||||
if (util.isString(data)) {
|
||||
data = util.stringToBuffer(data);
|
||||
}
|
||||
|
||||
if (encodings == null) {
|
||||
encodings = Encoding.orders;
|
||||
} else {
|
||||
if (util.isString(encodings)) {
|
||||
encodings = encodings.toUpperCase();
|
||||
if (encodings === 'AUTO') {
|
||||
encodings = Encoding.orders;
|
||||
} else if (~encodings.indexOf(',')) {
|
||||
encodings = encodings.split(/\s*,\s*/);
|
||||
} else {
|
||||
encodings = [encodings];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var len = encodings.length;
|
||||
var e, encoding, method;
|
||||
for (var i = 0; i < len; i++) {
|
||||
e = encodings[i];
|
||||
encoding = util.canonicalizeEncodingName(e);
|
||||
if (!encoding) {
|
||||
continue;
|
||||
}
|
||||
|
||||
method = 'is' + encoding;
|
||||
if (!hasOwnProperty.call(EncodingDetect, method)) {
|
||||
throw new Error('Undefined encoding: ' + e);
|
||||
}
|
||||
|
||||
if (EncodingDetect[method](data)) {
|
||||
return encoding;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Convert character encoding
|
||||
*
|
||||
* If `from` is "AUTO", or the encoding-list as an array, or
|
||||
* comma separated list string it will be detected automatically
|
||||
*
|
||||
* @param {Array.<number>|TypedArray|string} data The data being converted
|
||||
* @param {(string|Object)} to The name of encoding to
|
||||
* @param {(string|Array.<string>)=} [from] The encoding-list of
|
||||
* character encoding
|
||||
* @return {Array|TypedArray|string} The converted data
|
||||
*/
|
||||
convert: function(data, to, from) {
|
||||
var result, type, options;
|
||||
|
||||
if (!util.isObject(to)) {
|
||||
options = {};
|
||||
} else {
|
||||
options = to;
|
||||
from = options.from;
|
||||
to = options.to;
|
||||
|
||||
if (options.type) {
|
||||
type = options.type;
|
||||
}
|
||||
}
|
||||
|
||||
if (util.isString(data)) {
|
||||
type = type || 'string';
|
||||
data = util.stringToBuffer(data);
|
||||
} else if (data == null || data.length === 0) {
|
||||
data = [];
|
||||
}
|
||||
|
||||
var encodingFrom;
|
||||
if (from != null && util.isString(from) &&
|
||||
from.toUpperCase() !== 'AUTO' && !~from.indexOf(',')) {
|
||||
encodingFrom = util.canonicalizeEncodingName(from);
|
||||
} else {
|
||||
encodingFrom = Encoding.detect(data);
|
||||
}
|
||||
|
||||
var encodingTo = util.canonicalizeEncodingName(to);
|
||||
var method = encodingFrom + 'To' + encodingTo;
|
||||
|
||||
if (hasOwnProperty.call(EncodingConvert, method)) {
|
||||
result = EncodingConvert[method](data, options);
|
||||
} else {
|
||||
// Returns the raw data if the method is undefined
|
||||
result = data;
|
||||
}
|
||||
|
||||
switch (('' + type).toLowerCase()) {
|
||||
case 'string':
|
||||
return util.codeToString_fast(result);
|
||||
case 'arraybuffer':
|
||||
return util.codeToBuffer(result);
|
||||
default: // array
|
||||
return util.bufferToCode(result);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Encode a character code array to URL string like encodeURIComponent
|
||||
*
|
||||
* @param {Array.<number>|TypedArray} data The data being encoded
|
||||
* @return {string} The percent encoded string
|
||||
*/
|
||||
urlEncode: function(data) {
|
||||
if (util.isString(data)) {
|
||||
data = util.stringToBuffer(data);
|
||||
}
|
||||
|
||||
var alpha = util.stringToCode('0123456789ABCDEF');
|
||||
var results = [];
|
||||
var i = 0;
|
||||
var len = data && data.length;
|
||||
var b;
|
||||
|
||||
for (; i < len; i++) {
|
||||
b = data[i];
|
||||
|
||||
// urlEncode is for an array of numbers in the range 0-255 (Uint8Array), but if an array
|
||||
// of numbers greater than 255 is passed (Unicode code unit i.e. charCodeAt range),
|
||||
// it will be tentatively encoded as UTF-8 using encodeURIComponent.
|
||||
if (b > 0xFF) {
|
||||
return encodeURIComponent(util.codeToString_fast(data));
|
||||
}
|
||||
|
||||
if ((b >= 0x61 /*a*/ && b <= 0x7A /*z*/) ||
|
||||
(b >= 0x41 /*A*/ && b <= 0x5A /*Z*/) ||
|
||||
(b >= 0x30 /*0*/ && b <= 0x39 /*9*/) ||
|
||||
b === 0x21 /*!*/ ||
|
||||
(b >= 0x27 /*'*/ && b <= 0x2A /***/) ||
|
||||
b === 0x2D /*-*/ || b === 0x2E /*.*/ ||
|
||||
b === 0x5F /*_*/ || b === 0x7E /*~*/
|
||||
) {
|
||||
results[results.length] = b;
|
||||
} else {
|
||||
results[results.length] = 0x25; /*%*/
|
||||
if (b < 0x10) {
|
||||
results[results.length] = 0x30; /*0*/
|
||||
results[results.length] = alpha[b];
|
||||
} else {
|
||||
results[results.length] = alpha[b >> 4 & 0xF];
|
||||
results[results.length] = alpha[b & 0xF];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return util.codeToString_fast(results);
|
||||
},
|
||||
|
||||
/**
|
||||
* Decode a percent encoded string to
|
||||
* character code array like decodeURIComponent
|
||||
*
|
||||
* @param {string} string The data being decoded
|
||||
* @return {Array.<number>} The decoded array
|
||||
*/
|
||||
urlDecode: function(string) {
|
||||
var results = [];
|
||||
var i = 0;
|
||||
var len = string && string.length;
|
||||
var c;
|
||||
|
||||
while (i < len) {
|
||||
c = string.charCodeAt(i++);
|
||||
if (c === 0x25 /*%*/) {
|
||||
results[results.length] = parseInt(
|
||||
string.charAt(i++) + string.charAt(i++), 16);
|
||||
} else {
|
||||
results[results.length] = c;
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
},
|
||||
|
||||
/**
|
||||
* Encode a character code array to Base64 encoded string
|
||||
*
|
||||
* @param {Array.<number>|TypedArray} data The data being encoded
|
||||
* @return {string} The Base64 encoded string
|
||||
*/
|
||||
base64Encode: function(data) {
|
||||
if (util.isString(data)) {
|
||||
data = util.stringToBuffer(data);
|
||||
}
|
||||
return util.base64encode(data);
|
||||
},
|
||||
|
||||
/**
|
||||
* Decode a Base64 encoded string to character code array
|
||||
*
|
||||
* @param {string} string The data being decoded
|
||||
* @return {Array.<number>} The decoded array
|
||||
*/
|
||||
base64Decode: function(string) {
|
||||
return util.base64decode(string);
|
||||
},
|
||||
|
||||
/**
|
||||
* Joins a character code array to string
|
||||
*
|
||||
* @param {Array.<number>|TypedArray} data The data being joined
|
||||
* @return {String} The joined string
|
||||
*/
|
||||
codeToString: util.codeToString_fast,
|
||||
|
||||
/**
|
||||
* Splits string to an array of character codes
|
||||
*
|
||||
* @param {string} string The input string
|
||||
* @return {Array.<number>} The character code array
|
||||
*/
|
||||
stringToCode: util.stringToCode,
|
||||
|
||||
/**
|
||||
* 全角英数記号文字を半角英数記号文字に変換
|
||||
*
|
||||
* Convert the ascii symbols and alphanumeric characters to
|
||||
* the zenkaku symbols and alphanumeric characters
|
||||
*
|
||||
* @example
|
||||
* console.log(Encoding.toHankakuCase('Hello World! 12345'));
|
||||
* // 'Hello World! 12345'
|
||||
*
|
||||
* @param {Array.<number>|TypedArray|string} data The input unicode data
|
||||
* @return {Array.<number>|string} The conveted data
|
||||
*/
|
||||
toHankakuCase: function(data) {
|
||||
var asString = false;
|
||||
if (util.isString(data)) {
|
||||
asString = true;
|
||||
data = util.stringToBuffer(data);
|
||||
}
|
||||
|
||||
var results = [];
|
||||
var len = data && data.length;
|
||||
var i = 0;
|
||||
var c;
|
||||
|
||||
while (i < len) {
|
||||
c = data[i++];
|
||||
if (c >= 0xFF01 && c <= 0xFF5E) {
|
||||
c -= 0xFEE0;
|
||||
}
|
||||
results[results.length] = c;
|
||||
}
|
||||
|
||||
return asString ? util.codeToString_fast(results) : results;
|
||||
},
|
||||
|
||||
/**
|
||||
* 半角英数記号文字を全角英数記号文字に変換
|
||||
*
|
||||
* Convert to the zenkaku symbols and alphanumeric characters
|
||||
* from the ascii symbols and alphanumeric characters
|
||||
*
|
||||
* @example
|
||||
* console.log(Encoding.toZenkakuCase('Hello World! 12345'));
|
||||
* // 'Hello World! 12345'
|
||||
*
|
||||
* @param {Array.<number>|TypedArray|string} data The input unicode data
|
||||
* @return {Array.<number>|string} The conveted data
|
||||
*/
|
||||
toZenkakuCase: function(data) {
|
||||
var asString = false;
|
||||
if (util.isString(data)) {
|
||||
asString = true;
|
||||
data = util.stringToBuffer(data);
|
||||
}
|
||||
|
||||
var results = [];
|
||||
var len = data && data.length;
|
||||
var i = 0;
|
||||
var c;
|
||||
|
||||
while (i < len) {
|
||||
c = data[i++];
|
||||
if (c >= 0x21 && c <= 0x7E) {
|
||||
c += 0xFEE0;
|
||||
}
|
||||
results[results.length] = c;
|
||||
}
|
||||
|
||||
return asString ? util.codeToString_fast(results) : results;
|
||||
},
|
||||
|
||||
/**
|
||||
* 全角カタカナを全角ひらがなに変換
|
||||
*
|
||||
* Convert to the zenkaku hiragana from the zenkaku katakana
|
||||
*
|
||||
* @example
|
||||
* console.log(Encoding.toHiraganaCase('ボポヴァアィイゥウェエォオ'));
|
||||
* // 'ぼぽう゛ぁあぃいぅうぇえぉお'
|
||||
*
|
||||
* @param {Array.<number>|TypedArray|string} data The input unicode data
|
||||
* @return {Array.<number>|string} The conveted data
|
||||
*/
|
||||
toHiraganaCase: function(data) {
|
||||
var asString = false;
|
||||
if (util.isString(data)) {
|
||||
asString = true;
|
||||
data = util.stringToBuffer(data);
|
||||
}
|
||||
|
||||
var results = [];
|
||||
var len = data && data.length;
|
||||
var i = 0;
|
||||
var c;
|
||||
|
||||
while (i < len) {
|
||||
c = data[i++];
|
||||
if (c >= 0x30A1 && c <= 0x30F6) {
|
||||
c -= 0x0060;
|
||||
// 「ワ゛」 => 「わ」 + 「゛」
|
||||
} else if (c === 0x30F7) {
|
||||
results[results.length] = 0x308F;
|
||||
c = 0x309B;
|
||||
// 「ヲ゛」 => 「を」 + 「゛」
|
||||
} else if (c === 0x30FA) {
|
||||
results[results.length] = 0x3092;
|
||||
c = 0x309B;
|
||||
}
|
||||
results[results.length] = c;
|
||||
}
|
||||
|
||||
return asString ? util.codeToString_fast(results) : results;
|
||||
},
|
||||
|
||||
/**
|
||||
* 全角ひらがなを全角カタカナに変換
|
||||
*
|
||||
* Convert to the zenkaku katakana from the zenkaku hiragana
|
||||
*
|
||||
* @example
|
||||
* console.log(Encoding.toKatakanaCase('ぼぽう゛ぁあぃいぅうぇえぉお'));
|
||||
* // 'ボポヴァアィイゥウェエォオ'
|
||||
*
|
||||
* @param {Array.<number>|TypedArray|string} data The input unicode data
|
||||
* @return {Array.<number>|string} The conveted data
|
||||
*/
|
||||
toKatakanaCase: function(data) {
|
||||
var asString = false;
|
||||
if (util.isString(data)) {
|
||||
asString = true;
|
||||
data = util.stringToBuffer(data);
|
||||
}
|
||||
|
||||
var results = [];
|
||||
var len = data && data.length;
|
||||
var i = 0;
|
||||
var c;
|
||||
|
||||
while (i < len) {
|
||||
c = data[i++];
|
||||
if (c >= 0x3041 && c <= 0x3096) {
|
||||
if ((c === 0x308F || // 「わ」 + 「゛」 => 「ワ゛」
|
||||
c === 0x3092) && // 「を」 + 「゛」 => 「ヲ゛」
|
||||
i < len && data[i] === 0x309B) {
|
||||
c = c === 0x308F ? 0x30F7 : 0x30FA;
|
||||
i++;
|
||||
} else {
|
||||
c += 0x0060;
|
||||
}
|
||||
}
|
||||
results[results.length] = c;
|
||||
}
|
||||
|
||||
return asString ? util.codeToString_fast(results) : results;
|
||||
},
|
||||
|
||||
/**
|
||||
* 全角カタカナを半角カタカナに変換
|
||||
*
|
||||
* Convert to the hankaku katakana from the zenkaku katakana
|
||||
*
|
||||
* @example
|
||||
* console.log(Encoding.toHankanaCase('ボポヴァアィイゥウェエォオ'));
|
||||
* // 'ボポヴァアィイゥウェエォオ'
|
||||
*
|
||||
* @param {Array.<number>|TypedArray|string} data The input unicode data
|
||||
* @return {Array.<number>|string} The conveted data
|
||||
*/
|
||||
toHankanaCase: function(data) {
|
||||
var asString = false;
|
||||
if (util.isString(data)) {
|
||||
asString = true;
|
||||
data = util.stringToBuffer(data);
|
||||
}
|
||||
|
||||
var results = [];
|
||||
var len = data && data.length;
|
||||
var i = 0;
|
||||
var c, d, t;
|
||||
|
||||
while (i < len) {
|
||||
c = data[i++];
|
||||
|
||||
if (c >= 0x3001 && c <= 0x30FC) {
|
||||
t = KanaCaseTable.HANKANA_TABLE[c];
|
||||
if (t !== void 0) {
|
||||
results[results.length] = t;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 「ヴ」, 「ワ」+「゛」, 「ヲ」+「゛」
|
||||
if (c === 0x30F4 || c === 0x30F7 || c === 0x30FA) {
|
||||
results[results.length] = KanaCaseTable.HANKANA_SONANTS[c];
|
||||
results[results.length] = 0xFF9E;
|
||||
// 「カ」 - 「ド」
|
||||
} else if (c >= 0x30AB && c <= 0x30C9) {
|
||||
results[results.length] = KanaCaseTable.HANKANA_TABLE[c - 1];
|
||||
results[results.length] = 0xFF9E;
|
||||
// 「ハ」 - 「ポ」
|
||||
} else if (c >= 0x30CF && c <= 0x30DD) {
|
||||
d = c % 3;
|
||||
results[results.length] = KanaCaseTable.HANKANA_TABLE[c - d];
|
||||
results[results.length] = KanaCaseTable.HANKANA_MARKS[d - 1];
|
||||
} else {
|
||||
results[results.length] = c;
|
||||
}
|
||||
}
|
||||
|
||||
return asString ? util.codeToString_fast(results) : results;
|
||||
},
|
||||
|
||||
/**
|
||||
* 半角カタカナを全角カタカナに変換 (濁音含む)
|
||||
*
|
||||
* Convert to the zenkaku katakana from the hankaku katakana
|
||||
*
|
||||
* @example
|
||||
* console.log(Encoding.toZenkanaCase('ボポヴァアィイゥウェエォオ'));
|
||||
* // 'ボポヴァアィイゥウェエォオ'
|
||||
*
|
||||
* @param {Array.<number>|TypedArray|string} data The input unicode data
|
||||
* @return {Array.<number>|string} The conveted data
|
||||
*/
|
||||
toZenkanaCase: function(data) {
|
||||
var asString = false;
|
||||
if (util.isString(data)) {
|
||||
asString = true;
|
||||
data = util.stringToBuffer(data);
|
||||
}
|
||||
|
||||
var results = [];
|
||||
var len = data && data.length;
|
||||
var i = 0;
|
||||
var c, code, next;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
c = data[i];
|
||||
// Hankaku katakana
|
||||
if (c > 0xFF60 && c < 0xFFA0) {
|
||||
code = KanaCaseTable.ZENKANA_TABLE[c - 0xFF61];
|
||||
if (i + 1 < len) {
|
||||
next = data[i + 1];
|
||||
// 「゙」 + 「ヴ」
|
||||
if (next === 0xFF9E && c === 0xFF73) {
|
||||
code = 0x30F4;
|
||||
i++;
|
||||
// 「゙」 + 「ワ゛」
|
||||
} else if (next === 0xFF9E && c === 0xFF9C) {
|
||||
code = 0x30F7;
|
||||
i++;
|
||||
// 「゙」 + 「ヲ゛」
|
||||
} else if (next === 0xFF9E && c === 0xFF66) {
|
||||
code = 0x30FA;
|
||||
i++;
|
||||
// 「゙」 + 「カ」 - 「コ」 or 「ハ」 - 「ホ」
|
||||
} else if (next === 0xFF9E &&
|
||||
((c > 0xFF75 && c < 0xFF85) ||
|
||||
(c > 0xFF89 && c < 0xFF8F))) {
|
||||
code++;
|
||||
i++;
|
||||
// 「゚」 + 「ハ」 - 「ホ」
|
||||
} else if (next === 0xFF9F &&
|
||||
(c > 0xFF89 && c < 0xFF8F)) {
|
||||
code += 2;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
c = code;
|
||||
}
|
||||
results[results.length] = c;
|
||||
}
|
||||
|
||||
return asString ? util.codeToString_fast(results) : results;
|
||||
},
|
||||
|
||||
/**
|
||||
* 全角スペースを半角スペースに変換
|
||||
*
|
||||
* Convert the em space(U+3000) to the single space(U+0020)
|
||||
*
|
||||
* @param {Array.<number>|TypedArray|string} data The input unicode data
|
||||
* @return {Array.<number>|string} The conveted data
|
||||
*/
|
||||
toHankakuSpace: function(data) {
|
||||
if (util.isString(data)) {
|
||||
return data.replace(/\u3000/g, ' ');
|
||||
}
|
||||
|
||||
var results = [];
|
||||
var len = data && data.length;
|
||||
var i = 0;
|
||||
var c;
|
||||
|
||||
while (i < len) {
|
||||
c = data[i++];
|
||||
if (c === 0x3000) {
|
||||
c = 0x20;
|
||||
}
|
||||
results[results.length] = c;
|
||||
}
|
||||
|
||||
return results;
|
||||
},
|
||||
|
||||
/**
|
||||
* 半角スペースを全角スペースに変換
|
||||
*
|
||||
* Convert the single space(U+0020) to the em space(U+3000)
|
||||
*
|
||||
* @param {Array.<number>|TypedArray|string} data The input unicode data
|
||||
* @return {Array.<number>|string} The conveted data
|
||||
*/
|
||||
toZenkakuSpace: function(data) {
|
||||
if (util.isString(data)) {
|
||||
return data.replace(/\u0020/g, '\u3000');
|
||||
}
|
||||
|
||||
var results = [];
|
||||
var len = data && data.length;
|
||||
var i = 0;
|
||||
var c;
|
||||
|
||||
while (i < len) {
|
||||
c = data[i++];
|
||||
if (c === 0x20) {
|
||||
c = 0x3000;
|
||||
}
|
||||
results[results.length] = c;
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = Encoding;
|
||||
5
backend/node_modules/encoding-japanese/src/jis-to-utf8-table.js
generated
vendored
Normal file
5
backend/node_modules/encoding-japanese/src/jis-to-utf8-table.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* Encoding conversion table for JIS to UTF-8
|
||||
*/
|
||||
var JIS_TO_UTF8_TABLE = null;
|
||||
module.exports = JIS_TO_UTF8_TABLE;
|
||||
5
backend/node_modules/encoding-japanese/src/jisx0212-to-utf8-table.js
generated
vendored
Normal file
5
backend/node_modules/encoding-japanese/src/jisx0212-to-utf8-table.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* Encoding conversion table for JIS X 0212:1990 (Hojo-Kanji) to UTF-8
|
||||
*/
|
||||
var JISX0212_TO_UTF8_TABLE = null;
|
||||
module.exports = JISX0212_TO_UTF8_TABLE;
|
||||
41
backend/node_modules/encoding-japanese/src/kana-case-table.js
generated
vendored
Normal file
41
backend/node_modules/encoding-japanese/src/kana-case-table.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
/* eslint-disable key-spacing */
|
||||
/**
|
||||
* Katakana table
|
||||
*/
|
||||
exports.HANKANA_TABLE = {
|
||||
0x3001:0xFF64,0x3002:0xFF61,0x300C:0xFF62,0x300D:0xFF63,0x309B:0xFF9E,
|
||||
0x309C:0xFF9F,0x30A1:0xFF67,0x30A2:0xFF71,0x30A3:0xFF68,0x30A4:0xFF72,
|
||||
0x30A5:0xFF69,0x30A6:0xFF73,0x30A7:0xFF6A,0x30A8:0xFF74,0x30A9:0xFF6B,
|
||||
0x30AA:0xFF75,0x30AB:0xFF76,0x30AD:0xFF77,0x30AF:0xFF78,0x30B1:0xFF79,
|
||||
0x30B3:0xFF7A,0x30B5:0xFF7B,0x30B7:0xFF7C,0x30B9:0xFF7D,0x30BB:0xFF7E,
|
||||
0x30BD:0xFF7F,0x30BF:0xFF80,0x30C1:0xFF81,0x30C3:0xFF6F,0x30C4:0xFF82,
|
||||
0x30C6:0xFF83,0x30C8:0xFF84,0x30CA:0xFF85,0x30CB:0xFF86,0x30CC:0xFF87,
|
||||
0x30CD:0xFF88,0x30CE:0xFF89,0x30CF:0xFF8A,0x30D2:0xFF8B,0x30D5:0xFF8C,
|
||||
0x30D8:0xFF8D,0x30DB:0xFF8E,0x30DE:0xFF8F,0x30DF:0xFF90,0x30E0:0xFF91,
|
||||
0x30E1:0xFF92,0x30E2:0xFF93,0x30E3:0xFF6C,0x30E4:0xFF94,0x30E5:0xFF6D,
|
||||
0x30E6:0xFF95,0x30E7:0xFF6E,0x30E8:0xFF96,0x30E9:0xFF97,0x30EA:0xFF98,
|
||||
0x30EB:0xFF99,0x30EC:0xFF9A,0x30ED:0xFF9B,0x30EF:0xFF9C,0x30F2:0xFF66,
|
||||
0x30F3:0xFF9D,0x30FB:0xFF65,0x30FC:0xFF70
|
||||
};
|
||||
|
||||
exports.HANKANA_SONANTS = {
|
||||
0x30F4:0xFF73,
|
||||
0x30F7:0xFF9C,
|
||||
0x30FA:0xFF66
|
||||
};
|
||||
|
||||
exports.HANKANA_MARKS = [0xFF9E, 0xFF9F];
|
||||
|
||||
/**
|
||||
* Zenkaku table [U+FF61] - [U+FF9F]
|
||||
*/
|
||||
exports.ZENKANA_TABLE = [
|
||||
0x3002, 0x300C, 0x300D, 0x3001, 0x30FB, 0x30F2, 0x30A1, 0x30A3,
|
||||
0x30A5, 0x30A7, 0x30A9, 0x30E3, 0x30E5, 0x30E7, 0x30C3, 0x30FC,
|
||||
0x30A2, 0x30A4, 0x30A6, 0x30A8, 0x30AA, 0x30AB, 0x30AD, 0x30AF,
|
||||
0x30B1, 0x30B3, 0x30B5, 0x30B7, 0x30B9, 0x30BB, 0x30BD, 0x30BF,
|
||||
0x30C1, 0x30C4, 0x30C6, 0x30C8, 0x30CA, 0x30CB, 0x30CC, 0x30CD,
|
||||
0x30CE, 0x30CF, 0x30D2, 0x30D5, 0x30D8, 0x30DB, 0x30DE, 0x30DF,
|
||||
0x30E0, 0x30E1, 0x30E2, 0x30E4, 0x30E6, 0x30E8, 0x30E9, 0x30EA,
|
||||
0x30EB, 0x30EC, 0x30ED, 0x30EF, 0x30F3, 0x309B, 0x309C
|
||||
];
|
||||
1493
backend/node_modules/encoding-japanese/src/utf8-to-jis-table.js
generated
vendored
Normal file
1493
backend/node_modules/encoding-japanese/src/utf8-to-jis-table.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1224
backend/node_modules/encoding-japanese/src/utf8-to-jisx0212-table.js
generated
vendored
Normal file
1224
backend/node_modules/encoding-japanese/src/utf8-to-jisx0212-table.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
361
backend/node_modules/encoding-japanese/src/util.js
generated
vendored
Normal file
361
backend/node_modules/encoding-japanese/src/util.js
generated
vendored
Normal file
@@ -0,0 +1,361 @@
|
||||
var config = require('./config');
|
||||
var fromCharCode = String.fromCharCode;
|
||||
var slice = Array.prototype.slice;
|
||||
var toString = Object.prototype.toString;
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
var nativeIsArray = Array.isArray;
|
||||
var nativeObjectKeys = Object.keys;
|
||||
|
||||
|
||||
function isObject(x) {
|
||||
var type = typeof x;
|
||||
return type === 'function' || type === 'object' && !!x;
|
||||
}
|
||||
exports.isObject = isObject;
|
||||
|
||||
|
||||
function isArray(x) {
|
||||
return nativeIsArray ? nativeIsArray(x) : toString.call(x) === '[object Array]';
|
||||
}
|
||||
exports.isArray = isArray;
|
||||
|
||||
|
||||
function isString(x) {
|
||||
return typeof x === 'string' || toString.call(x) === '[object String]';
|
||||
}
|
||||
exports.isString = isString;
|
||||
|
||||
|
||||
function objectKeys(object) {
|
||||
if (nativeObjectKeys) {
|
||||
return nativeObjectKeys(object);
|
||||
}
|
||||
|
||||
var keys = [];
|
||||
for (var key in object) {
|
||||
if (hasOwnProperty.call(object, key)) {
|
||||
keys[keys.length] = key;
|
||||
}
|
||||
}
|
||||
|
||||
return keys;
|
||||
}
|
||||
exports.objectKeys = objectKeys;
|
||||
|
||||
|
||||
function createBuffer(bits, size) {
|
||||
if (config.HAS_TYPED) {
|
||||
switch (bits) {
|
||||
case 8: return new Uint8Array(size);
|
||||
case 16: return new Uint16Array(size);
|
||||
}
|
||||
}
|
||||
return new Array(size);
|
||||
}
|
||||
exports.createBuffer = createBuffer;
|
||||
|
||||
|
||||
function stringToBuffer(string) {
|
||||
var length = string.length;
|
||||
var buffer = createBuffer(16, length);
|
||||
|
||||
for (var i = 0; i < length; i++) {
|
||||
buffer[i] = string.charCodeAt(i);
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
exports.stringToBuffer = stringToBuffer;
|
||||
|
||||
|
||||
function codeToString_fast(code) {
|
||||
if (config.CAN_CHARCODE_APPLY && config.CAN_CHARCODE_APPLY_TYPED) {
|
||||
var len = code && code.length;
|
||||
if (len < config.APPLY_BUFFER_SIZE && config.APPLY_BUFFER_SIZE_OK) {
|
||||
return fromCharCode.apply(null, code);
|
||||
}
|
||||
|
||||
if (config.APPLY_BUFFER_SIZE_OK === null) {
|
||||
try {
|
||||
var s = fromCharCode.apply(null, code);
|
||||
if (len > config.APPLY_BUFFER_SIZE) {
|
||||
config.APPLY_BUFFER_SIZE_OK = true;
|
||||
}
|
||||
return s;
|
||||
} catch (e) {
|
||||
// Ignore the RangeError "arguments too large"
|
||||
config.APPLY_BUFFER_SIZE_OK = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return codeToString_chunked(code);
|
||||
}
|
||||
exports.codeToString_fast = codeToString_fast;
|
||||
|
||||
|
||||
function codeToString_chunked(code) {
|
||||
var string = '';
|
||||
var length = code && code.length;
|
||||
var i = 0;
|
||||
var sub;
|
||||
|
||||
while (i < length) {
|
||||
if (code.subarray) {
|
||||
sub = code.subarray(i, i + config.APPLY_BUFFER_SIZE);
|
||||
} else {
|
||||
sub = code.slice(i, i + config.APPLY_BUFFER_SIZE);
|
||||
}
|
||||
i += config.APPLY_BUFFER_SIZE;
|
||||
|
||||
if (config.APPLY_BUFFER_SIZE_OK) {
|
||||
string += fromCharCode.apply(null, sub);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (config.APPLY_BUFFER_SIZE_OK === null) {
|
||||
try {
|
||||
string += fromCharCode.apply(null, sub);
|
||||
if (sub.length > config.APPLY_BUFFER_SIZE) {
|
||||
config.APPLY_BUFFER_SIZE_OK = true;
|
||||
}
|
||||
continue;
|
||||
} catch (e) {
|
||||
config.APPLY_BUFFER_SIZE_OK = false;
|
||||
}
|
||||
}
|
||||
|
||||
return codeToString_slow(code);
|
||||
}
|
||||
|
||||
return string;
|
||||
}
|
||||
exports.codeToString_chunked = codeToString_chunked;
|
||||
|
||||
|
||||
function codeToString_slow(code) {
|
||||
var string = '';
|
||||
var length = code && code.length;
|
||||
|
||||
for (var i = 0; i < length; i++) {
|
||||
string += fromCharCode(code[i]);
|
||||
}
|
||||
|
||||
return string;
|
||||
}
|
||||
exports.codeToString_slow = codeToString_slow;
|
||||
|
||||
|
||||
function stringToCode(string) {
|
||||
var code = [];
|
||||
var len = string && string.length;
|
||||
|
||||
for (var i = 0; i < len; i++) {
|
||||
code[i] = string.charCodeAt(i);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
exports.stringToCode = stringToCode;
|
||||
|
||||
|
||||
function codeToBuffer(code) {
|
||||
if (config.HAS_TYPED) {
|
||||
// Unicode code point (charCodeAt range) values have a range of 0-0xFFFF, so use Uint16Array
|
||||
return new Uint16Array(code);
|
||||
}
|
||||
|
||||
if (isArray(code)) {
|
||||
return code;
|
||||
}
|
||||
|
||||
var length = code && code.length;
|
||||
var buffer = [];
|
||||
|
||||
for (var i = 0; i < length; i++) {
|
||||
buffer[i] = code[i];
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
exports.codeToBuffer = codeToBuffer;
|
||||
|
||||
|
||||
function bufferToCode(buffer) {
|
||||
if (isArray(buffer)) {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
return slice.call(buffer);
|
||||
}
|
||||
exports.bufferToCode = bufferToCode;
|
||||
|
||||
/**
|
||||
* Canonicalize the passed encoding name to the internal encoding name
|
||||
*/
|
||||
function canonicalizeEncodingName(target) {
|
||||
var name = '';
|
||||
var expect = ('' + target).toUpperCase().replace(/[^A-Z0-9]+/g, '');
|
||||
var aliasNames = objectKeys(config.EncodingAliases);
|
||||
var len = aliasNames.length;
|
||||
var hit = 0;
|
||||
var encoding, encodingLen, j;
|
||||
|
||||
for (var i = 0; i < len; i++) {
|
||||
encoding = aliasNames[i];
|
||||
if (encoding === expect) {
|
||||
name = encoding;
|
||||
break;
|
||||
}
|
||||
|
||||
encodingLen = encoding.length;
|
||||
for (j = hit; j < encodingLen; j++) {
|
||||
if (encoding.slice(0, j) === expect.slice(0, j) ||
|
||||
encoding.slice(-j) === expect.slice(-j)) {
|
||||
name = encoding;
|
||||
hit = j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hasOwnProperty.call(config.EncodingAliases, name)) {
|
||||
return config.EncodingAliases[name];
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
exports.canonicalizeEncodingName = canonicalizeEncodingName;
|
||||
|
||||
// Base64
|
||||
/* Copyright (C) 1999 Masanao Izumo <iz@onicos.co.jp>
|
||||
* Version: 1.0
|
||||
* LastModified: Dec 25 1999
|
||||
* This library is free. You can redistribute it and/or modify it.
|
||||
*/
|
||||
// -- Masanao Izumo Copyright 1999 "free"
|
||||
// Added binary array support for the Encoding.js
|
||||
|
||||
var base64EncodeChars = [
|
||||
65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
|
||||
78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
|
||||
97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
|
||||
110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
|
||||
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47
|
||||
];
|
||||
|
||||
var base64DecodeChars = [
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
|
||||
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
|
||||
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
|
||||
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
|
||||
-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
|
||||
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1
|
||||
];
|
||||
|
||||
var base64EncodePadding = '='.charCodeAt(0);
|
||||
|
||||
|
||||
function base64encode(data) {
|
||||
var out, i, len;
|
||||
var c1, c2, c3;
|
||||
|
||||
len = data && data.length;
|
||||
i = 0;
|
||||
out = [];
|
||||
|
||||
while (i < len) {
|
||||
c1 = data[i++];
|
||||
if (i == len) {
|
||||
out[out.length] = base64EncodeChars[c1 >> 2];
|
||||
out[out.length] = base64EncodeChars[(c1 & 0x3) << 4];
|
||||
out[out.length] = base64EncodePadding;
|
||||
out[out.length] = base64EncodePadding;
|
||||
break;
|
||||
}
|
||||
|
||||
c2 = data[i++];
|
||||
if (i == len) {
|
||||
out[out.length] = base64EncodeChars[c1 >> 2];
|
||||
out[out.length] = base64EncodeChars[((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4)];
|
||||
out[out.length] = base64EncodeChars[(c2 & 0xF) << 2];
|
||||
out[out.length] = base64EncodePadding;
|
||||
break;
|
||||
}
|
||||
|
||||
c3 = data[i++];
|
||||
out[out.length] = base64EncodeChars[c1 >> 2];
|
||||
out[out.length] = base64EncodeChars[((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4)];
|
||||
out[out.length] = base64EncodeChars[((c2 & 0xF) << 2) | ((c3 & 0xC0) >> 6)];
|
||||
out[out.length] = base64EncodeChars[c3 & 0x3F];
|
||||
}
|
||||
|
||||
return codeToString_fast(out);
|
||||
}
|
||||
exports.base64encode = base64encode;
|
||||
|
||||
|
||||
function base64decode(str) {
|
||||
var c1, c2, c3, c4;
|
||||
var i, len, out;
|
||||
|
||||
len = str && str.length;
|
||||
i = 0;
|
||||
out = [];
|
||||
|
||||
while (i < len) {
|
||||
/* c1 */
|
||||
do {
|
||||
c1 = base64DecodeChars[str.charCodeAt(i++) & 0xFF];
|
||||
} while (i < len && c1 == -1);
|
||||
|
||||
if (c1 == -1) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* c2 */
|
||||
do {
|
||||
c2 = base64DecodeChars[str.charCodeAt(i++) & 0xFF];
|
||||
} while (i < len && c2 == -1);
|
||||
|
||||
if (c2 == -1) {
|
||||
break;
|
||||
}
|
||||
|
||||
out[out.length] = (c1 << 2) | ((c2 & 0x30) >> 4);
|
||||
|
||||
/* c3 */
|
||||
do {
|
||||
c3 = str.charCodeAt(i++) & 0xFF;
|
||||
if (c3 == 61) {
|
||||
return out;
|
||||
}
|
||||
c3 = base64DecodeChars[c3];
|
||||
} while (i < len && c3 == -1);
|
||||
|
||||
if (c3 == -1) {
|
||||
break;
|
||||
}
|
||||
|
||||
out[out.length] = ((c2 & 0xF) << 4) | ((c3 & 0x3C) >> 2);
|
||||
|
||||
/* c4 */
|
||||
do {
|
||||
c4 = str.charCodeAt(i++) & 0xFF;
|
||||
if (c4 == 61) {
|
||||
return out;
|
||||
}
|
||||
c4 = base64DecodeChars[c4];
|
||||
} while (i < len && c4 == -1);
|
||||
|
||||
if (c4 == -1) {
|
||||
break;
|
||||
}
|
||||
|
||||
out[out.length] = ((c3 & 0x03) << 6) | c4;
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
exports.base64decode = base64decode;
|
||||
Reference in New Issue
Block a user