duancifu6769 2014-12-08 20:20
浏览 217
已采纳

如何查看unicode类别中的所有字符?

I've read the documentation and can't find any examples.

http://golang.org/pkg/unicode/#IsPunct

Is there a place in the documentation that explicitly lists all characters in these categories? I'd like to see what characters are contained in category P or category M.

  • 写回答

2条回答 默认 最新

  • douyi3676 2014-12-08 20:29
    关注

    It's not in the documentation, but you can still read the source code. The categories you're talking about are defined in this file: http://golang.org/src/pkg/unicode/tables.go

    For example, the P category is defined this way:

    2029    var _P = &RangeTable{
    2030        R16: []Range16{
    2031            {0x0021, 0x0023, 1},
    2032            {0x0025, 0x002a, 1},
    2033            {0x002c, 0x002f, 1},
    2034            {0x003a, 0x003b, 1},
    2035            {0x003f, 0x0040, 1},
    2036            {0x005b, 0x005d, 1},
    2037            {0x005f, 0x007b, 28},
                    ...
    2141            {0xff5d, 0xff5f, 2},
    2142            {0xff60, 0xff65, 1},
    2143        },
    2144        R32: []Range32{
    2145            {0x10100, 0x10102, 1},
    2146            {0x1039f, 0x103d0, 49},
    2147            {0x10857, 0x1091f, 200},
                    ...
    2157            {0x12470, 0x12473, 1},
    2158        },
    2159        LatinOffset: 11,
    2160    }
    

    And here is a simple way to print all of them:

    var p = unicode.Punct.R16
    for _, r := range p {
        for c := r.Lo; c <= r.Hi; c += r.Stride {
            fmt.Print(string(c))
        }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私