Home > Web Front-end > JS Tutorial > Instructions for using the buffer.Buffer.isEncoding method in node.js_node.js

Instructions for using the buffer.Buffer.isEncoding method in node.js_node.js

WBOY
Release: 2016-05-16 16:27:24
Original
1613 people have browsed it

Method description:

Check whether it is a valid encoding parameter and return true or false.

Grammar:

Copy code The code is as follows:

Buffer.isEncoding(encoding)

Receive parameters:

encoding {String} The detected encoding format

Example:

Copy code The code is as follows:

var a = Buffer.isEncoding('base64');

console.log(a);

Source code:

Copy 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;
}
};
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template