[phobos] Transcoded text stdio

Shin Fujishiro rsinfu at gmail.com
Fri Sep 17 10:05:00 PDT 2010


By the way:  For now, how about working around the Windows console
problem by putting the following code in LockingTextWriter?

// workaround
if (fps == core.stdc.stdio.stdout && orientation <= 0)
{
    foreach (dchar c; writeme)
    {
        immutable cp = GetConsoleOutputCP();
        wchar[2] wc;
        char[16] mb;
        immutable wcLen = encode(wc, c);
        immutable mbLen = WideCharToMultiByte(
                cp, 0, wc.ptr, wcLen, mb.ptr, mb.length, null, null);
        foreach (char c; mb[0 .. mbLen])
        {
            FPUTC(c, handle);
        }
    }
}

Although the long-term solution is a conversion-aware I/O system, we
should make it sure that the following works under Windows:

import std.stdio;
void main()
{
    writeln("Hallå, Värld!");
}


Shin


More information about the phobos mailing list