Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/deno/ext/node/polyfills/internal/buffer.d.ts>Buffer.isEncoding

A modern runtime for JavaScript and TypeScript.
Latest
method Buffer.isEncoding
import { Buffer } from "https://deno.land/x/deno@v2.0.4/ext/node/polyfills/internal/buffer.d.ts";

Returns true if encoding is the name of a supported character encoding, or false otherwise.

import { Buffer } from "ext:deno_node/internal/buffer";

console.log(Buffer.isEncoding('utf8'));
// Prints: true

console.log(Buffer.isEncoding('hex'));
// Prints: true

console.log(Buffer.isEncoding('utf/8'));
// Prints: false

console.log(Buffer.isEncoding(''));
// Prints: false

Parameters

encoding: string

A character encoding name to check.

Returns

boolean