Stream: beginners

Topic: Changing Str case


view this post on Zulip Artem (Nov 06 2024 at 10:32):

Hi! Since docs mention that transforming a string to lower or upper case is not implemented in Roc yes, and I didn't manage to find any solutions by Googling, can anyone suggest a solution for this?

I bet there should be some package somewhere that already implemented it

view this post on Zulip Luke Boswell (Nov 06 2024 at 10:41):

It's a unicode thing I think. It's not implemented in roc-lang/unicode yet.

view this post on Zulip Luke Boswell (Nov 06 2024 at 10:46):

Correction... if you know you're only dealing with Ascii checkout Hannes https://github.com/Hasnep/roc-ascii

view this post on Zulip Patrick Wierer (Nov 06 2024 at 12:06):

It also tripped me up when I worked on some exercism tasks. Usually you would find such functions in any language.
Having said that, it was a nice exercise to think about ASCII vs Unicode again and what it actually means to e.g. downcase characters in a string.

view this post on Zulip Brendan Hansknecht (Nov 06 2024 at 17:52):

I think uppercasing a Unicode string is technically locale dependent

view this post on Zulip Brendan Hansknecht (Nov 06 2024 at 17:53):

But if you just have ascii, it is as easy as changing a single bit.

view this post on Zulip Richard Feldman (Nov 06 2024 at 18:00):

yep, uppercasing "i" gives a different answers depending on whether you're talking about English or Turkish

view this post on Zulip Richard Feldman (Nov 06 2024 at 18:01):

most languages either incorrectly handle that case or silently do something different depending on the system locale, but I don't think we should do either; I think we should correctly and explicitly handle that, so that a Roc pure function always gives the same answer no matter what system you run it on

view this post on Zulip Richard Feldman (Nov 06 2024 at 18:02):

which is why it's not in the standard library; locales change over time, so the idea is to have a separate package for that.


Last updated: Jul 06 2025 at 12:14 UTC