Make it Unicode safe.
authorBehdad Esfahbod <behdad@gnome.org>
Tue, 6 Jan 2009 10:40:30 +0000 (10:40 +0000)
committerBehdad Esfahbod <behdad@src.gnome.org>
Tue, 6 Jan 2009 10:40:30 +0000 (10:40 +0000)
2009-01-06  Behdad Esfahbod  <behdad@gnome.org>

        * pango/fonts.c (pango_font_description_to_filename):
        Make it Unicode safe.

svn path=/trunk/; revision=2786

ChangeLog
pango/fonts.c

index 2870707..c66b02d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2009-01-06  Behdad Esfahbod  <behdad@gnome.org>
 
+       * pango/fonts.c (pango_font_description_to_filename):
+       Make it Unicode safe.
+
+2009-01-06  Behdad Esfahbod  <behdad@gnome.org>
+
        * pango/fonts.c (find_field), (parse_field), (pango_parse_style),
        (pango_parse_variant), (pango_parse_weight), (pango_parse_stretch):
        Move the parse_*() functions in fonts.c and have them share tables
index 532adbe..5e145ae 100644 (file)
@@ -1280,13 +1280,12 @@ pango_font_description_to_filename (const PangoFontDescription  *desc)
 
   result = pango_font_description_to_string (desc);
 
-  /* XXX This should be rewritten to read char-by-char instead
-   * of byte-by-byte, to be Unicode safe.
-   */
   p = result;
   while (*p)
     {
-      if (strchr ("-+_.", *p) == NULL && !g_ascii_isalnum (*p))
+      if (G_UNLIKELY ((guchar) *p >= 128))
+        /* skip over non-ASCII chars */;
+      else if (strchr ("-+_.", *p) == NULL && !g_ascii_isalnum (*p))
        *p = '_';
       else
        *p = g_ascii_tolower (*p);