<div>On Tue, Apr 25, 2017 at 9:21 PM Robert Kern <<a href="mailto:robert.kern@gmail.com" target="_blank">robert.kern@gmail.com</a>> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>On Tue, Apr 25, 2017 at 6:27 PM, Charles R Harris <<a href="mailto:charlesr.harris@gmail.com" target="_blank">charlesr.harris@gmail.com</a>> wrote:<br><br>> The maximum length of an UTF-8 character is 4 bytes, so we could use that to size arrays by character length. The advantage over UTF-32 is that it is easily compressible, probably by a factor of 4 in many cases. That doesn't solve the in memory problem, but does have some advantages on disk as well as making for easy display. We could compress it ourselves after encoding by truncation.<br><br></div><div>The major use case that we have for a UTF-8 array is HDF5, and it specifies the width in bytes, not Unicode characters.</div></blockquote><div><br></div></div></div><div><div class="gmail_quote"><div>It's not just HDF5. Counting bytes is the Right Way to measure the size of UTF-8 encoded text:</div><div><a href="http://utf8everywhere.org/#myths" target="_blank">http://utf8everywhere.org/#myths</a><br></div><div><br></div><div>I also firmly believe (though clearly this is not universally agreed upon) that UTF-8 is the Right Way to encode strings for *non-legacy* applications. So if we're adding any new string encodings, it needs to be one of them.</div></div></div>