I'm trying to enable my C++ program to accept both signs from CP852(Latin 2) in form of text written in the console, as well as loaded up from a simple text file. I cannot figure out what is the default encoding since either way gives me different ANSI code. I've set the CP to Central European (DOS) 852 in Advanced Save Options.
1) casting with (int)ł gave me the number 136
2) assigning to a variable unsigned char sign = 'ł' and printing it on the screen with cout gave me the number 136
3) using "Add watch" control to the variable containing ł, it shows the number 179
4) while loading from a text file, 179 again, using this simple code
int x;
FILE* plik;
plik= fopen("Text.txt", "r"); // It contains 2 signs, "oł"
while ((x = fgetc(plik)) != EOF)
{
cout << (char)x;
}
fclose(plik);
Output: "o|"
My main question is, why does it handle the same sign (or am i wrong?) "ł" once as 136 and other time as 179? How to deal with this problem? This way i cannot print and accept a sign with comparison, since their codes are different, even if what is in the file is exactly the same as in the console window.
Aucun commentaire:
Enregistrer un commentaire