Created
July 8, 2021 03:15
-
-
Save Double1996/6fd3e956141b8bc2c63e0ccea8a3d872 to your computer and use it in GitHub Desktop.
判断中文字符长度
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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