"Rolf Kalbermatter" r.kalbermatter@hccnet.nl writes:
Go figure. To me it seems they messed up with the conversion from Widechar to ASCII when needing to calculate the needed size. Unless they use some other function than WideCharToMultiByte() it couldn't be for avoiding an extra buffer allocation since WideCharToMultiByte() specifically states that the input and output buffer can not be the same pointer. Maybe that native NTDLL provides a lower level Unicode -> ASCII conversion that does allow for overlapping buffers.
No, returning twice the W size is the normal behavior when you don't want to retrieve the full W text but only its length. Since each W char can map to at most two A chars (at least with standard Windows codepages) doubling the size is an upper bound on the A buffer size, and doing it that way can avoid a lot of unnecessary work.