Weird string bug

So i was making this program that works with text. It reads 1 line at a time and does stuff with that line ( counts the number of words in it and how many words have fewer symbols than the first one in a line. Then Writes configured line into other file). I had it running good already, made few fixes here and there and it bugged out. i have tried to get back to the state it was working correctly, but have same result. Some Asian language symols appear in my configured text file. How do i fix this? Can anybody help me out?

Here is my program :

#include <string>
#include <iostream>
#include <fstream>
using namespace std;
//--------------------------------------------
const char CDfv[] = "Duom.txt"; //Duomenų failo vardas
const char CRfv[] = "Rezultatai.txt"; //Rezultatų failo vardas
void DarbasSuTekstu(const char CDfv[], const char CRfv[]);
int RastiTrumpŽodžiųSk(string eil, string skyr);
void RastiŽodSk(string eil, string skyr, long & mzs);
int RastiMažŽodSk(string eil, string skyr, long mzs);
//---------------------------------------------
int main()
{
setlocale(LC_ALL, "Lithuanian");
ofstream fout(CRfv);
fout.close();
DarbasSuTekstu(CDfv, CRfv);

return 0;
}
//---------------------------------------------
int RastiTrumpŽodžiųSk(string eil, string skyr)
{
int zpr, zpb=0;
int tzk=0;
string eill= " " + eil + " ";
zpr = eill.find_first_not_of(skyr, zpb);
zpb = eill.find_first_of(skyr, zpr);
int trump=zpb-zpr;
while ((zpr = eill.find_first_not_of(skyr, zpb)) != -1) {
zpb = eill.find_first_of(skyr, zpr);
if (zpb - zpr < trump)
tzk++;
}
return tzk;
}
//---------------------------------------------
void RastiŽodSk(string eil, string skyr, long & mzs)
{
int zpr, zpb=0;
int zs=0;
string eill= " " + eil + " ";
while ((zpr = eill.find_first_not_of(skyr, zpb)) != -1) {
zpb = eill.find_first_of(skyr, zpr);
zs++;
}
if (zs<mzs) mzs=zs;
}
//---------------------------------------------
int RastiMažŽodSk(string eil, string skyr, long mzs)
{
int zpr, zpb=0;
int zs=0;
string eill= " " + eil + " ";
while ((zpr = eill.find_first_not_of(skyr, zpb)) != -1) {
zpb = eill.find_first_of(skyr, zpr);
zs++;
}
if (zs==mzs) return 1;
else return -1;
}
//---------------------------------------------
void DarbasSuTekstu(const char CDfv[], const char CRfv[])
{
long zs=LONG_MAX;
int mzs;
int tzk;
string eil;
string skyr=" ,.!?:;()@#$%^&*_+<>|}{][";
ifstream fin(CDfv);
ofstream fout(CRfv, ios::app);
while (!fin.eof()) {
getline(fin, eil);

tzk=RastiTrumpŽodžiųSk(eil, skyr);
RastiŽodSk(eil, skyr, zs);
fout << eil << " <<(" << tzk << ")" << endl;
}
fin.close();

ifstream finn(CDfv);
while (!finn.eof()) {
getline(finn, eil);
mzs=RastiMažŽodSk(eil, skyr, zs);
if (mzs==1) fout << eil << endl;
}
finn.close();
fout.close();
}
//---------------------------------------------
Oh nwm, my roommate helped me out. Appereantly the text itself was in wrong text code so i used notepad++ to code it to UTF-8 c++ standart.
Topic archived. No new replies allowed.