[patch] filter invalid utf-8 characters from volume labels

Joe Shaw joeshaw at novell.com
Wed Jul 28 07:33:15 PDT 2004


On Wed, 2004-07-28 at 09:12 +0200, Sjoerd Simons wrote:
>   Attached path replaces the invalid utf-8 characters in a volume label with ?.
>   I believe David is thinking about a better long-term solution, but he can 
>   better comment on that himself.  And ofcourse there is the traditional
>   screenshot[1] :)

If we don't know what encoding the label is in, we'll never be able to
know definitively.  Maybe it would make sense to have a filename
encoding setting in hal.conf.  In the meantime though I'd recommend just
assuming ISO-8859-15, and doing something like this:

        if (!g_utf8_validate (vid->label_string, -1, NULL)) {
        	char *tmp;
        
        	tmp = g_convert_with_fallback (vid->label_string, -1,
                                               "UTF-8", "ISO-8859-15",
                                               "?", NULL, NULL, NULL);
        
        	g_free (vid->label_string);
        	vid->label_string = tmp;
        }
        
So that valid ISO-8859-15 characters get converted to UTF-8 (like, say,
the euro symbol).

Joe

_______________________________________________
hal mailing list
hal at freedesktop.org
http://freedesktop.org/mailman/listinfo/hal



More information about the Hal mailing list