www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How do I display unicode characters in D on standard (english) Windows

reply WhatMeWorry <kheaser gmail.com> writes:
This is a very stupid question but from Ali's book, I took this 
segment:


writeln("Résumé preparation: 10.25€");
writeln("\x52\&eacute;sum\u00e9 preparation: 10.25\&euro;");


and after running it all I get is the following:


Résumé preparation: 10.25€
Résumé preparation: 10.25€


I was expecting the symbol "£" or something like that.  What am I 
missing?
Jul 29 2019
next sibling parent reply kinke <noone nowhere.com> writes:
On Monday, 29 July 2019 at 22:17:55 UTC, WhatMeWorry wrote:
 What am I missing?
Switching the console code page to UTF-8, and then restoring the original one before termination. See https://github.com/ldc-developers/ldc/pull/3086/commits/5915534530fa095e7e5d58bcfb4ad100d249bbca#diff-c59e7716a40a0 ce42f141c738f2c311. You may have to set a non-raster console font (e.g., Consolas).
Jul 29 2019
parent reply Martin Krejcirik <mk-junk i-line.cz> writes:
On Monday, 29 July 2019 at 22:31:01 UTC, kinke wrote:
 Switching the console code page to UTF-8, and then restoring 
 the original one before termination. See 
 https://github.com/ldc-developers/ldc/pull/3086/commits/5915534530fa095e7e5d58bcfb4ad100d249bbca#diff-c59e7716a40a0
ce42f141c738f2c311. You may have to set a non-raster console font (e.g.,
Consolas).
Just be advised, this was seriously broken in the past. Depends on windows, ms libraries, whether it's stdout or stderr and more. Current versions are probably ok, will check. Don't count on this to work on older windows including older Win10. I always convert to/from console codepage to be safe.
Jul 30 2019
parent kinke <kinke gmx.net> writes:
On Tuesday, 30 July 2019 at 12:06:23 UTC, Martin Krejcirik wrote:
 Just be advised, this was seriously broken in the past. Depends 
 on windows, ms libraries, whether it's stdout or stderr and 
 more. Current versions are probably ok, will check. Don't count 
 on this to work on older windows including older Win10.
stderr was fixed with Win10 v1809.
Jul 30 2019
prev sibling parent Carl Sturtivant <sturtivant gmail.com> writes:
On Monday, 29 July 2019 at 22:17:55 UTC, WhatMeWorry wrote:
 This is a very stupid question but from Ali's book, I took this 
 segment:


 writeln("Résumé preparation: 10.25€");
 writeln("\x52\&eacute;sum\u00e9 preparation: 10.25\&euro;");


 and after running it all I get is the following:


 Résumé preparation: 10.25€
 Résumé preparation: 10.25€


 I was expecting the symbol "£" or something like that.  What am 
 I missing?
In my Windows 10 build 1803 I was able to find a box to check to globally use the UTF-8 code page. Checking it requires a restart as it says the locale has changed. Settings>Time&Language>Region&Language>Administrative_Language_Settings brings up a Region dialog, and clicking on "Change system locale..." brought up a dialog where this box can be checked. After doing this the console acted sensibly right away with the code you wrote.
Jul 31 2019