Fixing encoding of non-string arrays

When array of non-string values assigned from array of strings (controller params, for example) it blows up with <tt>NoMethodError: undefined method `gsub'</tt> in <tt>quote_and_escape</tt>

It's because of <tt>quote_and_escape</tt> is called for values, which are strings before cast, while after casting it may become something other than string.

This patch fixes it, by calling <tt>quote_and_escape</tt> for values, which are strings after cast, not before.