Re: Unicode - Windows 1252
El 18/03/2011 21:15, Stewart Gordon escribió: On 16/03/2011 22:17, Tom wrote: I have a D2 code that writes some stuff to the screen (usually runs in cmd.exe pseudo-console). When I print spanish characters they show wrong (gibberish symbols and so, wich corresponds to CP-1252 encoding). Is there a way to convert all outputted streams to CP-1252 without having to wrap writeln function (and replacing all its calls)? My utility library has a console I/O module that converts to/from the console codepage under Windows: http://pr.stewartsplace.org.uk/d/sutil/ See if it's useful to you. I'm not sure whether it works under D2, but it's probably quite straightforward to tweak it so that it does. Stewart. Thanks! I'll give it a try. Tom;
Re: Unicode - Windows 1252
On 16/03/2011 22:17, Tom wrote: I have a D2 code that writes some stuff to the screen (usually runs in cmd.exe pseudo-console). When I print spanish characters they show wrong (gibberish symbols and so, wich corresponds to CP-1252 encoding). Is there a way to convert all outputted streams to CP-1252 without having to wrap writeln function (and replacing all its calls)? My utility library has a console I/O module that converts to/from the console codepage under Windows: http://pr.stewartsplace.org.uk/d/sutil/ See if it's useful to you. I'm not sure whether it works under D2, but it's probably quite straightforward to tweak it so that it does. Stewart.
Unicode - Windows 1252
I have a D2 code that writes some stuff to the screen (usually runs in cmd.exe pseudo-console). When I print spanish characters they show wrong (gibberish symbols and so, wich corresponds to CP-1252 encoding). Is there a way to convert all outputted streams to CP-1252 without having to wrap writeln function (and replacing all its calls)? TIA, Tom;
Re: Unicode - Windows 1252
import std.c.windows.windows; extern(Windows) BOOL SetConsoleOutputCP(UINT); SetConsoleOutputCP(65001);
Re: Unicode - Windows 1252
Otherwise you might be interested in using the WinAPI library from dsource which has that function prototype and many others: http://www.dsource.org/projects/bindings/wiki/WindowsApi
Re: Unicode - Windows 1252
Sorry, 65001 is actually UTF-8 or UTF-7 IIRC. For CP-1252 you'll have to find the correct value, I guess.
Re: Unicode - Windows 1252
El 16/03/2011 19:27, Andrej Mitrovic escribió: import std.c.windows.windows; extern(Windows) BOOL SetConsoleOutputCP(UINT); SetConsoleOutputCP(65001); Tried a bunch of values and all yields the same result. Thanks anyway.
Re: Unicode - Windows 1252
El 16/03/2011 19:27, Andrej Mitrovic escribió: Otherwise you might be interested in using the WinAPI library from dsource which has that function prototype and many others: http://www.dsource.org/projects/bindings/wiki/WindowsApi Mmh, the whole winapi just for that seems a little too much. :S
Re: Unicode - Windows 1252
El 16/03/2011 20:36, Tom escribió: El 16/03/2011 19:27, Andrej Mitrovic escribió: import std.c.windows.windows; extern(Windows) BOOL SetConsoleOutputCP(UINT); SetConsoleOutputCP(65001); Tried a bunch of values and all yields the same result. Thanks anyway. Forget it, I'll just use chcp...
Re: Unicode - Windows 1252
On 3/17/11, Tom t...@nospam.com wrote: El 16/03/2011 20:36, Tom escribió: El 16/03/2011 19:27, Andrej Mitrovic escribió: import std.c.windows.windows; extern(Windows) BOOL SetConsoleOutputCP(UINT); SetConsoleOutputCP(65001); Tried a bunch of values and all yields the same result. Thanks anyway. Forget it, I'll just use chcp... You probably already know this, but you can do that programmatically: import std.process; void main() { system(chcp 1252); }
Re: Unicode - Windows 1252
El 16/03/2011 21:21, Andrej Mitrovic escribió: On 3/17/11, Tomt...@nospam.com wrote: El 16/03/2011 20:36, Tom escribió: El 16/03/2011 19:27, Andrej Mitrovic escribió: import std.c.windows.windows; extern(Windows) BOOL SetConsoleOutputCP(UINT); SetConsoleOutputCP(65001); Tried a bunch of values and all yields the same result. Thanks anyway. Forget it, I'll just use chcp... You probably already know this, but you can do that programmatically: import std.process; void main() { system(chcp 1252); } Yeah. And by the way, SetConsoleOutputCP(65001) worked! Don't know what I did the first time I tried it. Another question: is there a way to hook a function or delegate before every output of the program, so I can filter the output in some way? Tom;