Adding utf8.reverse

The name is descriptive enough, a function that reverses a string containing UTF-8 characters. Implementing said function is obvious and doable from the user’s end, but would be helpful to have it included.

print(utf8.reverse("Cop👮‍♀️")) -- expected output: 👮‍♀️poC

This is obviously useful for cases when your strings have non-ASCII UTF-8 characters in them, but especially when dealing with player input, through chat or even a TextBox, where string.reverse-ing a string which contains for example emojis would break.


Just a tip in general to help you get feature requests implemented sooner: it will help if you provide actual use cases for where you would use the feature. That way they can justify working on this vs. another feature request. The given example isn’t really showing how reversing utf8 could be useful for actual work, so it’ll be hard to prioritize the request.


…Do people really need a example to know how reversing a string is useful when string.reverse already exists?


Yeah, when there’s a million things to implement it surprisingly tends to help to add use cases, so that anyone working on the feature actually knows they’re not wasting their time instead of working on something more impactful.

It’s not about it being useful or not, it’s about how useful it is for developers vs the other requests that could be worked on. Don’t assume everyone inside Roblox understands what you would use this feature for.

Not sure I follow why the snarky response since this is just trying to help. If you feel like writing badly-argumented feature requests that have a hard time getting implemented, that’s totally fine by me too, it’s your request.


Ah that makes sense as a priority thing. Because I mean this feature isn’t really necessary it just is a code simplification from one function.

And it wasn’t really a snarky comment, I was just a bit surprised and confused why a basic API like this wasn’t self-explanatory.


Reversing UTF8 would be so much help, I’ve personally needed it for localization purposes.

I’ve written this function a while back, though the post gives a description of a good use case:


Unicode is really scary. You probably don’t want utf8.reverse - the name implies doing it codepoint by codepoint which will produce surprising results any time decomposition forms are used.

What you might want is a grapheme reversal. We already provide a grapheme iterator - it should be trivial to concatenate the results in reverse order yourself.

What you may want alternatively is a BiDi implementation. That is decidedly non-trivial but we don’t have one in the engine yet so we can’t easily expose it yet.