Project

General

Profile

Actions

Patch #2862

open

Make user sorting by his localized encoding name instead of utf-8 encoding name

Added by Chaoqun Zou about 15 years ago. Updated about 13 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
I18n
Target version:
-
Start date:
2009-02-28
Due date:
% Done:

0%

Estimated time:

Description

For those using non-ASCII systems, sorting user by name using a utf-8 encoding name and sorting user by name using their localized encoding name have different results.

For example: there are three users: user1, user2, user3.
If we sort them by name using the original utf-8 strings, the order may be: user1, user2, user3.
But when we convert the name string to another encoding(like gb2312) first, and then sort them by name, the result's order may be: user2, user1, user3.
And the second result is more acceptable than the first one.

So I thought that it would be great to convert the name string from utf-8 to the localized encoding before sorting user by name.

Since there is just one line bo be add to the user's model class, I didn't attach a diff file.
About line 217:

  def <=>(user)
    ic = Iconv.new(l(:general_csv_encoding), 'UTF-8')
    ic.iconv(self.to_s.downcase) <=> ic.iconv(user.to_s.downcase)
  end

Actions #1

Updated by Toshi MARUYAMA about 13 years ago

  • Category set to I18n
Actions

Also available in: Atom PDF