<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Ben,<div class="">thank you, yes, I know all that by now.&nbsp;</div><div class=""><br class=""></div><div class="">Have seen that one goes to great lengths to optimise, not only for storage but also for speed. But how far does this need to go? &nbsp;In any case, optimisation should not be used</div><div class="">as an argument for restricting a PLs functionality that is to refrain from PL elements which are common and useful.?</div><div class=""><br class=""></div><div class="">I wouldn’t worry so much over storage (unless one wants to load a complete book into memory… in iOS, the average app is about 15-50 MB, String data is mostly a fraction of that. In macOS or similar I’d think it is even less significant…</div><div class=""><br class=""></div><div class="">I wonder how much performance and memory consumption would be different from the current contiguous memory implementation? &nbsp;if a String is just is a plain row of (references to) Character (extended grapheme cluster) objects, Array&lt;[Character&gt;, which would simplify the basic logic and (sub)string handling significantly, because then one has direct access to the String’s elements directly, using the reasonably fast access methods of a Swift Collection/Array.&nbsp;</div><div class=""><br class=""></div><div class="">I have experimented &nbsp;with an alternative String struct based upon Array&lt;Character&gt;, seeing how easy it was to implement most popular string handling functions as one can work with the Character array directly.&nbsp;</div><div class=""><br class=""></div><div class="">Currently at deep-dive-depth in the standard lib sources, especially String &amp; Co.</div><div class=""><br class=""></div><div class="">Kind Regards</div><div class="">TedvG</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div><blockquote type="cite" class=""><div class="">On 21 Feb 2017, at 01:31, Ben Cohen &lt;<a href="mailto:ben_cohen@apple.com" class="">ben_cohen@apple.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Ted,<div class=""><br class=""></div><div class="">While Character is the Element type for String, it would be unsuitable for a String’s implementation to actually use Character for storage. Character is fairly large (currently 9 bytes), very little of which is used for most values. For unusual graphemes that require more storage, it allocates more memory on the heap. By contrast, String’s actual storage is a buffer of 1- or 2-byte elements, and all graphemes (what we expose as Characters) are held in that contiguous memory no matter how many code points they comprise. When you iterate over the string, the graphemes are unpacked into a Character on the fly. This gives you an user interface of a collection that superficially appears to resemble [Character], but this does not mean that this would be a workable implementation.</div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Feb 20, 2017, at 12:59 PM, Ted F.A. van Gaalen &lt;<a href="mailto:tedvgiosdev@gmail.com" class="">tedvgiosdev@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Ben, Dave (you should not read this now, you’re on vacation :o) &nbsp;&amp; Others<div class=""><br class=""></div><div class="">As described in the Swift Standard Library API Reference:</div><div class=""><br class=""></div><div class=""><div style="box-sizing: inherit; margin: 0px; padding: 0px; color: rgb(51, 51, 51); font-family: 'SF Pro Text', 'SF Pro Icons', 'Helvetica Neue', Helvetica, Arial, sans-serif; letter-spacing: -0.3569999933242798px;" class="">The&nbsp;<code class="code-voice" style="box-sizing: inherit; font-family: 'SF Mono', Menlo, monospace;">Character</code>&nbsp;type represents a character made up of one or more Unicode scalar values,&nbsp;</div><div style="box-sizing: inherit; margin: 0px; padding: 0px; color: rgb(51, 51, 51); font-family: 'SF Pro Text', 'SF Pro Icons', 'Helvetica Neue', Helvetica, Arial, sans-serif; letter-spacing: -0.3569999933242798px;" class="">grouped by a Unicode boundary algorithm. Generally, a&nbsp;<code class="code-voice" style="box-sizing: inherit; font-family: 'SF Mono', Menlo, monospace;">Character</code>&nbsp;instance matches what&nbsp;</div><div style="box-sizing: inherit; margin: 0px; padding: 0px; color: rgb(51, 51, 51); font-family: 'SF Pro Text', 'SF Pro Icons', 'Helvetica Neue', Helvetica, Arial, sans-serif; letter-spacing: -0.3569999933242798px;" class="">the reader of a string will perceive as a single character. The number of visible characters is&nbsp;</div><div style="box-sizing: inherit; margin: 0px; padding: 0px; color: rgb(51, 51, 51); font-family: 'SF Pro Text', 'SF Pro Icons', 'Helvetica Neue', Helvetica, Arial, sans-serif; letter-spacing: -0.3569999933242798px;" class="">generally the most natural way to count the length of a string.</div><figure id="2844880" style="box-sizing: inherit; margin: -62px 0px 0px; padding: 1.4em 0px 0px; border-top-width: 62px; border-top-style: solid; border-top-color: transparent; position: static; color: rgb(51, 51, 51); font-family: 'SF Pro Text', 'SF Pro Icons', 'Helvetica Neue', Helvetica, Arial, sans-serif; letter-spacing: -0.3569999933242798px;" class=""><div class="formatted-content" style="box-sizing: inherit;"></div></figure></div><div class=""><div class="">The smallest discrete unit we (app programmers) are mostly working with is this</div><div class="">perceived visible character, what else?&nbsp;</div><div class=""><br class=""></div></div><div class="">If that is the case, my reasoning is, that Strings (could / should? ) be relatively simple,&nbsp;</div><div class="">because most, if not all, complexity of Unicode is confined within the Character object and</div><div class="">completely hidden** &nbsp;for the average application programmer, who normally only needs</div><div class="">to work with Strings which contains these visible Characters, right?&nbsp;</div><div class="">It doesn’t then make no difference at all “what’ is in” the Character, (excellent implementation btw)&nbsp;</div><div class="">(Unicode, ASCCII, EBCDIC, Elvish, KlingonIV, IntergalacticV.2, whatever)</div><div class="">because we rely in sublime oblivion for the visually representation of whatever is in</div><div class="">the Character on miraculous font processors hidden in the dark depths of the OS.&nbsp;</div><div class=""><br class=""></div><div class="">Then, in this perspective, my question is: why is String not implemented as&nbsp;</div><div class="">directly based upon an array [Character] &nbsp;? In that case one can refer to the Characters of the</div><div class="">String directly, not only for direct subscripting and other String functionality in an efficient way.&nbsp;</div><div class="">(i do hava scope of independent Swift here, that is interaction with libraries should be&nbsp;</div><div class="">solved by the compiler, so as not to be restricted by legacy ObjC etc.&nbsp;</div><div class=""><br class=""></div><div class="">** &nbsp; (expect if one needs to do e.g. access individual elements and/or compose graphics directly?</div><div class="">&nbsp; &nbsp; &nbsp; but for &nbsp;this purpose the Character’s properties are accessible)&nbsp;</div><div class=""><br class=""></div><div class="">For the sake of convenience, based upon the above reasoning, &nbsp;I now “emulate" this in&nbsp;</div><div class="">a string extension, thereby ignoring the rare cases that a visible character could be based&nbsp;</div><div class="">upon more than a single Character (extended grapheme cluster) &nbsp;If that would occur,&nbsp;</div><div class="">thye should be merged into one extended grapheme cluster, a single Character that is.&nbsp;</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">//: Playground - implement direct subscripting using a Character array</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">// of course, when the String is defined as an array of Characters, directly</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">// accessible it would be more efficient as in these extension functions.&nbsp;</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">extension</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">{</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">var</span><span style="font-variant-ligatures: no-common-ligatures" class=""> count: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; {</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">get</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; {</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">return</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">self</span><span style="font-variant-ligatures: no-common-ligatures" class="">.characters.count</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; }</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; }</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 21px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">subscript</span><span style="font-variant-ligatures: no-common-ligatures" class=""> (n: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures" class="">) -&gt; </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; {</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">return</span><span style="font-variant-ligatures: no-common-ligatures" class=""> String(Array(</span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">self</span><span style="font-variant-ligatures: no-common-ligatures" class="">.characters)[n])</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; }</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 21px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp;&nbsp; &nbsp;</span><br class="webkit-block-placeholder"></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">subscript</span><span style="font-variant-ligatures: no-common-ligatures" class=""> (r: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Range</span><span style="font-variant-ligatures: no-common-ligatures" class="">&lt;</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures" class="">&gt;) -&gt; </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; {</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">return</span><span style="font-variant-ligatures: no-common-ligatures" class=""> String(Array(</span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">self</span><span style="font-variant-ligatures: no-common-ligatures" class="">.characters)[r])</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; }</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 21px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp;&nbsp; &nbsp;</span><br class="webkit-block-placeholder"></div><div style="margin: 0px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">subscript</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> (r: </span><span style="font-variant-ligatures: no-common-ligatures" class="">ClosedRange</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&lt;</span><span style="font-variant-ligatures: no-common-ligatures" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&gt;) -&gt; </span><span style="font-variant-ligatures: no-common-ligatures" class="">String</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; {</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">return</span><span style="font-variant-ligatures: no-common-ligatures" class=""> String(Array(</span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">self</span><span style="font-variant-ligatures: no-common-ligatures" class="">.characters)[r])</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; }</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 21px;" class=""><br class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">func</span><span style="font-variant-ligatures: no-common-ligatures" class=""> test()</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">{</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> zoo = </span><span style="font-variant-ligatures: no-common-ligatures" class="">"Koala </span><span style="line-height: normal; font-family: 'Apple Color Emoji'; font-variant-ligatures: no-common-ligatures;" class="">🐨</span><span style="font-variant-ligatures: no-common-ligatures" class="">, Snail </span><span style="line-height: normal; font-family: 'Apple Color Emoji'; font-variant-ligatures: no-common-ligatures;" class="">🐌</span><span style="font-variant-ligatures: no-common-ligatures" class="">, Penguin </span><span style="line-height: normal; font-family: 'Apple Color Emoji'; font-variant-ligatures: no-common-ligatures;" class="">🐧</span><span style="font-variant-ligatures: no-common-ligatures" class="">, Dromedary </span><span style="line-height: normal; font-family: 'Apple Color Emoji'; font-variant-ligatures: no-common-ligatures;" class="">🐪</span><span style="font-variant-ligatures: no-common-ligatures" class="">"</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp; &nbsp; print(</span><span style="font-variant-ligatures: no-common-ligatures" class="">"zoo has </span><span style="font-variant-ligatures: no-common-ligatures;" class="">\</span><span style="font-variant-ligatures: no-common-ligatures" class="">(</span><span style="font-variant-ligatures: no-common-ligatures;" class="">zoo.count</span><span style="font-variant-ligatures: no-common-ligatures" class="">) characters (discrete extended graphemes):"</span><span style="font-variant-ligatures: no-common-ligatures;" class="">)</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">for</span><span style="font-variant-ligatures: no-common-ligatures" class=""> i </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">in</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span><span style="font-variant-ligatures: no-common-ligatures" class="">..&lt;zoo.count</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; {</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; print(i,zoo[i],separator: </span><span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"="</span><span style="font-variant-ligatures: no-common-ligatures" class="">, terminator:</span><span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">" "</span><span style="font-variant-ligatures: no-common-ligatures" class="">)</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; }</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; print(</span><span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"\n"</span><span style="font-variant-ligatures: no-common-ligatures" class="">)</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; print(zoo[</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span><span style="font-variant-ligatures: no-common-ligatures" class="">..&lt;</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">7</span><span style="font-variant-ligatures: no-common-ligatures" class="">])</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; print(zoo[</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">9</span><span style="font-variant-ligatures: no-common-ligatures" class="">..&lt;</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">16</span><span style="font-variant-ligatures: no-common-ligatures" class="">])</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; print(zoo[</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">18</span><span style="font-variant-ligatures: no-common-ligatures" class="">...</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">26</span><span style="font-variant-ligatures: no-common-ligatures" class="">])</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; print(zoo[</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">29</span><span style="font-variant-ligatures: no-common-ligatures" class="">...</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">39</span><span style="font-variant-ligatures: no-common-ligatures" class="">])</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; print(</span><span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"images:"</span><span style="font-variant-ligatures: no-common-ligatures" class=""> + zoo[</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">6</span><span style="font-variant-ligatures: no-common-ligatures" class="">] + zoo[</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">15</span><span style="font-variant-ligatures: no-common-ligatures" class="">] + zoo[</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">26</span><span style="font-variant-ligatures: no-common-ligatures" class="">] + zoo[</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">39</span><span style="font-variant-ligatures: no-common-ligatures" class="">])</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 21px;" class=""><br class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">test()</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 21px;" class=""><br class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span></div></div><div class="">this works as intended &nbsp;and generates the following output: &nbsp;</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">zoo has 40 characters (discrete extended graphemes):</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">0=K 1=o 2=a 3=l 4=a 5=&nbsp; 6=</span><span style="line-height: normal; font-family: 'Apple Color Emoji'; font-variant-ligatures: no-common-ligatures;" class="">🐨</span><span style="font-variant-ligatures: no-common-ligatures" class=""> 7=, 8=&nbsp; 9=S 10=n 11=a 12=i 13=l 14=&nbsp; 15=</span><span style="line-height: normal; font-family: 'Apple Color Emoji'; font-variant-ligatures: no-common-ligatures;" class="">🐌</span><span style="font-variant-ligatures: no-common-ligatures" class=""> 16=, 17=&nbsp;&nbsp;</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">18=P 19=e 20=n 21=g 22=u 23=i 24=n 25=&nbsp; 26=</span><span style="line-height: normal; font-family: 'Apple Color Emoji'; font-variant-ligatures: no-common-ligatures;" class="">🐧</span><span style="font-variant-ligatures: no-common-ligatures" class=""> 27=, 28=&nbsp; 29=D 30=r 31=o 32=m&nbsp;</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">33=e 34=d 35=a 36=r 37=y 38=&nbsp; 39=</span><span style="line-height: normal; font-family: 'Apple Color Emoji'; font-variant-ligatures: no-common-ligatures;" class="">🐪</span><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp;</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 21px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">Koala </span><span style="line-height: normal; font-family: 'Apple Color Emoji'; font-variant-ligatures: no-common-ligatures;" class="">🐨</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">Snail </span><span style="line-height: normal; font-family: 'Apple Color Emoji'; font-variant-ligatures: no-common-ligatures;" class="">🐌</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">Penguin </span><span style="line-height: normal; font-family: 'Apple Color Emoji'; font-variant-ligatures: no-common-ligatures;" class="">🐧</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">Dromedary </span><span style="line-height: normal; font-family: 'Apple Color Emoji'; font-variant-ligatures: no-common-ligatures;" class="">🐪</span></div><div style="margin: 0px; line-height: normal; font-family: 'Apple Color Emoji';" class=""><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures;" class="">images:</span><span style="font-variant-ligatures: no-common-ligatures" class="">🐨🐌🐧🐪</span></div></div><div class=""><br class=""></div><div class="">I don’t know how (in) efficient this method is.&nbsp;</div><div class=""><div class="">but in many cases this is not so important as e.g. with numerical computation.</div></div><div class=""><br class=""></div><div class="">I still fail to understand why direct subscripting strings would be unnecessary,</div><div class="">and would like to see this built-in in Swift asap.&nbsp;</div><div class=""><br class=""></div><div class="">Btw, I do share the concern as expressed by Rien regarding the increasing complexity of the language.</div><div class=""><br class=""></div><div class="">Kind Regards,&nbsp;</div><div class=""><br class=""></div><div class="">TedvG</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">&nbsp;</div></div></div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div></body></html>