January 07, 2011 Printing wide characters in console | ||||
|---|---|---|---|---|
| ||||
I think I found a solution for it. This code changes encoding of string to ansi which is default string encoding in windows console.
import std.c.windows.windows;
string ansi(string str)
{
wchar[] src = toUTF16(str).dup;
char[] dest;
dest.length = str.length;
WideCharToMultiByte(0, 0, src.ptr, -1, dest.ptr, dest.length, null,
null);
return cast(string)dest;
}
It's inconvinient to call this function every time printing string, I think simillar code should be in the standard library.
| ||||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply