Monday, 15 July 2013

c++ - boost::locale icu sortKey -



c++ - boost::locale icu sortKey -

i writing code, making indexes in database. icu library workflow is:

string in user locale -> converting utf8 -> normalize utf8 -> phone call icu ucol_getsortkey sorting key building index.

now switched boost locale. can boost locale build sort keys icu? or should phone call icu somehow directly?

it looks boost locale knows 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); homecoming 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); homecoming std::basic_string<chartype>(tmp.begin(),tmp.end()); }

for performance, looks you'd want phone call do_basic_compare

c++ boost icu

No comments:

Post a Comment