On Sunday, February 24, 2013 05:18:18 Andrej Mitrovic wrote: > On 2/24/13, Jonathan M Davis <[email protected]> wrote: > > strings and dstrings aren't comparable. > > Why aren't they? They're just different encodings of UTF, I'd expect > Phobos to support comparing UTF8/UTF16/UTF32 against each other.
Because the compiler doesn't general deal on the level of code points. It deals with code units, and it doesn't generally treat strings as being special at all. So, you can't compare string and dstring any more than you can compare ubye[] and uint[]. Pretty much the only place in the language where you get automatic decoding is when you ask for it with a foreach loop by making the iteration type dchar. All the rest of it is Phobos, and equals is specifically the way to compare strings by code point. It just isn't recursive, which is why your'e having trouble. However, now that I think about it, equal takes a predicate, so it would probably work to do something like equal!"equal(a, b)"(["hello"d], ["hello"]); - Jonathan M Davis
