Hello, I am writing a simple calculator in lithuanian and I have to use the letters "ąčęėįšųūž". If I write the line setlocale(LC_all, "Lithuanian");, it works fine for output text, but if I set the console title to that, any lithuanian characters are turned into gibberish (the lithuanian characters are turned into the exact same nonsense, letter for letter, if I delete the setlocale line). It's as if the setlocale doesn't affect the console title. Help would be appreciated, thanks!
Windows supports two ways of handling strings: ANSI (SetConsoleTitleA) and UTF-16 (SetConsoleTitleW). You have to define some preprocessor flags to let the Windows.h header know you want Unicode support and then make sure your string literals are wide string literals by prefixing them with L.
How do I do that in Code::Blocks? I've set the editor to use the "default" encoding when opening files (before I did that, it was messing up the lithuanian characters in the code). Also under "Edit" > "File encoding" I've set it to "System default". If I set it to UTF-8, it turns the lithuanian characters into gibberish in the console, to similiar effect if I hadn't written the setlocale line. Under the compiler settings I can't find anything about file encoding or UTF-8 or anything like that.
I don't know, I've never used Code::Blocks. Also, be aware that the Windows console host has very poor support for UTF-8/Unicode in general. You'd be best to just not use the console at all if you need to display non-ASCII text - use a graphics library to render real fonts to the screen instead.