aboutsummaryrefslogtreecommitdiffstats
path: root/epan/strutil.c
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2006-09-22 21:14:54 +0000
committerGerald Combs <gerald@wireshark.org>2006-09-22 21:14:54 +0000
commit9e23f31e5f116054682b9f8460f56fb7e73eedd1 (patch)
treef003e5ec1c257836dda6c2c807fdb0ecccb60e73 /epan/strutil.c
parentb4b9ced31a8ab30e521309304689e80e82b13530 (diff)
Add support for reading from stdin under Windows. Based on a patch sent
in last year by Gianluca Varenni. Add partial support for reading from named pipes (currently disabled). Move utf_8to16() and utf_16to8() to a separate module (unicode-utils.[ch]) so that we don't have to cut and paste code in dumpcap.c. Fix up whitespace. svn path=/trunk/; revision=19291
Diffstat (limited to 'epan/strutil.c')
-rw-r--r--epan/strutil.c89
1 files changed, 1 insertions, 88 deletions
diff --git a/epan/strutil.c b/epan/strutil.c
index 01a9745cda..4ada04a2e9 100644
--- a/epan/strutil.c
+++ b/epan/strutil.c
@@ -262,7 +262,7 @@ format_text(const guchar *string, int len)
/*
* Given a string, generate a string from it that shows non-printable
- * characters as C-style escapes except a whitespace character
+ * characters as C-style escapes except a whitespace character
* (space, tab, carriage return, new line, vertical tab, or formfeed)
* which will be replaved by a space, and return a pointer to it.
*/
@@ -765,90 +765,3 @@ g_strlcat(gchar *dst, gchar *src, gsize size)
return strl+strs;
}
#endif
-
-#ifdef _WIN32
-
-/*
- * XXX - Should we use g_utf8_to_utf16() and g_utf16_to_utf8()
- * instead? The goal of the functions below was to provide simple
- * wrappers for UTF-8 <-> UTF-16 conversion without making the
- * caller worry about freeing up memory afterward.
- */
-
-/* Convert from UTF-8 to UTF-16. */
-wchar_t * utf_8to16(const char *utf8str) {
- static wchar_t *utf16buf[3];
- static int utf16buf_len[3];
- static int idx;
-
- if (utf8str == NULL)
- return NULL;
-
- idx = (idx + 1) % 3;
-
- /*
- * Allocate the buffer if it's not already allocated.
- */
- if (utf16buf[idx] == NULL) {
- utf16buf_len[idx] = INITIAL_FMTBUF_SIZE;
- utf16buf[idx] = g_malloc(utf16buf_len[idx] * sizeof(wchar_t));
- }
-
- while (MultiByteToWideChar(CP_UTF8, 0, utf8str,
- -1, NULL, 0) >= utf16buf_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'.
- */
- utf16buf_len[idx] *= 2;
- utf16buf[idx] = g_realloc(utf16buf[idx], utf16buf_len[idx] * sizeof(wchar_t));
- }
-
- if (MultiByteToWideChar(CP_UTF8, 0, utf8str,
- -1, utf16buf[idx], utf16buf_len[idx]) == 0)
- return NULL;
-
- return utf16buf[idx];
-}
-
-/* Convert from UTF-16 to UTF-8. */
-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];
-}
-
-#endif