Lines Matching refs:encoding

291  * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
293 * Buffer.from(str[, encoding])
402 * alloc(size[, fill[, encoding]])
404 Buffer.alloc = function alloc(size, fill, encoding) {
408 return _fill(buf, fill, 0, buf.length, encoding);
476 function fromString(string, encoding) {
478 if (typeof encoding !== 'string' || encoding.length === 0) {
482 encoding = undefined;
484 ops = getEncodingOps(encoding);
486 throw new ERR_UNKNOWN_ENCODING(encoding);
574 Buffer.isEncoding = function isEncoding(encoding) {
575 return typeof encoding === 'string' && encoding.length !== 0 &&
576 normalizeEncoding(encoding) !== undefined;
634 encoding: 'utf8',
643 encoding: 'ucs2',
652 encoding: 'utf16le',
661 encoding: 'latin1',
670 encoding: 'ascii',
683 encoding: 'base64',
696 encoding: 'base64url',
710 encoding: 'hex',
723 function getEncodingOps(encoding) {
724 encoding += '';
725 switch (encoding.length) {
727 if (encoding === 'utf8') return encodingOps.utf8;
728 if (encoding === 'ucs2') return encodingOps.ucs2;
729 encoding = StringPrototypeToLowerCase(encoding);
730 if (encoding === 'utf8') return encodingOps.utf8;
731 if (encoding === 'ucs2') return encodingOps.ucs2;
734 if (encoding === 'utf-8') return encodingOps.utf8;
735 if (encoding === 'ascii') return encodingOps.ascii;
736 if (encoding === 'ucs-2') return encodingOps.ucs2;
737 encoding = StringPrototypeToLowerCase(encoding);
738 if (encoding === 'utf-8') return encodingOps.utf8;
739 if (encoding === 'ascii') return encodingOps.ascii;
740 if (encoding === 'ucs-2') return encodingOps.ucs2;
743 if (encoding === 'utf16le' ||
744 StringPrototypeToLowerCase(encoding) === 'utf16le')
748 if (encoding === 'utf-16le' ||
749 StringPrototypeToLowerCase(encoding) === 'utf-16le')
753 if (encoding === 'latin1' || encoding === 'binary')
755 if (encoding === 'base64') return encodingOps.base64;
756 encoding = StringPrototypeToLowerCase(encoding);
757 if (encoding === 'latin1' || encoding === 'binary')
759 if (encoding === 'base64') return encodingOps.base64;
762 if (encoding === 'hex' || StringPrototypeToLowerCase(encoding) === 'hex')
766 if (encoding === 'base64url' ||
767 StringPrototypeToLowerCase(encoding) === 'base64url')
773 function byteLength(string, encoding) {
788 if (encoding) {
789 const ops = getEncodingOps(encoding);
828 Buffer.prototype.toString = function toString(encoding, start, end) {
850 if (encoding === undefined)
853 const ops = getEncodingOps(encoding);
855 throw new ERR_UNKNOWN_ENCODING(encoding);
958 // - encoding - an optional encoding, relevant if val is a string
960 function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
964 encoding = byteOffset;
983 if (encoding === undefined)
986 ops = getEncodingOps(encoding);
990 throw new ERR_UNKNOWN_ENCODING(encoding);
1005 Buffer.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
1006 return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
1009 Buffer.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
1010 return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
1013 Buffer.prototype.includes = function includes(val, byteOffset, encoding) {
1014 return this.indexOf(val, byteOffset, encoding) !== -1;
1020 // buffer.fill(string[, offset[, end]][, encoding])
1021 Buffer.prototype.fill = function fill(value, offset, end, encoding) {
1022 return _fill(this, value, offset, end, encoding);
1025 function _fill(buf, value, offset, end, encoding) {
1028 encoding = offset;
1032 encoding = end;
1036 const normalizedEncoding = normalizeEncoding(encoding);
1038 validateString(encoding, 'encoding');
1039 throw new ERR_UNKNOWN_ENCODING(encoding);
1057 encoding = undefined;
1085 const res = bindingFill(buf, value, offset, end, encoding);
1096 Buffer.prototype.write = function write(string, offset, length, encoding) {
1101 // Buffer#write(string, encoding)
1103 encoding = offset;
1107 // Buffer#write(string, offset[, length][, encoding])
1116 encoding = length;
1125 if (!encoding)
1128 const ops = getEncodingOps(encoding);
1130 throw new ERR_UNKNOWN_ENCODING(encoding);
1239 // Transcodes the Buffer from one encoding to another, returning a new