Thunar的“按名称排列”的依据是什么?

其它类软件,非上述版软件
回复
头像
chenjietao
帖子: 130
注册时间: 2010-09-21 1:50

Thunar的“按名称排列”的依据是什么?

#1

帖子 chenjietao »

2012-07-19--1342688665_1024x768_scrot.png
如图,按名称排列,结果有的中文字在数字英文前面,有的中文在英文后面,中文的及排列既不是按拼音排列,也不是按笔画排列,实在搞不懂。
262652047
帖子: 495
注册时间: 2008-01-04 9:55
系统: Ubuntu 12.10
来自: Beijing /PRC
联系:

Re: Thunar的“按名称排列”的依据是什么?

#2

帖子 262652047 »

utf8编码
还在纠结发行版和版本号的基本上是新手
$.get('better.life',
  {study:hard,work:hard},
    function(reality){
      return Math.random(reality)
    })
头像
chenjietao
帖子: 130
注册时间: 2010-09-21 1:50

Re: Thunar的“按名称排列”的依据是什么?

#3

帖子 chenjietao »

262652047,
能把它恢复正常吗? :em06
即按照数字>英文>中文的顺序排列,中文按拼音排列。
我的桌面是openbox。
头像
cuihao
帖子: 4793
注册时间: 2008-07-24 11:33
来自: 郑州
联系:

Re: Thunar的“按名称排列”的依据是什么?

#4

帖子 cuihao »

恢复正常
这就是正常……
求人不如求它仨: 天蓝的Wiki 屎黄的Wiki 绿
Site: CUIHAO.TK    Twitter: @cuihaoleo
Machine: Athlon64 X2 5200+ / 2x2GB DDR2-800 / GeForce GTS 450
AD: ~まだ見ぬ誰かの笑顔のために~
头像
chenjietao
帖子: 130
注册时间: 2010-09-21 1:50

Re: Thunar的“按名称排列”的依据是什么?

#5

帖子 chenjietao »

cuihao 写了:
恢复正常
这就是正常……
能不能让它不正常
头像
cuihao
帖子: 4793
注册时间: 2008-07-24 11:33
来自: 郑州
联系:

Re: Thunar的“按名称排列”的依据是什么?

#6

帖子 cuihao »

:em01 修改代码?
不知道一般是怎么排的,比如Windows是怎么弄的呢?
求人不如求它仨: 天蓝的Wiki 屎黄的Wiki 绿
Site: CUIHAO.TK    Twitter: @cuihaoleo
Machine: Athlon64 X2 5200+ / 2x2GB DDR2-800 / GeForce GTS 450
AD: ~まだ見ぬ誰かの笑顔のために~
头像
cuihao
帖子: 4793
注册时间: 2008-07-24 11:33
来自: 郑州
联系:

Re: Thunar的“按名称排列”的依据是什么?

#7

帖子 cuihao »

我写了个挺无聊的补丁…… LZ看如何:
图片

[c]--- Thunar-1.4.0 的副本/thunar/thunar-file.c 2012-04-29 04:16:39.000000000 +0800
+++ Thunar-1.4.0/thunar/thunar-file.c 2012-07-19 19:51:07.000000000 +0800
@@ -3327,19 +3327,6 @@ thunar_file_compare_by_name (const Thuna
if (ac != bc || ac == 0 || ac > 127)
break;
}
-
- /* fallback to Unicode comparison */
- if (G_UNLIKELY (ac > 127 || bc > 127))
- {
- for (;; ap = g_utf8_next_char (ap), bp = g_utf8_next_char (bp))
- {
- /* check if characters differ or end of string */
- ac = g_utf8_get_char (ap);
- bc = g_utf8_get_char (bp);
- if (ac != bc || ac == 0)
- break;
- }
- }
}
else
{
@@ -3352,19 +3339,6 @@ thunar_file_compare_by_name (const Thuna
if (g_ascii_tolower (ac) != g_ascii_tolower (bc) || ac == 0 || ac > 127)
break;
}
-
- /* fallback to Unicode comparison (case-insensitive!) */
- if (G_UNLIKELY (ac > 127 || bc > 127))
- {
- for (;; ap = g_utf8_next_char (ap), bp = g_utf8_next_char (bp))
- {
- /* check if characters differ or end of string */
- ac = g_utf8_get_char (ap);
- bc = g_utf8_get_char (bp);
- if (g_unichar_tolower (ac) != g_unichar_tolower (bc) || ac == 0)
- break;
- }
- }
}

/* if both strings are equal, we're done */
@@ -3402,44 +3376,6 @@ thunar_file_compare_by_name (const Thuna
}
}

- /* otherwise, if they differ in a unicode char, use the
- * appropriate collate function for the current locale (only
- * if charset is UTF-8, else the required transformations
- * would be too expensive)
- */
-#ifdef HAVE_STRCOLL
- if ((ac > 127 || bc > 127) && g_get_charset (NULL))
- {
- /* case-sensitive is easy, case-insensitive is expensive,
- * but we use a simple optimization to make it fast.
- */
- if (G_LIKELY (case_sensitive))
- {
- return strcoll (ap, bp);
- }
- else
- {
- /* we use a trick here, so we don't need to allocate
- * and transform the two strings completely first (8
- * byte for each buffer, so all compilers should align
- * them properly)
- */
- gchar abuf[8];
- gchar bbuf[8];
-
- /* transform the unicode chars to strings and
- * make sure the strings are nul-terminated.
- */
- abuf[g_unichar_to_utf8 (g_unichar_tolower(ac), abuf)] = '\0';
- bbuf[g_unichar_to_utf8 (g_unichar_tolower(bc), bbuf)] = '\0';
-
- /* compare the unicode chars (as strings) */
- return strcoll (abuf, bbuf);
- }
- }
-#endif
-
- /* else, they differ in an ASCII character */
if (G_UNLIKELY (!case_sensitive))
return (g_unichar_tolower (ac) > g_unichar_tolower (bc)) ? 1 : -1;
else[/c]
(嘛,为了折叠代码,直接用C高亮算了。)
求人不如求它仨: 天蓝的Wiki 屎黄的Wiki 绿
Site: CUIHAO.TK    Twitter: @cuihaoleo
Machine: Athlon64 X2 5200+ / 2x2GB DDR2-800 / GeForce GTS 450
AD: ~まだ見ぬ誰かの笑顔のために~
头像
chenjietao
帖子: 130
注册时间: 2010-09-21 1:50

Re: Thunar的“按名称排列”的依据是什么?

#8

帖子 chenjietao »

cuihao, 辛苦了,貌似是删掉一些代码,下次用用你的补丁。
头像
cuihao
帖子: 4793
注册时间: 2008-07-24 11:33
来自: 郑州
联系:

Re: Thunar的“按名称排列”的依据是什么?

#9

帖子 cuihao »

:em08 删除掉utf8字符排序部分,退化成纯编码排序就好了…… 不知道有没有副作用,因为我也不知道原来的代码都是干啥的。
求人不如求它仨: 天蓝的Wiki 屎黄的Wiki 绿
Site: CUIHAO.TK    Twitter: @cuihaoleo
Machine: Athlon64 X2 5200+ / 2x2GB DDR2-800 / GeForce GTS 450
AD: ~まだ見ぬ誰かの笑顔のために~
回复