Changeset c6b84df for public/vendors/dataTable/pdfmake-0.1.36
- Timestamp:
- 10/21/21 23:45:59 (3 years ago)
- Branches:
- develop, master
- Children:
- 4b7e2d3
- Parents:
- 6b95845
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
public/vendors/dataTable/pdfmake-0.1.36/pdfmake.js
r6b95845 rc6b84df 6932 6932 var res = encoder.write(str); 6933 6933 var trail = encoder.end(); 6934 6934 6935 6935 return (trail && trail.length > 0) ? Buffer.concat([res, trail]) : res; 6936 6936 } … … 6972 6972 if (!iconv.encodings) 6973 6973 iconv.encodings = __webpack_require__(171); // Lazy load all encoding definitions. 6974 6974 6975 6975 // Canonicalize encoding name: strip all non-alphanumeric chars and appended year. 6976 6976 var enc = (''+encoding).toLowerCase().replace(/[^0-9a-z]|:\d{4}$/g, ""); … … 6996 6996 if (!codecOptions.encodingName) 6997 6997 codecOptions.encodingName = enc; 6998 6998 6999 6999 enc = codecDef.type; 7000 7000 break; … … 7486 7486 UnicodeTrie = __webpack_require__(43); 7487 7487 7488 7488 7489 7489 7490 7490 base64 = __webpack_require__(131); … … 7660 7660 this.tag = 0; 7661 7661 this.bitcount = 0; 7662 7662 7663 7663 this.dest = dest; 7664 7664 this.destLen = 0; 7665 7665 7666 7666 this.ltree = new Tree(); /* dynamic length/symbol tree */ 7667 7667 this.dtree = new Tree(); /* dynamic distance tree */ … … 7805 7805 d.bitcount += 8; 7806 7806 } 7807 7807 7808 7808 var sum = 0, cur = 0, len = 0; 7809 7809 var tag = d.tag; … … 7818 7818 cur -= t.table[len]; 7819 7819 } while (cur >= 0); 7820 7820 7821 7821 d.tag = tag; 7822 7822 d.bitcount -= len; … … 7929 7929 var length, invlength; 7930 7930 var i; 7931 7931 7932 7932 /* unread from bitbuffer */ 7933 7933 while (d.bitcount > 8) { … … 8002 8002 return d.dest.subarray(0, d.destLen); 8003 8003 } 8004 8004 8005 8005 return d.dest; 8006 8006 } … … 11509 11509 return 16; 11510 11510 } 11511 11511 11512 11512 n = br.readBits(3); 11513 11513 if (n > 0) { 11514 11514 return 17 + n; 11515 11515 } 11516 11516 11517 11517 n = br.readBits(3); 11518 11518 if (n > 0) { 11519 11519 return 8 + n; 11520 11520 } 11521 11521 11522 11522 return 17; 11523 11523 } … … 11544 11544 11545 11545 function DecodeMetaBlockLength(br) { 11546 var out = new MetaBlockLength; 11546 var out = new MetaBlockLength; 11547 11547 var size_nibbles; 11548 11548 var size_bytes; 11549 11549 var i; 11550 11550 11551 11551 out.input_end = br.readBits(1); 11552 11552 if (out.input_end && br.readBits(1)) { 11553 11553 return out; 11554 11554 } 11555 11555 11556 11556 size_nibbles = br.readBits(2) + 4; 11557 11557 if (size_nibbles === 7) { 11558 11558 out.is_metadata = true; 11559 11559 11560 11560 if (br.readBits(1) !== 0) 11561 11561 throw new Error('Invalid reserved bit'); 11562 11562 11563 11563 size_bytes = br.readBits(2); 11564 11564 if (size_bytes === 0) 11565 11565 return out; 11566 11566 11567 11567 for (i = 0; i < size_bytes; i++) { 11568 11568 var next_byte = br.readBits(8); 11569 11569 if (i + 1 === size_bytes && size_bytes > 1 && next_byte === 0) 11570 11570 throw new Error('Invalid size byte'); 11571 11571 11572 11572 out.meta_block_length |= next_byte << (i * 8); 11573 11573 } … … 11577 11577 if (i + 1 === size_nibbles && size_nibbles > 4 && next_nibble === 0) 11578 11578 throw new Error('Invalid size nibble'); 11579 11579 11580 11580 out.meta_block_length |= next_nibble << (i * 4); 11581 11581 } 11582 11582 } 11583 11583 11584 11584 ++out.meta_block_length; 11585 11585 11586 11586 if (!out.input_end && !out.is_metadata) { 11587 11587 out.is_uncompressed = br.readBits(1); 11588 11588 } 11589 11589 11590 11590 return out; 11591 11591 } … … 11594 11594 function ReadSymbol(table, index, br) { 11595 11595 var start_index = index; 11596 11596 11597 11597 var nbits; 11598 11598 br.fillBitWindow(); … … 11614 11614 var repeat_code_len = 0; 11615 11615 var space = 32768; 11616 11616 11617 11617 var table = []; 11618 11618 for (var i = 0; i < 32; i++) 11619 11619 table.push(new HuffmanCode(0, 0)); 11620 11620 11621 11621 BrotliBuildHuffmanTable(table, 0, 5, code_length_code_lengths, CODE_LENGTH_CODES); 11622 11622 … … 11624 11624 var p = 0; 11625 11625 var code_len; 11626 11626 11627 11627 br.readMoreInput(); 11628 11628 br.fillBitWindow(); … … 11659 11659 throw new Error('[ReadHuffmanCodeLengths] symbol + repeat_delta > num_symbols'); 11660 11660 } 11661 11661 11662 11662 for (var x = 0; x < repeat_delta; x++) 11663 11663 code_lengths[symbol + x] = repeat_code_len; 11664 11664 11665 11665 symbol += repeat_delta; 11666 11666 11667 11667 if (repeat_code_len !== 0) { 11668 11668 space -= repeat_delta << (15 - repeat_code_len); … … 11673 11673 throw new Error("[ReadHuffmanCodeLengths] space = " + space); 11674 11674 } 11675 11675 11676 11676 for (; symbol < num_symbols; symbol++) 11677 11677 code_lengths[symbol] = 0; … … 11682 11682 var simple_code_or_skip; 11683 11683 var code_lengths = new Uint8Array(alphabet_size); 11684 11684 11685 11685 br.readMoreInput(); 11686 11686 11687 11687 /* simple_code_or_skip is used as follows: 11688 11688 1 for simple code; … … 11720 11720 throw new Error('[ReadHuffmanCode] invalid symbols'); 11721 11721 } 11722 11722 11723 11723 code_lengths[symbols[1]] = 1; 11724 11724 break; … … 11732 11732 throw new Error('[ReadHuffmanCode] invalid symbols'); 11733 11733 } 11734 11734 11735 11735 if (br.readBits(1)) { 11736 11736 code_lengths[symbols[2]] = 3; … … 11748 11748 /* Static Huffman code for the code length code lengths */ 11749 11749 var huff = [ 11750 new HuffmanCode(2, 0), new HuffmanCode(2, 4), new HuffmanCode(2, 3), new HuffmanCode(3, 2), 11750 new HuffmanCode(2, 0), new HuffmanCode(2, 4), new HuffmanCode(2, 3), new HuffmanCode(3, 2), 11751 11751 new HuffmanCode(2, 0), new HuffmanCode(2, 4), new HuffmanCode(2, 3), new HuffmanCode(4, 1), 11752 new HuffmanCode(2, 0), new HuffmanCode(2, 4), new HuffmanCode(2, 3), new HuffmanCode(3, 2), 11752 new HuffmanCode(2, 0), new HuffmanCode(2, 4), new HuffmanCode(2, 3), new HuffmanCode(3, 2), 11753 11753 new HuffmanCode(2, 0), new HuffmanCode(2, 4), new HuffmanCode(2, 3), new HuffmanCode(4, 5) 11754 11754 ]; … … 11767 11767 } 11768 11768 } 11769 11769 11770 11770 if (!(num_codes === 1 || space === 0)) 11771 11771 throw new Error('[ReadHuffmanCode] invalid num_codes or space'); 11772 11772 11773 11773 ReadHuffmanCodeLengths(code_length_code_lengths, alphabet_size, code_lengths, br); 11774 11774 } 11775 11775 11776 11776 table_size = BrotliBuildHuffmanTable(tables, table, HUFFMAN_TABLE_BITS, code_lengths, alphabet_size); 11777 11777 11778 11778 if (table_size === 0) { 11779 11779 throw new Error("[ReadHuffmanCode] BuildHuffmanTable failed: "); 11780 11780 } 11781 11781 11782 11782 return table_size; 11783 11783 } … … 11827 11827 this.alphabet_size = alphabet_size; 11828 11828 this.num_htrees = num_htrees; 11829 this.codes = new Array(num_htrees + num_htrees * kMaxHuffmanTableSize[(alphabet_size + 31) >>> 5]); 11829 this.codes = new Array(num_htrees + num_htrees * kMaxHuffmanTableSize[(alphabet_size + 31) >>> 5]); 11830 11830 this.htrees = new Uint32Array(num_htrees); 11831 11831 } … … 11848 11848 var table; 11849 11849 var i; 11850 11850 11851 11851 br.readMoreInput(); 11852 11852 var num_htrees = out.num_htrees = DecodeVarLenUint8(br) + 1; … … 11861 11861 max_run_length_prefix = br.readBits(4) + 1; 11862 11862 } 11863 11863 11864 11864 table = []; 11865 11865 for (i = 0; i < HUFFMAN_MAX_TABLE_SIZE; i++) { 11866 11866 table[i] = new HuffmanCode(0, 0); 11867 11867 } 11868 11868 11869 11869 ReadHuffmanCode(num_htrees + max_run_length_prefix, table, 0, br); 11870 11870 11871 11871 for (i = 0; i < context_map_size;) { 11872 11872 var code; … … 11894 11894 InverseMoveToFrontTransform(context_map, context_map_size); 11895 11895 } 11896 11896 11897 11897 return out; 11898 11898 } … … 11955 11955 for (var x = 0; x < tail; x++) 11956 11956 ringbuffer[rb_pos + x] = br.buf_[br_pos + x]; 11957 11957 11958 11958 nbytes -= tail; 11959 11959 rb_pos += tail; … … 11964 11964 for (var x = 0; x < nbytes; x++) 11965 11965 ringbuffer[rb_pos + x] = br.buf_[br_pos + x]; 11966 11966 11967 11967 rb_pos += nbytes; 11968 11968 len -= nbytes; … … 11972 11972 if (rb_pos >= rb_size) { 11973 11973 output.write(ringbuffer, rb_size); 11974 rb_pos -= rb_size; 11974 rb_pos -= rb_size; 11975 11975 for (var x = 0; x < rb_pos; x++) 11976 11976 ringbuffer[x] = ringbuffer[rb_size + x]; … … 12020 12020 function BrotliDecompressBuffer(buffer, output_size) { 12021 12021 var input = new BrotliInput(buffer); 12022 12022 12023 12023 if (output_size == null) { 12024 12024 output_size = BrotliDecompressedSize(buffer); 12025 12025 } 12026 12026 12027 12027 var output_buffer = new Uint8Array(output_size); 12028 12028 var output = new BrotliOutput(output_buffer); 12029 12029 12030 12030 BrotliDecompress(input, output); 12031 12031 12032 12032 if (output.pos < output.buffer.length) { 12033 12033 output.buffer = output.buffer.subarray(0, output.pos); 12034 12034 } 12035 12035 12036 12036 return output.buffer; 12037 12037 } … … 12120 12120 12121 12121 br.readMoreInput(); 12122 12122 12123 12123 var _out = DecodeMetaBlockLength(br); 12124 12124 meta_block_remaining_len = _out.meta_block_length; … … 12128 12128 tmp.set( output.buffer ); 12129 12129 output.buffer = tmp; 12130 } 12130 } 12131 12131 input_end = _out.input_end; 12132 12132 is_uncompressed = _out.is_uncompressed; 12133 12133 12134 12134 if (_out.is_metadata) { 12135 12135 JumpToByteBoundary(br); 12136 12136 12137 12137 for (; meta_block_remaining_len > 0; --meta_block_remaining_len) { 12138 12138 br.readMoreInput(); … … 12140 12140 br.readBits(8); 12141 12141 } 12142 12142 12143 12143 continue; 12144 12144 } 12145 12145 12146 12146 if (meta_block_remaining_len === 0) { 12147 12147 continue; 12148 12148 } 12149 12149 12150 12150 if (is_uncompressed) { 12151 12151 br.bit_pos_ = (br.bit_pos_ + 7) & ~7; … … 12155 12155 continue; 12156 12156 } 12157 12157 12158 12158 for (i = 0; i < 3; ++i) { 12159 12159 num_block_types[i] = DecodeVarLenUint8(br) + 1; … … 12165 12165 } 12166 12166 } 12167 12167 12168 12168 br.readMoreInput(); 12169 12169 12170 12170 distance_postfix_bits = br.readBits(2); 12171 12171 num_direct_distance_codes = NUM_DISTANCE_SHORT_CODES + (br.readBits(4) << distance_postfix_bits); … … 12178 12178 context_modes[i] = (br.readBits(2) << 1); 12179 12179 } 12180 12180 12181 12181 var _o1 = DecodeContextMap(num_block_types[0] << kLiteralContextBits, br); 12182 12182 num_literal_htrees = _o1.num_htrees; 12183 12183 context_map = _o1.context_map; 12184 12184 12185 12185 var _o2 = DecodeContextMap(num_block_types[2] << kDistanceContextBits, br); 12186 12186 num_dist_htrees = _o2.num_htrees; 12187 12187 dist_context_map = _o2.context_map; 12188 12188 12189 12189 hgroup[0] = new HuffmanTreeGroup(kNumLiteralCodes, num_literal_htrees); 12190 12190 hgroup[1] = new HuffmanTreeGroup(kNumInsertAndCopyCodes, num_block_types[1]); … … 12216 12216 12217 12217 br.readMoreInput(); 12218 12218 12219 12219 if (block_length[1] === 0) { 12220 12220 DecodeBlockType(num_block_types[1], … … 12272 12272 if (distance_code < 0) { 12273 12273 var context; 12274 12274 12275 12275 br.readMoreInput(); 12276 12276 if (block_length[2] === 0) { … … 12334 12334 if (copy_dst >= ringbuffer_end) { 12335 12335 output.write(ringbuffer, ringbuffer_size); 12336 12336 12337 12337 for (var _x = 0; _x < (copy_dst - ringbuffer_end); _x++) 12338 12338 ringbuffer[_x] = ringbuffer[ringbuffer_end + _x]; … … 12399 12399 count = this.buffer.length - this.pos; 12400 12400 } 12401 12401 12402 12402 for (var p = 0; p < count; p++) 12403 12403 buf[i + p] = this.buffer[this.pos + p]; 12404 12404 12405 12405 this.pos += count; 12406 12406 return count; … … 12417 12417 if (this.pos + count > this.buffer.length) 12418 12418 throw new Error('Output buffer is not large enough'); 12419 12419 12420 12420 this.buffer.set(buf.subarray(0, count), this.pos); 12421 12421 this.pos += count; … … 12549 12549 } 12550 12550 } 12551 12551 12552 12552 table_bits = root_bits; 12553 12553 table_size = 1 << table_bits; … … 12559 12559 root_table[table + key] = new HuffmanCode(0, sorted[0] & 0xffff); 12560 12560 } 12561 12561 12562 12562 return total_size; 12563 12563 } … … 12592 12592 } 12593 12593 } 12594 12594 12595 12595 return total_size; 12596 12596 } … … 12604 12604 12605 12605 /* 12606 PDFImage - embeds images in PDF documents12606 PDFImage - embeds images in PDF folders 12607 12607 By Devon Govett 12608 12608 */ … … 13139 13139 * var docDefinition = { 13140 13140 * info: { 13141 * title: 'awesome Document',13141 * title: 'awesome Folder', 13142 13142 * author: 'john doe', 13143 13143 * subject: 'subject of document', … … 25518 25518 this._font = null; 25519 25519 this._registeredFonts = {}; 25520 25520 25521 25521 }, 25522 25522 font: function(src, family, size) { … … 26017 26017 26018 26018 // ISO (deprecated) 26019 [], { // windows 26019 [], { // windows 26020 26020 0x0436: 'af', 0x4009: 'en-IN', 0x0487: 'rw', 0x0432: 'tn', 26021 26021 0x041C: 'sq', 0x1809: 'en-IE', 0x0441: 'sw', 0x045B: 'si', … … 33419 33419 * - apply ljmo, vjmo, and tjmo OpenType features to decomposed Jamo sequences. 33420 33420 * 33421 * This logic is based on the following documents:33421 * This logic is based on the following folders: 33422 33422 * - http://www.microsoft.com/typography/OpenTypeDev/hangul/intro.htm 33423 33423 * - http://ktug.org/~nomos/harfbuzz-hangul/hangulshaper.pdf … … 40790 40790 ]; 40791 40791 40792 // Put all encoding/alias/codec definitions to single object and export it. 40792 // Put all encoding/alias/codec definitions to single object and export it. 40793 40793 for (var i = 0; i < modules.length; i++) { 40794 40794 var module = modules[i]; … … 40942 40942 40943 40943 InternalDecoderCesu8.prototype.write = function(buf) { 40944 var acc = this.acc, contBytes = this.contBytes, accBytes = this.accBytes, 40944 var acc = this.acc, contBytes = this.contBytes, accBytes = this.accBytes, 40945 40945 res = ''; 40946 40946 for (var i = 0; i < buf.length; i++) { … … 41116 41116 this.initialBytes.push(buf); 41117 41117 this.initialBytesLen += buf.length; 41118 41118 41119 41119 if (this.initialBytesLen < 16) // We need more bytes to use space heuristic (see below) 41120 41120 return ''; … … 41212 41212 // Non-direct chars are encoded as "+<base64>-"; single "+" char is encoded as "+-". 41213 41213 return new Buffer(str.replace(nonDirectChars, function(chunk) { 41214 return "+" + (chunk === '+' ? '' : 41215 this.iconv.encode(chunk, 'utf16-be').toString('base64').replace(/=+$/, '')) 41214 return "+" + (chunk === '+' ? '' : 41215 this.iconv.encode(chunk, 'utf16-be').toString('base64').replace(/=+$/, '')) 41216 41216 + "-"; 41217 41217 }.bind(this))); … … 41235 41235 base64Chars[i] = base64Regex.test(String.fromCharCode(i)); 41236 41236 41237 var plusChar = '+'.charCodeAt(0), 41237 var plusChar = '+'.charCodeAt(0), 41238 41238 minusChar = '-'.charCodeAt(0), 41239 41239 andChar = '&'.charCodeAt(0); … … 41484 41484 41485 41485 // Single-byte codec. Needs a 'chars' string parameter that contains 256 or 128 chars that 41486 // correspond to encoded bytes (if 128 - then lower half is ASCII). 41486 // correspond to encoded bytes (if 128 - then lower half is ASCII). 41487 41487 41488 41488 exports._sbcs = SBCSCodec; … … 41490 41490 if (!codecOptions) 41491 41491 throw new Error("SBCS codec is called without the data.") 41492 41492 41493 41493 // Prepare char buffer for decoding. 41494 41494 if (!codecOptions.chars || (codecOptions.chars.length !== 128 && codecOptions.chars.length !== 256)) 41495 41495 throw new Error("Encoding '"+codecOptions.type+"' has incorrect 'chars' (must be of len 128 or 256)"); 41496 41496 41497 41497 if (codecOptions.chars.length === 128) { 41498 41498 var asciiString = ""; … … 41503 41503 41504 41504 this.decodeBuf = new Buffer(codecOptions.chars, 'ucs2'); 41505 41505 41506 41506 // Encoding buffer. 41507 41507 var encodeBuf = new Buffer(65536); … … 41526 41526 for (var i = 0; i < str.length; i++) 41527 41527 buf[i] = this.encodeBuf[str.charCodeAt(i)]; 41528 41528 41529 41529 return buf; 41530 41530 } … … 42259 42259 this.decodeTables[0] = UNASSIGNED_NODE.slice(0); // Create root node. 42260 42260 42261 // Sometimes a MBCS char corresponds to a sequence of unicode chars. We store them as arrays of integers here. 42261 // Sometimes a MBCS char corresponds to a sequence of unicode chars. We store them as arrays of integers here. 42262 42262 this.decodeTableSeq = []; 42263 42263 … … 42268 42268 this.defaultCharUnicode = iconv.defaultCharUnicode; 42269 42269 42270 42270 42271 42271 // Encode tables: Unicode -> DBCS. 42272 42272 … … 42277 42277 // <= SEQ_START -> it's an index in encodeTableSeq, see below. The character starts a sequence. 42278 42278 this.encodeTable = []; 42279 42279 42280 42280 // `encodeTableSeq` is used when a sequence of unicode characters is encoded as a single code. We use a tree of 42281 42281 // objects where keys correspond to characters in sequence and leafs are the encoded dbcs values. A special DEF_CHAR key … … 42295 42295 skipEncodeChars[j] = true; 42296 42296 } 42297 42297 42298 42298 // Use decode trie to recursively fill out encode tables. 42299 42299 this._fillEncodeTable(0, 0, skipEncodeChars); … … 42332 42332 for (var i = 0x30; i <= 0x39; i++) 42333 42333 fourthByteNode[i] = GB18030_CODE 42334 } 42334 } 42335 42335 } 42336 42336 … … 42397 42397 writeTable[curAddr++] = code; // Basic char 42398 42398 } 42399 } 42399 } 42400 42400 else if (typeof part === "number") { // Integer, meaning increasing sequence starting with prev character. 42401 42401 var charCode = writeTable[curAddr - 1] + 1; … … 42428 42428 42429 42429 DBCSCodec.prototype._setEncodeSequence = function(seq, dbcsCode) { 42430 42430 42431 42431 // Get the root of character tree according to first character of the sequence. 42432 42432 var uCode = seq[0]; … … 42489 42489 this.leadSurrogate = -1; 42490 42490 this.seqObj = undefined; 42491 42491 42492 42492 // Static data 42493 42493 this.encodeTable = codec.encodeTable; … … 42498 42498 42499 42499 DBCSEncoder.prototype.write = function(str) { 42500 var newBuf = new Buffer(str.length * (this.gb18030 ? 4 : 3)), 42500 var newBuf = new Buffer(str.length * (this.gb18030 ? 4 : 3)), 42501 42501 leadSurrogate = this.leadSurrogate, 42502 42502 seqObj = this.seqObj, nextChar = -1, … … 42511 42511 else { 42512 42512 var uCode = nextChar; 42513 nextChar = -1; 42513 nextChar = -1; 42514 42514 } 42515 42515 … … 42533 42533 uCode = UNASSIGNED; 42534 42534 } 42535 42535 42536 42536 } 42537 42537 } … … 42574 42574 if (subtable !== undefined) 42575 42575 dbcsCode = subtable[uCode & 0xFF]; 42576 42576 42577 42577 if (dbcsCode <= SEQ_START) { // Sequence start 42578 42578 seqObj = this.encodeTableSeq[SEQ_START-dbcsCode]; … … 42597 42597 if (dbcsCode === UNASSIGNED) 42598 42598 dbcsCode = this.defaultCharSingleByte; 42599 42599 42600 42600 if (dbcsCode < 0x100) { 42601 42601 newBuf[j++] = dbcsCode; … … 42644 42644 this.leadSurrogate = -1; 42645 42645 } 42646 42646 42647 42647 return newBuf.slice(0, j); 42648 42648 } … … 42668 42668 DBCSDecoder.prototype.write = function(buf) { 42669 42669 var newBuf = new Buffer(buf.length*2), 42670 nodeIdx = this.nodeIdx, 42670 nodeIdx = this.nodeIdx, 42671 42671 prevBuf = this.prevBuf, prevBufOffset = this.prevBuf.length, 42672 42672 seqStart = -this.prevBuf.length, // idx of the start of current parsed sequence. … … 42675 42675 if (prevBufOffset > 0) // Make prev buf overlap a little to make it easier to slice later. 42676 42676 prevBuf = Buffer.concat([prevBuf, buf.slice(0, 10)]); 42677 42677 42678 42678 for (var i = 0, j = 0; i < buf.length; i++) { 42679 42679 var curByte = (i >= 0) ? buf[i] : prevBuf[i + prevBufOffset]; … … 42682 42682 var uCode = this.decodeTables[nodeIdx][curByte]; 42683 42683 42684 if (uCode >= 0) { 42684 if (uCode >= 0) { 42685 42685 // Normal character, just use it. 42686 42686 } … … 42714 42714 42715 42715 // Write the character to buffer, handling higher planes using surrogate pair. 42716 if (uCode > 0xFFFF) { 42716 if (uCode > 0xFFFF) { 42717 42717 uCode -= 0x10000; 42718 42718 var uCodeLead = 0xD800 + Math.floor(uCode / 0x400); … … 42784 42784 42785 42785 module.exports = { 42786 42786 42787 42787 // == Japanese/ShiftJIS ==================================================== 42788 42788 // All japanese encodings are based on JIS X set of standards: 42789 42789 // JIS X 0201 - Single-byte encoding of ASCII + ¥ + Kana chars at 0xA1-0xDF. 42790 // JIS X 0208 - Main set of 6879 characters, placed in 94x94 plane, to be encoded by 2 bytes. 42790 // JIS X 0208 - Main set of 6879 characters, placed in 94x94 plane, to be encoded by 2 bytes. 42791 42791 // Has several variations in 1978, 1983, 1990 and 1997. 42792 42792 // JIS X 0212 - Supplementary plane of 6067 chars in 94x94 plane. 1990. Effectively dead. … … 42806 42806 // * JIS X 208: 7-bit, direct encoding of 0208. Byte ranges: 0x21-0x7E (94 values). Uncommon. 42807 42807 // Used as-is in ISO2022 family. 42808 // * ISO2022-JP: Stateful encoding, with escape sequences to switch between ASCII, 42808 // * ISO2022-JP: Stateful encoding, with escape sequences to switch between ASCII, 42809 42809 // 0201-1976 Roman, 0208-1978, 0208-1983. 42810 42810 // * ISO2022-JP-1: Adds esc seq for 0212-1990. … … 42918 42918 // * Big5-2003 (Taiwan standard) almost superset of cp950. 42919 42919 // * Unicode-at-on (UAO) / Mozilla 1.8. Falling out of use on the Web. Not supported by other browsers. 42920 // * Big5-HKSCS (-2001, -2004, -2008). Hong Kong standard. 42920 // * Big5-HKSCS (-2001, -2004, -2008). Hong Kong standard. 42921 42921 // many unicode code points moved from PUA to Supplementary plane (U+2XXXX) over the years. 42922 42922 // Plus, it has 4 combining sequences. … … 42929 42929 // Official spec: http://www.ogcio.gov.hk/en/business/tech_promotion/ccli/terms/doc/2003cmp_2008.txt 42930 42930 // http://www.ogcio.gov.hk/tc/business/tech_promotion/ccli/terms/doc/hkscs-2008-big5-iso.txt 42931 // 42931 // 42932 42932 // Current understanding of how to deal with Big5(-HKSCS) is in the Encoding Standard, http://encoding.spec.whatwg.org/#big5-encoder 42933 42933 // Unicode mapping (http://www.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/OTHER/BIG5.TXT) is said to be wrong. … … 42998 42998 // == Exports ================================================================== 42999 42999 module.exports = function(iconv) { 43000 43000 43001 43001 // Additional Public API. 43002 43002 iconv.encodeStream = function encodeStream(encoding, options) { … … 43093 43093 try { 43094 43094 var res = this.conv.end(); 43095 if (res && res.length) this.push(res, this.encoding); 43095 if (res && res.length) this.push(res, this.encoding); 43096 43096 done(); 43097 43097 } … … 43141 43141 43142 43142 var nodeNativeEncodings = { 43143 'hex': true, 'utf8': true, 'utf-8': true, 'ascii': true, 'binary': true, 43143 'hex': true, 'utf8': true, 'utf-8': true, 'ascii': true, 'binary': true, 43144 43144 'base64': true, 'ucs2': true, 'ucs-2': true, 'utf16le': true, 'utf-16le': true, 43145 43145 }; … … 46996 46996 this.buf_ = new Uint8Array(BROTLI_IBUF_SIZE); 46997 46997 this.input_ = input; /* input callback */ 46998 46998 46999 46999 this.reset(); 47000 47000 } … … 47010 47010 this.bit_end_pos_ = 0; /* bit-reading end position from LSB of val_ */ 47011 47011 this.eos_ = 0; /* input stream is finished */ 47012 47012 47013 47013 this.readMoreInput(); 47014 47014 for (var i = 0; i < 4; i++) { … … 47016 47016 ++this.pos_; 47017 47017 } 47018 47018 47019 47019 return this.bit_end_pos_ > 0; 47020 47020 }; … … 47044 47044 throw new Error('Unexpected end of input'); 47045 47045 } 47046 47046 47047 47047 if (bytes_read < BROTLI_READ_SIZE) { 47048 47048 this.eos_ = 1; … … 47051 47051 this.buf_[dst + bytes_read + p] = 0; 47052 47052 } 47053 47053 47054 47054 if (dst === 0) { 47055 47055 /* Copy the head of the ringbuffer to the slack region. */ … … 47061 47061 this.buf_ptr_ = 0; 47062 47062 } 47063 47063 47064 47064 this.bit_end_pos_ += bytes_read << 3; 47065 47065 } … … 47067 47067 47068 47068 /* Guarantees that there are at least 24 bits in the buffer. */ 47069 BrotliBitReader.prototype.fillBitWindow = function() { 47069 BrotliBitReader.prototype.fillBitWindow = function() { 47070 47070 while (this.bit_pos_ >= 8) { 47071 47071 this.val_ >>>= 8; … … 47082 47082 this.fillBitWindow(); 47083 47083 } 47084 47084 47085 47085 var val = ((this.val_ >>> this.bit_pos_) & kBitMask[n_bits]); 47086 47086 this.bit_pos_ += n_bits; … … 47099 47099 47100 47100 /** 47101 * The normal dictionary-data.js is quite large, which makes it 47102 * unsuitable for browser usage. In order to make it smaller, 47101 * The normal dictionary-data.js is quite large, which makes it 47102 * unsuitable for browser usage. In order to make it smaller, 47103 47103 * we read dictionary.bin, which is a compressed version of 47104 * the dictionary, and on initial load, Brotli decompresses 47104 * the dictionary, and on initial load, Brotli decompresses 47105 47105 * it's own dictionary. 😜 47106 47106 */ … … 47613 47613 this.transform = transform; 47614 47614 this.suffix = new Uint8Array(suffix.length); 47615 47615 47616 47616 for (var i = 0; i < prefix.length; i++) 47617 47617 this.prefix[i] = prefix.charCodeAt(i); 47618 47618 47619 47619 for (var i = 0; i < suffix.length; i++) 47620 47620 this.suffix[i] = suffix.charCodeAt(i); … … 47755 47755 return 1; 47756 47756 } 47757 47757 47758 47758 /* An overly simplified uppercasing model for utf-8. */ 47759 47759 if (p[i] < 0xe0) { … … 47761 47761 return 2; 47762 47762 } 47763 47763 47764 47764 /* An arbitrary transform for three byte characters. */ 47765 47765 p[i + 2] ^= 5; … … 47775 47775 var start_idx = idx; 47776 47776 var uppercase; 47777 47777 47778 47778 if (skip > len) { 47779 47779 skip = len; 47780 47780 } 47781 47781 47782 47782 var prefix_pos = 0; 47783 47783 while (prefix_pos < prefix.length) { 47784 47784 dst[idx++] = prefix[prefix_pos++]; 47785 47785 } 47786 47786 47787 47787 word += skip; 47788 47788 len -= skip; 47789 47789 47790 47790 if (t <= kOmitLast9) { 47791 47791 len -= t; 47792 47792 } 47793 47793 47794 47794 for (i = 0; i < len; i++) { 47795 47795 dst[idx++] = BrotliDictionary.dictionary[word + i]; 47796 47796 } 47797 47797 47798 47798 uppercase = idx - len; 47799 47799 47800 47800 if (t === kUppercaseFirst) { 47801 47801 ToUpperCase(dst, uppercase); … … 47807 47807 } 47808 47808 } 47809 47809 47810 47810 var suffix_pos = 0; 47811 47811 while (suffix_pos < suffix.length) { 47812 47812 dst[idx++] = suffix[suffix_pos++]; 47813 47813 } 47814 47814 47815 47815 return idx - start_idx; 47816 47816 } … … 49545 49545 # MIT LICENSE 49546 49546 # Copyright (c) 2011 Devon Govett 49547 # 49548 # Permission is hereby granted, free of charge, to any person obtaining a copy of this 49549 # software and associated documentation files (the "Software"), to deal in the Software 49550 # without restriction, including without limitation the rights to use, copy, modify, merge, 49551 # publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 49547 # 49548 # Permission is hereby granted, free of charge, to any person obtaining a copy of this 49549 # software and associated documentation files (the "Software"), to deal in the Software 49550 # without restriction, including without limitation the rights to use, copy, modify, merge, 49551 # publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 49552 49552 # to whom the Software is furnished to do so, subject to the following conditions: 49553 # 49554 # The above copyright notice and this permission notice shall be included in all copies or 49553 # 49554 # The above copyright notice and this permission notice shall be included in all copies or 49555 49555 # substantial portions of the Software. 49556 # 49557 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 49558 # BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 49559 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 49560 # DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 49556 # 49557 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 49558 # BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 49559 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 49560 # DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 49561 49561 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 49562 49562 */
Note:
See TracChangeset
for help on using the changeset viewer.