Added a replace function to strings - #12782
Conversation
|
I'd like to better understand the use-cases for index based string operations. I'm all in favor of safe iterators of kinds, but even indexing by grapheme cluster can destroy strings in a UI, and that's bad. For example, in Indic scripts you can split at grapheme cluster boundaries, but the resulting string may be an incomplete syllable, which may be unreadable to the user without context. The same goes for Arabic, where you may end up with valid Unicode, but different shaping because of missing adjacent clusters. Given that complex scripts are the least tested in real life apps ("oh, here is the machine translation, I guess it's fine") I'd like to avoid that APIs that work fine with western scripts (predominantly used by devs/designers) will break with end users. By better understanding the use-cases, perhaps we can design safer APIs. |
|
The main use case is rapid simple prototyping of user interaction patterns without going to the backend language. With this use case I think there are two directions we can go in. The first is simply putting index based string operations behind experimental features so it can be used when prototyping and then can be dropped later. The second is making |
8b0567d to
f7fae91
Compare
|
Dropped |
Functions added
replace(from, to)This replaces all occurrences of
fromwithtoand returns a new string. This makes it easy to modify parts of strings in slint without going to the backend language.