Human stupidity or is this a regression?

H. S. Teoh hsteoh at quickfur.ath.cx
Thu Dec 26 13:56:28 PST 2013


On Thu, Dec 26, 2013 at 09:38:02PM +0000, Vladimir Panteleev wrote:
> On Thursday, 26 December 2013 at 05:39:26 UTC, Lionello Lunesu
> wrote:
> >On 12/26/13, 11:58, bearophile wrote:
> >>Lionello Lunesu:
> >>
> >>>I could have sworn this used to work. Is my memory failing me, or
> >>>was this a deliberate change at some point? Perhaps a regression?
> >>
> >>It's not a regression, it's a locked-in design mistake. Write it
> >>like this and try again:
> >>
> >>foreach (dchar d; "你好")
> >>
> >>Bye,
> >>bearophile
> >
> >Yeah, that's what I ended up doing. But D being D, the default
> >should be safe and correct.
> 
> It is impossible for it to be "correct", unless with a very specific
> definition of "correct" which makes sense for some languages/locales
> and not others. As a challenge, try to define a "foreach" semantic
> that works "correctly" with the OP's code for Unicode composite
> characters, or Hebrew.

To be truly "correct" in the intuitive sense, use std.uni.byGrapheme.
(Yes it's slow, but that's the price you pay for intuitive correctness.)


T

-- 
It always amuses me that Windows has a Safe Mode during bootup. Does that mean that Windows is normally unsafe?


More information about the Digitalmars-d-learn mailing list