[Insight-developers] Image writing with unicode filename impossible with MSVC

Tom Vercauteren tom.vercauteren at m4x.org
Tue Oct 13 12:16:38 EDT 2009


Hi Luis,

> I'm curious of taking a look at other libraries and
> seeing how they have managed this issue.
>
> A good candidate to learn from is Qt, since they
> have such an international user base, and support
> anything from KDE to cell phone applications.

Indeed, QT handles unicode data quite nicely with its QString class.

> [snip]
> In short: I don't see too much trouble in
> inserting this sort of modifications in ITK itself.
> What will be tricky is to propagate this down
> each one ImageIO class and their respective
> libraries (PNG, JPEG, gdcm, Meta, Nifti).

Agreed, this will require some tedious work and its not even sure that
it will get accepted upstream. Below is some insight on the different
third-party libraries.

PNG and JPEG should not be an issue. The file is indeed opened by ITK:
See the constructor of PNGFileWrapper and JPEGFileWrapper
http://www.itk.org/cgi-bin/viewcvs.cgi/Code/IO/itkPNGImageIO.cxx?root=Insight&sortby=file&view=markup
http://www.itk.org/cgi-bin/viewcvs.cgi/Code/IO/itkJPEGImageIO.cxx?root=Insight&sortby=file&view=markup
This would require using _wfopen on windows (instead of fopen):
http://msdn.microsoft.com/en-us/library/yeby3zcb(VS.80).aspx

Looking at GDCM, the following seems somehow promising:
http://sourceforge.net/apps/mediawiki/gdcm/index.php?title=MS_Windows_questions#Is_Unicode_supported.3F
"  Is Unicode supported? No (not yet)."

A fix for Meta should be easy to port upstream I guess.

NRRD can apparently be given a FILE * instead of a filename meaning
ITK could handle the unicode question without modifying this third
party library
http://teem.sourceforge.net/nrrd/lib.html#io
This would require using _wfopen on windows:
http://msdn.microsoft.com/en-us/library/yeby3zcb(VS.80).aspx

NIFTI doesn't provide much information on the unicode topic.


> The option of using ICU is tempting.
>
> The license is fine:
> http://source.icu-project.org/repos/icu/icu/trunk/license.html
>
> The source code size. however, is:   69 Mb.    :-/
>
> ITK itself (with all the third party libraries) is 133 Mb.
>
> I'm finding difficult to justify including such a large library
> for dealing with a rather localized feature.

Wow! I didn't realize that... However, apart from ICU, I don't know
any good unicode library we could use. QString is not much better in
this case since it would require all of QT core at least.

The dependency on either QT or ICU could be optional but this would
require even more ifdefs.


> Let's start with the isolated experiment,
> to test the waters...(that is, just a test that
> doesn't modify yet any of the ITK classes).
>
> Would you like to take a first crack at it ?

Sure, the test submitted by Benjamin (in the form of a patch) is
already quite nice:
http://public.kitware.com/Bug/file_download.php?file_id=2500&type=bug

Should I simply go on and commit this patch or were you expecting
something else?

Tom


More information about the Insight-developers mailing list