GitLab steht wegen Wartungsarbeiten am Montag, den 10. Mai, zwischen 17:00 und 19:00 Uhr nicht zur Verfügung.

Commit b86f19b0 authored by jplang's avatar jplang

Don't use iconv with ruby1.9 (#12787).

git-svn-id: https://svn.redmine.org/redmine/trunk@11440 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 06bd5f72
......@@ -18,7 +18,7 @@
desc 'Mantis migration script'
require 'active_record'
require 'iconv'
require 'iconv' if RUBY_VERSION < '1.9'
require 'pp'
namespace :redmine do
......@@ -440,9 +440,7 @@ task :migrate_from_mantis => :environment do
end
def self.encoding(charset)
@ic = Iconv.new('UTF-8', charset)
rescue Iconv::InvalidEncoding
return false
@charset = charset
end
def self.establish_connection(params)
......@@ -454,9 +452,12 @@ task :migrate_from_mantis => :environment do
end
def self.encode(text)
@ic.iconv text
rescue
text
if RUBY_VERSION < '1.9'
@ic ||= Iconv.new('UTF-8', @charset)
@ic.iconv text
else
text.to_s.force_encoding(@charset).encode('UTF-8')
end
end
end
......
......@@ -16,7 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require 'active_record'
require 'iconv'
require 'iconv' if RUBY_VERSION < '1.9'
require 'pp'
namespace :redmine do
......@@ -603,10 +603,7 @@ namespace :redmine do
end
def self.encoding(charset)
@ic = Iconv.new('UTF-8', charset)
rescue Iconv::InvalidEncoding
puts "Invalid encoding!"
return false
@charset = charset
end
def self.set_trac_directory(path)
......@@ -713,11 +710,13 @@ namespace :redmine do
end
end
private
def self.encode(text)
@ic.iconv text
rescue
text
if RUBY_VERSION < '1.9'
@ic ||= Iconv.new('UTF-8', @charset)
@ic.iconv text
else
text.to_s.force_encoding(@charset).encode('UTF-8')
end
end
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment