On 04/17/2012 06:09 PM, Ali Çehreli wrote:
On 04/17/2012 08:58 AM, bearophile wrote:
 > Ali Çehreli:
 >
 >> The reason is, a sequence of UTF-8 code units are not a valid UTF-8
 >> when reversed (or retro'ed :p).
 >
 > But reversed(char[]) now works :-)

That's pretty cool. :) (You meant reverse()).

Interesting, because there could be no other way anyway because
reverse() is in-place. Iterating by dchar without damaging the other end
must have been challenging because the first half of the string may have
been all multi-bype UTF-8 code units and all of the rest of single-bytes.

The algorithm must be building a local string.

 > Bye,
 > bearophile

Ali


It does not have to build a local string, see
http://dlang.org/phobos/std_utf.html#strideBack

Reply via email to