Compare commits
4 Commits
86f40396b7
...
0.2_workin
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fda084cd3c | ||
|
|
292a334abe | ||
|
|
5f2e186ae1 | ||
|
|
c6654fbcc8 |
@@ -1,54 +0,0 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
if (argc < 3) {
|
||||
std::cerr << "Usage: " << argv[0] << " <inputfile> <outputfile>\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::ifstream infile(argv[1], std::ios::binary);
|
||||
if (!infile) {
|
||||
std::cerr << "Error opening input file.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::vector<char> buffer((std::istreambuf_iterator<char>(infile)),
|
||||
std::istreambuf_iterator<char>());
|
||||
infile.close();
|
||||
|
||||
// Step 1: Replace ASCII 171 with 189
|
||||
/*
|
||||
for (auto& c : buffer) {
|
||||
if ((unsigned char)c == 171) {
|
||||
c = (char)189;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// Step 2: Remove form feed (ASCII 12) from the last 16 bytes only
|
||||
size_t size = buffer.size();
|
||||
size_t start = (size >= 16) ? size - 16 : 0;
|
||||
for (size_t i = start; i < size; ) {
|
||||
if ((unsigned char)buffer[i] == 12) {
|
||||
buffer.erase(buffer.begin() + i);
|
||||
size--; // update size since vector shrinks
|
||||
}
|
||||
else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
std::ofstream outfile(argv[2], std::ios::binary);
|
||||
if (!outfile) {
|
||||
std::cerr << "Error opening output file.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
outfile.write(buffer.data(), buffer.size());
|
||||
outfile.close();
|
||||
|
||||
//std::cout << "Processing complete. Output written to " << argv[2] << "\n";
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user