首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >boost:地区icu sortKey

boost:地区icu sortKey
EN

Stack Overflow用户
提问于 2014-10-05 17:54:09
回答 1查看 142关注 0票数 2

我正在编写代码,在数据库中创建索引。对于ICU库,我的工作流程是:

  • 用户区域设置->中的字符串 转换为utf8 -> 规范化utf8 -> 调用ICU ucol_getSortKey获取建立索引的排序密钥。

现在我换了个地方。可以促进地区建设排序键,如ICU?还是我应该直接给重症监护室打电话?

EN

回答 1

Stack Overflow用户

发布于 2014-10-05 18:54:56

看起来这就是Boost Locale所知道的collate_impl::do_[basic_]transform()

代码语言:javascript
复制
std::vector<uint8_t> do_basic_transform(level_type level,CharType const *b,CharType const *e) const 
{
    icu::UnicodeString str=cvt_.icu(b,e);
    std::vector<uint8_t> tmp;
    tmp.resize(str.length());
    icu::Collator *collate = get_collator(level);
    int len = collate->getSortKey(str,&tmp[0],tmp.size());
    if(len > int(tmp.size())) {
        tmp.resize(len);
        collate->getSortKey(str,&tmp[0],tmp.size());
    }
    else 
        tmp.resize(len);
    return tmp;
}

std::basic_string<CharType> do_transform(level_type level,CharType const *b,CharType const *e) const
{
    std::vector<uint8_t> tmp = do_basic_transform(level,b,e);
    return std::basic_string<CharType>(tmp.begin(),tmp.end());
}

为了提高性能,您似乎希望调用do_basic_compare

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26205528

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档