Re: [xml] The issue around LoadLibrary on Windows


On Wed, May 23, 2012 at 2:16 PM, Bjoern Hoehrmann  wrote:
* Daniel Veillard wrote:
 C.f. the bug Fix windows unicode build

and the previous discussions here:

now that the release is done, can we have a final decision on this.
As I understand it, LoadLibraryW takes a wchar_t* parameter, while
internally we are using only a char * (or xmlChar *) so it makes
no sense to try to call LoadLibraryW, and instead of using the
macro LoadLibrary which can only break build, calling LoadLibraryA
seems to be the simplest.

It is not clear to me that building libxml2 with UNICODE defined is a
sound idea if libxml2 is not designed for that, but apart from that I
would agree, if the idea is that `xmlModulePlatformOpen` takes some
platform string you know nothing about, as opposed to, say, xmlChar*,
which you would know is a UTF-8 text string.

There's nothing wrong with compiling libxml2 with UNICODE defined.
libxml2 doesn't use TCHARs and as long as it doesn't try to use TCHAR
functions (like LoadLibrary), there won't be problems. Of course,
passing TCHAR strings to libxml2 won't compile under UNICODE, but
that's to signal that the string needs to be converted.

"LoadLibrary" is for programs that (conceivably) want to be compiled
both with and without UNICODE. To do this, it has to use TCHAR*
strings, which will be either narrow or wide depending on the #define.

libxml2 does not play by those rules (just as well, because then it
would have to worry about code pages). It does not use TCHAR, hence it
has to decide whether to use LoadLibraryA or LoadLibraryW. This would
make it independent of whether UNICODE is #defined or not.

xmlModuleOpen and its worker, xmlModulePlatformOpen take a const
char*, not const xmlChar*. This suggests that the parameter is not
UTF-8, in which case libxml2 should just use LoadLibraryA. This would
work as long as the entire path of the library is made of ASCII

GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ w++$ tv+ b++ DI D++ 5++
The Tao of math: The numbers you can count are not the real numbers.
Life is complex, with real and imaginary parts.
"Ok, it boots. Which means it must be bug-free and perfect. " -- Linus Torvalds
"People disagree with me. I just ignore them." -- Linus Torvalds

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