width

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Reader added in v0.5.0

func Reader(txt io.Reader, opt Option) io.Reader

Reader returns transformed text reader

Example
package main

import (
	"bytes"
	"fmt"
	"io"
	"strings"

	"github.com/spiegel-im-spiegel/text/width"
)

func main() {
	buf := &bytes.Buffer{}
	if _, err := io.Copy(buf, width.Reader(strings.NewReader("abヲ₩○¥A"), width.Fold)); err != nil {
		return
	}
	fmt.Println(buf)
}
Output:

abヲ₩○¥A

func String added in v0.5.1

func String(txt string, opt Option) string

String returns normalized text reader

Example
package main

import (
	"fmt"

	"github.com/spiegel-im-spiegel/text/width"
)

func main() {
	res := width.String("abヲ₩○¥A", width.Fold)
	fmt.Println(res)
}
Output:

abヲ₩○¥A

Types

type Option

type Option int

Option is form of width transformer

const (
	Unknown Option = iota //Unknown form of width transformer
	Fold                  //Fold form of width transformer
	Narrow                //Narrow form of width transformer
	Widen                 //Widen form of width transformer
)

func FormofWidth

func FormofWidth(s string) Option

FormofWidth returns form of width transformer

func (Option) GetForm

func (w Option) GetForm() *wdth.Transformer

GetForm returns transform.Transformer instance

func (Option) String

func (w Option) String() string

Jump to

Keyboard shortcuts

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