AUDIT: r14679 - gnucash/trunk - Add gnc_utf8_strip_invalid_strdup() that returns a stripped copy instead of working in-place.

Christian Stimming cstim at cvs.gnucash.org
Tue Aug 15 16:00:15 EDT 2006


Author: cstim
Date: 2006-08-15 16:00:14 -0400 (Tue, 15 Aug 2006)
New Revision: 14679
Trac: http://svn.gnucash.org/trac/changeset/14679

Modified:
   gnucash/trunk/ChangeLog
   gnucash/trunk/src/core-utils/gnc-glib-utils.c
   gnucash/trunk/src/core-utils/gnc-glib-utils.h
Log:
Add gnc_utf8_strip_invalid_strdup() that returns a stripped copy instead of working in-place.
BP

Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog	2006-08-15 19:45:09 UTC (rev 14678)
+++ gnucash/trunk/ChangeLog	2006-08-15 20:00:14 UTC (rev 14679)
@@ -1,5 +1,9 @@
 2006-08-15  Christian Stimming <stimming at tuhh.de>
 
+	* src/core-utils/gnc-glib-utils.[hc]: Add
+	gnc_utf8_strip_invalid_strdup() that returns a stripped copy
+	instead of working in-place.
+
 	* src/import-export/hbci/dialog-hbcitrans.c (blz_changed_cb):
 	Ensure the encoding of the ktoblzcheck library is used
 	correctly. Their encoding is still always ISO-8859-1, but in

Modified: gnucash/trunk/src/core-utils/gnc-glib-utils.c
===================================================================
--- gnucash/trunk/src/core-utils/gnc-glib-utils.c	2006-08-15 19:45:09 UTC (rev 14678)
+++ gnucash/trunk/src/core-utils/gnc-glib-utils.c	2006-08-15 20:00:14 UTC (rev 14679)
@@ -214,3 +214,11 @@
     memmove(end, end+1, len);	/* shuffle the remainder one byte */
   } while (!gnc_utf8_validate(str, -1, (const gchar **)&end));
 }
+
+gchar *
+gnc_utf8_strip_invalid_strdup(const gchar* str)
+{
+  gchar *result = g_strdup (str);
+  gnc_utf8_strip_invalid (result);
+  return result;
+}

Modified: gnucash/trunk/src/core-utils/gnc-glib-utils.h
===================================================================
--- gnucash/trunk/src/core-utils/gnc-glib-utils.h	2006-08-15 19:45:09 UTC (rev 14678)
+++ gnucash/trunk/src/core-utils/gnc-glib-utils.h	2006-08-15 20:00:14 UTC (rev 14679)
@@ -67,7 +67,21 @@
  *  characters. */
 void gnc_utf8_strip_invalid (gchar *str);
 
+/** Returns a newly allocated copy of the given string but with any
+ * non-utf8 character stripped from it.
+ *
+ * Note that it also removes some subset of invalid XML characters,
+ * too.  See http://www.w3.org/TR/REC-xml/#NT-Char linked from bug
+ * #346535
+ *
+ * @param str A pointer to the string to be copied and stripped of
+ * non-utf8 characters.
+ *
+ * @return A newly allocated string that has to be g_free'd by the
+ * caller. */
+gchar *gnc_utf8_strip_invalid_strdup (const gchar* str);
 
+
 /** @} */
 
 #endif /* GNC_GLIB_UTILS_H */



More information about the gnucash-changes mailing list