Problems with code pages

I've writen a program in C++. It reads text from ASCII file, but it don't know signs č, š, ž. So I've set "SetConsoleOutputCP(852)" and "SetConsoleCP(852)" in program code, but it didn't help. I'm using compiler Dev-C++.
BTW I'm using Windows 7 and I've changed language to Slovene (I thought that this change means "Central and East European Latin" in fact code page 1250, but I can see, I was wrong). After typing chcp in CMD window I get "Active code page: 852". In Windows environment, in Word I can get characters by pressing ALT-xxx and I've find out, that actually all these characters belong to code page 852, and not 1250. OK.
I've made a few programs to write out characters with codes higher than 127 - first I've used code page 852 and I've get all correct characters. Then I've used 850 and 1250, and I simply did't get all the characters that belongs to these tables: some characters are wrong, some are missing, etc.
Everything looks like a mess. Who would know, how to solve this?
Very strange, that changing code page inside program code doesn't change characters. It would be nice to know why.


Last edited on
I find that dealing with non-ASCII user IO in Windows console programs is just not worth it. Too many things, some outside the programmer's control, need to go right in order for it to work. My suggestion would be to move on to GUI.

My other suggestion would be to avoid ANSI files if you can. Prefer UTF-8 and UTF-16. UTF-16, if the endianness matches the platform, can be directly copied to buffers to hand off to WinAPI functions, without any other processing.
Last edited on
+1, except for UTF-16. Stick to UTF-8. When you need to pass off to WinAPi functions, it takes almost nothing to convert to UTF-16 before passing to the function.
Thank you for your answers. I've started to learn C++ and thought, that reading from and writing to files is simple as it only can be, but ...
First I've tried a few free, on line compilers and found out, that they don't know almost any library and they are useless even for beginners. I don't want to get and organize myself another partition or new HDD or even another computer with Linux, Unix or DOS, so I decided to download Dev-C++.
I will study your suggestions and I hope, everything will work fine.
Well, yes, reading from a file is simple enough. The problems start when you want to correctly display the contents to the user.
Topic archived. No new replies allowed.