- size_t len = WideCharToMultiByte(m_CodePage, 0, psz, -1, buf,
- buf ? n : 0, NULL, NULL);
- //VS: returns # of written chars for buf!=NULL and *size*
- // needed buffer for buf==NULL
- return len ? (buf ? len : len-1) : (size_t)-1;
+ const size_t len = ::WideCharToMultiByte
+ (
+ m_CodePage, // code page
+ 0, // flags (none)
+ psz, // input string
+ -1, // it is (wide) NUL-terminated
+ buf, // output buffer
+ buf ? n : 0, // and its size
+ NULL, // default "replacement" char
+ NULL // [out] was it used?
+ );
+
+ // see the comment above!
+ return len ? (buf ? len : len - 1) : (size_t)-1;