(non-allegro) How do I handle non-american characters in a console application?

I am building a console application in Dev C++, which does some operations on words that are either input from keyboard or read from files.

It's a very basic program with mostly char arrays and comparison between them.

All it does is compare the char values contained in these words, for example it could ask you for a password to enter the program and then check in a data file if the password is correct.

I have 1 problem with this: I live in Sweden and we use some characters that are non-american, such as å ä ö. The program cannot handle this, instead these characters become strange other things.

I have also seen that é for example, becomes Ú when input into the program.

It seems that every character that the program cannot handle, has a specific character that it becomes instead (as with é above), so it would probably be possible to handle each such character by itself and convert inside the program (that is, if I recieve an é, it becomes an Ù but then I can change it back with error checking inside the program).

But that's quite a bit of work looking up every specific character.

Is there some way to make the program support non-english characters by #include a file or something to do this?

Thanks for your help,



emilb, it is like gnolam said. What's happening is that your program is trying to calculate your input as ASCII, where you should actually be using Unicode so it can calculate the region code (ie Swedish).


Thanks for telling me this.

I am currently not using allegro in this project, but I suppose I can do it and still be in the console and do the same things.

Is there a way to be able to do this without using allegro, though?
The original program was only running in the console with iostream and fstream loaded, and I started making tables of characters on my own, to be able to repair the char* arrays that were in bad condition after entering åäö and similar things.

I'll try this with allegro and see if I can make it work in the console, without changing the gfx mode.

Tobias Dammers

You need to somehow get the encoding right. UTF8, Windows, DOS, Apple, whatever it is...


I know that cppreference.com talks about wchar_t, and so I don't know if that's what you're looking for:


You may try defining your input as type wchar_t and doing a cin >> or whatever. On the "data_types" page, however, it mentions that it's newly introduced to C++ (not C).

Matt Smith

Does the Windows console use unicode? I thought it still used DOS code-pages. I think you need a Swedish system.fnt


I assume you are on Windows. Then your source code is probably in Windows-1252, and your console likely uses code page 850.

Both code pages are listed here:

You just need two arrays to convert back and forth between these encodings. The data you need is probably on the web somewhere, so you don't have to type it out yourself. I haven't had the need to do this myself, so I can't tell the quickest way to get this working.

The iconv lib supposedly can do this.


Online docs here:

Thread #590542. Printed from Allegro.cc