Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cassert>
- #include <codecvt>
- #include <fstream>
- #include <string>
- #include <algorithm>
- using namespace std;
- int main() {
- //The input file:
- //you just need to change it's value to access different files
- string inputFileName = R"(permutations-contact-keyword-export.txt)";
- //The output file:
- //No need to change anything here
- string outFileName = "updated-" + inputFileName;
- //Delete the old file with the same name
- remove(outFileName.c_str());
- //Open the file that we need to modify
- wifstream inFile(inputFileName);
- std::locale inLoc(std::locale(inFile.getloc(), new std::codecvt_utf16<wchar_t, 0x10ffff, std::little_endian>));
- inFile.imbue(inLoc);
- //Open the output file
- wofstream outFile;
- std::locale outLoc(std::locale(std::cout.getloc(), new std::codecvt_utf16<wchar_t, 0x10ffff, std::little_endian>));
- outFile.imbue(outLoc);
- outFile.open(outFileName, std::ios::binary);
- //Copy from input file to output file, removing spaces
- std::remove_copy_if(std::istreambuf_iterator<wchar_t>(inFile), std::istreambuf_iterator<wchar_t>(), std::ostreambuf_iterator<wchar_t>(outFile), [](wchar_t c) { return c == L' '; });
- //Close input file
- inFile.close();
- //Close the output file
- outFile.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement