www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Messy code in console

reply =?ISO-8859-1?B?SWNlTmF0dXJl?= via Digitalmars-d-learn writes:
	charset="ISO-8859-1"
Content-Transfer-Encoding: base64

V2hlbiB0aGVyZSBhcmUgQ2hpbmVzZSBjaGFyYWN0ZXJzIGluIHRoZSBvdXRwdXQsIHRoZSBj
b25zb2xlIHdpbGwgICAgICAgZGlzcGxheSBtZXNzeSBjb2RlLkkgY2hhbmdlIHRoZSBlbmNv
ZGluZyBvZiB0aGUgc291cmNlIGZpbGUgaW50byAgICAgICBVVEYtOCBvciBVVEYtMTYsYnV0
IHRoZSBtZXNzeSBjb2RlIGlzIHN0aWxsIHRoZXJlLi4uDQogICAgICAgSSB1c2UgdGhlIGRt
ZCAyLjA2NSxWaXN1YWwgU3R1ZGlvIDIwMTMgd2l0aCBWaXN1YWxELg0KICAgICAgIEhvdyB0
byBzb2x2ZSB0aGlzIHByb2JsZW0/DQogICAgICAgVGhhbmsgeW91IQ==
May 10 2014
next sibling parent reply =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 05/10/2014 07:19 PM, IceNature via Digitalmars-d-learn wrote:
 When there are Chinese characters in the output, the console will      
display messy code.I change the encoding of the source file into       UTF-8 or
UTF-16,but the messy code is still there...
         I use the dmd 2.065,Visual Studio 2013 with VisualD.
         How to solve this problem?
         Thank you!
If this is on Windows, you must 1) Set the console code page to 65001 e.g. by the command chcp 65001 (It is possible to make it the default through a Windows registry setting.) 2) Set the font to a unicode one e.g. Lucida Ali
May 10 2014
parent IceNature via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> writes:
 charset=UTF-8

Thank you for your help. But if I change the default setting,will it affect
other programs,making other console program show messy code?

On 2014年5月11日 格林尼治标准时间+0800下午12时30分40秒, "Ali
Çehreli via Digitalmars-d-learn" <digitalmars-d-learn puremagic.com> wrote:
On 05/10/2014 07:19 PM, IceNature via Digitalmars-d-learn wrote:
 When there are Chinese characters in the output, the console will    
display messy code.I change the encoding of the source file into UTF-8 or UTF-16,but the messy code is still there...
         I use the dmd 2.065,Visual Studio 2013 with VisualD.
         How to solve this problem?
         Thank you!
If this is on Windows, you must 1) Set the console code page to 65001 e.g. by the command chcp 65001 (It is possible to make it the default through a Windows registry setting.) 2) Set the font to a unicode one e.g. Lucida Ali .
May 10 2014
prev sibling next sibling parent reply "FrankLike" <1150015857 qq.com> writes:
On Sunday, 11 May 2014 at 02:38:44 UTC, IceNature via 
Digitalmars-d-learn wrote:
 When there are Chinese characters in the output, the console 
 will       display messy code.I change the encoding of the 
 source file into       UTF-8 or UTF-16,but the messy code is 
 still there...
        I use the dmd 2.065,Visual Studio 2013 with VisualD.
        How to solve this problem?
        Thank you
You can get answer from here: http://forum.dlang.org/thread/ucfpqgzzxcacqxkdrkmj forum.dlang.org
May 10 2014
parent reply IceNature via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> writes:
 charset=UTF-8

Thank you for your help. But if I change the default console encoding,will it
affect other programs,making other console program show messy code?

On 2014年5月11日 格林尼治标准时间+0800下午1时18分42秒,
FrankLike via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:
On Sunday, 11 May 2014 at 02:38:44 UTC, IceNature via 
Digitalmars-d-learn wrote:
 When there are Chinese characters in the output, the console 
 will       display messy code.I change the encoding of the 
 source file into       UTF-8 or UTF-16,but the messy code is 
 still there...
        I use the dmd 2.065,Visual Studio 2013 with VisualD.
        How to solve this problem?
        Thank you
You can get answer from here: http://forum.dlang.org/thread/ucfpqgzzxcacqxkdrkmj forum.dlang.org .
May 10 2014
parent reply "FrankLike" <1150015857 qq.com> writes:
On Sunday, 11 May 2014 at 06:35:26 UTC, IceNature via 
Digitalmars-d-learn wrote:
 Thank you for your help. But if I change the default console 
 encoding,will it affect other programs,making other console 
 program show messy code?
Don't affect,and you must set the font to a unicode font ,such as Lucida.
May 11 2014
next sibling parent IceNature via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> writes:
 charset=UTF-8

The problem has been solved with your help. Thank you very much.

On 2014年5月11日 格林尼治标准时间+0800下午3时43分41秒,
FrankLike via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:
On Sunday, 11 May 2014 at 06:35:26 UTC, IceNature via 
Digitalmars-d-learn wrote:
 Thank you for your help. But if I change the default console 
 encoding,will it affect other programs,making other console 
 program show messy code?
Don't affect,and you must set the font to a unicode font ,such as Lucida. .
May 11 2014
prev sibling parent reply IceNature via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> writes:
 charset=UTF-8

I've just thought of a problem. Others who uses my program on their computers
needs to change their setting. It is a bit troublesome.

On 2014年5月11日 格林尼治标准时间+0800下午3时43分41秒,
FrankLike via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:
On Sunday, 11 May 2014 at 06:35:26 UTC, IceNature via 
Digitalmars-d-learn wrote:
 Thank you for your help. But if I change the default console 
 encoding,will it affect other programs,making other console 
 program show messy code?
Don't affect,and you must set the font to a unicode font ,such as Lucida. .
May 12 2014
parent reply =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 05/12/2014 09:53 PM, IceNature via Digitalmars-d-learn wrote:

 I've just thought of a problem. Others who uses my program on their
 computers needs to change their setting. It is a bit troublesome.
It is also possible to set the code page when the program is running: http://forum.dlang.org/thread/ilrd33$1bir$1 digitalmars.com#post-ilrd33:241bir:241:40digitalmars.com There must be a function to change the font as well. Ali
May 12 2014
parent IceNature via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> writes:
 charset=UTF-8

I see... I will search the document. Thank you.

On 2014年5月13日 格林尼治标准时间+0800下午1时58分20秒, "Ali
Çehreli via Digitalmars-d-learn" <digitalmars-d-learn puremagic.com> wrote:
On 05/12/2014 09:53 PM, IceNature via Digitalmars-d-learn wrote:

 I've just thought of a problem. Others who uses my program on their
 computers needs to change their setting. It is a bit troublesome.
It is also possible to set the code page when the program is running: http://forum.dlang.org/thread/ilrd33$1bir$1 digitalmars.com#post-ilrd33:241bir:241:40digitalmars.com There must be a function to change the font as well. Ali .
May 13 2014
prev sibling parent reply "Kagamin" <spam here.lot> writes:
Known bug https://issues.dlang.org/show_bug.cgi?id=2742
May 11 2014
parent reply "FreeSlave" <freeslave93 gmail.com> writes:
On Sunday, 11 May 2014 at 07:43:07 UTC, Kagamin wrote:
 Known bug https://issues.dlang.org/show_bug.cgi?id=2742
It's not bug. Write-functions are designed to output text to stdout, and it's issue of programmer to make sure that expected "acceptor" can interpret them properly. Note that stdout may be redirected to file or be part of pipe, that does nothing with cmd console.
May 11 2014
parent "Kagamin" <spam here.lot> writes:
On Sunday, 11 May 2014 at 08:48:43 UTC, FreeSlave wrote:
 On Sunday, 11 May 2014 at 07:43:07 UTC, Kagamin wrote:
 Known bug https://issues.dlang.org/show_bug.cgi?id=2742
It's not bug. Write-functions are designed to output text to stdout, and it's issue of programmer to make sure that expected "acceptor" can interpret them properly. Note that stdout may be redirected to file or be part of pipe, that does nothing with cmd console.
OK, just tested it: after a program calls SetConsoleOutputCP(CP_UTF8); it's able to print utf-8 text correctly, but if it fails to reset the codepage back, the console remains in utf-8, so other programs will fail to print text in oem encoding in such console. If this program runs other programs, they fail to print oem text to this console, because the console expects utf-8.
May 11 2014