How to reverse strings that contain surrogate pairs in Dart? #38854
Labels
area-core-library
SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.
library-core
type-question
A question about expected behavior or functionality
I was playing with algorithms using Dart and as I actually followed TDD, I realized that my code has some limitations.
I was trying to reverse strings as part of an interview problem, but I couldn't get the surrogate pairs correctly reversed.
The output:
You can see that the simple emojis are correctly reversed as I'm using the
runes
instead of just simply executings.split('').toList().reversed.join('');
but the surrogate pairs are reversed incorrectly.How can I reverse a string that might contain surrogate pairs using the Dart programming language?
The text was updated successfully, but these errors were encountered: