Project

General

Profile

Bug #11631

Rawspeed: Opening files with non-ASCII filename fails on Windows

Added by Roman Lebedev almost 2 years ago. Updated almost 2 years ago.

Status:
Fixed
Priority:
Low
Assignee:
-
Category:
-
Target version:
Start date:
05/30/2017
Due date:
% Done:

100%

Affected Version:
git master branch
System:
Windows
bitness:
64-bit
hardware architecture:
amd64/x86

Description

Same as #11630
I did not test, but i'm also pretty sure that is still the case


Related issues

Related to darktable - Bug #11630: Opening ICC files with non-ASCII filename fails on Windows Fixed 05/30/2017

Associated revisions

Revision 4aea69e3
Added by Roman Lebedev almost 2 years ago

RawSpeed submodule update: oss-fuzz, non-ASCII filenames,

Fixes #11631.

History

#1 Updated by Roman Lebedev almost 2 years ago

  • Related to Bug #11630: Opening ICC files with non-ASCII filename fails on Windows added

#2 Updated by Tobias Ellinghaus almost 2 years ago

  • Status changed from New to Triaged
  • % Done changed from 0 to 20

Indeed, I just tried and it fails. Good thing we can fix rs ourselves. :-)

#3 Updated by Roman Lebedev almost 2 years ago

Yes :)
I still haven't fixed it yet because i really would love to see how it is handled in some other places, and then pick the best and smallest fix.

#4 Updated by Tobias Ellinghaus almost 2 years ago

From seeing what is suggested or used elsewhere I'd say the proper fix would be an #ifdef to use _wfopen() on Windows and fopen() elsewhere – and document that on Windows the filename has to be utf8 encoded.

#5 Updated by Roman Lebedev almost 2 years ago

Tobias Ellinghaus wrote:

From seeing what is suggested or used elsewhere I'd say the proper fix would be an

#ifdef to use _wfopen() on Windows and fopen() elsewhere

Currently it is already an #ifdef, but instead, on windows, CreateFile is used to open.

https://github.com/darktable-org/rawspeed/blob/172595a30f22e837810f70e1e3d4b3606ec6485e/src/librawspeed/io/FileReader.cpp#L76-L80

and document that on Windows the filename has to be utf8 encoded.

#6 Updated by Tobias Ellinghaus almost 2 years ago

I see. Well, then you have to use CreateFileW it seems. In any case, you have to deal with turning the utf8 char* into a Windows wide char string. :(

#7 Updated by Peter Budai almost 2 years ago

There are basically two options IMHO:
1) you can use the MS CRT _wfopen(), as houz suggested. You can look at how glib does it (also with #ifdef):
https://github.com/GNOME/glib/blob/master/glib/gstdio.c#L713
2) You can go with Windows API CreateFileW() - as current RS code is apparently using Windows API, that might be less intrusive.

For converting utf8 to wide, you can also check the glib way:
https://github.com/GNOME/glib/blob/6b948d9613f2dcdec72828f3429ba01403063ff2/glib/gutf8.c#L1279

The 1) has some limitations like max 500 files can be opened at a time, no rename on open files etc, I'm not sure whether it is an issue for RS. The 2) is more versatile from that point of view, but I guess a little bit more work.

#8 Updated by Roman Lebedev almost 2 years ago

  • % Done changed from 20 to 100
  • Status changed from Triaged to Fixed

Also available in: Atom PDF