I entered my nickname in katakana マスコミ into a form and then said <%= h(@person.nickname) %> when displaying the results, and the resulting output was &#12510;&#12473;&#12467;&#12511; which looks like マスコミ in the browser. since h(...) is supposed to muck with ampersand chars like that I wonder how exactly I am expected to deal with international characters? Is there a setting somewhere that i don''t know about or does rails just have limitations when it comes to dealing with foreign chars.? -- -Kate (masukomi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org)
kate rhodes wrote:> I entered my nickname in katakana > マスコミ > into a form and then said <%= h(@person.nickname) %> when displaying > the results, > and the resulting output was > &#12510;&#12473;&#12467;&#12511; > which looks like > マスコミ > in the browser.If you paste "マスコミ" into an html file, you''ll see it''s rendered correctly. What it looks like to me is that your original katakana is being h()''d by the browser on upload, but not being un-h()''d before hitting your database, so it''s being saved in the h()''d format. Then, when you pull it out again and *re*-h() it, the control sequence itself is getting h()''d, creating an unholy mess. The first thing to check is that you''ve got: $KCODE=''u'' require ''jcode'' in your environment.rb - that makes ruby understand about Unicode. If you have, and you''re still having problems, you can always call CGI.unescapeHTML() on any string you need converted before saving it to the database. Hope this helps, -- Alex
Do you add some code in the file in layouts directory? for example, <html> <head> <title>Admin: <%= controller.action_name %></title> <meta Content-Type: text/html; charset="utf-8"> <%= stylesheet_link_tag ''scaffold'' %> </head> <body> <p style="color: green"><%= flash[:notice] %></p> <%= @content_for_layout %> </body> </html> masukomi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> I entered my nickname in katakana > マスコミ > into a form and then said <%= h(@person.nickname) %> when displaying > the results, > and the resulting output was > マスコミ > which looks like > マスコミ > in the browser. > > since h(...) is supposed to muck with ampersand chars like that I > wonder how exactly I am expected to deal with international > characters? > > Is there a setting somewhere that i don''t know about or does rails > just have limitations when it comes to dealing with foreign chars.? > > -- > -Kate > (masukomi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org) > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
What was the character encoding on the form used to enter the nickname? I demonstrated a system to a Japanese client recently, and one of the first things they did was enter kana into the search box. They were impressed (surprised?) to see that it worked fine. I just used sjis for the input forms and it comes out normally with h(). Mark Beattie Easy Schedule Management http://easy-online-schedule.com On Wednesday 02 November 2005 1:34 pm, kate rhodes wrote:> I entered my nickname in katakana > マスコミ > into a form and then said <%= h(@person.nickname) %> when displaying > the results, > and the resulting output was > &#12510;&#12473;&#12467;&#12511; > which looks like > マスコミ > in the browser. > > since h(...) is supposed to muck with ampersand chars like that I > wonder how exactly I am expected to deal with international > characters? > > Is there a setting somewhere that i don''t know about or does rails > just have limitations when it comes to dealing with foreign chars.? > > -- > -Kate > (masukomi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org) > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails