ruby - Isn't user data that comes in from a form in Rails going to be UTF-8 encoded? -



ruby - Isn't user data that comes in from a form in Rails going to be UTF-8 encoded? -

a rails 3.2 app i'm contributing has method coerces user input utf-8.

require "iconv" def normalize(user_input_text) iconv.new('utf-8//ignore', 'utf-8').iconv(user_input_text.dup) end

it encodes string in utf-8 , ignores characters can't transcoded.

but isn't user info that's entering rails through form going utf-8 encoded?

in other words, isn't code specious , unnecessary?

these resources suggest indeed right.

now vast bulk of web input utf-8, set inbound parameters utf-8. eliminate many cases of incompatible encodings between ascii-8bit , utf-8.

https://github.com/rails/rails/commit/25215d7285db10e2c04d903f251b791342e4dd6a

rails 3 solves nicely doing number of things including interpreting params utf-8 , adding workarounds net explorer

http://jasoncodes.com/posts/ruby19-rails2-encodings

ruby-on-rails ruby ruby-on-rails-3 character-encoding

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -