Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
I need to open images with unicode filepaths, such as japanese characters (example: 私.tga).
I'm using MagickCore and noticed that ImageInfo::filename is a char array. I need it to use wchar_t... or at least open the FILE* ImageInfo::file some other way.
wchar_t* path = L"私.tga";
ExceptionInfo *exception = AcquireExceptionInfo();
ImageInfo *image_info=CloneImageInfo((ImageInfo *) NULL);
wcstombs(image_info->filename, path, sizeof(image_info->filename)/sizeof(char)); // Here I copy the wchar_t* path to the char* filename in ImageInfo.
Image *images=ReadImage(image_info,exception);
How should I read an image that has unicode characters in the filepath?
We unpacked your image and displayed and converted it without any problems. We tried both *.tga and ç§.tga. We're using ImageMagick 6.3.1-5 under Fedora Core 6.
UTF-8 unicode is designed to be storable in normal strings. Just with specal meta-charcater codes to handle the non-ascii parts. that is one character may not ne one byte.
char* is fine for unicode, you just have to know it may be unicode and use the appropriate librarys to handle the unicode strings, rather than the old one byte = one char techniques.
On my target platform (Windows XP) the following holds true:
printf("%p\n", fopen("c:\\temp\\ç§.tga", "rb")); // null
printf("%p\n", _wfopen(L"c:\\temp\\ç§.tga", L"rb"));// works!
Im guessing Fedora Core is a bit smarter about its path handling.
So how do I pass a wchar_t* as a file path, or how do I override the file loading rutine?
Seriema wrote:
Im guessing Fedora Core is a bit smarter about its path handling.
More likely the Window OS is just makign things more complex. The OS designers tend to fix things by adding replacement routines, rather than fixing the original OS routines as it is done in the UNIX.
The need to specify 'binary' for files is a case in point, dating back to the DOS days.
PS: you may have guessed, I am not a big fan of Window-doze!
Sorry for not writing in sooner. I did try out that patch and even version 6.3.2, but I don't see how it's fixed anything since the function still takes a regular char*. As I noted in my earlier example you have to pass a string as a wide char pointer otherwise Windows won't recognize any special characters. Did I miss something? Was a new ReadImage introduced that I didn't see?