normalize

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: 3 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 normalized text reader

Example
package main

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

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

func main() {
	buf := &bytes.Buffer{}
	if _, err := io.Copy(buf, normalize.Reader(strings.NewReader("ペンギン"), normalize.NFKC)); err != nil {
		return
	}
	fmt.Println(buf)
}
Output:

ペンギン

func String added in v0.5.1

func String(txt string, opt Option) string

String returns normalized text string

Example
package main

import (
	"fmt"

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

func main() {
	res := normalize.String("ペンギン", normalize.NFKC)
	fmt.Println(res)
}
Output:

ペンギン

Types

type Option

type Option int

Option is type of Unicode normalization

const (
	Unknown Option = iota //Unknown type of Unicode normalization
	NFC                   //NFC type of Unicode normalization
	NFD                   //NFD type of Unicode normalization
	NFKC                  //NFKC type of Unicode normalization
	NFKD                  //NFKD type of Unicode normalization
)

func FormofNormalize

func FormofNormalize(s string) Option

FormofNormalize returns Option

func (Option) GetForm

func (n Option) GetForm() norm.Form

GetForm returns norm.Form instance

func (Option) String

func (n Option) String() string

Jump to

Keyboard shortcuts

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