iconv has been removed in ruby 2, use glib instead (pterjan)
authorGuillaume Cottenceau <gcottenc@gmail.com>
Thu, 19 Dec 2013 21:41:02 +0000 (22:41 +0100)
committerGuillaume Cottenceau <gcottenc@gmail.com>
Thu, 19 Dec 2013 21:41:02 +0000 (22:41 +0100)
lib/booh/booh-lib.rb

index 9495810..af6f331 100644 (file)
@@ -17,7 +17,6 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-require 'iconv'
 require 'timeout'
 require 'tempfile'
 require 'monitor'
@@ -30,6 +29,7 @@ bindtextdomain("booh")
 
 require 'booh/config.rb'
 require 'booh/version.rb'
+require 'glib2'
 begin
     require 'gtk2'
 rescue LoadError, Gtk::InitError
@@ -55,7 +55,7 @@ module Booh
 
     def utf8(string)
         begin
-            return Iconv.conv("UTF-8", $CURRENT_CHARSET, string)
+            return GLib.convert(string, 'UTF-8', $CURRENT_CHARSET)
         rescue
             return "???"
         end
@@ -63,7 +63,7 @@ module Booh
 
     def utf8cut(string, maxlen)
         begin
-            return Iconv.conv("UTF-8", $CURRENT_CHARSET, string[0..maxlen-1])
+            return GLib.convert(string[0..maxlen-1], 'UTF-8', $CURRENT_CHARSET)
         rescue Iconv::InvalidCharacter
             return utf8cut(string, maxlen-1)
         rescue
@@ -92,12 +92,12 @@ module Booh
     end
     
     def from_utf8(string)
-        return Iconv.conv($CURRENT_CHARSET, "UTF-8", string)
+        return GLib.convert(string, $CURRENT_CHARSET, 'UTF-8')
     end
 
     def from_utf8_safe(string)
         begin
-            return Iconv.conv($CURRENT_CHARSET, "UTF-8", string)
+            return GLib.convert(string, $CURRENT_CHARSET, 'UTF-8')
         rescue Iconv::IllegalSequence
             return ''
         end