svn commit: r1933247 - subversion/trunk/subversion/libsvn_subr

[email protected]
Newsgroups gmane.comp.version-control.subversion.svn
Message-ID <177686520762.1565736.1550289068602101965@svn03-he-fi>
Author: ivan
Date: Wed Apr 22 13:40:07 2026
New Revision: 1933247

Log:
* subversion/libsvn_subr/sysinfo.c
  (wcs_to_utf8): Use svn_utf__win32_utf16_to_utf8() instead of using
   WideCharToMultiByte() directly.

Modified:
   subversion/trunk/subversion/libsvn_subr/sysinfo.c

Modified: subversion/trunk/subversion/libsvn_subr/sysinfo.c
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/sysinfo.c	Wed Apr 22 13:38:03 2026	(r1933246)
+++ subversion/trunk/subversion/libsvn_subr/sysinfo.c	Wed Apr 22 13:40:07 2026	(r1933247)
@@ -965,15 +965,17 @@ win32_canonical_host(apr_pool_t *pool)
 static const char *
 wcs_to_utf8(const wchar_t *wcs, apr_pool_t *pool)
 {
-  const int bufsize = WideCharToMultiByte(CP_UTF8, 0, wcs, -1,
-                                          NULL, 0, NULL, NULL);
-  if (bufsize > 0)
+  svn_error_t *err;
+  const char *utf8;
+
+  err = svn_utf__win32_utf16_to_utf8(&utf8, wcs, NULL, pool);
+  if (err)
     {
-      char *const utf8 = apr_palloc(pool, bufsize + 1);
-      WideCharToMultiByte(CP_UTF8, 0, wcs, -1, utf8, bufsize, NULL, NULL);
-      return utf8;
+      svn_error_clear(err);
+      return NULL;
     }
-  return NULL;
+
+  return utf8;
 }
 
 /* Query the value called NAME of the registry key HKEY. */
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.