Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. wifstream myfile(L"file.txt");
  2. wofstream dfresult(L"convertedfile.txt");
  3. if (myfile)
  4. {
  5. string hexadecimal;
  6. int rastas(0);
  7. int spausdinti(1);
  8. unsigned char sim_from_text;
  9. converter change_simbol;
  10. while (getline(myfile, line))
  11. {
  12. rastas = 0;
  13. spausdinti = 1;;
  14. for (int i = 0; i < line.length(); i++)
  15. {
  16. vector <string> utf_file;
  17. sim_from_text = line[i];
  18. int symbol_value = int(sim_from_text);
  19. //cout << "numFromStringElement:" << symbol_value << endl;
  20. if (symbol_value > 127 && symbol_value < 256)
  21. {
  22. spausdinti = 0;
  23. for (itr = table.begin(); itr != table.end(); ++itr)
  24. {
  25. if (itr->first == symbol_value)
  26. {
  27. hexadecimal = itr->second;
  28. rastas = 1;
  29. }
  30. }
  31. if (rastas)
  32. {
  33. int decimal_converted = stoi(hexadecimal, 0, 16);
  34. //cout << "New sim value: " << decimal_converted << endl;
  35. change_simbol.fillDec(decimal_converted);
  36. change_simbol.decToBinary();
  37. shex = change_simbol.getHex();
  38. change_simbol.getBinUtf();
  39. change_simbol.getUtf(utf_file);
  40. wchar_t output = strtol(hexadecimal.c_str(), NULL, 16);
  41. dfresult.imbue(utf8_locale);
  42. dfresult << output;
  43. }
  44. rastas = 0;
  45. }
  46. else
  47. {
  48. dfresult << line[i];
  49. }
  50.  
  51. }
  52. dfresult << endl;
  53. }
  54.  
  55. }
  56. else cout << "No txt file by the name file.txt";
  57. myfile.close();
  58.  
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement