Re: [evolution-patches] UTF8 conversion fix



Le mer 01/10/2003 à 21:56, Jeffrey Stedfast a écrit :
> 1. are we sure this isn't a glib2 bug? I would have thought that it
> should give this to us in UTF-8 format...

No, it is not.. glib2 is supposed to return gecos field without touching
it..

> assuming not:
> 
> 2. } else {

Fixed.

> 3. s/converted_name/utf8_name/ ? or maybe uname? something shorter would
> be preferable to me.

fixed with uname

Reponding to NotZed :
> I wonder, should it just do the conversion always from locale, if that
> string is supposed to be in locale format?
> Just simplifies the logic, not having to special case that.

Well, I thought it could lead to problem trying to convert if current
locale was already UTF-8 but after checking glib code, in that case, it
checks if it is valid UTF8 and will do a strdup on the string if that
case (otherwise, it returns NULL).

So it is safe to always convert into UTF-8.. 

New patch attached (and I think I'll have to fix all my similar patches
in nautilus and gdm :)) and I've also simplified code a little bit..

-- 
Frederic Crozat <fcrozat mandrakesoft com>
Mandrakesoft
? .mail-config-druid.c.swp
? evolution-1.4.5-utf8user.patch
? evolution-1.4.5-utf8user1.patch
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/mail/ChangeLog,v
retrieving revision 1.2761.2.28
diff -u -r1.2761.2.28 ChangeLog
--- ChangeLog	30 Sep 2003 18:50:14 -0000	1.2761.2.28
+++ ChangeLog	2 Oct 2003 09:56:18 -0000
@@ -1,3 +1,8 @@
+2003-10-02  Frederic Crozat  <fcrozat mandrakesoft com>
+
+	* mail-config-druid.c: (identity_prepare), (config_wizard_new):
+	Convert real name to UTF-8 if needed.
+
 2003-09-30  Rodney Dawes  <dobey ximian com>
 
 	* mail-callbacks.c: Use "Sans Regular" instead of "Helvetica"
Index: mail-config-druid.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-config-druid.c,v
retrieving revision 1.100
diff -u -r1.100 mail-config-druid.c
--- mail-config-druid.c	16 Apr 2003 17:03:11 -0000	1.100
+++ mail-config-druid.c	2 Oct 2003 09:56:18 -0000
@@ -133,14 +133,14 @@
 static void
 identity_prepare (MailConfigWizard *mcw)
 {
-	const char *name;
-	
 	mcw->page = MAIL_CONFIG_WIZARD_PAGE_IDENTITY;
 	
-	name = gtk_entry_get_text (mcw->gui->full_name);
-	if (!name) {
-		name = g_get_real_name ();
-		gtk_entry_set_text (mcw->gui->full_name, name ? name : "");
+	if (!gtk_entry_get_text (mcw->gui->full_name)) {
+		char *uname;
+		
+		uname = g_locale_to_utf8 (g_get_real_name (), -1, NULL, NULL, NULL);
+		gtk_entry_set_text (mcw->gui->full_name, uname ? uname : "");
+		g_free (uname);
 		gtk_editable_select_region (GTK_EDITABLE (mcw->gui->full_name), 0, -1);
 	}
 	gtk_widget_grab_focus (GTK_WIDGET (mcw->gui->full_name));
@@ -478,7 +478,7 @@
 config_wizard_new (void)
 {
 	MailConfigWizard *mcw;
-	const char *name, *user;
+	const char *user;
 	EAccountService *xport;
 	struct utsname uts;
 	EAccount *account;
@@ -487,8 +487,7 @@
 	account = e_account_new ();
 	account->enabled = TRUE;
 	
-	name = g_get_real_name ();
-	account->id->name = g_strdup (name);
+	account->id->name = g_locale_to_utf8 (g_get_real_name (), -1, NULL, NULL, NULL);
 	user = g_get_user_name ();
 	if (user && !uname (&uts) && strchr (uts.nodename, '.'))
 		account->id->address = g_strdup_printf ("%s %s", user, uts.nodename);


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