Exception "Unknown error" thrown reading and writing certain files
jenskalusniak opened this issue · 5 comments
An exception "Unknown error" is thrown, when trying to read from (or writing to) a file, which name includes mutated vowels/umlauts like ä,ö,ü. Maybe even other characters, but those are the ones I can test it with.
This happens when I use lib57Format in our software, but the error also occurs in CloudCompare.
OS: Windows 10 (latest)
Windows SDK: 10.0.18362.0
Compiler: Visual Studio 2019 (v142)
libE57Format Version 2.2.0
This should be handled by this commit from this this issue.
The last comment there suggests that maybe the file name being passed in from the application side isn't UTF-8. Is that a possibility?
Not totally helpful since I can't test it on Windows - and this code is Windows-specific - but files like open me äöü.e57
work for me on macOS.
Are you sure the "Unknown error" is a result of the file name? Have you set breakpoints to see what's causing an "Unknown error"?
In CloudCompare, we are using QSting::toStdString to pass the filemane to e57::ImageFile.
According to Qt documentation:
The Unicode data is converted into 8-bit characters using the toUtf8() function.
With the latest version of CC (2.12), I can successfully load files with local characters:
F:\répertoire cheloû\manitou éééééé - Copie.e57
@dgirardeau:
I can confirm that it works just fine with CC 2.12alpha, but not with the latest stable version 2.11.3. Saving and opening e57 files results in an error.
Is the use of the toUtf8() function a new thing in CC 2.12?
@asmaloney:
I "undid" the changes from the commit you mentioned and it works without any errors. Also the GNUC case works just fine on (my) Windows.
As for the _MSC_VER case: The conversion seems to cause an error in the Windows C Runtime Library (ucrtbase.dll) according to the Windows Event Manager.
Unfortunatly I cant access my work computer the next couple of days to do further checking.
@jenskalusniak Yes probably. See CloudCompare/CloudCompare@b683f43
For future readers - I added tests for reading file names with umlauts & they pass.
The main thing that is not obvious is if you are including UTF-8 characters directly in a source file (as I do in the tests), you need to set the utf-8
flag on MSVC:
target_compile_options( testE57
PUBLIC
$<$<C_COMPILER_ID:MSVC>:/utf-8>
$<$<CXX_COMPILER_ID:MSVC>:/utf-8>
)