Does the STL sort function support alphabetical sorting of names which have UTF-8 characters in them? Say names from German/French language?
That entirely depends on how you store the UTF-8 characters and how your comparer looks like. The sort function is completely agnostic of the elements it sorts.
But you probably mean “… when stored in a char array” and then the answer is no since the chars will store individual bytes of a given UTF-8 character, instead of the logical character. The sort function sorts elements delimited by iterators. sort works only if the iterators / the elements they refer to are aware of the data that they contain. This isn’t the case for an array of chars that encode UTF-8.
The “correct” solution here is to parse the UTF-8 input into an array of proper (normalised) Unicode code points, sort those, and translate back to UTF-8.
All that is required is the proper comparison function. You can probably find one in ICU - International Components for Unicode . Look specifically at Collation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With