A
amandeep.bhatia1
Hello Friends,
I am working on a project to support internationalization for a
existing project.
While supporting UTF-8 I am facing a problem , while doing POC.
I have a C string
which I have declared as
const char* utf8buf = "Bienvenue à l'anglais ";
I want to supporint UTF-8 for I/0 and wchat_t strings for internal
manipulations. So I am setting locale to setlocale(LC_CTYPE,"UTF8");
before I start with the main code for string handling.
Then I am using MultiByteToWideChar (using codepage as CP_UTF8) to
convert it to wstring.
Then again before output I am converting the string back to UTF8 format
using WideCharToMultiByte.
The problem is after getting back the UTF8 string after above
conversion , when I am printing the string, I am getting "Bienvenue
l'anglais" as output , which is not same as the input utfbuf.
Does C++ string class support UTF-8 ?
In real environment , we are planning to get the UTF8 strings from
MySQL database.
How can I correct this?
Is there any other way in C/C++ to represent UTF8 strings?
Thanks,
Aman
I am working on a project to support internationalization for a
existing project.
While supporting UTF-8 I am facing a problem , while doing POC.
I have a C string
which I have declared as
const char* utf8buf = "Bienvenue à l'anglais ";
I want to supporint UTF-8 for I/0 and wchat_t strings for internal
manipulations. So I am setting locale to setlocale(LC_CTYPE,"UTF8");
before I start with the main code for string handling.
Then I am using MultiByteToWideChar (using codepage as CP_UTF8) to
convert it to wstring.
Then again before output I am converting the string back to UTF8 format
using WideCharToMultiByte.
The problem is after getting back the UTF8 string after above
conversion , when I am printing the string, I am getting "Bienvenue
l'anglais" as output , which is not same as the input utfbuf.
Does C++ string class support UTF-8 ?
In real environment , we are planning to get the UTF8 strings from
MySQL database.
How can I correct this?
Is there any other way in C/C++ to represent UTF8 strings?
Thanks,
Aman