attachments_helper.rb.patch

attachments_helper.rb.patch - Akiko Takano, 2010-03-25 08:02

Download (693 Bytes)

View differences:

/mnt/base02_data/attachments_helper.rb 2010-03-25 15:57:53.764533400 +0900
27 27
      render :partial => 'attachments/links', :locals => {:attachments => container.attachments, :options => options}
28 28
    end
29 29
  end
30

  
30
  
31 31
  def to_utf8(str)
32
    return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii
33
    @encodings ||= Setting.repositories_encodings.split(',').collect(&:strip)
34
    @encodings.each do |encoding|
35
      begin
36
        return Iconv.conv('UTF-8', encoding, str)
37
      rescue Iconv::Failure
38
        # do nothing here and try the next encoding
39
      end
40
    end
41 32
    str
42 33
  end
43 34
end