Patch #2862

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

Added by Chaoqun Zou over 12 years ago. Updated over 10 years ago.

Status:NewStart date:2009-02-28
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:I18n
Target version:-

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

History

#1 Updated by Toshi MARUYAMA over 10 years ago

  • Category set to I18n

Also available in: Atom PDF