I have a page which validates “tentatively,” because the validator
uses the default character encoding. None was specified apparently,
so it falls back to UTF-8. How and where do I specify the character
encoding?
Pat
I have a page which validates “tentatively,” because the validator
uses the default character encoding. None was specified apparently,
so it falls back to UTF-8. How and where do I specify the character
encoding?
Pat
Pat
I have a page which validates “tentatively,” because the validator
uses the default character encoding. None was specified apparently,
so it falls back to UTF-8. How and where do I specify the character
encoding?
In layouts/application.html (f.ex), you can add:
...If you use AJAX and partial rendering, you may have to specify it
through headers, in order for special international characters to render
correctly :
def update_positions
@lists = ...
@headers["Content-Type"] = "text/html; charset=utf-8"
render :partial => 'lists'
end
Alain
On Feb 25, 2006, at 10:38, Alain R. wrote:
If you use AJAX and partial rendering, you may have to specify it
through headers, in order for special international characters to
render correctly :def update_positions @lists = ... @headers["Content-Type"] = "text/html; charset=utf-8" render :partial => 'lists' end
Argh, I missed that detail in my AJAX actions, which are called as
components as well.
Since all my application is UTF-8 setting the header could be done
for all actions, would it be clean to set that header with a filter
in application.rb provided my program only serves XHTML? If that’s
right, is the META element still needed? Maybe it doesn’t hurt as
long as they coincide?
– fxn
class ApplicationController < ActionController::Base
before_filter :set_charset
def set_charset
@headers[“Content-Type”] = “text/html; charset=iso-8859-1”
end
end
Great tip.
AFAIK, this is the only way to make in_place_edit work with special
characters, as the methods that return the partial are generated by
Rails, and we can’t access them.
How come Rails doesn’t do this by default?
Alain
On 2/25/06, Alain R. [email protected] wrote:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> @lists = ...
Just wanted to say this worked perfectly, thanks.
Pat M. wrote:
I have a page which validates “tentatively,” because the validator
uses the default character encoding. None was specified apparently,
so it falls back to UTF-8. How and where do I specify the character
encoding?
This works for me
app/constrollers/application.rb:
class ApplicationController < ActionController::Base
before_filter :set_charset
def set_charset
@headers["Content-Type"] = "text/html; charset=iso-8859-1"
end
end
// Daniel
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs