Re: [xml] LoadLibrary needs to be LoadLibraryA

2008/2/19, Roland Schwingel <Roland Schwingel onevision com>:


> When I tried to compile libxml on Windows along with my application that is built with 'UNICODE' defined (i.e. as a Unicode
> application rather than as an "ANSI" application),  I came across a problem in xmlmodule.c.


> With UNICODE defined, LoadLibrary is resolved to LoadLibraryW which expects to get 'const wchar_t*' rather than 'const char*'.
> To avoid the problem,  we have to use LoadLibraryA explicitly.  


> Below is my trivial patch:

I agree that the explicitely stating LoadLibraryA or LoadLibraryW would be best.
But IMHO LoadLibraryA would be a bad idea. This would not allow to load modules
located in pathes containing unicode characters.

IMHO interpreting the path as utf-8 and then converting it to wchar would be better
and then trying LoadLibraryW(). If the path cannot be converted or LoadLibraryW()
fails a second attempt can be made using the original argument of the xmlModulePlatformOpen
function passed to LoadLibraryA(). For the utf-8 -> wchar thingy there is already code
in xmlIO.c doing these things it should be recycled here.

Yeah, I thought about suggesting that, but didn't because it was not clear to me whether the argument is the full path or just a leaf filename. I have done exactly the same thing in another project  and I fully agree with you that we'd better do it.  It's not a perfect but a 'work-most-of-time' method (and, certainly  better than just calling  LoadLibraryA). 

I'll make a new patch. 




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]