QFTP SERV-U(UTF-8)中文文件以及中文文件夹乱码问题
XoAoX 2011-04-18 03:53:47 前段时间被wxftp和qftp搞死了
之前用mfc写了基于dialog的客户端
不满意,要求像360那么花哨的
害的我分别用wxWidgets和qt重写了两遍
到现在我还一遗留问题
----------------------------------------
serv-u(已设置 "对所有已收发的文件和路径名使用UTF-8编码")
qt环境下
现在下行解码没问题.就是上行的时候命令用serv-u日志看都是乱码,不能正确解释返回错误
获取文件列表(没问题)
-----------------------------------------------------
void DialogSynchor::listInfo ( const QUrlInfo & i )
{
QString name = i.name();
QByteArray arr = name.toLatin1();
name = QString::fromUtf8(arr);
FtpFileInfoModel ftpFile;
if(i.isDir()){
if("." == name || ".." == name || ftpListCommandTemp == name)return;
ftpFile.setDir(true);
ftpFile.setName(name);
}else{
ftpFile.setLength(i.size());
ftpFile.setDir(false);
ftpFile.setName(name);
}
ftpListTemp.push_back(ftpFile);
}
-----------------------------------------------
下载文件(有问题)
--------------------------------------------------
int DialogSynchor::doFtpDownloadFile(QString localPath,QString remotePath)
{
ftpCommandFinished = false;
ftpReadyRead = false;
ftpDownloadLocalPath = localPath;
// char *tmp = remotePath.toLocal8Bit().data();
// std::string str = remotePath.toStdString();
// QTextCodec *codec = QTextCodec::codecForLocale();
// //the text is unicode so it should cover from unicode to chinese
// char *sec = (codec->fromUnicode(remotePath)).data();
// printf("sec %s\n",sec);
// QByteArray arr = remotePath.toLatin1();
// QString remotePathTemp = QString::fromAscii(arr);
ftpDownloadLocalFile = new QFile(localPath);
if (!ftpDownloadLocalFile->open(QIODevice::WriteOnly)) {
return eonx_error::file_cannot_write;
}
// pFtp->get(remotePath,ftpDownloadLocalFile);
// QString ansiFilePath = QString::fromLocal8Bit(remotePath.toLatin1());
// pFtp->get(ansiFilePath,ftpDownloadLocalFile);
pFtp->get(remotePath,ftpDownloadLocalFile);
return eonx_error::noerror;
}
====================================================
求解