another place missing a call to utf_16to8(), the about box was showing "Windows XP...
authorulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 13 Aug 2006 12:12:06 +0000 (12:12 +0000)
committerulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 13 Aug 2006 12:12:06 +0000 (12:12 +0000)
dumpcap uses this too, so I had to duplicate utf_16to8 there :-(

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@18891 f5534014-38df-0310-8fa8-9805f1628bb7

dumpcap.c
version_info.c

index 8136eaebd4f8401bfbaab0fee10501cf4fa690db..5486bf98952e6b9f6355224ffa07b5f3f7ec8ce8 100644 (file)
--- a/dumpcap.c
+++ b/dumpcap.c
@@ -624,3 +624,46 @@ signal_pipe_check_running(void)
 
 
 const char *netsnmp_get_version(void) { return ""; }
+
+
+/* Convert from UTF-16 to UTF-8. */
+/* XXX - copied from epan/strutil.c */
+#define        INITIAL_FMTBUF_SIZE     128
+
+gchar * utf_16to8(const wchar_t *utf16str) {
+  static gchar *utf8buf[3];
+  static int utf8buf_len[3];
+  static int idx;
+
+  if (utf16str == NULL)
+    return NULL;
+
+  idx = (idx + 1) % 3;
+
+  /*
+   * Allocate the buffer if it's not already allocated.
+   */
+  if (utf8buf[idx] == NULL) {
+    utf8buf_len[idx] = INITIAL_FMTBUF_SIZE;
+    utf8buf[idx] = g_malloc(utf8buf_len[idx]);
+  }
+
+  while (WideCharToMultiByte(CP_UTF8, 0, utf16str, -1,
+      NULL, 0, NULL, NULL) >= utf8buf_len[idx]) {
+    /*
+     * Double the buffer's size if it's not big enough.
+     * The size of the buffer starts at 128, so doubling its size
+     * adds at least another 128 bytes, which is more than enough
+     * for one more character plus a terminating '\0'.
+     */
+    utf8buf_len[idx] *= 2;
+    utf8buf[idx] = g_realloc(utf8buf[idx], utf8buf_len[idx]);
+  }
+
+  if (WideCharToMultiByte(CP_UTF8, 0, utf16str, -1,
+      utf8buf[idx], utf8buf_len[idx], NULL, NULL) == 0)
+    return NULL;
+
+  return utf8buf[idx];
+}
+
index dc8721e652cc7b1c1cbd0fbe0f2c2d3667de41d2..1bfeba4a37c2c64f945dd786210d2dfdae2fa949 100644 (file)
@@ -354,7 +354,7 @@ get_runtime_version_info(GString *str)
                break;
        }
        if (info.szCSDVersion[0] != '\0')
-               g_string_sprintfa(str, " %s", info.szCSDVersion);
+               g_string_sprintfa(str, " %s", utf_16to8(info.szCSDVersion));
        g_string_sprintfa(str, ", build %lu", info.dwBuildNumber);
 #elif defined(HAVE_SYS_UTSNAME_H)
        /*