1. Как определить в какой кодировке текстовый файл (CP1251, UTF-8 ) для последуещего открытия в textEdit?
2. Как открыть текстовый файл в любой кодировке ((CP1251, UTF-8 ) и сохранить в ней же?
ps у меня система в utf8
QString auto_detect (const QString &filename, bool iconvret )
{
QString com_enca("enca");
if (iconvret) com_enca += " -i '"+filename+"'";
else com_enca += " -e '"+filename+"'";
FILE *enca = popen( com_enca.local8Bit(), "r");
char outstr[80];
fgets(outstr, 80, enca);
pclose(enca);
QString cp( outstr );
cp = cp.stripWhiteSpace();
int pozslash;
if ( (pozslash = cp.find( '/' )) != -1 )
cp = cp.left( pozslash );
return cp;
}