Revision: 707 Author: ntrel Date: 2006-08-12 14:36:55 -0700 (Sat, 12 Aug 2006) ViewCVS: http://svn.sourceforge.net/geany/?rev=707&view=rev
Log Message: ----------- Add wrappers for converting between utf8 and locale encoding
Modified Paths: -------------- trunk/src/utils.c trunk/src/utils.h Modified: trunk/src/utils.c =================================================================== --- trunk/src/utils.c 2006-08-12 17:27:09 UTC (rev 706) +++ trunk/src/utils.c 2006-08-12 21:36:55 UTC (rev 707) @@ -2623,3 +2623,21 @@ } return ret; } + + +gchar *utils_get_locale_from_utf8(const gchar *utf8_text) +{ + gchar *locale_text = g_locale_from_utf8(utf8_text, -1, NULL, NULL, NULL); + if (locale_text == NULL) locale_text = g_strdup(utf8_text); + return locale_text; +} + + +gchar *utils_get_utf8_from_locale(const gchar *locale_text) +{ + gchar *utf8_text = g_locale_to_utf8(locale_text, -1, NULL, NULL, NULL); + if (utf8_text == NULL) utf8_text = g_strdup(locale_text); + return utf8_text; +} + +
Modified: trunk/src/utils.h =================================================================== --- trunk/src/utils.h 2006-08-12 17:27:09 UTC (rev 706) +++ trunk/src/utils.h 2006-08-12 21:36:55 UTC (rev 707) @@ -233,4 +233,10 @@ * wrapstart is the minimum position to start wrapping or -1 for default */ gboolean utils_wrap_string(gchar *string, gint wrapstart);
+/* Simple wrapper for g_locale_from_utf8; returns a copy of utf8_text on failure. */ +gchar *utils_get_locale_from_utf8(const gchar *utf8_text); + +/* Simple wrapper for g_locale_to_utf8; returns a copy of locale_text on failure. */ +gchar *utils_get_utf8_from_locale(const gchar *locale_text); + #endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.