HOW TO:write cirillic to a file

hi, does somebody knows how to write cirillic symbols to a file.
i use array of type wchar_t to keep cirillic symbols.
i write this array to a file, but when i open file it contain a strange symbols.
i tried to write file in binary but it doesn't work. why it happens can somebody help?
You should specify the encoding

eg:
1
2
3
4
5
6
7
8
9
10
11
fstream f("file.txt");

f.put(239);
f.put(187);
f.put(191);//these 3 bytes tell that you are using UTF-8
	
f.put(0xD0);//all cirillic have this first byte
f.put(144);//letter code (А)

f.put(0xD0);
f.put(145);//Б 

The resulting file will have "АБ" as text
Last edited on
Topic archived. No new replies allowed.