Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertString ¶
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
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.