Fixes utf8 conversions with ruby1.9.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4605 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
488285e123
commit
ad727d3781
|
@ -29,7 +29,13 @@ module AttachmentsHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_utf8(str)
|
def to_utf8(str)
|
||||||
return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii
|
if str.respond_to?(:force_encoding)
|
||||||
|
str.force_encoding('UTF-8')
|
||||||
|
return str if str.valid_encoding?
|
||||||
|
else
|
||||||
|
return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii
|
||||||
|
end
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Iconv.conv('UTF-8//IGNORE', 'UTF-8', str + ' ')[0..-3]
|
Iconv.conv('UTF-8//IGNORE', 'UTF-8', str + ' ')[0..-3]
|
||||||
rescue Iconv::InvalidEncoding
|
rescue Iconv::InvalidEncoding
|
||||||
|
|
|
@ -113,7 +113,13 @@ module RepositoriesHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_utf8(str)
|
def to_utf8(str)
|
||||||
return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii
|
if str.respond_to?(:force_encoding)
|
||||||
|
str.force_encoding('UTF-8')
|
||||||
|
return str if str.valid_encoding?
|
||||||
|
else
|
||||||
|
return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii
|
||||||
|
end
|
||||||
|
|
||||||
@encodings ||= Setting.repositories_encodings.split(',').collect(&:strip)
|
@encodings ||= Setting.repositories_encodings.split(',').collect(&:strip)
|
||||||
@encodings.each do |encoding|
|
@encodings.each do |encoding|
|
||||||
begin
|
begin
|
||||||
|
|
|
@ -227,7 +227,13 @@ class Changeset < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.to_utf8(str)
|
def self.to_utf8(str)
|
||||||
return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii
|
if str.respond_to?(:force_encoding)
|
||||||
|
str.force_encoding('UTF-8')
|
||||||
|
return str if str.valid_encoding?
|
||||||
|
else
|
||||||
|
return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii
|
||||||
|
end
|
||||||
|
|
||||||
encoding = Setting.commit_logs_encoding.to_s.strip
|
encoding = Setting.commit_logs_encoding.to_s.strip
|
||||||
unless encoding.blank? || encoding == 'UTF-8'
|
unless encoding.blank? || encoding == 'UTF-8'
|
||||||
begin
|
begin
|
||||||
|
|
Loading…
Reference in New Issue