加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

正则表达式 – RE2和UTF16(或UCS-2)

发布时间:2020-12-14 05:58:08 所属栏目:百科 来源:网络整理
导读:RE2很棒.快速和确定性. 但是,它仅支持UTF8.我的字符串本身就是UTF16,来回转换会破坏性能. 在RE2中实现原生UTF16功能有多难? 在RE2中实现本机UCS-2功能有多难? (这应该更容易) 也就是说,普通程序员需要多少小时才能做到这一点. 这困扰了我几个星期,所以我想
RE2很棒.快速和确定性.

但是,它仅支持UTF8.我的字符串本身就是UTF16,来回转换会破坏性能.

在RE2中实现原生UTF16功能有多难?

在RE2中实现本机UCS-2功能有多难? (这应该更容易)

也就是说,普通程序员需要多少小时才能做到这一点.

这困扰了我几个星期,所以我想我会问!

解决方法

RE2的创建者Russ Cox非常友好地发布了UCS-2支持补丁.但是,UCS-2不支持某些断言. Russ的回复是逐字发布的:

Hi. RE2 had a UCS-2 mode before I open sourced it,but it could not
support assertions like ^,$,and b,which limited its utility. If
you don’t need those operators,then it would probably work for you.
I don’t plan to re-add UCS-2 mode to the RE2 sources,but I did just
publish the diff for the change that removed it. You should be able
to reverse the diff in a local copy to get the UCS-2 support back.
The file is ucs2.diff in the root of the Mercurial repository.

Enjoy.

链接到代码:http://code.google.com/p/re2/source/list

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读