I used the following on ASCII file:
#include <fstream>
#include <streambuf>
#include <string>
#include <cerrno>
std::string get_file_contents(const char *filename)
{
std::ifstream in(filename, std::ios::in | std::ios::binary);
if (in)
{
return(std::string((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>()));
}
throw(errno);
}
I want to confirm if it will work for a UTF-8 file as well into std::string or are there any special settings?