Hello!
First, thank you Julian for the useful plugin ‘unicode_hacks’ <
http://julik.textdriven.com/svn/tools/rails_plugins/unicode_hacks/>.
I have found some problems running my app in development on Webrick
and looking at it with Safari (MacOS X 10.4.3, Safari 2.0.2). Some
files are sent with different sizes (e.g. default css example, or
controls.js ), and it causes long delays for each request.
When I changed KCODE to ‘none’, everything worked OK. It seems that
string overloading borks something in Webrick internally.
My solution is to set KCODE in before/after filters, so that webrick
code is not affected. There is some Rails code run before/after the
filters, so it is not completely fullproof solution. Maybe some Rails
code which runs before/after filters would need Unicode string
processing - it doesn’t seem likely to me, but you never know.
I have modified file actionpack_filters.rb, where I added the
following private methods:
def set_kcode_utf8
@old_kcode = $KCODE
$KCODE = 'u'
end
def restore_kcode
$KCODE = @old_kcode
end
and added these two as filters in init.rb:
Object::ActionController::Base.send(:before_filter, :set_kcode_utf8)
Object::ActionController::Base.send(:after_filter, :restore_kcode)
Additionally, I have modified the safari fix, so that it re-encodes
the entities only for Safari version less than 1.3. Instead of
original condition I propose this one:
if @request.xhr? and @request.env['HTTP_USER_AGENT'] =~ /
AppleWebKit/(\d+)/ and $1.to_i < 312
Julian, if you want to include these solutions into your plugin, feel
free to do so…
Regards,
Izidor J.