locale encoding filename in Nautilus



When nautilus accesses smb:// URI, it will dispaly all the locale
encoding filename as "Invalid Unicode", nautilus has never tried to
convert them to utf8. The same to ftp:// . Nautilus can display locale
encoding filename in local filesystem correctly, however, when you export your directory as Samba Share, your network neighbor cannot
display them at all! This is strange and troubles users a lot.

About line 2396 in the function nautilus_file_get_display_name_nocopy()
of the file libnautilus-private/nautilus-file.c, I found the following
code:

if (has_local_path (file)) {
   ...
   if (broken_filenames || !g_utf8_validate (name, -1, NULL)) {
       utf8_name = g_locale_to_utf8 (name, -1, NULL, NULL, NULL);
... Im wondering why the convert just performes on files in the local filesystem. I want to move it before 'if' so that it will be efficient
on all of the URI.

Besides that, the file operations progress box needs a similar modify, too. My patch is attached.

diff -u nautilus-2.4.1/libnautilus-private/nautilus-file.c nautilus-2.4.1-locale/libnautilus-private/nautilus-file.c
--- nautilus-2.4.1/libnautilus-private/nautilus-file.c	2003-09-19 19:28:07.000000000 +0800
+++ nautilus-2.4.1-locale/libnautilus-private/nautilus-file.c	2003-10-22 14:11:09.000000000 +0800
@@ -2407,20 +2407,21 @@
 			 * thing with any local filename that does not
 			 * validate as good UTF-8.
 			 */
-			if (has_local_path (file)) {
-				broken_filenames = have_broken_filenames ();
-				if (broken_filenames || !g_utf8_validate (name, -1, NULL)) {
-					utf8_name = g_locale_to_utf8 (name, -1, NULL, NULL, NULL);
-					if (utf8_name != NULL) {
-						g_free (name);
-						name = utf8_name;
-						/* Guaranteed to be correct utf8 here */
-						validated = TRUE;
-					}
-				} else if (!broken_filenames) {
-					/* name was valid, no need to re-validate */
+			broken_filenames = have_broken_filenames ();
+			if (broken_filenames || !g_utf8_validate (name, -1, NULL)) {
+				utf8_name = g_locale_to_utf8 (name, -1, NULL, NULL, NULL);
+				if (utf8_name != NULL) {
+					g_free (name);
+					name = utf8_name;
+					/* Guaranteed to be correct utf8 here */
 					validated = TRUE;
 				}
+			} else if (!broken_filenames) {
+				/* name was valid, no need to re-validate */
+				validated = TRUE;
+			}
+
+			if (has_local_path (file)) {
 			} else if (strcmp (name, "/") == 0) {
 				/* Special-case the display name for roots that are not local files */
 				g_free (name);
diff -u nautilus-2.4.1/libnautilus-private/nautilus-file-operations-progress.c nautilus-2.4.1-locale/libnautilus-private/nautilus-file-operations-progress.c
--- nautilus-2.4.1/libnautilus-private/nautilus-file-operations-progress.c	2003-02-28 23:14:57.000000000 +0800
+++ nautilus-2.4.1-locale/libnautilus-private/nautilus-file-operations-progress.c	2003-10-22 16:39:01.000000000 +0800
@@ -162,8 +162,19 @@
 		return;
 	}
 	
+	printf("text: %s ", text);
 	unescaped_text = gnome_vfs_unescape_string_for_display (text);
+	printf("unescaped: %s ", unescaped_text);
+	if (!g_utf8_validate(unescaped_text, -1, NULL)) {
+		char *convert;
+		convert = g_locale_to_utf8 (unescaped_text, -1, NULL, NULL, NULL);
+		if (convert != NULL) {
+			g_free (unescaped_text);
+			unescaped_text = convert;
+		}
+	}
 	unescaped_utf8 = eel_make_valid_utf8 (unescaped_text);
+	printf("utf8: %s\n\r", unescaped_utf8);
 	eel_ellipsizing_label_set_text (label, unescaped_utf8);
 	g_free (unescaped_utf8);
 	g_free (unescaped_text);


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