I ended up in here
How can I get the list of files in a directory using C or C++?
I am afraid none of the codes support UTF-8. I modified Bad's code a bit to accept the UTF-8 directory.
//#define BOOST_FILESYSTEM_VERSION 3
#include <string>
#include <iostream>
#include <boost/filesystem.hpp>
#include <boost/filesystem/detail/utf8_codecvt_facet.hpp>
using namespace std;
using namespace boost::filesystem;
int main()
{
boost::filesystem::detail::utf8_codecvt_facet utf8;
boost::filesystem::path p;
p.assign(u8"C:\\", utf8);
for (auto i = directory_iterator(p); i != directory_iterator(); i++)
{
if (!is_directory(i->path())) //we eliminate directories
{
cout << u8"Fil:" + i-> path().filename().string() << endl;
}
else
{
cout << u8"Dir:" + i-> path().filename().string() << endl;
}
}
}
But I don't know how to get the UTF-8 files output.