Ok so I'm trying to read a json formatted text file with accents (French), under W8, using C++ (Visual Studio 2012 Express).
This is the file:
{"products": [{"id": 125, "label": "Billél"}, {"id": 4, "label": "Rùbin"}]}
One line, encoded in UTF-8 (no BOM), saved as D:/p.txt
This is the reading code in C++:
std::ifstream in("D:/p.txt", std::ios::binary | std::ios::in);
std::string content( (std::istreambuf_iterator<char>(in) ), (std::istreambuf_iterator<char>() ) );
The output I get:
{"products": [{"id": 125, "label": "Bill├®l"}, {"id": 4, "label": "R├╣bin"}]}
Tried using CharToOemA :
{"products": [{"id": 125, "label": "Billél"}, {"id": 4, "label": "Rùbin"}]}
My codepage should allow me to display accents in the console (I tried echoing such accents which yielded a perfectly good display). Both the input and output codepages for my c++ console is CP850 (IBM Internatinal Latin-1).
How can I get my code to output a correct accent in the console? I would ultimately need a cross-platform solution if possible.