Stream: beginners

Topic: string padding


view this post on Zulip drew (Oct 19 2024 at 17:36):

is there a built in function for string padding?

view this post on Zulip drew (Oct 19 2024 at 17:37):

i also don't see a way to find the size of a string

view this post on Zulip drew (Oct 19 2024 at 17:39):

looks like countUtf8Bytes

view this post on Zulip Dan G Knutson (Oct 19 2024 at 20:07):

You probably want this:
https://github.com/roc-lang/unicode
https://roc-lang.github.io/unicode/CodePoint/#utf8Len
String length is weirder than it looks, and the byte count will be different than the character count for non-english languages. If you're only working with ascii then you get to mostly not think about it.
Edit: I just saw your other thread; for AOC byte length is probably fine (and maybe I'm telling you things you know :sweat_smile:)

view this post on Zulip Brendan Hansknecht (Oct 19 2024 at 21:32):

For advent of code, I advice not using strings as the input

view this post on Zulip Brendan Hansknecht (Oct 19 2024 at 21:32):

Just commit to List U8. It is the most correct and what Roc really pushes you to work with

view this post on Zulip Luke Boswell (Oct 19 2024 at 21:33):

For Advent Of Code, you can checkout Hannes' ASCII package https://github.com/Hasnep/roc-ascii

view this post on Zulip Luke Boswell (Oct 19 2024 at 21:34):

Lot's of nice helpers there :heart:


Last updated: Jul 05 2025 at 12:14 UTC