Advertisement
getivan

Space Remover - UTF-8 and ANSI

Sep 17th, 2021
1,345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. #include <codecvt>
  2. #include <fstream>
  3. #include <string>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9.     //The input file path:
  10.     //you just need to change it's value to access different files
  11.     string inputFileName = R"(permutations-contact-keyword-export.txt)";
  12.  
  13.     //The output file path:
  14.     //No need to change anything here
  15.     string outFileName = "updated-" + inputFileName;
  16.  
  17.     //Open the input file
  18.     wifstream inFile(inputFileName);
  19.  
  20.     //Open the output file
  21.     wofstream outFile;
  22.     outFile.open(outFileName, std::ios::binary);
  23.  
  24.     //Copy from input file to output file, removing spaces
  25.     std::remove_copy_if(std::istreambuf_iterator<wchar_t>(inFile), {}, std::ostreambuf_iterator<wchar_t>(outFile), [](wchar_t c) {
  26.         return c == L' ';
  27.     });
  28.  
  29.     //Close the input file
  30.     inFile.close();
  31.  
  32.     //Close the output file
  33.     outFile.close();
  34.  
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement