Something goes wrong with range and sort?
Peter Alexander
peter.alexander.au at gmail.com
Fri Jun 14 03:25:03 PDT 2013
On Friday, 14 June 2013 at 10:07:13 UTC, Andrea Fontana wrote:
> This code crash! It's just a useless trimmed-down version of a
> more complex code, just to show you the bug.
>
> If you remove accented letters from "blacklist" array it works
> fine. Why?
Works for me...
http://dpaste.dzfl.pl/79db5a8b
Can you produce a failing case on dpaste?
> sort() requires UTF32 input (a dstring/dchar[]) or it will fail.
>
> UTF8 (i.e. string type in D) is a variable-length encoding and
> if such input is given to sort it would refuse to compile since
> it cannot sort it in-place (a guarantee sort() makes).
>
> I guess that in case UTF8 input with 1-byte only characters is
> given to sort() it can detect that there are no variable length
> characters and that is probably the reason your code works when
> you remove non-ascii characters.
sort works just fine with string[]. Note that he's not sorting a
string, he's sorting an array of strings.
More information about the Digitalmars-d
mailing list