Logo Search packages:      
Sourcecode: ardour version File versions  Download package

std::string Glib::ustring::collate_key (  )  const

Create a unique sorting key for the UTF-8 string. If you need to compare UTF-8 strings regularly, e.g. for sorted containers such as std::set<>, you should consider creating a collate key first and compare this key instead of the actual string.

The ustring::compare() methods as well as the relational operators == != < > <= >= are quite costly because they have to deal with Unicode and the collation rules defined by the current locale. Converting both operands to UCS-4 is just the first of several costly steps involved when comparing ustrings. So be careful.

Definition at line 1160 of file ustring.cc.

{
  const ScopedPtr<char> buf (g_utf8_collate_key(string_.data(), string_.size()));
  return std::string(buf.get());
}


Generated by  Doxygen 1.6.0   Back to index