Method description:
Detect whether it is a valid encoding parameter, return true or false.
grammar:
The code copy is as follows:
Buffer.isEncoding(encoding)
Receive parameters:
encoding {String} The detected encoding format
example:
The code copy is as follows:
var a = Buffer.isEncoding('base64');
console.log(a);
Source code:
The code copy is as follows:
Buffer.isEncoding = function(encoding) {
switch ((encoding + '').toLowerCase()) {
case 'hex':
case 'utf8':
case 'utf-8':
case 'ascii':
case 'binary':
case 'base64':
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
case 'raw':
return true;
default:
return false;
}
};