Forum: Rails-ES Re: Exportar datos a excell (Jorge Cal?s Lozano)

Posted by Angel Mauricio Pino Gonzalez (Guest)
on 2009-06-25 21:33
(Received via mailing list)
Tube el mismo problemay encontre este fuente que lo agregue a mi 
aplicaciòn:
meti este trozo de codigo en config/environment.rb

class String
  def encoding
    cuenta=0
    ascii=true
    self.each_byte do |byte|
      if cuenta>0
        if (byte >> 6) != 0b10
          return "iso8859"
        else
          cuenta-=1
        end
      elsif (byte & 0x80)
        ascii=false
        if (byte >> 5) == 0b110
          cuenta=1
        elsif (byte >> 4) == 0b1110
          cuenta=2
        elsif (byte >> 3) == 0b11110
          cuenta=3
        else
          return "iso8859"
        end
      end
    end
    return ascii ? "ascii":"utf8"
  end

  def to_utf8
    (self.encoding=='iso8859') ?
Iconv.new("utf-8","iso-8859-1").iconv(self.to_s) : self
  end
end


Lamentablemente no recuerdo de donde lo saque peo no es de mi 
invención.Espero te sea util
--
Angel Mauricio Pino G
AngelMauricio.PinoGonzalez@gmail.com
Movil: 08-577.92.72
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.