gtkieembed r193 - in trunk: . src test



Author: hiikezoe
Date: Wed Jan 28 01:11:55 2009
New Revision: 193
URL: http://svn.gnome.org/viewvc/gtkieembed?rev=193&view=rev

Log:
2009-01-28  Hiroyuki Ikezoe  <poincare ikezoe net>

	* src/ie-utils.[cpp|h]: Added string conversion functions.




Added:
   trunk/src/ie-utils.cpp
   trunk/src/ie-utils.h
   trunk/test/test-utils.c
Modified:
   trunk/ChangeLog
   trunk/src/Makefile.am
   trunk/test/Makefile.am

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Wed Jan 28 01:11:55 2009
@@ -32,6 +32,7 @@
 
 noinst_HEADERS =				\
 	gtk-ie-embed-private.h			\
+	ie-utils.h				\
 	ie-bridge.h				\
 	ie-document-event-dispatcher.h		\
 	ie-browser-event-dispatcher.h
@@ -51,6 +52,7 @@
 	ie-document-event-dispatcher.cpp	\
 	ie-browser-event-dispatcher.cpp		\
 	ie-bridge.cpp				\
+	ie-utils.cpp				\
 	gtk-ie-embed.c
 
 libgtkieembed_la_LIBADD = 			\

Added: trunk/src/ie-utils.cpp
==============================================================================
--- (empty file)
+++ trunk/src/ie-utils.cpp	Wed Jan 28 01:11:55 2009
@@ -0,0 +1,51 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ *  Copyright (C) 2009 Hiroyuki Ikezoe  <poincare ikezoe net>
+ *
+ *  This library is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU Lesser General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "ie-utils.h"
+
+gchar *
+_ie_utils_BSTR_to_utf8 (BSTR bstr)
+{
+    gchar *utf8;
+    glong size;
+
+    utf8 = g_utf16_to_utf8 ((gunichar2*)bstr, SysStringLen (bstr), NULL, &size, NULL);
+    return utf8;
+}
+
+
+BSTR 
+_ie_utils_utf8_to_BSTR  (const gchar *str)
+{
+    BSTR bstr;
+    gunichar2 *utf16;
+    glong size;
+
+    utf16 = g_utf8_to_utf16 (str, -1, NULL, &size, NULL);
+    if (!utf16)
+        return NULL;
+
+    bstr = SysAllocStringByteLen ((const char*)utf16, size * sizeof(OLECHAR));
+    g_free (utf16);
+    return bstr;
+}
+
+/*
+vi:ts=4:nowrap:ai:expandtab:sw=4
+*/

Added: trunk/src/ie-utils.h
==============================================================================
--- (empty file)
+++ trunk/src/ie-utils.h	Wed Jan 28 01:11:55 2009
@@ -0,0 +1,37 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ *  Copyright (C) 2009 Hiroyuki Ikezoe  <poincare ikezoe net>
+ *
+ *  This library is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU Lesser General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef __IE_UTILS__
+#define __IE_UTILS__
+
+#include <glib.h>
+#include <windows.h>
+
+G_BEGIN_DECLS
+
+gchar *_ie_utils_BSTR_to_utf8 (BSTR bstr);
+
+BSTR   _ie_utils_utf8_to_BSTR (const gchar *str);
+
+G_END_DECLS
+
+#endif /* __IE_UTILS__ */
+/*
+vi:ts=4:nowrap:ai:expandtab:sw=4
+*/

Modified: trunk/test/Makefile.am
==============================================================================
--- trunk/test/Makefile.am	(original)
+++ trunk/test/Makefile.am	Wed Jan 28 01:11:55 2009
@@ -3,7 +3,8 @@
 TESTS_ENVIRONMENT = NO_MAKE=yes CUTTER="$(CUTTER)"
 
 noinst_LTLIBRARIES =			\
-	test-gtk-ie-embed.la
+	test-gtk-ie-embed.la		\
+	test-utils.la
 endif
 
 EXTRA_DIST =		\
@@ -29,6 +30,8 @@
 	$(GCUTTER_LIBS)
 
 test_gtk_ie_embed_la_SOURCES = test-gtk-ie-embed.c
+test_utils_la_SOURCES = test-utils.c
+test_utils_la_LIBADD = $(top_builddir)/src/libgtkieembed_la-ie-utils.lo
 
 echo-cutter:
 	@echo $(CUTTER)

Added: trunk/test/test-utils.c
==============================================================================
--- (empty file)
+++ trunk/test/test-utils.c	Wed Jan 28 01:11:55 2009
@@ -0,0 +1,36 @@
+#include "ie-utils.h"
+#include <gcutter.h>
+
+void test_convert (void);
+
+static BSTR bstr;
+static gchar *utf8_string;
+
+void
+setup (void)
+{
+    bstr = NULL;
+    utf8_string = NULL;
+}
+
+void
+teardown (void)
+{
+    SysFreeString (bstr);
+    g_free (utf8_string);
+}
+
+
+void
+test_convert (void)
+{
+    bstr = _ie_utils_utf8_to_BSTR ("ABC");
+
+    utf8_string = _ie_utils_BSTR_to_utf8 (bstr);
+
+    cut_assert_equal_string ("ABC", utf8_string);
+}
+
+/*
+vi:ts=4:nowrap:ai:expandtab:sw=4
+*/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]