def decode_irc!(string, encoding = :irc)
      if encoding == :irc
        # If incoming text is valid UTF-8, it will be interpreted as
        # such. If it fails validation, a CP1252 -> UTF-8 conversion
        # is performed. This allows you to see non-ASCII from mIRC
        # users (non-UTF-8) and other users sending you UTF-8.
        #
        # (from http://xchat.org/encoding/#hybrid)
        string.force_encoding("UTF-8")
        if !string.valid_encoding?
          string.force_encoding("CP1252").encode!("UTF-8", {:invalid => :replace, :undef => :replace})
        end
      else
        string.force_encoding(encoding).encode!({:invalid => :replace, :undef => :replace})
        string = string.chars.select { |c| c.valid_encoding? }.join
      end

      return string
    end
def decode_irc!(string, encoding = :irc)
      if encoding == :irc
        # If incoming text is valid UTF-8, it will be interpreted as
        # such. If it fails validation, a CP1252 -> UTF-8 conversion
        # is performed. This allows you to see non-ASCII from mIRC
        # users (non-UTF-8) and other users sending you UTF-8.
        #
        # (from http://xchat.org/encoding/#hybrid)
        string.force_encoding("UTF-8")
        if !string.valid_encoding?
          string.force_encoding("CP1252").encode!("UTF-8", {:invalid => :replace, :undef => :replace})
        end
      else
        string.force_encoding(encoding).encode!({:invalid => :replace, :undef => :replace})
        string = string.chars.select { |c| c.valid_encoding? }.join
      end

      return string
    end
Decode a message from an IRC connection, modifying it in place.
 @param [String] string The IRC string you want to decode.
 @param [Symbol] encoding The source encoding.
 @return [String] A UTF-8 Ruby string.