<div dir="auto"><div>Simple "solution" to editing: treat (encoded) Strings as immutable.</div><div dir="auto"><br></div><div dir="auto">For editing/stringbuilding, use a WideString or a special kind of stream (MultiByteBinaryOrTextStream or how is it called) plus additional support for inserting in the middle if desired. I remember somebody proposing Ropes when discussing a reformation of strings previously. Could be interesting at "edit-time".</div><div dir="auto"><br></div><div dir="auto">For (in-memory) storage, encoded Strings should maybe just be ByteArrays paired with some TextConverter-like thing or at least a spec of the encoding so you can fetch Characters or configure streams from it on demand.</div><div dir="auto"><br></div><div dir="auto">If licensing permits it one could also have a look at how the OpenJDK deals with UTF-16 in StringBuilder.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_extra" dir="auto"><br><div class="gmail_quote">Am 30.07.2017 03:20 schrieb "tim Rowledge" <<a href="mailto:tim@rowledge.org" target="_blank">tim@rowledge.org</a>>:<br type="attribution"><blockquote class="m_7416030891587909987quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="m_7416030891587909987quoted-text"><br>
> On 29-07-2017, at 12:48 PM, Nicolas Cellier <<a href="mailto:nicolas.cellier.aka.nice@gmail.com" target="_blank">nicolas.cellier.aka.nice@gmai<wbr>l.com</a>> wrote:<br>
> Absolutely,<br>
> to me a String is a sequence of characters.<br>
> squeakToUtf8 is a hack that makes us consider a String as a sequence of codePoints whose encoding is in the eye of the beholder (or implicitly in the Context - the Smalltalk one).<br>
> I's not very object oriented and quite fragile.<br>
</div>> We started to clean Multilingual but never finished the job…<br>
<br>
Yes, that’s pretty much how I see it. Currently the utf8 ‘string’ is just kept as a byte string and the user is expected to understand that it is in a rather dangerous state.<br>
<div class="m_7416030891587909987quoted-text"><br>
><br>
> It's difficult to finish it, because we value backward compatibility.<br>
> So maybe the ByteArray change was a bit radical with this respect.<br>
<br>
</div>Backward compatibility can sometimes drive you to loud swearing!<br>
<br>
Maybe a new message to return the bytearray of the uft8 data could be added, leaving the old one alone. We should probably consider making an actual UTF8String class, though I did try to work out the best thing to do for that several years ago for NuScratch and got lost in the tangles. Editing the damn things is a pain, to say the leat, so you get to thinking about having the canonical string as an instvar and a byte array and edits work on the String which gets converted at the end of the edit to update bytearray. Or the other way around… or… aaargh!<br>
<div class="m_7416030891587909987quoted-text"><br>
<br>
tim<br>
--<br>
tim Rowledge; <a href="mailto:tim@rowledge.org" target="_blank">tim@rowledge.org</a>; <a href="http://www.rowledge.org/tim" rel="noreferrer" target="_blank">http://www.rowledge.org/tim</a><br>
</div>Useful random insult:- Immune from any serious head injury.<br>
<br>
<br>
<br>
</blockquote></div><br></div></div></div>