Skip to main content
Module

std/media_types/mod.ts>getCharset

Deno standard library
Go to Latest
function getCharset
import { getCharset } from "https://deno.land/std@0.165.0/media_types/mod.ts";

Given a media type or header value, identify the encoding charset. If the charset cannot be determined, the function returns undefined.

Examples

import { getCharset } from "https://deno.land/std@0.165.0/media_types/mod.ts";

getCharset("text/plain"); // `UTF-8`
getCharset("application/foo"); // undefined
getCharset("application/news-checkgroups"); // `US-ASCII`
getCharset("application/news-checkgroups; charset=UTF-8"); // `UTF-8`

Parameters

type: string

Returns

string | undefined