Writing unicode strings to the console

Adam D. Ruppe destructionator at gmail.com
Mon Dec 17 16:42:06 PST 2012


I suggest you use string instead of dstring, because utf-8 
(string) has better output support than utf-32 (dstring), and 
both support the complete unicode character set.

If string doesn't work, the question is: Windows or Linux?

On Windows, the api call SetConsoleOutputCP will help

http://msdn.microsoft.com/en-us/library/windows/desktop/ms686036%28v=vs.85%29.aspx

The magic number for UTF-8 is 65001. (see here: 
http://msdn.microsoft.com/en-us/library/dd317756%28v=VS.85%29.aspx 
)

The link says utf32 is only available to managed applications, so 
you probably want to use utf-8.



If you are on linux, you need to get a terminal that supports 
utf8. Writing "\033%G" to an xterm will switch it to utf8, but 
this is the default most the time.... so you'll probably be ok on 
that.


Again though, writing strings is probably going to give better 
results than dstring on either OS with any set of options.


More information about the Digitalmars-d-learn mailing list