Add utf_8to16_snprintf() which creates a UTF16 string according to the given format string. The format string + arguments are expected to be in UTF-8 format. This change effectively removes the only place where we use PRIu64.
svn path=/trunk/; revision=29635
This commit is contained in:
parent
80d50191a3
commit
418699b85d
|
@ -947,7 +947,7 @@ preview_set_filename(HWND of_hwnd, gchar *preview_file) {
|
||||||
TCHAR string_buff[PREVIEW_STR_MAX];
|
TCHAR string_buff[PREVIEW_STR_MAX];
|
||||||
gint64 data_offset;
|
gint64 data_offset;
|
||||||
guint packet = 0;
|
guint packet = 0;
|
||||||
guint64 filesize;
|
gint64 filesize;
|
||||||
time_t ti_time;
|
time_t ti_time;
|
||||||
struct tm *ti_tm;
|
struct tm *ti_tm;
|
||||||
guint elapsed_time;
|
guint elapsed_time;
|
||||||
|
@ -993,7 +993,7 @@ preview_set_filename(HWND of_hwnd, gchar *preview_file) {
|
||||||
|
|
||||||
/* size */
|
/* size */
|
||||||
filesize = wtap_file_size(wth, &err);
|
filesize = wtap_file_size(wth, &err);
|
||||||
_snwprintf(string_buff, PREVIEW_STR_MAX, _T("%") _T(PRIu64) _T(" bytes"), filesize);
|
utf_8to16_snprintf(string_buff, PREVIEW_STR_MAX, "%" G_GINT64_FORMAT " bytes", filesize);
|
||||||
cur_ctrl = GetDlgItem(of_hwnd, EWFD_PTX_SIZE);
|
cur_ctrl = GetDlgItem(of_hwnd, EWFD_PTX_SIZE);
|
||||||
SetWindowText(cur_ctrl, string_buff);
|
SetWindowText(cur_ctrl, string_buff);
|
||||||
|
|
||||||
|
|
|
@ -47,4 +47,4 @@ type_util_guint64_to_gdouble
|
||||||
; unicode-utils.c
|
; unicode-utils.c
|
||||||
utf_16to8
|
utf_16to8
|
||||||
utf_8to16
|
utf_8to16
|
||||||
|
utf_8to16_snprintf
|
||||||
|
|
|
@ -26,13 +26,8 @@
|
||||||
#error "This is only for Windows"
|
#error "This is only for Windows"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
#include "unicode-utils.h"
|
#include "unicode-utils.h"
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
#include <tchar.h>
|
|
||||||
#include <wchar.h>
|
|
||||||
|
|
||||||
/** @file
|
/** @file
|
||||||
* Unicode utilities (internal interface)
|
* Unicode utilities (internal interface)
|
||||||
*
|
*
|
||||||
|
@ -89,6 +84,19 @@ wchar_t * utf_8to16(const char *utf8str) {
|
||||||
return utf16buf[idx];
|
return utf16buf[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void utf_8to16_snprintf(TCHAR *utf16buf, gint utf16buf_len, const gchar* fmt, ...) {
|
||||||
|
va_list ap;
|
||||||
|
gchar* dst;
|
||||||
|
|
||||||
|
va_start(ap,fmt);
|
||||||
|
dst = g_strdup_vprintf(fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
_snwprintf(utf16buf, utf16buf_len, _T("%s"), utf_8to16(dst));
|
||||||
|
|
||||||
|
g_free(dst);
|
||||||
|
}
|
||||||
|
|
||||||
/* Convert from UTF-16 to UTF-8. */
|
/* Convert from UTF-16 to UTF-8. */
|
||||||
gchar * utf_16to8(const wchar_t *utf16str) {
|
gchar * utf_16to8(const wchar_t *utf16str) {
|
||||||
static gchar *utf8buf[3];
|
static gchar *utf8buf[3];
|
||||||
|
|
|
@ -27,6 +27,15 @@
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <windows.h>
|
||||||
|
#include <tchar.h>
|
||||||
|
#include <wchar.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file Unicode convenience routines.
|
* @file Unicode convenience routines.
|
||||||
*/
|
*/
|
||||||
|
@ -40,6 +49,14 @@
|
||||||
*/
|
*/
|
||||||
wchar_t * utf_8to16(const char *utf8str);
|
wchar_t * utf_8to16(const char *utf8str);
|
||||||
|
|
||||||
|
/** Create a UTF-16 string (in place) according to the format string.
|
||||||
|
*
|
||||||
|
* @param utf16buf The buffer to return the UTF-16 string in.
|
||||||
|
* @param utf16buf_len The size of the 'utf16buf' parameter
|
||||||
|
* @param fmt A standard g_printf() format string
|
||||||
|
*/
|
||||||
|
void utf_8to16_snprintf(TCHAR *utf16buf, gint utf16buf_len, const gchar* fmt, ...);
|
||||||
|
|
||||||
/** Given a UTF-16 string, convert it to UTF-8. This is meant to be used
|
/** Given a UTF-16 string, convert it to UTF-8. This is meant to be used
|
||||||
* to convert between GTK+ 2.x (UTF-8) to Windows (UTF-16).
|
* to convert between GTK+ 2.x (UTF-8) to Windows (UTF-16).
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue