Greetings, everyone. In my program, I read an input file encoded in utf-8 and I want to convert the data into std::wstring. My working platform is 32-bit Linux, which means wchar_t is commonly 32-bit. My idea is to use mbsrtwcs to convert the multi-byte into wchar_t. However, mbsrtwcs always failed whenever invoked.
Here is the code. In the code, I just convert only one Chinese character. The compilation works fine but the program complains "Invalid or incomplete multi-byte or wide character" when mbsrtowcs is invoked. I am not quite sure whether mbsrtowcs is a correct choice. Any one could help me? Thanks in advance.
mbsrtowcs() doesn't just convert a UTF-8 string to a wide string. It converts a multibyte string to a wide string. The format of the accepted string depends on the system locale or on a previous call to setlocale().