Method description:
Check whether it is a valid encoding parameter and return true or false.
Grammar:
Buffer.isEncoding(encoding)
Receive parameters:
encoding {String} The detected encoding format
Example:
var a = Buffer.isEncoding('base64');
console.log(a);
Source code:
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;
}
};
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn