opened
sametdev
username_0
I want dump folder/file names in a json file.. With utf8 chars. like indian/turkish/german/finland chars etc. But i get crashs when i add some file with utf8 format.

I'm using VS2019 Preview currently. Also im using the lastest version of json.hpp

The code:
`
void read_dir(string folder)
{
    json jdata;
    string search_path = folder + "/*.*";
    WIN32_FIND_DATA fd;

    std::wstring stemp = utils::s2ws(search_path);
    LPCWSTR result = stemp.c_str();

    HANDLE hFind = ::FindFirstFile(result, &fd);
    if (hFind != INVALID_HANDLE_VALUE) {
        do {
            json j;
            string name = "";
            //Eger listedeki bir dosya ise
            if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
                wstring ws(fd.cFileName);
                string str(ws.begin(), ws.end());
                name = str.c_str();
                j["object"]["type"] = "File";
                j["object"]["name"] = name; //put the name of file anyways.. i need an converter or something else
            }
            //Eger listedeki bir klasor ise (gizli degilse)
            if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) && (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
            {
                wstring ws(fd.cFileName);
                string str(ws.begin(), ws.end());
                name = str.c_str();
                j["object"]["type"] = "Folder";
                j["object"]["name"] = name; //put the name of file anyways.. i need an converter or something else
            }
            jdata.push_back(j);
        } while (::FindNextFile(hFind, &fd));
        ::FindClose(hFind);

        std::ofstream o("dump.json");
        o << std::setw(4) << jdata << std::endl;

    }
}
`

https://prnt.sc/sdlaet
UTF8 
issue
created
nlohmann
username_1
The error says that the input is not valid UTF-8. From your code, it seems that you convert a `std::wstring` to a `std::string`. I assume the `std::wstring` is UTF-16 encoded, and just casting it into a `std::string` does not change the encoding to UTF-8. The library only supports UTF-8.
comment
created
sametdev
username_0
I just make a function for delete utf8 characters :D its look better for now.. Thanks username_1.
comment
closed
sametdev
username_0
issue