#include #include #include #include #include #include int main( int argc, char *args[] ){ unsigned char *fcontents = NULL; std::fstream *charfile = new std::fstream( reinterpret_cast("./unicodechars.txt"), std::ios::in ); if ( charfile->fail() ){ std::cerr << "Failed to open file\n"; exit( EXIT_FAILURE ); } charfile->seekg( 0, std::ios::end ); ssize_t fsize = static_cast(charfile->tellg()); charfile->seekg( 0, std::ios::beg ); fcontents = static_cast(calloc(fsize, sizeof(unsigned char))); if ( fcontents == NULL ){ std::cerr << "calloc failed\n"; exit( EXIT_FAILURE ); } charfile->read( reinterpret_cast(fcontents), fsize ); charfile->close(); delete charfile; fsize = 0; std::string *uchars = new std::string( "" ); uchars->assign( reinterpret_cast(fcontents) ); free( fcontents ); std::cout << uchars->c_str() << "\n"; delete uchars; exit( EXIT_SUCCESS ); }