First of all, I'm sorry for my English.
I'm trying to change the locale in a C++ program to put accented letters in a wchar_t variables and viewed it on terminal, as here reported:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
#include "iostream"
#include "locale"
using namespace std;
int main()
{
setlocale (LC_ALL," ");
locale loc;
loc= locale("INVARIANT");
wcin.imbue(loc);
wcout.imbue(loc);
cout<<"locale : "<< loc.name() <<endl;
wchar_t a;
wcin >> a ;
wcout << a;
}
|
The cout is: " terminate called after throwing an instance of 'std::runtime_error'
what(): locale::facet::_S_create_c_locale name not valid
Annullato (core dump creato) "
If I change the arguments of setlocale and locale in, respectively, " NULL" 'n "POSIX", the program is compiled and cout is:
" locale : C
à"
the "à" is variable of wcin, but there isn't wcout.
How can i resolve it?
P.S. I use Korora 64-bit on xfce, xfce terminal with UTF-8 like charset