unicode.go 342 B

1234567891011121314151617
  1. package tool
  2. import (
  3. "regexp"
  4. "unicode"
  5. )
  6. var hanRe = regexp.MustCompile("[\u3002\uff1b\uff0c\uff1a\u201c\u201d\uff08\uff09\u3001\uff1f\u300a\u300b]")
  7. func ContainChineseChar(str string) bool {
  8. for _, r := range str {
  9. if unicode.Is(unicode.Scripts["Han"], r) || (hanRe.MatchString(string(r))) {
  10. return true
  11. }
  12. }
  13. return false
  14. }