table

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: LGPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Package table creates a table of all the characters in the named 8-bit character set.

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	ErrNil   = errors.New("character encoding cannot be a nil value")
	ErrUTF16 = errors.New("utf-16 table encodings are not supported")
	ErrUTF32 = errors.New("utf-32 table encodings are not supported")
)

Functions

func Alias

func Alias(alias, value string, e encoding.Encoding) (string, error)

Alias returns an alias for a encoding. Only the alias argument is required.

Example
package main

import (
	"fmt"

	"github.com/bengarrett/retrotxtgo/table"
)

func main() {
	s, _ := table.Alias("", "cp437", nil)
	fmt.Println(s)
}
Output:

msdos

func Character

func Character(cp encoding.Encoding, code int, r rune) string

Character converts code or rune to an character mapped string.

func CharmapAlias

func CharmapAlias(cp encoding.Encoding) string

CharmapAlias humanizes encodings.

func Charmaps

func Charmaps() []encoding.Encoding

Charmaps returns all the supported legacy text encodings.

func CodePage

func CodePage(s string) (encoding.Encoding, error)

CodePage returns the encoding of the code page name or alias. But without any of the custom, ASA ASCII or ISO-8859-11 encodings.

func Footnote

func Footnote(w io.Writer, name string)

Footnote writes a footnote with extra details or corrections for the named code page or encoding. It is called by Table.

func Language

func Language(e encoding.Encoding) string

Language returns the natural language usge of the encoding.

Example
package main

import (
	"fmt"

	"github.com/bengarrett/retrotxtgo/table"
	"golang.org/x/text/encoding/charmap"
)

func main() {
	l := table.Language(charmap.CodePage437)
	fmt.Print(l)
}
Output:

US English

func List

func List(wr io.Writer) error

List returns a tabled list of supported IANA character set encodings.

func ListLanguage

func ListLanguage(wr io.Writer) error

ListLanguage writes a tabled list of supported IANA character set encodings and the languages they target.

func Numeric

func Numeric(name string) int

Numeric returns a numeric alias for a character encoding. A -1 int is returned whenever an alias could not be generated. Unicode based encodings always return -1.

func Replacement

func Replacement(name string, code int) string

Replacement returns a replacement character for the code page.

func SHY173

func SHY173(name string) bool

SHY173 reports whether the code page has a SHY (soft hyphen) at code 173.

func SHY240

func SHY240(x encoding.Encoding) bool

SHY240 reports whether the code page has a SHY (soft hyphen) at code 240.

func Table

func Table(wr io.Writer, name string) error

Table prints, aligns and formats to the writer all characters in the named 8-bit character set.

func Uniform

func Uniform(mime string) string

Uniform formats MIME values.

Types

type Lang

type Lang map[encoding.Encoding]string

Lang describes the common natural language uses of the encoding.

func Languages

func Languages() Lang

Languages returns a list of code page encodings and their target natural languages.

Example
package main

import (
	"fmt"

	"github.com/bengarrett/retrotxtgo/table"
	"golang.org/x/text/encoding/charmap"
)

func main() {
	l := table.Languages()
	fmt.Print(l[charmap.CodePage437])
}
Output:

US English

type Row

type Row struct {
	Name    string // Name is the formal name of the character encoding.
	Value   string // Value is the short name of the character encoding.
	Numeric string // Numeric is an optional, shorter numeric value of the character encoding.
	Alias   string // Alias is an optional, informal but common use value of the character encoding.
}

Row is an item for the list of code pages.

func Rows

func Rows(e encoding.Encoding) (Row, error)

Rows return character encoding details for use in a text table.

Jump to

Keyboard shortcuts

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