# 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!
> ```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wskdsgcf.gitbook.io/mastering-go-zh-cn/04.0/04.5/04.5.2.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
