icu4x
icu4x copied to clipboard
Provide a C++ interface to the collator
Currently, the collator isn't exposed to C++ via Diplomat. It should be.
Apart from the constructor, the Collator
object has three public methods in Rust:
-
compare()
(takes guaranteed-valid UTF-8) -
compare_utf8()
(takes potentially-invalid UTF-8) -
compare_utf16()
(takes potentially-invalid UTF-16)
I expect these to be exposed to C++ as follows:
- C++
compare()
takingstd::u16string_view
: Rustcompare_utf16()
- C++
compare()
takingstd::string_view
: Rustcompare_utf8()
- C++
compare_unsafe()
takingstd::string_view
: Rustcompare()
with documentation note that the call is UB unless the C++ caller has ensured UTF-8 validity.
(Once we support C++20, there should be std::u8string_view
overloads for the same things that have std::string_view
versions.)
In Rust, these return Ordering
. It's a bit unclear if they should return int
with values -1, 0, 1 or something fancier in C++.