pinyin

package
v0.0.0-...-d31700d Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2022 License: MIT Imports: 3 Imported by: 0

README

goa

golang pinyin utils.

usage

package main

import (
	"fmt"

	"gitee.com/go-better/dev/type/text/pinyin"
)

func ExampleInitials() {
	fmt.Println(pinyin.Initials("长大", false))
	fmt.Println(pinyin.Initials("长城abc", false))
	fmt.Println(pinyin.Initials(" a长b大,c ", true))
	// Output:
	// ZD
	// CCABC
	//  AZBD,C 
}

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Initials

func Initials(s string, keepSpecial bool) (res string)

获取所有汉字的首字母组合, 比如"长城ABC",返回"CCABC" -keepSpecial 保留特殊符号

Example
package main

import (
	"fmt"

	"gitee.com/go-better/dev/type/text/pinyin"
)

func main() {
	fmt.Println(pinyin.Initials("长大", false))
	fmt.Println(pinyin.Initials("长城abc", false))
	fmt.Println(pinyin.Initials(" A长b大°,c ", true))
}
Output:

ZD
CCABC
 AZBD°,C

Types

This section is empty.

Jump to

Keyboard shortcuts

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