> For the complete documentation index, see [llms.txt](https://wskdsgcf.gitbook.io/mastering-go-zh-cn/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wskdsgcf.gitbook.io/mastering-go-zh-cn/04.0/04.5/04.5.2.md).

# 04.5.2 关于Unicode的包

Go提供的`unicode`标准库提供了很多便捷的函数，其中`unicode.IsPrint()`能帮助你判断字符串的某一部分是否能够以rune的类型打印出来。接下来将会在代码`unicode.go`中分两部分展示该函数的用法。

第一部分：

> ```go
> package main
>
> import (
>    "fmt"
>    "unicode"
> )
>
> func main() {
>    const sL= "\x99\x00ab\x50\x00\x23\x50\x29\x9c"
> ```

第二部分：

> ```go
> for i := 0; i < len(sL); i++ {
>       if unicode.IsPrint(rune(sL[i])) {
>          fmt.Printf("%c\n", sL[i])
>       } else {
>          fmt.Println("Not printable!")
>       }
>    }
> }
> ```

`unicode.IsPrint()`函数将检查字符串`sL`的每个元素是否是rune类型，如果是的话将返回`true`否则返回false。如果你需要更多操作Unicode字符的方法，可以参考官方`unicode`包的介绍。

执行`unicode.go`将会打印：

> $ go run unicode.go
>
> ```
> Not printable!
> Not printable!
> a
> b
> P
> Not printable!
> #
> P
> )
> Not printable!
> ```
