Open zhjr2019 opened 1 year ago
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.
But when the file name contains Chinese, calling the workbook.load() function does indeed result in an error: std::range_error。 Upon checking the source code, it was found that the error occurred at the following location:xlocbuf _Throw(range_error("bad conversion")). If possible, please fix it!Thank you.
As discussed in issue https://github.com/tfussell/xlnt/issues/748, this repo has been unmaintained for several years.
In order to continue this great project started by tfussell, we have created a new repo to support further development by the community.
Furthermore, specifically regarding this issue, I have changed the way Unicode conversions are done in Pull Request https://github.com/xlnt-community/xlnt/pull/29. So @szfbit could you please clone our new fork, build XLNT using the newest commit of our master
branch, and tell me if it solved your problem? If not, feel free to open an issue in our new repo with a detailed example that causes the issue you described. Thank you!
Hello, thank you for your reply! My problem has been solved now, just change the encoding format of the source code from GBK to UTF8. I will continue to monitor the new code repository, keep up the good ! @doomlaur
error:bad conversion
Do Excel files not support Chinese path?