Tutorials References Menu

Node.js Buffer.isEncoding() Method

❮ Buffer Module


Example

Check if the Buffer supports the utf8 encoding:

console.log(Buffer.isEncoding('utf8'));
Run example »

Definition and Usage

The Buffer.isEncoding() method returns true if the specified encoding is supported.


Syntax

Buffer.isEncoding(encoding);

Parameter Values

Parameter Description
encoding Required. The encoding to test. Normally these encodings are supported in Node.js:
"ascii"
"utf8"
"utf16le"
"ucs2"
"base64"
"latin1"
"binary"
"hex"

Technical Details

Return Value: A Boolean, true if the specified encoding is supported, otherwise false
Node.js Version: 0.9.1

More Examples

Example

Check if the Buffer supports the utf8 encoding:

console.log(Buffer.isEncoding('windows-1252'));
Run example »

❮ Buffer Module