Forum: Ruby on Rails Display problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A71728118f219c95758cea1af0c4845c?d=identicon&s=25 weirdmonkey (Guest)
on 2006-03-22 18:41
hey guys,

Does anyone know why the french letter "é" is displayed as a question
mark "?" inside an <h1> tag ?
5d15c6821f3c3054c04b85471824ba7c?d=identicon&s=25 Mikkel Bruun (Guest)
on 2006-03-22 18:46
(Received via mailing list)
check your character eoncoding header...

On Wednesday, March 22, 2006, at 6:41 PM, weirdmonkey wrote:
>http://lists.rubyonrails.org/mailman/listinfo/rails
Mikkel Bruun

www.strongside.dk    - Football Portal(DK)
nflfeed.helenius.org - Football News(DK)
ting.minline.dk      - Buy Old Stuff!(DK)
B8d11b4c89cfc6e34d6c9fb121c9acac?d=identicon&s=25 Claus Guttesen (Guest)
on 2006-03-22 18:48
(Received via mailing list)
> Does anyone know why the french letter "é" is displayed as a question
> mark "?" inside an <h1> tag ?

utf8/latin1 characterset?

regards
Claus
8d30b78dcd3ae8ff8d5e6085059060c7?d=identicon&s=25 Martin Bernd Schmeil (thebernd)
on 2006-03-22 19:10
Add this to app/controllers/application.rb. You may need to replace
iso-8859-1 with something else like utf8...

class ApplicationController < ActionController::Base
  ...

  after_filter :set_charset

  def set_charset
    @headers["Content-Type"] ||= "text/html; charset=iso-8859-1"
  end
end

- Bernd
89d967359903c639d31e4cad4569f537?d=identicon&s=25 Charlie Bowman (Guest)
on 2006-03-22 19:31
(Received via mailing list)
I have the same type of problems sometimes.  Will there be problems for
some users if I switch my charecter encoding to utf8?

On Wed, 2006-03-22 at 19:10 +0100, Martin Bernd Schmeil wrote:

>   end
> end
>
> - Bernd
>

Charlie Bowman
Programmer
Castle Branch Inc.
A71728118f219c95758cea1af0c4845c?d=identicon&s=25 weirdmonkey (Guest)
on 2006-03-22 23:30
Same problem with utf8....

here a pic: http://img214.imageshack.us/img214/1517/rordisplay2qj.jpg

Do I need to configure the MySQL fields with the utf8 charset ?
858392acd1398aa6071fb1d44cc33842?d=identicon&s=25 John Smilanick (Guest)
on 2006-03-22 23:48
(Received via mailing list)
Try using the h() function. It should change most characters to web
friendly characters.
Ex.
<%= h("text goes here") %>

-John

--
John Smilanick
Computing Staff - Webmaster
Kavli Institute for Theoretical Physics
University of California, Santa Barbara
jsmilani@kitp.ucsb.edu
(805) 893-6307
A71728118f219c95758cea1af0c4845c?d=identicon&s=25 weirdmonkey (Guest)
on 2006-03-23 00:05
here is my code for my list.rhtml :

<h1>Livres entrés dans MySQL</h1>

<% for livre in @livres %>
<div>
	<strong><%= livre.titre %></strong>: <%= link_to 'Afficher', :action =>
'show', :id => livre %>,
	<%= link_to 'Ã?diter', :action => 'edit', :id => livre %>,
	<%= link_to 'Enlever', { :action => 'destroy', :id => livre }, :confirm
=> "Voulez-vous vraiment enlever ce résumé ?" %>
</div>
<% end %>
<br />

<%= link_to 'Nouveau livre', :action => 'new' %>

everything that comes for the db displays fine, it is just Ruby
generated content that displays weird.

John, can you edit my code just to see how to implent it (i'm a big
beginner)

Thank you
858392acd1398aa6071fb1d44cc33842?d=identicon&s=25 John Smilanick (Guest)
on 2006-03-23 01:52
(Received via mailing list)
Try this...
==============
<h1><%= h("Livres entrés dans MySQL") %></h1>

<% for livre in @livres %>
<div>
	<strong><%= h(livre.titre) %></strong>: <%= link_to
'Afficher', :action =>
'show', :id => livre %>,
	<%= link_to h('Ã?diter'), :action => 'edit', :id => livre %>,
	<%= link_to 'Enlever', { :action => 'destroy', :id => livre }, :confirm
=> h("Voulez-vous vraiment enlever ce résumé ?") %>
</div>
<% end %>
<br />

<%= link_to 'Nouveau livre', :action => 'new' %>
=================
So if you look at the source of the page you will see "Livres entrés
dans MySQL" has become "Livres entr&eacute;s dans MySQL". You could
even rewrite the above rhtml after you view the source and get the
following:
==============
<h1>Livres entr&eacute;s dans MySQL</h1>

<% for livre in @livres %>
<div>
	<strong><%= h(livre.titre) %></strong>: <%= link_to
'Afficher', :action =>
'show', :id => livre %>,
	<%= link_to '&Eacute;diter', :action => 'edit', :id => livre %>,
	<%= link_to 'Enlever', { :action => 'destroy', :id => livre }, :confirm
=> "Voulez-vous vraiment enlever ce r&eacute;sum&eacute; ?" %>
</div>
<% end %>
<br />

<%= link_to 'Nouveau livre', :action => 'new' %>
=================
This will reduce a few unnecessary calls to h().


-John

--
John Smilanick
Computing Staff - Webmaster
Kavli Institute for Theoretical Physics
University of California, Santa Barbara
jsmilani@kitp.ucsb.edu
(805) 893-6307
A71728118f219c95758cea1af0c4845c?d=identicon&s=25 weirdmonkey (Guest)
on 2006-03-23 05:59
John Smilanick wrote:
> Try this...
> ==============
> <h1><%= h("Livres entrés dans MySQL") %></h1>
>
> <% for livre in @livres %>
> <div>
> 	<strong><%= h(livre.titre) %></strong>: <%= link_to
> 'Afficher', :action =>
...
>
> -John
>
> --
> John Smilanick
> Computing Staff - Webmaster
> Kavli Institute for Theoretical Physics
> University of California, Santa Barbara
> jsmilani@kitp.ucsb.edu
> (805) 893-6307

Thank you!
Problem fixed!
This topic is locked and can not be replied to.