Forum: Ruby on Rails special characters?

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.
69d524565ee927f209b5dcc04f313450?d=identicon&s=25 Chris Sepic (csepic)
on 2006-03-05 18:28
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?
6738e5c4f17822f7e163ba938344755d?d=identicon&s=25 last resort (Guest)
on 2006-03-05 19:44
Chris Sepic 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
__________________________________________
69d524565ee927f209b5dcc04f313450?d=identicon&s=25 Chris Sepic (csepic)
on 2006-03-05 20:45
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 Sepic 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
> __________________________________________
0091f92762685860109bbcb02edfdf27?d=identicon&s=25 Alain Ravet (Guest)
on 2006-03-05 21:00
(Received via mailing list)
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
69d524565ee927f209b5dcc04f313450?d=identicon&s=25 Chris Sepic (csepic)
on 2006-03-05 21:12
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 Ravet 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
69d524565ee927f209b5dcc04f313450?d=identicon&s=25 Chris Sepic (csepic)
on 2006-03-05 21:51
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 Sepic 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 Ravet 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
This topic is locked and can not be replied to.