xud

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: 6 Imported by: 0

Documentation

Overview

Package xud provides X User Defined, character encodings. It does not encode or decode text, only provides information about the encodings.

This includes the early American Standards Association (ASA) ASCII character encodings. There are three ASA encodings, X3.4-1963, X3.4-1965, X3.4-1967 and one missing ISO 8859-11 encoding. These encodings are not compatible with each other.

But the X3.4-1967 character codes are compatible with the ANSI X3.4-1977 and ANSI X3.4-1986 encodings. Which are also compatible with many of the IBM Code Page and ISO 8859-X encodings, as-well as Unicode.

Index

Examples

Constants

View Source
const (
	Name11  = "iso-8859-11" // name of ISO 8859-11
	Name63  = "ascii-63"    // name of ASA X3.4 1963
	Name65  = "ascii-65"    // name of ASA X3.4 1965
	Name67  = "ascii-67"    // name of ANSI X3.4 1967/77/86
	Numr11  = "11"          // numeric value for ISO 8859-11
	Numr63  = "1963"        // numeric value for ASA X3.4 1963
	Numr65  = "1965"        // numeric value for ASA X3.4 1965
	Numr67  = "1967"        // numeric value for ANSI X3.4 1967/77/86
	Alias11 = "iso885911"   // alias for ISO 8859-11
	Alias67 = "ansi"        // alias for ANSI X3.4 1967/77/86
)

Named, numeric and alias values for the legacy ASA ASCII character encodings.

Variables

View Source
var (
	// XUserDefinedISO11 ISO-8859-11.
	XUserDefinedISO11 encoding.Encoding = &xThaiISO11
	// XUserDefined1963 ASA X3.4 1963.
	XUserDefined1963 encoding.Encoding = &x34_1963
	// XUserDefined1965 ASA X3.4 1965.
	XUserDefined1965 encoding.Encoding = &x34_1965
	// XUserDefined1967 ANSI X3.4 1967/77/86.
	XUserDefined1967 encoding.Encoding = &x34_1967
)
View Source
var ErrName = errors.New("there is no encoding name")

Functions

func Alias

func Alias(e encoding.Encoding) string

Alias returns an alias value for the legacy ASA ASCII character encodings.

Example
package main

import (
	"fmt"

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

func main() {
	fmt.Println(xud.Alias(xud.XUserDefined1963))
	fmt.Println(xud.Alias(xud.XUserDefined1965))
	fmt.Println(xud.Alias(xud.XUserDefined1967))
}
Output:


ansi

func Char

func Char(e encoding.Encoding, code int) rune

Char returns a string for the 8-bit, character encoding decimal code. If the code is not defined in the encoding, then a space is returned. If the code matches an existing Windows-1252 character, then -1 is returned.

Example
package main

import (
	"fmt"

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

func main() {
	const code = 94
	r := xud.Char(xud.XUserDefined1963, code)
	fmt.Printf("code %d is the rune %s (%v)\n", code, string(r), r)
	r = xud.Char(xud.XUserDefined1965, code)
	fmt.Printf("code %d is skipped (%v)\n", code, r)
}
Output:

code 94 is the rune ↑ (8593)
code 94 is skipped (-1)

func CharISO885911

func CharISO885911(code int) rune

CharISO885911 returns a rune for the ISO-8859-11 character code. If the code is not defined in the encoding, then a space is returned. If the code matches an existing Windows-1252 character, then -1 is returned.

func CharX3463

func CharX3463(code int) rune

CharX3463 returns a rune for the legacy ASA X3.4 1963 character code. If the code is not defined in the encoding, then a space is returned. If the code matches an existing Windows-1252 character, then -1 is returned.

func CharX3465

func CharX3465(code int) rune

CharX3465 returns a string for the legacy ASA X3.4 1965 character code. If the code is not defined in the encoding, then a space is returned. If the code matches an existing Windows-1252 character, then -1 is returned.

func CharX3467

func CharX3467(code int) rune

CharX3467 returns a string for the legacy ASA X3.4 1967 character code. If the code is not defined in the encoding, then a space is returned. If the code matches an existing Windows-1252 character, then -1 is returned.

func Code7bit

func Code7bit(e encoding.Encoding) bool

Code7bit reports whether the encoding is a 7-bit ASCII encoding. The 7-bit encodings are limited to 127 characters. The more common 8-bit encodings are limited to 256 characters.

func CodePage

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

CodePage returns the encoding of the code page name or alias.

func Footnote

func Footnote(w io.Writer, e encoding.Encoding)

Footnote returns a footnote value for the legacy ASA ASCII character encodings.

func Name

func Name(e encoding.Encoding) string

Name returns a named value for the legacy ASA ASCII character encodings.

Example
package main

import (
	"fmt"

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

func main() {
	fmt.Println(xud.Name(xud.XUserDefined1963))
	fmt.Println(xud.Name(xud.XUserDefined1965))
	fmt.Println(xud.Name(xud.XUserDefined1967))
}
Output:

ascii-63
ascii-65
ascii-67

func Numeric

func Numeric(e encoding.Encoding) string

Numeric returns a numeric value for the legacy ASA ASCII character encodings.

Example
package main

import (
	"fmt"

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

func main() {
	fmt.Println(xud.Numeric(xud.XUserDefined1963))
	fmt.Println(xud.Numeric(xud.XUserDefined1965))
	fmt.Println(xud.Numeric(xud.XUserDefined1967))
}
Output:

1963
1965
1967

Types

type Encoding

type Encoding struct {
	encoding.Encoding        // Encoding is the underlying encoding.
	Name              string // Name is the formal name of the character encoding.
}

Encoding is an implementation of the Encoding interface that adds a formal name to a custom encoding.

Example
package main

import (
	"fmt"

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

func main() {
	fmt.Println(xud.XUserDefined1963)
	fmt.Println(xud.XUserDefined1965)
	fmt.Println(xud.XUserDefined1967)
}
Output:

ASA X3.4 1963
ASA X3.4 1965
ANSI X3.4 1967/77/86

func (Encoding) String

func (e Encoding) String() string

String returns the formal name of the ASA encoding.

Jump to

Keyboard shortcuts

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