E
E
Evgeny Petryaev2019-05-27 12:46:12
C++ / C#
Evgeny Petryaev, 2019-05-27 12:46:12

Weird coding?

In general, I copied the text from one file to another with my hands, one file is read normally, and the second with characters of an incomprehensible encoding5cebb1d210096715922228.jpeg

setlocale(LC_ALL, "Russian");
  SetConsoleOutputCP(1251);

Here is a piece of the program
setlocale(LC_ALL, "Russian");
  //setlocale(LC_ALL, "");
  std::vector<Type> *vector2 = new std::vector<Type>();
  std::ifstream fin("playlist2.m3u8");
  if (!fin.is_open())
  {
    std::cout << "File not found!" << std::endl;
  }
  Type elem;
  std::string str="";
  while (std::getline(fin,elem.filename))
  {
    std::getline(fin, str);
    elem.length = std::stof(str);
    vector2->push_back(elem);
  }
  fin.close();
  std::cout << (*vector2)[0].filename<<std::endl<< (*vector2)[0].length << std::endl;

  setlocale(LC_ALL, "ru_RU.UTF-8");
  std::vector<Type> *vector3 = new std::vector<Type>();
  std::ifstream fin2("playlist3.m3u8");
  if (!fin2.is_open())
  {
    std::cout << "File not found!" << std::endl;
  }
  while (std::getline(fin2, elem.filename))
  {
    std::getline(fin2, str);
    elem.length = std::stof(str);
    vector3->push_back(elem);
  }
  fin2.close();

Everything is ok in the console, but utf-8 is written in vector3 and it needs to be readable

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Evgeny Petryaev, 2019-05-27
@Gremlin92

Converted to ANSI with notepad++

A
Alexander, 2019-05-27
@NeiroNx

This is UTF-8 output in CP-1251

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question