From 418699b85d0bbe5497ca0570f3c15ae9274460ed Mon Sep 17 00:00:00 2001 From: Kovarththanan Rajaratnam Date: Mon, 31 Aug 2009 18:16:16 +0000 Subject: 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 --- wsutil/unicode-utils.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'wsutil/unicode-utils.c') diff --git a/wsutil/unicode-utils.c b/wsutil/unicode-utils.c index 91c4aeca88..f011d46292 100644 --- a/wsutil/unicode-utils.c +++ b/wsutil/unicode-utils.c @@ -26,13 +26,8 @@ #error "This is only for Windows" #endif -#include #include "unicode-utils.h" -#include -#include -#include - /** @file * Unicode utilities (internal interface) * @@ -89,6 +84,19 @@ wchar_t * utf_8to16(const char *utf8str) { 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. */ gchar * utf_16to8(const wchar_t *utf16str) { static gchar *utf8buf[3]; -- cgit v1.2.1