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 ¶
- Constants
- Variables
- func Alias(e encoding.Encoding) string
- func Char(e encoding.Encoding, code int) rune
- func CharISO885911(code int) rune
- func CharX3463(code int) rune
- func CharX3465(code int) rune
- func CharX3467(code int) rune
- func Code7bit(e encoding.Encoding) bool
- func CodePage(name string) encoding.Encoding
- func Footnote(w io.Writer, e encoding.Encoding)
- func Name(e encoding.Encoding) string
- func Numeric(e encoding.Encoding) string
- type Encoding
Examples ¶
Constants ¶
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 ¶
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 )
var ErrName = errors.New("there is no encoding name")
Functions ¶
func Alias ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 Name ¶
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 ¶
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