list

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

Documentation

Overview

Package list provides the list command run function.

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	ErrTable = errors.New("could not display the table")
	ErrIANA  = errors.New("could not work out the IANA index or MIME type")
)

Functions

func Examples

func Examples(wr io.Writer) error

Examples writes the list command examples.

func Printable

func Printable(name string) bool

Printable reports whether the named encoding can be shown as a 256 character table. UTF-16 and UTF-32 are not printable.

func Table

func Table(w io.Writer, names ...string) error

Table writes one or more named encodings as a formatted table.

Example
package main

import (
	"fmt"
	"log"
	"os"
	"strings"

	"github.com/bengarrett/retrotxtgo/cmd/list"
	"github.com/gookit/color"
)

func main() {
	color.Enable = false
	names := []string{"cp437"}
	s := strings.Builder{}
	if err := list.Table(&s, names...); err != nil {
		log.Fatal(err)
	}
	fmt.Fprintf(os.Stdout, "%d characters in the table", len(s.String()))
}
Output:

1693 characters in the table

func Tables

func Tables(w io.Writer) error

Tables writes all the supported encodings as formatted tables.

Example
package main

import (
	"fmt"
	"log"
	"os"
	"strings"

	"github.com/bengarrett/retrotxtgo/cmd/list"
	"github.com/gookit/color"
)

func main() {
	color.Enable = false
	s := strings.Builder{}
	if err := list.Tables(&s); err != nil {
		log.Print(err)
	}
	const val = 70000
	l := s.Len()
	fmt.Fprintf(os.Stdout, "characters > 70000: %v", l > val)
}
Output:

characters > 70000: true

Types

This section is empty.

Jump to

Keyboard shortcuts

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