Print a copyright symbol

Adam D. Ruppe destructionator at gmail.com
Fri Jan 11 16:52:54 UTC 2019


On Friday, 11 January 2019 at 16:48:40 UTC, Head Scratcher wrote:
> How would I use writeln to print a copyright symbol to the 
> console? I have tried using the unicode code \u00A9, as well as 
> embedding the symbol directly in the string, but I just get 
> garbage when I run it.

You need to be using a system that supports the output.

On Windows, it means changing the console mode to utf-8 so it 
understands the bytes when it sees them.

import core.sys.windows.windows;
SetConsoleOutputCP(65001); // UTF-8

before you do some writeln and it should work on windows 10. On 
older systems, you might have to go into console properties and 
select a truetype font too.

(or as the user btw you can go into console properties and change 
the code page there, but I think it is slightly easier to do it 
on code)


More information about the Digitalmars-d-learn mailing list