[Issue 2742] std.stdio assumes console works in utf-8

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Oct 13 21:06:03 PDT 2016


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

Vladimir Panteleev <thecybershadow at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |WONTFIX

--- Comment #14 from Vladimir Panteleev <thecybershadow at gmail.com> ---
I think we should let this one go.

1. To see international characters in the first place, you have to change the
console font from a raster one.
2. Setting the output console CP to 65001 is not an option because it breaks
spawned programs. In particular, batch files stop working. Problems also occur
if the console isn't changed back.
3. Changing the data's output encoding according to the user's locale cannot be
done if the output is a file or pipe, as it would be a breaking change.
4. As a result, the only way to do this is to check if the output is the
console. However, because we do output via the C standard library, whatever
stdout points to may change at any moment, so we cannot cache the check.
5. Since all output is done via the C standard library, it is its
responsibility to handle this, however it does not. We do not have control over
the MS standard C library, which does not implement this check.

I think this is unactionable unless either we move away from using C for
input/output (see: std.io), or someone presents a C example program that
produces correct Unicode output to both console and file and which works with
all C runtimes that D uses (AFAIU, this is impossible).

> If this is not going to be fixed, it should be documented.

The problem is with Windows and the C libraries, not D.

--


More information about the Digitalmars-d-bugs mailing list