Back to / encoding / ianaindex

Package ianaindex

Latest Go to latest

The highest tagged major version is .

Published: Oct 21, 2020 | License: BSD-3-Clause | Module:


Package ianaindex maps names to Encodings as specified by the IANA registry. This includes both the MIME and IANA names.

See for more details.



type Index

type Index struct {
	// contains filtered or unexported fields

Index maps names registered by IANA to Encodings. Currently different Indexes only differ in the names they return for encodings. In the future they may also differ in supported aliases.



package main

import (

func main() {

	e, _ := ianaindex.IANA.Encoding("cp437")

ISO-8859-7 <nil>
ISO_8859-7:1987 <nil>
ISOLatinGreek <nil>
IBM437 <nil>
var (
	// MIME is an index to map MIME names.
	MIME *Index = mime

	// IANA is an index that supports all names and aliases using IANA names as
	// the canonical identifier.
	IANA *Index = iana

	// MIB is an index that associates the MIB display name with an Encoding.
	MIB *Index = mib

func (*Index) Encoding

func (x *Index) Encoding(name string) (encoding.Encoding, error)

Encoding returns an Encoding for IANA-registered names. Matching is case-insensitive.

If the provided name doesn't match a IANA-registered charset, an error is returned. If the name matches a IANA-registered charset but isn't supported, a nil encoding and a nil error are returned.

func (*Index) Name

func (x *Index) Name(e encoding.Encoding) (string, error)

Name reports the canonical name of the given Encoding. It will return an error if the e is not associated with a known encoding scheme.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier