vendor/bundle/ruby/2.1.0/gems/gitlab-flowdock-git-hook-0.4.2.2/lib/flowdock/git/builder.rb
def encode_as_utf8(obj)
        if obj.is_a? Hash
          obj.each_pair do |key, val|
            encode_as_utf8(val)
          end
        elsif obj.is_a?(Array)
          obj.each do |val|
            encode_as_utf8(val)
          end
        elsif obj.is_a?(String) && obj.encoding != Encoding::UTF_8
          if !obj.force_encoding("UTF-8").valid_encoding?
            obj.force_encoding("ISO-8859-1").encode!(Encoding::UTF_8, :invalid => :replace, :undef => :replace)
          end
        end
        obj
      end
# This only works on Ruby 1.9
This only works on Ruby 1.9
This only works on Ruby 1 . 9
def encode_as_utf8(obj)
        if obj.is_a? Hash
          obj.each_pair do |key, val|
            encode_as_utf8(val)
          end
        elsif obj.is_a?(Array)
          obj.each do |val|
            encode_as_utf8(val)
          end
        elsif obj.is_a?(String) && obj.encoding != Encoding::UTF_8
          if !obj.force_encoding("UTF-8").valid_encoding?
            obj.force_encoding("ISO-8859-1").encode!(Encoding::UTF_8, :invalid => :replace, :undef => :replace)
          end
        end
        obj
      end
def encode_as_utf8 ( obj ) if obj . is_a? Hash obj . each_pair do | key , val | encode_as_utf8 ( val ) end elsif obj . is_a? ( Array ) obj . each do | val | encode_as_utf8 ( val ) end elsif obj . is_a? ( String ) && obj . encoding != Encoding :: UTF_8 if ! obj . force_encoding ( "UTF-8" ) . valid_encoding? obj . force_encoding ( "ISO-8859-1" ) . encode! ( Encoding :: UTF_8 , :invalid => :replace , :undef => :replace ) end end obj end
This only works on Ruby 1.9
This only works on Ruby 1 . 9
obj