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.
weirdmonkey (Guest)
on 2006-03-22 19:41
hey guys,

Does anyone know why the french letter "é" is displayed as a question
mark "?" inside an <h1> tag ?
Mikkel B. (Guest)
on 2006-03-22 19: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 B.

www.strongside.dk    - Football Portal(DK)
nflfeed.helenius.org - Football News(DK)
ting.minline.dk      - Buy Old Stuff!(DK)
Claus G. (Guest)
on 2006-03-22 19: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
Martin Bernd S. (Guest)
on 2006-03-22 20: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
Charlie B. (Guest)
on 2006-03-22 20: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 S. wrote:

>   end
> end
>
> - Bernd
>

Charlie B.
Programmer
Castle Branch Inc.
weirdmonkey (Guest)
on 2006-03-23 00: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 ?
John S. (Guest)
on 2006-03-23 00: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 S.
Computing Staff - Webmaster
Kavli Institute for Theoretical Physics
University of California, Santa Barbara
removed_email_address@domain.invalid
(805) 893-6307
weirdmonkey (Guest)
on 2006-03-23 01: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
John S. (Guest)
on 2006-03-23 02: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 S.
Computing Staff - Webmaster
Kavli Institute for Theoretical Physics
University of California, Santa Barbara
removed_email_address@domain.invalid
(805) 893-6307
weirdmonkey (Guest)
on 2006-03-23 06:59
John S. 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 S.
> Computing Staff - Webmaster
> Kavli Institute for Theoretical Physics
> University of California, Santa Barbara
> removed_email_address@domain.invalid
> (805) 893-6307

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