I have a problem with unicode & RJS. I searched several boards & blogs,
but was not able to find a solution. Let me explain my problem with an
example.
View (test.rhtml):
…
Output:
äüö������
RJS-Template (an_action.rjs):
page.replace_html ‘a_test_div’, ‘äüöÃ?Ã?Ã?Ã?Ã?Ã?’
Calling ‘an_action’ changes the content of ‘a_test_div’, the output
should remain the same, but Instead of ‘äüöÃ?Ã?Ã?Ã?Ã?Ã?’ i get
‘Ã?¤Ã?¼Ã?¶Ã?Â?Ã?Â?Ã?Â?Ã?Â?Ã?Â?Ã?Â?’ which seems to be an encoding problem.
I’ve found a workaround for strings (introduced by Thomas F.) by
using
page.replace_html ‘messageEditor’, ‘äüöÃ?Ã?Ã?Ã?Ã?Ã?’.gsub(/([^\x00-\x9f])/u)
{ |s| “&#x%x;” % $1.unpack(‘U’)[0] }
instead of
page.replace_html ‘a_test_div’, ‘äüöÃ?Ã?Ã?Ã?Ã?Ã?’
but this strategy of course fails while rendering partials.
Are there any better suggestions?
Thanks
Dave