scm: Ruby 1.9 compatibility for diff, cat and blame (#2664).
"\xC2\x80" of latin1(iso-8859-1) is valid sequence of UTF-8. to_utf8() should not return string if it is UTF-8 valid_encoding. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4922 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
ae8f4c1f2a
commit
1e5e1b6ae7
|
@ -119,11 +119,13 @@ module RepositoriesHelper
|
||||||
def to_utf8(str)
|
def to_utf8(str)
|
||||||
if str.respond_to?(:force_encoding)
|
if str.respond_to?(:force_encoding)
|
||||||
str.force_encoding('UTF-8')
|
str.force_encoding('UTF-8')
|
||||||
return str if str.valid_encoding?
|
|
||||||
else
|
else
|
||||||
|
# TODO:
|
||||||
|
# Japanese Shift_JIS(CP932) is not compatible with ASCII.
|
||||||
|
# UTF-7 and Japanese ISO-2022-JP are 7bits clean.
|
||||||
return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii
|
return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii
|
||||||
end
|
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
|
||||||
|
|
Loading…
Reference in New Issue