doc.go 760 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. Package pinyin : 汉语拼音转换工具.
  3. Usage
  4. package main
  5. import (
  6. "fmt"
  7. "github.com/mozillazg/go-pinyin"
  8. )
  9. func main() {
  10. hans := "中国人"
  11. // 默认
  12. a := pinyin.NewArgs()
  13. fmt.Println(pinyin.Pinyin(hans, a))
  14. // [[zhong] [guo] [ren]]
  15. // 包含声调
  16. a.Style = pinyin.Tone
  17. fmt.Println(pinyin.Pinyin(hans, a))
  18. // [[zhōng] [guó] [rén]]
  19. // 声调用数字表示
  20. a.Style = pinyin.Tone2
  21. fmt.Println(pinyin.Pinyin(hans, a))
  22. // [[zho1ng] [guo2] [re2n]]
  23. // 开启多音字模式
  24. a = pinyin.NewArgs()
  25. a.Heteronym = true
  26. fmt.Println(pinyin.Pinyin(hans, a))
  27. // [[zhong zhong] [guo] [ren]]
  28. a.Style = pinyin.Tone2
  29. fmt.Println(pinyin.Pinyin(hans, a))
  30. // [[zho1ng zho4ng] [guo2] [re2n]]
  31. }
  32. */
  33. package pinyin