Kaydet (Commit) 921060f7 authored tarafından Nick Treleaven's avatar Nick Treleaven

Add wrappers for converting between utf8 and locale encoding

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@707 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 3f051214
......@@ -2623,3 +2623,21 @@ gboolean utils_wrap_string(gchar *string, gint wrapstart)
}
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;
}
......@@ -233,4 +233,10 @@ void utils_document_show_hide(gint idx);
* 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment