I don't speak any RTL languages, but I know UI frameworks like GTK don't use "left" and "right" for layout because they want the layout to be reversed for RTL languages like Arabic, instead they use words like "start" and "end". Do the Str.trimLeft and Str.trimRight functions make sense for Arabic text?
For example, if I have the string " رخ", i.e. the graphemes " " then " " then "ر"then "خ" and I want to remove the leading spaces, my terminal (and Zulip) renders them as being on the left, but web browsers and text editors that have the language set to Arabic will render them on the right.
Could Str.trimStart or Str.trimLeading and the opposite Str.trimEnd or Str.trimTrailing be better names?
Interestingly, I originally copied the graphemes from the Roc REPL and couldn't figure out why it was different in Zulip, turns out Zulip rendered the ", " in between the two Arabic letters in RTL mode, so I had to separate them with the English word "then" so it would be clear what order I meant.
image.png
image.png
Idk, a note in the docs should be sufficient
Yeah, it's not a particularly common situation I'll admit, you're right that there could be something in the docs about it.
If different surfaces render them differently, will start and leading even be clear?
Also, if it renders in reverse, does that mean if you copy from your browser into a txt file and then render again, it reverses the text a second time? Just curious how this works out.
The start is the part of text where you begin reading, that is the left for LTR text and the right for RTL text. To get a better understanding you can go to Arabic Wikipedia and try playing with the search bar, leading spaces will appear on the right, and pasting in Arabic text will be RTL, then trailing spaces will be on the left.
The data is always the same, so if you then copy the same text to a text field that's set to LTR like English Wikipedia or Zulip, then leading spaces will be interpreted as LTR, then the Arabic text will be RTL, then trailing spaces as LTR again.
It looks like Rust originally had trim_left and trim_right but later deprecated them and renamed them to trim_start and trim_end
That's good to know. Yeah, probably worth changing this.
yeah so I asked a friend of mine who:
and she said she would prefer trimLeft and trimRight over trimStart and trimEnd, contrary to my expectation :big_smile:
back in the day - that was why we went with trimStart and trimEnd in the first place
Would she expect trimLeft to actually trim the spaces on the left side of the text? If so, that means it would need to know the language to pick what to trim.
hm that's a good point, I don't remember if I asked
I talked to another friend who is both a programmer and speaks Hebrew, and he sold me on trimStart/trimEnd :big_smile:
if anyone wants to make a PR, I'm open to it!
Opened issue #5571 for this :)
And opened PR #5572 to address it :) It's my first attempt at contributing to the compiler, so I haven't managed to get all the tests passing yet, if someone can tell me what I'm missing that would be very helpful :)
My guess not seeing the specific tests failing is that they are mono or ui tests and you just need to check in the files they are modifying.
Oh, actually, looking at failures, I think you still have more uses of StrTrimLeft/Right to update to the new names
Ah, thanks @Brendan Hansknecht I'm running the tests again now
Anton has marked this topic as resolved.
Last updated: Jun 16 2026 at 16:19 UTC