H
himanshu.garg
Hello,
I have a std c++ program that uses char/string everywhere and
works well with single byte characters.
The program depends on what a char is so to make it work for
utf-8 I assume I just have to do the following :-
replace char by wchar_t
set the locale to unicode/utf-8 using
locale::global(loc("<locale name>"));
The following program on my system outputs :-
C
2
int main()
{
std::locale loc;
std::cout << loc.name() << std::endl;
std::cout << sizeof(wchar_t) << std::endl;
}
Is there a way I can find out the name of available locales for
use with the locale constructor? Will my approach work? If I read a
utf-8 file will wchar_t store the character code for the corresponding
characters?
Thank You,
Himanshu
I have a std c++ program that uses char/string everywhere and
works well with single byte characters.
The program depends on what a char is so to make it work for
utf-8 I assume I just have to do the following :-
replace char by wchar_t
set the locale to unicode/utf-8 using
locale::global(loc("<locale name>"));
The following program on my system outputs :-
C
2
int main()
{
std::locale loc;
std::cout << loc.name() << std::endl;
std::cout << sizeof(wchar_t) << std::endl;
}
Is there a way I can find out the name of available locales for
use with the locale constructor? Will my approach work? If I read a
utf-8 file will wchar_t store the character code for the corresponding
characters?
Thank You,
Himanshu