[Issue 391] New: .sort and .reverse break utf8 encoding

Walter Bright newshound at digitalmars.com
Tue Oct 3 18:45:59 PDT 2006

Derek Parnell wrote:
> On Tue, 03 Oct 2006 21:43:46 +0100, Stewart Gordon wrote:
>> d-bugmail at puremagic.com wrote:
>>>     writefln("sorted");   validate(a.sort);  // fails
>>>     writefln("reversed"); validate(a.reverse); // fails
>> AIUI sort and reverse are defined to sort/reverse the individual 
>> elements of the array, rather than the Unicode characters that make up a 
>> string.  But hmm....
> Yes, I realize that but it makes Walter's statements that char[] is all we
> need and we do not need a 'string' a bit weaker.

.sort and .reverse should reverse the unicode characters. If you want to 
reverse/sort the individual bytes, you should cast it to a ubyte[] first.

Both behaviors will be fixed in the next update.

More information about the Digitalmars-d-bugs mailing list