boost::locale icu sortKey

boost::locale icu sortKey

本文关键字:sortKey icu locale boost      更新时间:2023-10-16

我正在写代码,在数据库中制作索引。有了ICU图书馆,我的工作流程是:

  • 用户区域设置中的字符串->
    转换为utf8->
    normalize utf8->
    调用ICU ucol_getSortKey获取建筑索引的排序键

现在我切换到Boost Locale。Boost Locale可以构建像ICU这样的排序键吗?或者我应该直接打电话给重症监护室?

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

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