Special characters?


#1

I’m not sure if this is something in Rails or MySQL, but characters like
ü are showing up funky in my app. I see ‘ü’ in the DB using a query
browser, but in the app it shows up as ‘A1/4.’ Do I need to use another
charset or something?


#2

Chris S. wrote:

I’m not sure if this is something in Rails or MySQL, but characters like
ü are showing up funky in my app. I see ‘ü’ in the DB using a query
browser, but in the app it shows up as ‘A1/4.’ Do I need to use another
charset or something?

try to modify your ApplicationController:


Filters added to this controller will be run for all controllers in

the application.

Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base
before_filter :set_charset

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

end



#3

That almost worked… It is displaying properly, except when I update a
list with an ajax call. In the list, it it still showing as ‘A1/4.’
However if I display the list normally (using the list action) it looks
ok. Strange…

last resort wrote:

Chris S. wrote:

I’m not sure if this is something in Rails or MySQL, but characters like
ü are showing up funky in my app. I see ‘ü’ in the DB using a query
browser, but in the app it shows up as ‘A1/4.’ Do I need to use another
charset or something?

try to modify your ApplicationController:


Filters added to this controller will be run for all controllers in

the application.

Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base
before_filter :set_charset

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

end



#4

Chris

> That almost worked... It is displaying properly, except when I

update a
> list with an ajax call. In the list, it it still showing as
‘A1/4.’

You can set the header manually before rendering the partial :

 def update_partial_stuff
      ...
     @headers["Content-Type"] = "text/html; charset=utf-8"
     render       :partial => 'foo'
 end

Alain


#5

Still no joy…I think it’s because I’m using RJS templates to update
the list. In my .rjs I tried:

@headers[“Content-Type”] = “text/html; charset=utf-8”
page.insert_html :bottom, ‘cardList’, :partial => ‘card_chunk_add’

Alain R. wrote:

Chris

> That almost worked... It is displaying properly, except when I

update a
> list with an ajax call. In the list, it it still showing as
‘A1/4.’

You can set the header manually before rendering the partial :

 def update_partial_stuff
      ...
     @headers["Content-Type"] = "text/html; charset=utf-8"
     render       :partial => 'foo'
 end

Alain


#6

I think the problem is that RJS changes the content type to
text/javascript. If anyone knows how to get around this bug let me
know.

Chris S. wrote:

Still no joy…I think it’s because I’m using RJS templates to update
the list. In my .rjs I tried:

@headers[“Content-Type”] = “text/html; charset=utf-8”
page.insert_html :bottom, ‘cardList’, :partial => ‘card_chunk_add’

Alain R. wrote:

Chris

> That almost worked... It is displaying properly, except when I

update a
> list with an ajax call. In the list, it it still showing as
‘A1/4.’

You can set the header manually before rendering the partial :

 def update_partial_stuff
      ...
     @headers["Content-Type"] = "text/html; charset=utf-8"
     render       :partial => 'foo'
 end

Alain