www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - 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.
Jan 07 2011