Menu

Unicode and loading/saving problems

Jan Benes
2010-01-13
2013-05-02
  • Jan Benes

    Jan Benes - 2010-01-13

    Hi,
    I'm using MSVC 9.0 with  MSVC 2008 Express Edition onWindows XP, downloaded the SDK, used it's libs and dlls and headers. When trying to load or save a file, I always got errors like 1921 (decimal), which I couldn't even find defined in the header (when convertex to hex). The problems lies most probably with unicode, as forcing DevIL to use non unicode string by doing

    #undef _UNICODE

    #include <IL/il.h>
    #include <IL/ilu.h>

    #define _UNICODE

    makes everything work perfect (along with changing the path from L"image.png" to just "image.png"). This is a pretty annoying error and it took me quite a while to figure out, it would be nice to point the solution out somewhere (am I the only one having this problem?). Other than that, nice library, thanks for maintaining it.

     
  • Matěj Týč

    Matěj Týč - 2010-01-21

    If you are not a skilled unicode programmer, try to look here first, that may help:
    http://www.joelonsoftware.com/articles/Unicode.html
    There should not be any problem with whatever encoding you use as far as you don't intend to use app data on a system with different encoding.
    Also make sure that you set the correct locale in the beginning.

     
  • Jan Benes

    Jan Benes - 2010-01-21

    Well, obviously, I might be wrong, but I guess I have some knowledge of unicode (although not perfect).

    The thing I'm going to reiterate is that I use a fairly recent compiler that defaults to using unicode on a system that basically runs on unicode afaik, and all the other libraries work (not saying yours is wrong, though), with the exception of DevIL, which wouldn't work on an unicode (wide char) string, but starts working when I force it to use the plain chars by undefining unicode for the headers using pragma, thereby making all the DevIL string go from wchar_t * to just char *… The point is it doesn't work out of the box for some reason, which should concern you. I used ascii only letters. As for locale, do you mean thread locale? What exactly would that change? Or is there some DevIL locale I'm not aware of?

    I got what I needed from the library, I'm just trying to give you feedback (hopefully useful).

     
  • Matěj Týč

    Matěj Týč - 2010-01-22

    I meant no offense, I am sorry if it seemed so. We are happy if people give us useful feedback.
    Unfortunatelly, the main developer who wrote that code is extremely busy with his PhD, so I can only guess.
    Concerning the locale, I meant calling the setlocale function from the standard C library

    setlocale(LC_ALL, NULL);
    

    But if everything else works, it is most likely not the issue.
    We would be very grateful if you file a bug report with the exmple code that fails. We are quite close from releasing an updated version and it would be good to address this, too.

     
  • Anpu

    Anpu - 2010-02-09

    Same problem here - ilLoadImage fails with IL_COULD_NOT_OPEN_FILE.
    But… it works if the file name is non-unicode string:
    char * filename = "…"; ilLoadImage( (wchar_t*) filename )
    I've looked at disassembly, and it's obvious that “unicode” DevIL.dll in fact is non-unicode version.

     

Log in to post a comment.