[phobos] Transcoded text stdio

Andrei Alexandrescu andrei at erdani.com
Sun Jan 2 15:58:08 PST 2011


Shin, I think you may put this into Phobos. Please make sure you do so 
only on version(Windows).

Andrei

On 9/17/10 12:05 PM, Shin Fujishiro wrote:
> 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
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos


More information about the phobos mailing list