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.

53 lines
1.0 KiB

1 year ago
  1. #include <fstream>
  2. #include <functional>
  3. #include <iostream>
  4. #include <list>
  5. #include <map>
  6. #include <memory>
  7. #include <set>
  8. #include <sstream>
  9. #include <string>
  10. #include <thread>
  11. #include <vector>
  12. //
  13. #include <winsock2.h>
  14. //
  15. #include <Windows.h>
  16. //
  17. #include <stdio.h>
  18. #pragma comment(lib, "ws2_32.lib")
  19. #define PORT 8988
  20. int main(int argc, char *argv[]) {
  21. /**
  22. * @brief
  23. * raw.txt
  24. * ȡraw.txtȫ
  25. * ȥУո񣬻س
  26. * 16ַתɶ
  27. * дraw.bin
  28. */
  29. std::ifstream ifs("raw.txt");
  30. std::string str((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
  31. ifs.close();
  32. std::string str2;
  33. for (auto &c : str) {
  34. if (c == ' ' || c == '\n' || c == '\r') {
  35. continue;
  36. }
  37. str2.push_back(c);
  38. }
  39. std::ofstream ofs("raw.bin", std::ios::binary);
  40. for (size_t i = 0; i < str2.size(); i += 2) {
  41. std::string str3 = str2.substr(i, 2);
  42. char c = (char)std::stoi(str3, nullptr, 16);
  43. ofs.write(&c, 1);
  44. }
  45. ofs.close();
  46. return 0;
  47. }