"Martin Nowak" <d...@dawgfoto.de> writes:
> Incidentally this has brought me a nice idea.
> You need to combine the foreach loop 'bug' with the ability to alter
> the index variable
> (http://d.puremagic.com/issues/show_bug.cgi?id=6652).
> Then you can construct a terrifically fast, still correct, utf8 decoder.
>
>                     foreach(i, c; s)
>                     {
>                         if (c < 0x80)
>                             outp.put(c);
>                         else
>                             (outp.put(std.utf.decode(s, i)), --i);
>                     }
>

Or even simpler:

foreach (dchar c; s)
  outp.put(c);

foreach supports decoding built into the language.

Jerry



Reply via email to