On Friday, 6 November 2015 at 19:26:50 UTC, HeiHon wrote:
Am I using std.utf.decode wrongly or is it buggy?

It's obviously used wrongly, try this instead:

import std.utf, std.stdio;

---
dstring do_decode(string txt)
{
    dstring result;
    try
    {
        size_t idx;
        writeln("decode ", txt);
        while (true)
        {
            result ~= std.utf.decode(txt, idx);
            if (idx == txt.length) break;
        }
    }
    catch(Exception e)
    {
        writeln(e.msg, " file=", e.file, " line=", e.line);
    }
    return result;
}

void main()
{
    writeln(do_decode("abc"));
    writeln(do_decode("Ã¥bc"));
    writeln(do_decode("aåb"));
}

Reply via email to