gpt4 book ai didi

regex - RE2 和 UTF16(或 UCS-2)

转载 作者:行者123 更新时间:2023-12-05 00:35:41 24 4
gpt4 key购买 nike

RE2很棒。 快速和确定性。

但是,它仅支持 UTF8。 我的字符串 native 是 UTF16 ,来回转换会降低性能。

实现原生有多难 UTF16 RE2 中的能力?

实现原生有多难 UCS-2 RE2 中的能力? (这应该更容易)

即普通程序员需要多少小时才能做到这一点。

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

最佳答案

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

关于regex - RE2 和 UTF16(或 UCS-2),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9171812/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com