def safely_convert_to_utf8(binary_string)
      if binary_string.respond_to?(:force_encoding)
        # Ruby 1.9
        converter = Encoding::Converter.new('binary', 'utf-8', :invalid => :replace, :undef => :replace)
        converter.convert(binary_string)
      else
        # Ruby 1.8 - currently don't do anything
        binary_string
      end
    end
def safely_convert_to_utf8(binary_string)
      if binary_string.respond_to?(:force_encoding)
        # Ruby 1.9
        converter = Encoding::Converter.new('binary', 'utf-8', :invalid => :replace, :undef => :replace)
        converter.convert(binary_string)
      else
        # Ruby 1.8 - currently don't do anything
        binary_string
      end
    end
Converts a binary, (alomst) UTF-8 string into an actual UTF-8 string.
 It will replace any unknown characters or unvalid byte sequences into a UTF-8
 "unknown character" question mark.

 @param [String] binary_string The input string, should have binary encoding
 @return [String] The string using UTF-8 encoding.