[gnome-control-center] hostname-helper: use GLib transliteration API



commit 4736b03ed9e2ae9214117454f70811dbacd78739
Author: Ryan Lortie <desrt desrt ca>
Date:   Wed Feb 12 13:53:28 2014 -0500

    hostname-helper: use GLib transliteration API
    
    Use GLib's new transliteration API to avoid the shortcomings of iconv().
    
    Also solve an existing problem where strings entered in decomposed forms
    wouldn't be properly transliterated.  Always normalise before attempting
    transliteration.
    
    Bump GLib dependency to 2.39.91 for the new feature.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=724194

 configure.ac            |    2 +-
 shell/hostname-helper.c |   12 +++++-------
 2 files changed, 6 insertions(+), 8 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index aaa9b75..a8feb4f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -85,7 +85,7 @@ dnl ==============================================
 dnl Check that we meet the  dependencies
 dnl ==============================================
 
-GLIB_REQUIRED_VERSION=2.37.7
+GLIB_REQUIRED_VERSION=2.39.91
 GTK_REQUIRED_VERSION=3.11.1
 PA_REQUIRED_VERSION=2.0
 CANBERRA_REQUIRED_VERSION=0.13
diff --git a/shell/hostname-helper.c b/shell/hostname-helper.c
index e8e4954..3fffb95 100644
--- a/shell/hostname-helper.c
+++ b/shell/hostname-helper.c
@@ -104,21 +104,19 @@ pretty_hostname_to_static (const char *pretty,
 {
        char *result;
        char *valid_chars;
+       char *composed;
 
        g_return_val_if_fail (pretty != NULL, NULL);
        g_return_val_if_fail (g_utf8_validate (pretty, -1, NULL), NULL);
 
        g_debug ("Input: '%s'", pretty);
 
+       composed = g_utf8_normalize (pretty, -1, G_NORMALIZE_ALL_COMPOSE);
+       g_debug ("\tcomposed: '%s'", composed);
        /* Transform the pretty hostname to ASCII */
-       result = g_convert (pretty,
-                           -1,
-                           "ASCII//TRANSLIT//IGNORE",
-                           "UTF-8",
-                           NULL,
-                           NULL,
-                           NULL);
+       result = g_str_to_ascii (composed, NULL);
        g_debug ("\ttranslit: '%s'", result);
+       g_free (composed);
 
        CHECK;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]