mirror of
https://github.com/jmcnamara/libxlsxwriter.git
synced 2026-05-15 14:15:54 -06:00
[GH-ISSUE #104] MultiByteToWideChar breaks file name #85
Labels
No labels
awaiting user feedback
bug
cmake
cmake
docs
feature request
in progress
long term
medium term
medium term
pull-request
question
question
ready to close
short term
under investigation
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/libxlsxwriter#85
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kubajar on GitHub (Apr 25, 2017).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/104
Originally assigned to: @jmcnamara on GitHub.
lxw_workbook *workbook = workbook_new("filename.xlsx"); saves f instead of filename.xlsx.
Small fix in packager.c in line 62 fixes filename for me (program saves filename.xlsx): .
tested on latest trunk + Visual Studio 2010.
have a nice day.
@jmcnamara commented on GitHub (Apr 26, 2017):
I haven't had any other bug reports of that nature and that Windows code is used quite a lot.
Also, I don't see any issue with MSVC 2015. Is this just an issue with MSVC 2010.
@utelle, as the resident Windows expert, could you have a quick look at this to see if there is an issue?
@utelle commented on GitHub (Apr 26, 2017):
I use
libxlsxwriterin a 32-bit Windows application compiled with MSVC 2010. Up to now neither the users of my application nor I myself had any issues with it.However, it might depend on compiler settings. The filename parameter is passed as
const void*. Down the line this is casted toLPCTSTRin functionwin32_open64_file_func(iowin32.c).The type
LPCTSTRis defined asSo, if the symbol
_UNICODEis not defined, this would result in a cast toconst char*. And this could indeed explain the problem @kubajar experienced.The
premake4script coming withlibxlsxwriterdefines theUnicodeflag. However, ifpremake4was not used to generate the build files, theUnicodeflag might be missing.@kubajar commented on GitHub (Apr 26, 2017):
/D "_UNICODE" /D "UNICODE"is present in command line. I used cmake for makefile generation, maybe there is some issue. Tested both Unicode and multibyte character sets. It must be something unicode-specific, like in code (unicode character set):@utelle commented on GitHub (Apr 26, 2017):
You will have to verify that all
libxlsxwritersource files are really compiled with the Unicode symbols.libxlsxwriteralways converts the filename to wide string. Thus, for your filenamefilename.xlsxthe memory contains the bytes'f'followed by'\0'followed by'i'followed by'\0'and so on. If casted toconst char*you therefore get the filenamefdue to the zero byte.Obviously the wrong cast is applied in your case.
I would recommend to use the Visual Studio debugger to step through the relevant code and find out, where exactly the wrong cast is applied.
@kubajar commented on GitHub (Apr 26, 2017):
I found the problem - I compilled zlib and zlibwapi as multibyte. I switched character set to unicode and all works perfectly. Thank You for great software and help. Have a nice day.
@jmcnamara commented on GitHub (Apr 26, 2017):
@kubajar Thanks for the update and @utelle thanks for the help. Closing.
@kubajar for reference could you add the commands you used to build with cmake.