comparison app/helpers/.svn/text-base/attachments_helper.rb.svn-base @ 119:8661b858af72

* Update to Redmine trunk rev 4705
author Chris Cannam
date Thu, 13 Jan 2011 14:12:06 +0000
parents 513646585e45
children cbce1fd3b1b7
comparison
equal deleted inserted replaced
39:150ceac17a8d 119:8661b858af72
27 render :partial => 'attachments/links', :locals => {:attachments => container.attachments, :options => options} 27 render :partial => 'attachments/links', :locals => {:attachments => container.attachments, :options => options}
28 end 28 end
29 end 29 end
30 30
31 def to_utf8(str) 31 def to_utf8(str)
32 str 32 if str.respond_to?(:force_encoding)
33 str.force_encoding('UTF-8')
34 return str if str.valid_encoding?
35 else
36 return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii
37 end
38
39 begin
40 Iconv.conv('UTF-8//IGNORE', 'UTF-8', str + ' ')[0..-3]
41 rescue Iconv::InvalidEncoding
42 # "UTF-8//IGNORE" is not supported on some OS
43 str
44 end
33 end 45 end
34 end 46 end