User forums > Help

Weird foreign letters problem...

(1/3) > >>

5Nick7:
Hello,

I am a beginner with Code::Blocks and have recently ran into a problem which I can not seem to resolve. The actions that I do until the problem occurs goes something like this:
1. I open up Code::Blocks;
2. I write some code (using foreign Lithuanian letters "ą, č, ę...");
3. I save & exit;
4. Problem. After opening the .cpp file the Lithuanian letters change into other ones. (For example: 'ą' changes to 'à'; 'č' changes to 'è'; etc.).

Why is this? How do I fix it? I'm guessing the problem is in my code. When the problem occurs, the code goes from this:

--- Code: ---#include <iostream>
#include <iomanip>
using namespace std;
int main ()
{
    setlocale(LC_ALL, "Lithuanian");
cout << ("Ąą Čč Ęę Ėė Įį Šš Ųų Ūū Žž") << endl;
return 0;
}

--- End code ---
to this:
--- Code: ---#include <iostream>
#include <iomanip>
using namespace std;
int main ()
{
    setlocale(LC_ALL, "Lithuanian");
cout << ("Àà Èè Ææ Ëë Áá Ðð Øø Ûû Þþ") << endl;
return 0;
}
--- End code ---
The 'setlocale' is there so that the Lithuanian letters wouldn't turn into unknown (for me) symbols when i build and run the code, so I must also use system default file encoding.

I couldn't find anyone with a similar problem in the forums, sorry if this is post is purposeless.

Thank you.

raynebc:
Try saving your source files in Unicode (ie. UTF-8) format.

BlueHazzard:

--- Quote from: raynebc on November 21, 2018, 09:04:21 pm ---Try saving your source files in Unicode (ie. UTF-8) format.

--- End quote ---
You can do this wiht Edit->File encoding->UTF-8

5Nick7:

--- Quote from: BlueHazzard on November 21, 2018, 09:59:09 pm ---
--- Quote from: raynebc on November 21, 2018, 09:04:21 pm ---Try saving your source files in Unicode (ie. UTF-8) format.

--- End quote ---
You can do this wiht Edit->File encoding->UTF-8

--- End quote ---

While this saves all the written code and everything looks great, when I run it, the console prints symbols instead of the normal letters:
From

--- Code: ---Aą Čč Ęę Ėė Įį Šš Ųų Ūū Žž
--- End code ---
To

--- Code: ---Ä„Ä Ä?Ä? Ä?Ät Ä-Ä- Įį Å Å
--- End code ---

Any other ideas?

oBFusCATed:
You have to tell the compiler that what is the encoding of the file you're give it.

Navigation

[0] Message Index

[#] Next page

Go to full version