r14756 - gnucash/branches/2.0 - Add gnc_utf8_strip_invalid_strdup() that returns a stripped copy instead of working in-place.

Derek Atkins warlord at cvs.gnucash.org
Mon Aug 28 23:27:21 EDT 2006


Author: warlord
Date: 2006-08-28 23:27:20 -0400 (Mon, 28 Aug 2006)
New Revision: 14756
Trac: http://svn.gnucash.org/trac/changeset/14756

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

Merge from r14679.



Property changes on: gnucash/branches/2.0
___________________________________________________________________
Name: svk:merge
   - d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/branches/2.0:13183
   + d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/branches/2.0:13184

Modified: gnucash/branches/2.0/ChangeLog
===================================================================
--- gnucash/branches/2.0/ChangeLog	2006-08-29 03:27:08 UTC (rev 14755)
+++ gnucash/branches/2.0/ChangeLog	2006-08-29 03:27:20 UTC (rev 14756)
@@ -7,6 +7,10 @@
 
 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/branches/2.0/src/core-utils/gnc-glib-utils.c
===================================================================
--- gnucash/branches/2.0/src/core-utils/gnc-glib-utils.c	2006-08-29 03:27:08 UTC (rev 14755)
+++ gnucash/branches/2.0/src/core-utils/gnc-glib-utils.c	2006-08-29 03:27:20 UTC (rev 14756)
@@ -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/branches/2.0/src/core-utils/gnc-glib-utils.h
===================================================================
--- gnucash/branches/2.0/src/core-utils/gnc-glib-utils.h	2006-08-29 03:27:08 UTC (rev 14755)
+++ gnucash/branches/2.0/src/core-utils/gnc-glib-utils.h	2006-08-29 03:27:20 UTC (rev 14756)
@@ -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