The stream does not take the locale from the medium. I added:
#include <locale>
locale loc("el_GR.utf8");
f.imbue(loc);
So, the stream now supports the locale (if I'm wrong, please correct).
The correct code is:
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <wchar.h>
#include <locale>
using namespace std;
int main(int argc, char **argv)
{
locale loc("el_GR.utf8");
wcout<<"Hi I am starting Ξεκινάμε"<<endl;
cout<<"%s\n"<<setlocale(LC_ALL,"en_US.utf8")<<endl;
wofstream f("xxx.txt", ios::out);
if(f.is_open()){
f.imbue(loc);
f.write(L"good",4);f.flush();
f.write(L"καλημέρα",8);
f.close();
cout<<"fileClosed"<<endl;
}
cout<<"hello world"<<endl;
return 0;
}
source
share