_compareCommandNames operates on strings that are presented to the end-user, so it should sort like a human, not by codepoint. I'm not sure whether this project prefers CompareStringEx or lstrcmp or some CRT routine.
If there's some STL wstring locale-sensitive compare, I'd index towards that one. Thanks for pointing this out!
@DHowett - is something like this STL enough?
static bool _compareCommandNames(const Command& lhs, const Command& rhs)
{
const auto& f = std::use_facet<std::collate<wchar_t>>(std::locale());
const auto lhsName = lhs.Name();
const auto rhsName = rhs.Name();
return f.compare(lhsName.data(), lhsName.data() + lhsName.size(), rhsName.data(), rhsName.data() + rhsName.size()) < 0;
}
I am just confused what locale should we use.. just written commands in 3 languages and now wondering what should happen 馃槃
Based on what I see here, @Don-Vito 's way seems the way to go, would you mind making a PR with the change?
@PankajBhojwani - I can absolutely create a PR, but I am not sure what locale should be used. Is std::locale() good enough?
I think std::locale("") obtains the native locale (source), so that might be what we want actually. Will look into it more and let you know!
@Don-Vito at this point I want to say it probably is a fine implementation for now, and to go ahead and make the PR for it if you'd like! We can handle potential issues in post
@PankajBhojwani - great! I am creating one.
@PankajBhojwani - made it work by explicitly invoking winapi's GetUserDefaultLocaleName. Still need to cleanup the code but please take a look.
After some additional thought, we're going to try and solve this with #7039 instead. Thanks for all the investigation everyone!