Wrong output of quotes in Windows (encoding?)

Simon s.d.hammett at gmail.com
Thu Dec 19 11:38:20 PST 2013


On 18/12/2013 22:11, Ali Çehreli wrote:
> On 12/18/2013 01:17 PM, Hugo Florentino wrote:
>
>  > Changing the codepage worked indeed. Thanks.
>  > Now, how could I do that programmatically, so that if my application
>  > runs on a system with a different codepage, the output looks correct?
>
> It is not solvable in general because stdout is nothing but a stream
> that accepts characters. (Well, UTF-8 code units when it comes to Unicode).
>
> The program can detect or assume that it is running in a console and
> change that environment if it is allowed to do so.
>
> Google searches like "change code page console programmatically windows"
> produce some answers but I don't have any experience. :)
>
> Ali
>

Call:

   SetConsoleOutputCP(65001);

Works for me on win7 64bit. Not sure how far back it's supported though.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms686036(v=vs.85).aspx

You might need your own definition of it, don't know it's available in 
the phobos windows bit.

-- 
My enormous talent is exceeded only by my outrageous laziness.
http://www.ssTk.co.uk


More information about the Digitalmars-d-learn mailing list