如何切断UTF字符串中的最后一个符文?这种方法显然是不正确的:
package main
import ("fmt"
"unicode/utf8")
func main() {
string := "你好"
length := utf8.RuneCountInString(string)
// how to cut off last rune in UTF string?
// this method is obviously incorrect:
withoutLastRune := string[0:length-1]
fmt.Println(withoutLastRune)
}
宝慕林4294392
米脂
相关分类