View Single Post
Old 03-09-2013, 10:29 PM   #19
Japo
Autonomous human
 
Japo's Avatar


 
Join Date: Mar 2006
Location: ,
Posts: 4,613
Default

Hmm it's been a while since I learned C... Apparently (of course) Unicode is now part of the standard library. See versions of standard functions that include the letter w, for example:

http://msdn.microsoft.com/en-us/library/wc7014hz.aspx

Wide char strings are made of wchar_t instead of char, and their literals are preceded with an L:

Code:
wprintf(L"Hell\u00f8 wørld! %s",
	L'ø' == L'\u00f8' ? L"True" : L"False");
To change the console mode from ANSI to Unicode (solving the °/ø confusion), apparently you can do this:

Code:
#include <io.h>
#include <fcntl.h>
Code:
_setmode(_fileno(stdout), _O_U16TEXT);
Make sure though that the font used by your console window does have those strange characters. It's not the case by default in my case, but you can right-click on the console window title bar and go to choose properties > font tab. Then restart your program, because the font will have transformed the strange characters to ? or normal letters before outputting them. (See how pointless all this is...!)
__________________
Life starts every day anew. Prospects not so good...

Last edited by Japo; 03-09-2013 at 10:53 PM.
Japo is offline                         Send a private message to Japo
Reply With Quote