width

package
v0.7.7 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert

func Convert(formName string, writer io.Writer, txt io.Reader) error

Convert function converts character width in text stream.

func ConvertString

func ConvertString(formName, txt string) (string, error)

ConvertString function converts character width in text string.

Example
package main

import (
	"bytes"
	"fmt"
	"os"

	"github.com/goark/gnkf/dump"
	"github.com/goark/gnkf/width"
)

func main() {
	txt := "12345 コンバンハ、セカイ 67890 コンバンハ、ニッポン"
	str, err := width.ConvertString("narrow", txt)
	if err != nil {
		return
	}
	if err := dump.UnicodePoint(os.Stdout, bytes.NewBufferString(str)); err != nil {
		fmt.Fprintln(os.Stderr, err)
		return
	}
	fmt.Println()
	str, err = width.ConvertString("widen", txt)
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		return
	}
	if err := dump.UnicodePoint(os.Stdout, bytes.NewBufferString(str)); err != nil {
		fmt.Fprintln(os.Stderr, err)
		return
	}
	fmt.Println()
	str, err = width.ConvertString("fold", txt)
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		return
	}
	if err := dump.UnicodePoint(os.Stdout, bytes.NewBufferString(str)); err != nil {
		fmt.Fprintln(os.Stderr, err)
		return
	}
	fmt.Println()
}
Output:

0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0020, 0xff7a, 0xff9d, 0xff8a, 0xff9e, 0xff9d, 0xff8a, 0xff64, 0xff7e, 0xff76, 0xff72, 0x0020, 0x0036, 0x0037, 0x0038, 0x0039, 0x0030, 0x0020, 0xff7a, 0xff9d, 0xff8a, 0xff9e, 0xff9d, 0xff8a, 0xff64, 0xff86, 0xff6f, 0xff8e, 0xff9f, 0xff9d
0xff11, 0xff12, 0xff13, 0xff14, 0xff15, 0x3000, 0x30b3, 0x30f3, 0x30d0, 0x30f3, 0x30cf, 0x3001, 0x30bb, 0x30ab, 0x30a4, 0x3000, 0xff16, 0xff17, 0xff18, 0xff19, 0xff10, 0x3000, 0x30b3, 0x30f3, 0x30d0, 0x30f3, 0x30cf, 0x3001, 0x30cb, 0x30c3, 0x30dd, 0x30f3
0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0020, 0x30b3, 0x30f3, 0x30d0, 0x30f3, 0x30cf, 0x3001, 0x30bb, 0x30ab, 0x30a4, 0x0020, 0x0036, 0x0037, 0x0038, 0x0039, 0x0030, 0x0020, 0x30b3, 0x30f3, 0x30d0, 0x30f3, 0x30cf, 0x3001, 0x30cb, 0x30c3, 0x30dd, 0x30f3

func FormList

func FormList() []string

FormList returns list of width form

func FormOf

func FormOf(name string) (wdth.Transformer, error)

FormOf returns Unicode normalization form type from name string

Types

This section is empty.

Jump to

Keyboard shortcuts

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