Skip to content

Instantly share code, notes, and snippets.

@Double1996
Created July 8, 2021 03:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Double1996/6fd3e956141b8bc2c63e0ccea8a3d872 to your computer and use it in GitHub Desktop.
Save Double1996/6fd3e956141b8bc2c63e0ccea8a3d872 to your computer and use it in GitHub Desktop.
判断中文字符长度
func StrNum(str string) int {
str = strings.Replace(str, " ", "", -1)
// 去除换行符
str = strings.Replace(str, "\n", "", -1)
return utf8.RuneCountInString(str)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment