<div dir="ltr">Hi Euan,<div class="gmail_extra"><br><div class="gmail_quote">On Fri, Dec 11, 2015 at 5:45 PM, EuanM <span dir="ltr">&lt;<a href="mailto:euanmee@gmail.com" target="_blank">euanmee@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Elliot, what&#39;s your take on having heterogenous collections for the<br>
composed Unicode?<br></blockquote><div><br></div><div>I&#39;m not sure I&#39;m understanding the question, but... I&#39;m told by someone in the know that string concatenation is a big deal in certain applications, so providing tree-like representations for strings can be a win since concatenation is O(1) (allocate a new root and assign the two subtrees).  It seems reasonable to have a rich library with several representations available with different trade-offs.  But I&#39;d let requirements drive design, not feature dreams.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">i.e. collections with one element for each character, with some<br>
characters being themselves a collection of characters<br>
<br>
(Simple character like &quot;a&quot; is one char, and a character which is a<br>
collection of characters is the fully composed version of Ǖ (01d5), a<br>
U (0055) with a diaeresis - ¨ - ( 00a8  aka 0308 in combining form )<br>
on top to form the compatibility character Ü (ooDC) which then gets a<br>
macron-  ̄  -( 0304) on top of that<br>
<br>
so<br>
a  #(0061)<br>
<br>
Ǖ  #(01d5) = #( 00dc 0304) = #( 0055 0308 0304)<br>
<br>
i.e a string which alternated those two characters<br>
<br>
&#39;aǕaǕaǕaǕ&#39;<br>
<br>
would be represented by something equivalent to:<br>
<br>
#( 0061 #( 0055 0308 0304)  0061 #( 0055 0308 0304)  0061 #( 0055 0308<br>
0304)  0061 #( 0055 0308 0304) )<br>
<br>
as opposed to a string of compatibility characters:<br>
#( 0061 01d5  0061 01d5 0061 01d5 0061 01d5)<br>
<br>
Does alternating the type used for characters in a string have a<br>
significant effect on speed?<br></blockquote><div><br></div><div>I honestly don&#39;t know.  You&#39;ve just gone well beyond my familiarity with the issues :-).  I&#39;m just a VM guy :-). But I will say that in cases like this, real applications and the profiler are your friends.  Be guided by what you need now, not by what you think you&#39;ll need further down the road.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
On 11 December 2015 at 23:08, Eliot Miranda &lt;<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>&gt; wrote:<br>
&gt; Hi Todd,<br>
&gt;<br>
&gt; On Dec 11, 2015, at 12:57 PM, Todd Blanchard &lt;<a href="mailto:tblanchard@mac.com">tblanchard@mac.com</a>&gt; wrote:<br>
&gt;<br>
&gt;<br>
&gt; On Dec 11, 2015, at 12:19, EuanM &lt;<a href="mailto:euanmee@gmail.com">euanmee@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; &quot;If it hasn&#39;t already been said, please do not conflate Unicode and<br>
&gt; UTF-8. I think that would be a recipe for<br>
&gt; a high P.I.T.A. factor.&quot;  --Richard Sargent<br>
&gt;<br>
&gt;<br>
&gt; Well, yes. But  I think you guys are making this way too hard.<br>
&gt;<br>
&gt; A unicode character is an abstract idea - for instance the letter &#39;a&#39;.<br>
&gt; The letter &#39;a&#39; has a code point - its the number 97.  How the number 97 is<br>
&gt; represented in the computer is irrelevant.<br>
&gt;<br>
&gt; Now we get to transfer encodings.  These are UTF8, UTF16, etc....  A<br>
&gt; transfer encoding specifies the binary representation of the sequence of<br>
&gt; code points.<br>
&gt;<br>
&gt; UTF8 is a variable length byte encoding.  You read it one byte at a time,<br>
&gt; aggregating byte sequences to &#39;code points&#39;.  ByteArray would be an<br>
&gt; excellent choice as a superclass but it must be understood that #at: or<br>
&gt; #at:put refers to a byte, not a character.  If you want characters, you have<br>
&gt; to start at the beginning and process it sequentially, like a stream (if<br>
&gt; working in the ASCII domain - you can generally &#39;cheat&#39; this a bit).  A C<br>
&gt; representation would be char utf8[]<br>
&gt;<br>
&gt; UTF16 is also a variable length encoding of two byte quantities - what C<br>
&gt; used to call a &#39;short int&#39;.  You process it in two byte chunks instead of<br>
&gt; one byte chunks.  Like UTF8, you must read it sequentially to interpret the<br>
&gt; characters.  #at and #at:put: would necessarily refer to byte pairs and not<br>
&gt; characters.  A C representation would be short utf16[];  It would also to<br>
&gt; 50% space inefficient for ASCII - which is normally the bulk of your text.<br>
&gt;<br>
&gt; Realistically, you need exactly one in-memory format and stream<br>
&gt; readers/writers that can convert (these are typically table driven state<br>
&gt; machines).  My choice would be UTF8 for the internal memory format and the<br>
&gt; ability to read and write from UTF8 to UTF16.<br>
&gt;<br>
&gt; But I stress again...strings don&#39;t really need indexability as much as you<br>
&gt; think and neither UTF8 nor UTF16 provide this property anyhow as they are<br>
&gt; variable length encodings.  I don&#39;t see any sensible reason to have more<br>
&gt; than one in-memory binary format in the image.<br>
&gt;<br>
&gt;<br>
&gt; The only reasons are space and time.  If a string only contains code points<br>
&gt; in the range 0-255 there&#39;s no point in squandering 4 bytes per code point<br>
&gt; (same goes for 0-65535).  Further, if in some application interchange is<br>
&gt; more important than random access it may make sense in performance grounds<br>
&gt; to use utf-8 directly.<br>
&gt;<br>
&gt; Again, Smalltalk&#39;s dynamic typing makes it easy to have one&#39;s cake and eat<br>
&gt; it too.<br>
&gt;<br>
&gt; My $0.02c<br>
&gt;<br>
&gt;<br>
&gt; _,,,^..^,,,_ (phone)<br>
&gt;<br>
&gt;<br>
&gt; I agree. :-)<br>
&gt;<br>
&gt; Regarding UTF-16, I just want to be able to export to, and receive<br>
&gt; from, Windows (and any other platforms using UTF-16 as their native<br>
&gt; character representation).<br>
&gt;<br>
&gt; Windows will always be able to accept UTF-16.  All Windows apps *might<br>
&gt; well* export UTF-16.  There may be other platforms which use UTF-16 as<br>
&gt; their native format.  I&#39;d just like to be able to cope with those<br>
&gt; situations.  Nothing more.<br>
&gt;<br>
&gt; All this is requires is a Utf16String class that has an asUtf8String<br>
&gt; method (and any other required conversion methods).<br>
&gt;<br>
&gt;<br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div>
</div></div>