chinese.go 274 B

123456789101112131415161718192021
  1. package chinese
  2. import (
  3. "github.com/go-ego/gpy"
  4. "strings"
  5. )
  6. func FirstPinYin(r string) string {
  7. args := gpy.NewArgs()
  8. ss := gpy.Pinyin(r, args)
  9. if len(ss) == 0 {
  10. return "#"
  11. }
  12. if len(ss[0]) == 0 {
  13. return "#"
  14. }
  15. return strings.ToUpper(string(ss[0][0][0]))
  16. }