The-Golang-Standard-Library-by-Example icon indicating copy to clipboard operation
The-Golang-Standard-Library-by-Example copied to clipboard

unicode章节建议增加汉字range

Open rongyi opened this issue 7 years ago • 0 comments

在unicode package中定义了各种字符的range,比如unicode.Han则代表了所有中文字符的range,还有个方法提供判断一个字符是不是落在某个区间。具体可以参考下面的一个示例。

package main

import (
	"unicode"
	"fmt"
)

func main() {
	fmt.Println(unicode.In('C', unicode.Han))
	fmt.Println(unicode.In('具', unicode.Han))
}

output: false true

rongyi avatar Apr 26 '17 08:04 rongyi