This article mainly introduces node. buffer in js. buffer. description of the isEncoding method. This article introduces the buffer. buffer. isEncoding method description, syntax, receive parameters, use instances, and implementation source code. For more information, see
Method description:
Checks whether it is a valid encoding parameter and returns true or false.
Syntax:
The Code is as follows:
Buffer. isEncoding (encoding)
Receiving parameters:
Encoding format detected by encoding {String}
Example:
The Code is as follows:
Var a = Buffer. isEncoding ('base64 ');
Console. log ();
Source code:
The Code 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;
}
};