Add gnc_utf8_strip_invalid_strdup() that returns a stripped copy instead of working in-place.

BP

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@14679 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Christian Stimming 2006-08-15 20:00:14 +00:00
parent 3fc7807fda
commit dfaec6654b
3 changed files with 26 additions and 0 deletions

View File

@ -1,5 +1,9 @@
2006-08-15 Christian Stimming <stimming@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

View File

@ -214,3 +214,11 @@ gnc_utf8_strip_invalid (gchar *str)
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;
}

View File

@ -67,6 +67,20 @@ int safe_utf8_collate (const char *str1, const char *str2);
* 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);
/** @} */