##// END OF EJS Templates
Don't use iconv with ruby1.9 (#12787)....
Jean-Philippe Lang -
r11210:59c704dcd2a2
parent child
Show More
@@ -18,7 +18,7
18 18 desc 'Mantis migration script'
19 19
20 20 require 'active_record'
21 require 'iconv'
21 require 'iconv' if RUBY_VERSION < '1.9'
22 22 require 'pp'
23 23
24 24 namespace :redmine do
@@ -440,9 +440,7 task :migrate_from_mantis => :environment do
440 440 end
441 441
442 442 def self.encoding(charset)
443 @ic = Iconv.new('UTF-8', charset)
444 rescue Iconv::InvalidEncoding
445 return false
443 @charset = charset
446 444 end
447 445
448 446 def self.establish_connection(params)
@@ -454,9 +452,12 task :migrate_from_mantis => :environment do
454 452 end
455 453
456 454 def self.encode(text)
455 if RUBY_VERSION < '1.9'
456 @ic ||= Iconv.new('UTF-8', @charset)
457 457 @ic.iconv text
458 rescue
459 text
458 else
459 text.to_s.force_encoding(@charset).encode('UTF-8')
460 end
460 461 end
461 462 end
462 463
@@ -16,7 +16,7
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require 'active_record'
19 require 'iconv'
19 require 'iconv' if RUBY_VERSION < '1.9'
20 20 require 'pp'
21 21
22 22 namespace :redmine do
@@ -603,10 +603,7 namespace :redmine do
603 603 end
604 604
605 605 def self.encoding(charset)
606 @ic = Iconv.new('UTF-8', charset)
607 rescue Iconv::InvalidEncoding
608 puts "Invalid encoding!"
609 return false
606 @charset = charset
610 607 end
611 608
612 609 def self.set_trac_directory(path)
@@ -713,11 +710,13 namespace :redmine do
713 710 end
714 711 end
715 712
716 private
717 713 def self.encode(text)
714 if RUBY_VERSION < '1.9'
715 @ic ||= Iconv.new('UTF-8', @charset)
718 716 @ic.iconv text
719 rescue
720 text
717 else
718 text.to_s.force_encoding(@charset).encode('UTF-8')
719 end
721 720 end
722 721 end
723 722
General Comments 0
You need to be logged in to leave comments. Login now