Hi,
I was about to implement this function too, but it seems you've beaten me by two days :-) .
Am 2017-07-08 um 17:55 schrieb Mikhail Paulyshka:
- WCHAR longstr[MAX_PATH + 3];
memset(longstr, 'A', sizeof(longstr));
This memset doesn't do what you probably expect. It doesn't fill the string with 'A's, but instead with U+4141 characters (䅁, http://www.fileformat.info/info/unicode/char/4141/index.htm).
- if (!src || !dst)
return 0;
This is redundant. WideCharToMultiByte checks this for you and returns 0. I noticed this after sending the _To_wide patch and will send a patch removing the redundant check from _To_wide.
On 09.07.2017 13:42, Stefan Dösinger wrote:
- if (!src || !dst)
return 0;
This is redundant. WideCharToMultiByte checks this for you and returns 0. I noticed this after sending the _To_wide patch and will send a patch removing the redundant check from _To_wide.
Checking 'dst' is not redundant though.
On 09.07.2017 14:00, Nikolay Sivov wrote:
On 09.07.2017 13:42, Stefan Dösinger wrote:
- if (!src || !dst)
return 0;
This is redundant. WideCharToMultiByte checks this for you and returns 0. I noticed this after sending the _To_wide patch and will send a patch removing the redundant check from _To_wide.
Checking 'dst' is not redundant though.
Ah, maybe it is, because destination buffer length is never zero.
Am 2017-07-09 um 13:02 schrieb Nikolay Sivov:
Checking 'dst' is not redundant though.
Ah, maybe it is, because destination buffer length is never zero.
Yeah, those functions want a non-NULL dst buffer if they have a dst length.
if (!src || !srclen || (!dst && dstlen) || dstlen < 0)