ianaindex

package
v0.0.0-...-123e828 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2019 License: GPL-3.0, BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Overview

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

See http://www.iana.org/assignments/character-sets/character-sets.xhtml for more details.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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.

Example
package main

import (
	"fmt"

	"golang.org/x/text/encoding/charmap"
	"golang.org/x/text/encoding/ianaindex"
)

func main() {
	fmt.Println(ianaindex.MIME.Name(charmap.ISO8859_7))
	fmt.Println(ianaindex.IANA.Name(charmap.ISO8859_7))
	fmt.Println(ianaindex.MIB.Name(charmap.ISO8859_7))

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

}
Output:

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.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL