For a few day I am trying to solve an ecoding issue in my C++ code. I have the following content of a txt file (saved utf-8): "québécois". (and I have only read rights over the file). I am reading it with ReadFile function in a std::string variable.
The first surpize is that the strContnet is not "québécois", but "québécois". (double encoded ??) Why?
How cand I read it's content in a std::string variable in order to obtaint "québécois" (utf8 to ansi?)
Until now I have two ways to get somewere close to what I want but none satisfie me enought. 1. Convert from: std::string to std::wstring (using MultiByteToWideChar) create a CString from the wstring use CT2CA to obtaint a new std::string and finally use agin MultiByteToWideChar for a final std::wstring containint "québécois"
I thing the method is unsafe and not verry smart and I have a wstring not string.
- I found this article: How to convert from UTF-8 to ANSI using standard c++ And if I use utf8_to_string function twice I obtain what I want, but still I am not sure if it's the wright way.
Can anybody help me with a solution for this issue?