Black unicode magic.<br><br>It's not a big issue for me, but it probably will be for people that deal with Unicode all the time. Personally, ASCII is good enough for me. :)<br><br> Thanks for your efforts!<br><br><div class="gmail_quote">
On Wed, Jul 28, 2010 at 7:17 AM, Sean kelly <span dir="ltr"><<a href="mailto:sean@invisibleduck.org" target="_blank">sean@invisibleduck.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">After a bit more research, the situation is a bit more complicated than I realized. First, if I compile this C app using DMC:<br>
<br>
#include <stdio.h><br>
<br>
int main()<br>
{<br>
printf( "Hall\u00E5, V\u00E4rld!" );<br>
return 0;<br>
}<br>
<br>
The output is:<br>
<br>
Hall&#963;, V&#931;rld!<br>
<br>
This is what I was seeing once I started messing with std.stdio. An improvement I suppose, since it's not garbage, but the output it still incorrect if you're expecting Unicode. After a bit of experimenting, it looks like there are two ways to output non-ASCII correctly in Windows: convert to a multi-byte string (toMBSz) or call WriteConsoleW. Here's a test app and the associated output. Notice how writeln() has the same output as printf(unicodeString).<br>
<br>
import std.stdio;<br>
import std.string;<br>
import std.utf;<br>
import std.windows.charset;<br>
import core.sys.windows.windows;<br>
<br>
void main()<br>
{<br>
HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);<br>
DWORD ignore;<br>
wchar[] buf = ("\u00E5 \u00E4"w).dup;<br>
<br>
writeln(buf);<br>
printf("%s\n", toStringz(toUTF8(buf)));<br>
printf("%s\n", toMBSz(toUTF8(buf), 1));<br>
WriteConsoleW(h, buf.ptr, buf.length, &ignore, null);<br>
}<br>
<br>
prints:<br>
<br>
&#9500;Ñ &#9500;ñ<br>
&#9500;Ñ &#9500;ñ<br>
å ä<br>
å ä<br>
<br>
I'd think it should be enough to have std.stdio call the wide char output routine to have things display correctly, but I tried that and that's when I got the sigma. Figuring out what's going on there will take some more work, and the ultimate fix may end up being in the DMC libraries... I really don't know.<br>
</blockquote></div><br>