I'm so confused it is not funny.
Using VS2012, console project, the character set in the configuration is set to unicode.
The file is in UTF8.
I'm loading it with std::ifstream
into a vector of std::string
. The BOM is also taken care of and the bytes shown in the debugger match those in the file.
How on earth do I print this string to the console?
This line printf( "%s\n", line.c_str() );
only prints garbage.
Nothing special. Here is the complete code:
std::string line;
std::ifstream file( fullpath );
if( file == NULL )
{
printf( "Error opening file\n" );
return;
}
file.seekg( 3, file.beg );
while( std::getline( file, line ) )
{
printf( "%s\n", line.c_str() );
}