getivan icon

Space Remover - UTF-8 and ANSI

getivan | PRO | 09/17/21 08:45:26 PM UTC | 0 ⭐ | 1780 👁️ | Never ⏰ | []
C++ |

920 B

|

None

|

0 👍

/

0 👎

#include <codecvt>
#include <fstream>
#include <string>
#include <algorithm>
 
using namespace std;
 
int main() {
    //The input file path:
    //you just need to change it's value to access different files 
    string inputFileName = R"(permutations-contact-keyword-export.txt)";
 
    //The output file path:
    //No need to change anything here 
    string outFileName = "updated-" + inputFileName;
 
    //Open the input file
    wifstream inFile(inputFileName);
 
    //Open the output file
    wofstream outFile;
    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::ostreambuf_iterator<wchar_t>(outFile), [](wchar_t c) {
        return c == L' ';
    });
 
    //Close the input file
    inFile.close();
 
    //Close the output file
    outFile.close();
 
    return 0;
}

Comments