PDA

View Full Version : Help with special characters



supernerden
April 6th, 2007, 07:35 PM
As a proud norwegianer I often find myself in trouble when I start learning a new programming language, due to the norwegian characters æ, ø and å.

My question:

How do I make the C++-script


cout << "æøå";output correctly?

TheColonial
April 8th, 2007, 05:35 AM
You need to use unicode strings, not ansi strings.

Hint:

#include <tchar.h>
cout << _T("æøå");
Compile as unicode.

supernerden
April 8th, 2007, 09:34 AM
Sorry for asking, but how do you compile as unicode?
I'm using Dec-C++

TheColonial
April 8th, 2007, 10:05 AM
Dev-C++ uses MingW, which is based on GCC, so you need to define the following symbol when compiling: _GLIBCXX_USE_WCHAR_T

Hope that helps
OJ

Edit: Don't forget that your console must support Unicode characters. Since you're Norwegian (and hence your installation is probably the same), I'm guessing that your console does already support that :)

supernerden
April 8th, 2007, 11:52 AM
Well, not really, since I don't know what MingW and GCC is, and since i don't know how I can define symbols when compiling. As I said, I'm new to C++ (And programming in general)

I'm sorry, but I guess you'll have to help me with that too.

TheColonial
April 8th, 2007, 08:43 PM
MinGW - Minimalist GNU for Windows. That is, it's GCC for Windows. Dev-C++ uses this compiler, so you just need to specify that define when compiling.

I'm not a Dev-C++ user, but my guess is that you need to open the Compiler options, and look for an option that lets you specify preprocessor symbols/defines. when you find it, make sure you add _GLIBCXX_USE_WCHAR_T.

Recompile and you're away.

Cheers
OJ

supernerden
April 9th, 2007, 08:48 AM
Mmmnnnnnyeeees.... I tried that, but I didn't find any looking-good options.
I guess I'll just make english programs for the time being.

cheers mate :)