You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.0 KiB
54 lines
1.0 KiB
|
|
#include <fstream>
|
|
#include <functional>
|
|
#include <iostream>
|
|
#include <list>
|
|
#include <map>
|
|
#include <memory>
|
|
#include <set>
|
|
#include <sstream>
|
|
#include <string>
|
|
#include <thread>
|
|
#include <vector>
|
|
//
|
|
#include <winsock2.h>
|
|
//
|
|
#include <Windows.h>
|
|
//
|
|
#include <stdio.h>
|
|
|
|
#pragma comment(lib, "ws2_32.lib")
|
|
#define PORT 8988
|
|
|
|
int main(int argc, char *argv[]) {
|
|
/**
|
|
* @brief
|
|
* 打开raw.txt
|
|
* 读取raw.txt全部内容
|
|
* 去掉换行,空格,回车
|
|
* 将16进制字符串转换成二进制
|
|
* 写入raw.bin
|
|
*/
|
|
|
|
std::ifstream ifs("raw.txt");
|
|
std::string str((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
|
|
ifs.close();
|
|
|
|
std::string str2;
|
|
for (auto &c : str) {
|
|
if (c == ' ' || c == '\n' || c == '\r') {
|
|
continue;
|
|
}
|
|
str2.push_back(c);
|
|
}
|
|
|
|
std::ofstream ofs("raw.bin", std::ios::binary);
|
|
for (size_t i = 0; i < str2.size(); i += 2) {
|
|
std::string str3 = str2.substr(i, 2);
|
|
char c = (char)std::stoi(str3, nullptr, 16);
|
|
ofs.write(&c, 1);
|
|
}
|
|
ofs.close();
|
|
|
|
return 0;
|
|
}
|