wubi

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2023 License: MIT Imports: 4 Imported by: 0

README

简介

汉字转五笔编码,五笔编码转汉字,支持自定义码表,默认集成了86版、98版、新世纪版本码表。

使用示例

import "github.com/gopherlib/wubi"

以下代码使用86版五笔作为示例,其它98版、新世纪版使用方法类似。

86版汉字转五笔码

c := wubi.New86()
codes := c.GetCode('在')
fmt.Println(codes) 

// [d dhf dhfd]

86版多个汉字转五笔码

c := wubi.New86()
codes := c.GetCodes("干一行,爱一行,一行行,行行行,一行不行,行行不行")
fmt.Println(codes) 

// [[fggh] [g ggl ggll] [tf tfhh] [,] [ep epd epdc] [g ggl ggll] [tf tfhh] [,] [g ggl ggll] [tf tfhh] [tf tfhh] [,] [tf tfhh] [tf tfhh] [tf tfhh] [,] [g ggl ggll] [tf tfhh] [i gi gii] [tf tfhh] [,] [tf tfhh] [tf tfhh] [i gi gii] [tf tfhh]]

86版五笔码转汉字

c := wubi.New86()
chars := c.GetChar("d")
fmt.Println(chars) 

// [在 石]

86版多个五笔码转汉字

c := wubi.New86()
chars := c.GetChars([]string{"d", "r"})
fmt.Println(chars) 

// [[在 石] [白 的]]

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterVersion

func RegisterVersion(ver Version, dict Dictionary)

RegisterVersion 注册自定义版本,可以覆盖默认的码表数据

Types

type Dictionary

type Dictionary map[string]string

Dictionary 五笔码表

type Version

type Version string

Version 五笔版本

const (
	Version86 Version = "86"
	Version98 Version = "98"
	Version06 Version = "06"
)

默认支持的版本

type Wubi

type Wubi struct {
	// contains filtered or unexported fields
}

Wubi 五笔码转换器

func NenWithDict

func NenWithDict(d Dictionary) *Wubi

NenWithDict 使用自定义码表创建转换器实例

func New

func New(ver Version) (*Wubi, error)

New 创建一个转换器实例

func New06

func New06() *Wubi

New06 新世纪版

func New86

func New86() *Wubi

New86 86版

func New98

func New98() *Wubi

New98 98版

func (Wubi) GetChar

func (c Wubi) GetChar(code string) []string

GetChar 获取单个五笔码对应的汉字

func (Wubi) GetChars

func (c Wubi) GetChars(codes []string) [][]string

GetChars 获取五笔码列表对应的汉字

func (Wubi) GetCode

func (c Wubi) GetCode(char rune) []string

GetCode 获取单字的五笔码

func (Wubi) GetCodes

func (c Wubi) GetCodes(chars string) [][]string

GetCodes 获取字符串的五笔码列表

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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