form_for text_field

I have a form

... html .....

<% form_for @person do |f| %>

... html .....

<%= f.text_field :last_name %>

... html .....

<% end %>

When last_name field of @person doesn't contains french special symbols
like 'é', all characters are displayed in the input control
(f.text_field :last_name ).

Else only symbols before french special symbol are displayed.

Why is it?

I am using

abstract (1.0.0)
actionmailer (2.3.5)
actionpack (3.1.1, 2.3.5)
activemodel (3.1.1, 3.0.3)
activerecord (2.3.5)
activerecord-oracle_enhanced-adapter (1.3.0)
activeresource (2.3.5)
activesupport (3.1.1, 3.0.3, 2.3.8, 2.3.5)
arel (2.0.6)
builder (3.0.0, 2.1.2)
calendar_date_select (1.16.1)
cgi_multipart_eof_fix (2.5.0)
columnize (0.3.2)
composite_primary_keys (2.3.5.1)
cucumber (0.7.2)
cucumber-rails (0.3.1)
diff-lcs (1.1.2)
erubis (2.7.0, 2.6.6)
ezcrypto (0.7.2)
factory_girl (1.2.4)
fastercsv (1.5.3)
formtastic (0.9.8)
gem_plugin (0.2.3)
gherkin (2.3.2 x86-mingw32, 1.0.26 i386-mingw32)
hike (1.2.1)
i18n (0.6.0, 0.5.0)
json (1.4.6)
json_pure (1.4.6, 1.4.3)
linecache (0.43)
log4r (1.1.7)
mongrel (1.1.5 x86-mingw32)
multi_json (1.0.3)
nokogiri (1.4.1 x86-mingw32)
prawn (0.8.4)
prawn-core (0.8.4)
prawn-layout (0.8.4)
prawn-security (0.8.4)
rack (1.3.5, 1.2.1, 1.0.1)
rack-cache (1.1)
rack-mount (0.8.3, 0.6.13)
rack-test (0.6.1, 0.5.6)
rails (2.3.5)
rake (0.8.7)
remarkable (3.1.13)
rspec (2.2.0, 1.3.0)
rspec-core (2.2.1)
rspec-expectations (2.2.0)
rspec-mocks (2.2.0)
rspec-rails (1.3.2)
ruby-debug (0.10.4)
ruby-debug-base (0.10.4)
ruby-debug-ide (0.4.9)
ruby-oci8 (2.0.3 x86-mswin32-60)
sprockets (2.0.3)
sqlite3-ruby (1.2.5 x86-mingw32)
term-ansicolor (1.0.5)
tilt (1.3.3)
trollop (1.16.2)
tzinfo (0.3.23)
will_paginate (2.3.12)
win32-api (1.4.6 x86-mingw32)
win32-clipboard (0.5.2)
win32-dir (0.3.6)
win32-eventlog (0.5.2)
win32-file (0.6.3)
win32-file-stat (1.3.4)
win32-process (0.6.2)
win32-sapi (0.1.5)
win32-sound (0.4.2)
win32console (1.3.0 x86-mingw32)
windows-api (0.4.0)
windows-pr (1.1.2, 1.0.9)
wxruby (2.0.1 x86-mingw32)

gems

I have a form

... html .....

<% form_for @person do |f| %>

... html .....

<%= f.text_field :last_name %>

... html .....

<% end %>

When last_name field of @person doesn't contains french special symbols
like 'é', all characters are displayed in the input control
(f.text_field :last_name ).

Else only symbols before french special symbol are displayed.

I'd start by checking that you are using the same encoding throughout the app (the encoding advertised to the browser, database connection encoding, encoding of the table/columns etc) or funny things will happen. For example if you try and insert invalid UTF8 content in a UTF8 column (eg because it's actually Latin-1 text) MySQL will silently truncate it.

Fred

Frederick Cheung wrote in post #1029736:

I'd start by checking that you are using the same encoding throughout
the app (the encoding advertised to the browser, database connection
encoding, encoding of the table/columns etc) or funny things will
happen. For example if you try and insert invalid UTF8 content in a UTF8
column (eg because it's actually Latin-1 text) MySQL will silently
truncate it.

Fred

I understand this idea. But if, for example, I have last_name = "tést"
and execute:

<%= f.text_field :last_name %>

results: t

<%= f.object.per_last_name %>

results: tést

So, I am not sure, but I think that encoding of page and database is ok.

But what do you think about it?

Ivan

And also I had detected that if I change

      def escape_once(html)
        ActiveSupport::Multibyte.clean(html.to_s).gsub(/[\"><]|&(?!([a-zA-Z\u00C0-\u00FF]+|(#\d+));)/)
{ |special| ERB::Util::HTML_ESCAPE[special] }
      end

method in
c:\Ruby187\lib\ruby\gems\1.8\gems\actionpack-2.3.5\lib\action_view\helpers\tag_helper.rb

to

  def escape_once(html)
       html
  end

french symbols are displayed but also are displayed many wrong symbols
like new line...