[Issue 15845] Windows console cannot read properly UTF-8 lines

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Mar 29 14:48:53 PDT 2016


https://issues.dlang.org/show_bug.cgi?id=15845

ag0aep6g at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ag0aep6g at gmail.com

--- Comment #2 from ag0aep6g at gmail.com ---
For -m32 (DIGITAL_MARS_STDIO) it seems to come down to this (with `chcp 65001`
in the console):

----
import std.stdio;

void main()
{
    FILE* fps = core.stdc.stdio.stdin;
    FLOCK(fps);
    scope(exit) FUNLOCK(fps);

    auto fp = cast(_iobuf*)fps;
    assert(!(__fhnd_info[fp._file] & FHND_WCHAR)); /* passes; no wide
characters */
    assert(!(fp._flag & _IOTRAN)); /* passes; no translated mode */

    int c = FGETC(fp);
    assert(c != -1); /* passes with 'a'; fails with 'ä' */
}
----

That is, Digital Mars's FGETC (_fgetc_nlock) returns -1 for non-ASCII
characters.

The issue does not manifest with a pipe: `echo ä | test` works.

--


More information about the Digitalmars-d-bugs mailing list