Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do Excel files not support Chinese path? #724

Open
zhjr2019 opened this issue Dec 4, 2023 · 1 comment
Open

Do Excel files not support Chinese path? #724

zhjr2019 opened this issue Dec 4, 2023 · 1 comment

Comments

@zhjr2019
Copy link

zhjr2019 commented Dec 4, 2023

#include <xlnt/xlnt.hpp>
int main()
{
    xlnt::workbook fault_workbook;
    std::string fault_excel_file = "F:\\中国\\中国20220823224554.xlsx";
    fault_workbook.load(fault_excel_file);
    return 0;
}

error:bad conversion

Do Excel files not support Chinese path?

@doomlaur
Copy link
Contributor

I'm not sure which version of xlnt you are using, but if you're using version 1.5.0, you should maybe use the latest commit from the master branch instead. The issue you describe has been fixed by pull request #607 by using std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>>. As explained on cppreference, the previous code converted UTF-8 to UCS-2 (the predecessor of UTF-16) on Windows, causing Unicode code points that need 4 bytes (like emojis) to fail. Unfortunately, the fix has not been released in a stable version of XLNT yet, but at least in my experience, the master branch seems to be even more stable than version 1.5.0, as it contains many bugfixes - so you should definitely give it a go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants