C++ 目标多字节代码页C+;中的Unicode字符没有映射+;

C++ 目标多字节代码页C+;中的Unicode字符没有映射+;,c++,C++,我的代码过去工作得很好,我只是实现了一些线程,现在它坏了,我发现问题出在我的变量image_路径中,这些代码块专门用于: //Global vars namespace fs = std::filesystem; std::vector<fs::path> image_path; //Vector of paths in which to store all paths to the images void散列函数(int起点) { int计数器=0; 尝试 { long int

我的代码过去工作得很好,我只是实现了一些线程,现在它坏了,我发现问题出在我的变量image_路径中,这些代码块专门用于:

//Global vars
namespace fs = std::filesystem;
std::vector<fs::path> image_path; //Vector of paths in which to store all paths to the images
void散列函数(int起点)
{
int计数器=0;
尝试
{
long int hasher=1;//存储图像的哈希值
std::无序的_-map::iterator it;//hashmap的迭代器
for(int i=起点;istd::cout解决方案:不要使用windows附带的愚蠢的官方文件系统库,只需使用boost版本。它速度更快,bug更少

你确定错误与utf8有关吗?第59条路径是什么?你能使用简单的UTF-8库吗?注意:永远不要调用互斥锁的
lock
unlock
你自己吗如果可以避免,请使用RAII锁,如
std::lock_guard
,以确保在引发异常以防止死锁时释放这些锁。@spartygw路径是相同的,我尝试了不同的路径、其他图像等,所有这些都会在同一位置导致错误。@Mgetz这不是问题的重点,但我会记住这一点
for (const auto& el : fs::recursive_directory_iterator(path, fs::directory_options::skip_permission_denied))
    {
        if (is_directory(el) != true)
        {
            if ((el.path().extension().compare(".jpg")) == 0 || (el.path().extension().compare(".jpeg")) == 0 || (el.path().extension().compare(".png")) == 0)
            {
                image_path.push_back(el.path());
                count++;
            }
        }
    }
void hash_function(int start_point)
{
    int counter = 0;
    try
    {
    long int hasher = 1; //Store the hashed value of an image
    std::unordered_map<long int, int>::iterator it; //Iterator for hashmap
    for (int i = start_point; i < image_path.size(); i += THREADS)
    {
        std::cout << "Count = " << counter << "\n";
        cv::Mat processing_image = cv::imread(image_path[i].string(), cv::IMREAD_COLOR); //had to change from image_path[i].u8string() to .string() due to a library update
        hasher = 1; //Must reset hasher to 1
        counter++;
        if (processing_image.dims != 0)
        {
            cv::Mat gray_image; //Define gray image to create gray scale images

            cv::cvtColor(processing_image, gray_image, cv::COLOR_BGR2GRAY);
            cv::resize(gray_image, gray_image, SIZE);
            for (int j = 0; j < (gray_image.cols - 1); j++)
            {
                for (int l = 0; l < gray_image.rows; l++)
                {
                    hasher = hasher + gray_image.at<uchar>(l, j); //will leave it like this for now, seems to work
                }
                hasher = hasher * hasher; //just to make hasher even more unique
            }
            //Mutex this bad boi
            mtx.lock();
            //Extremely important things here 
            if (hashmap.empty() == true)
            {
                hashmap[hasher] = i;
                //Add hash value to each path (path is a number of the position of a path in the vector image_path)
            }
            else
            {
                //Solved the counting error by simply skipping the already in check
                it = hashmap.find(hasher);
                if (it != hashmap.end())
                {
                    repeated.push_back(image_path[it->second]);
                    count++;
                    repeated.push_back(image_path[i]);
                    count++;
                }
                else
                {
                    //Add hash value to each path (path is a number of the position of a path in the vector image_path)
                    hashmap[hasher] = i;
                }
            
            }
            mtx.unlock();
            //No more important thingys :D
        }else
        {
            hasher = -1;
        }
    }
    }catch(std::exception & e)
    {
        std::cout << e.what();
        exit(0);
    }
}