Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- wifstream myfile(L"file.txt");
- wofstream dfresult(L"convertedfile.txt");
- if (myfile)
- {
- string hexadecimal;
- int rastas(0);
- int spausdinti(1);
- unsigned char sim_from_text;
- converter change_simbol;
- while (getline(myfile, line))
- {
- rastas = 0;
- spausdinti = 1;;
- for (int i = 0; i < line.length(); i++)
- {
- vector <string> utf_file;
- sim_from_text = line[i];
- int symbol_value = int(sim_from_text);
- //cout << "numFromStringElement:" << symbol_value << endl;
- if (symbol_value > 127 && symbol_value < 256)
- {
- spausdinti = 0;
- for (itr = table.begin(); itr != table.end(); ++itr)
- {
- if (itr->first == symbol_value)
- {
- hexadecimal = itr->second;
- rastas = 1;
- }
- }
- if (rastas)
- {
- int decimal_converted = stoi(hexadecimal, 0, 16);
- //cout << "New sim value: " << decimal_converted << endl;
- change_simbol.fillDec(decimal_converted);
- change_simbol.decToBinary();
- shex = change_simbol.getHex();
- change_simbol.getBinUtf();
- change_simbol.getUtf(utf_file);
- wchar_t output = strtol(hexadecimal.c_str(), NULL, 16);
- dfresult.imbue(utf8_locale);
- dfresult << output;
- }
- rastas = 0;
- }
- else
- {
- dfresult << line[i];
- }
- }
- dfresult << endl;
- }
- }
- else cout << "No txt file by the name file.txt";
- myfile.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement