The API for WideCharToMultiByte says that the src-string has only to be
treated as NULL-terminated if srclen is -1.
diff --git a/win32/code_page.c b/win32/code_page.c
index 2cdf09e..2c395c2 100644
--- a/win32/code_page.c
+++ b/win32/code_page.c
@@ -178,6 +178,7 @@
{
int count = 0;
int eos = 0;
+ int care_for_eos=0;
int dont_copy= (dstlen==0);
if ((!src) | ((!dst) && (!dont_copy)) )
@@ -194,7 +195,10 @@
if(used)
*used=0;
if (srclen == -1)
+ {
srclen = lstrlen32W(src)+1;
+ care_for_eos=1;
+ }
while(srclen && (dont_copy || dstlen))
{
if(!dont_copy){
@@ -215,7 +219,7 @@
}
count++;
srclen--;
- if(!*src) {
+ if((!*src) && care_for_eos) {
eos = 1;
break;
}