天天看点

c++ poco读取中文文件路径

#include "stdafx.h"
#include <string>
 #include "Poco/DirectoryIterator.h"
 #include "Poco/SortedDirectoryIterator.h"
 #include "Poco/RecursiveDirectoryIterator.h"
  using namespace Poco;
 using namespace std;;Poco::Path path()
 {
     string strPath = Path::current();
     Path p(strPath);
     p.pushDirectory("DirectoryIteratorsTest");
     return p;
 }
 void TestDir()
 {
     Path p = path();
     DirectoryIterator dirIterator(p);
     DirectoryIterator end;
     std::vector<std::string> result;
     std::string file;
     while (dirIterator != end)
     {//这里需要将utf8转为gb2312
         file = UTF8ToGB2312(dirIterator->path());
         ++dirIterator;
         result.push_back(file);
     }
 }int _tmain(int argc, _TCHAR* argv[])
 {
     TestDir();
     return 0;
 }      

继续阅读