wstring UTF8toW(string const &utf8) { wstring wstr; int len=MultiByteToWideChar(CP_UTF8, 0, utf8.c_str(), -1, NULL, 0); if(len>0) { wchar_t *buf=new wchar_t[len]; MultiByteToWideChar(CP_UTF8, 0, utf8.c_str(), -1, buf, len); wstr.assign(buf); delete[] buf; } return wstr; } string WtoUTF8(wstring const &wstr) { string utf8; int len=WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, NULL, 0, 0, 0); if(len>0) { char *buf=new char[len]; WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, buf, len, 0, 0); utf8.assign(buf); delete[] buf; } return utf8; } ... string find_str(WtoUTF8(L"<h2> <span class=\"mw-headline\"> Условие задачи </span></h2>")); size_t found; string lines; while( !input_file.eof() ) { getline( input_file, lines ); //возвращает в lines строку из файла found = lines.find(find_str); //номер позиции содержащей данное выражение //output_file << found << endl; if( found != string::npos ) // если не равно значит есть такое выражение в строке есть { ident = 1; output_file << WtoUTF8(L"<h2>Задача " << numbZad << "</h2>") << endl; lines = find_str; numbZad++; }; }; |