This still looks unnecessarily complicative IMO.
Nikolay Sivov nsivov@codeweavers.com wrote:
+DWORD WINAPI SHAnsiToAnsi(const char *src, char *dest, int dest_len) +{
- DWORD ret;
- TRACE("(%s, %p, %d)\n", debugstr_a(src), dest, dest_len);
- if (!src || !dest || dest_len <= 0)
return 0;
- lstrcpynA(dest, src, dest_len);
- ret = strlen(dest);
- return src[ret] ? 0 : ret + 1;
+}
lstrcpynA(dest, src, dest_len); ret = strlen(dest); if (ret) ret++; return ret;
+DWORD WINAPI SHUnicodeToAnsi(const WCHAR *src, char *dest, int dest_len) +{
- int ret = 1;
- TRACE("(%s, %p, %d)\n", debugstr_w(src), dest, dest_len);
- if (!dest || !dest_len)
return 0;
- if (src)
- {
ret = WideCharToMultiByte(CP_ACP, 0, src, -1, dest, dest_len, NULL, NULL);
if (!ret)
{
dest[dest_len - 1] = 0;
ret = dest_len;
}
- }
- else
dest[0] = 0;
- return ret;
+}
if (!src) { *dst = 0; return 1; }
if (!WideCharToMultiByte(CP_ACP, 0, src, -1, dest, dest_len, NULL, NULL)) dest[dest_len - 1] = 0; return dest_len;