dcparker / ruby-gmail

A Rubyesque interface to Gmail. Connect to Gmail via IMAP and manipulate emails and labels. Send email with your Gmail account via SMTP. Includes full support for parsing and generating MIME messages.
http://dcparker.github.com/ruby-gmail
790 stars 123 forks source link

shared-mime-info needs updated for ruby1.9 #9

Closed dcparker closed 11 years ago

dcparker commented 14 years ago

Contacted the author, hopefully it will be fixed soon.

To fix for ruby1.9, replace line 250 of shared-mime-info.rb with the following:

enum = @globs.each_key rescue Enumerable::Enumerator.new(@globs, :each_key)

oren commented 14 years ago

Even after changing line 250 I get this error:

/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/shared-mime-info-0.1/lib/shared-mime-info.rb:345:in `block (2 levels) in load_magic': invalid byte sequence in UTF-8 (ArgumentError)

Any clues?

thekindofme commented 14 years ago

Got this same error on 1.9 Ubuntu stock installation. Works fine with 1.8 though.

delta32 commented 14 years ago

i got, too

dcparker commented 14 years ago

Try adding the following near the top of shared-mime-info.rb:

require 'unicode'
class String
  def to_ascii_unicode
    Unicode.normalize_KD(self).unpack('U*').select{ |cp| cp < 127 }.pack('U*')
  end
end

and add ".to_ascii_unicode" to the end of what will now be #359, "buf << line"

Someone please verify whether that works or not? I got that from http://www.jroller.com/obie/entry/fix_that_tranny_add_to, in case it doesn't work and you want to try some of the other methods there or learn more about the problem itself.

xxx commented 13 years ago

Another solution is to force the encoding in the File.open call on line 335:

open(file) { |f|

becomes

open(file, 'r:ASCII-8BIT') { |f|
marcbowes commented 12 years ago

Still broken? :-(

myobie commented 11 years ago

I'm pretty sure this is fixed in master and 0.3.0. Let me know if it's not.