Windows vs UTF-8 (issue 15845)
anonymous via Digitalmars-d
digitalmars-d at puremagic.com
Sun Apr 3 16:11:53 PDT 2016
On Sunday, 3 April 2016 at 22:48:21 UTC, Adam D. Ruppe wrote:
> What happens if you give it a 4 char buffer? I imagine it would
> work fine then in all cases. It seems to for me.
Doesn't seem to work for me.
The exact code I tested:
----
import std.stdio;
import std.exception: enforce;
import core.sys.windows.windows;
void main()
{
SetConsoleCP(65001);
SetConsoleOutputCP(65001);
uint readBytes;
ubyte[4] c;
ReadFile(GetStdHandle(STD_INPUT_HANDLE), c.ptr, c.length,
&readBytes, null).enforce();
writeln(readBytes, " ", c[]);
}
----
When I enter "a", it prints "3 [97, 13, 10, 0]".
When I enter "รค", it prints "0 [0, 0, 0, 0]".
I've also tried even larger buffers. Same result.
More information about the Digitalmars-d
mailing list