I have french unicoded coded characters in my database. They use the
ê format.
When I use form.collection_select it turns the & into & and then the
french character is not displayed.
How can I resolve this.
Thanks in advance
I have french unicoded coded characters in my database. They use the
ê format.
When I use form.collection_select it turns the & into & and then the
french character is not displayed.
How can I resolve this.
Thanks in advance
I wouldn’t use HTML entities in the database since you may display
them in other contexts than HTML/XML, and also get problems like this
one. So if possible, store the text in some unicode encoding in the
database, without entities.
If you must use entities for some reason, I suppose you could just
decode them before passing to collection_select. I think
CGI.unescapeHTML is pretty limited, but there are libs:
http://www.google.com/search?q=ruby+decode+html+entities
Henrik — wrote:
I wouldn’t use HTML entities in the database since you may display
them in other contexts than HTML/XML, and also get problems like this
one. So if possible, store the text in some unicode encoding in the
database, without entities.If you must use entities for some reason, I suppose you could just
decode them before passing to collection_select. I think
CGI.unescapeHTML is pretty limited, but there are libs:
ruby decode html entities - Google Search
The problem no matter what I am using as encoding the form helper
function form.collection_select changes the & to �.
If I put the same code for the french accent on the page I get the
correct output.
Norvège => Norvège.
I really just want to turn the html escaping off so that the characters
are displayed properly.
That would solve one of my problems. Why does rails make it so hard to
do basic stuff with language?
Mitchell G. wrote:
Henrik — wrote:
I wouldn’t use HTML entities in the database since you may display
them in other contexts than HTML/XML, and also get problems like this
one. So if possible, store the text in some unicode encoding in the
database, without entities.If you must use entities for some reason, I suppose you could just
decode them before passing to collection_select. I think
CGI.unescapeHTML is pretty limited, but there are libs:
ruby decode html entities - Google SearchThe problem no matter what I am using as encoding the form helper
function form.collection_select changes the & to �.If I put the same code for the french accent on the page I get the
correct output.Norvège => Norvège.
I really just want to turn the html escaping off so that the characters
are displayed properly.That would solve one of my problems. Why does rails make it so hard to
do basic stuff with language?
I found a way around the problem. I am not sure if its the best
practices way but here it is
<%= form.collection_select( :country, @countries, :name, :name,
options ={ :prompt => t(‘services.req_form.country_prompt’)}
).gsub(‘&’, ‘&’) %>
collection_select escapes the & used for my french character html
entity. So I replace all instances of the & with &. It works.
I would appreciate any comments if this is ok to do and if not what is a
better way.
Thanks
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