Bug 22638 - incompatible character encodings: UTF-8 and ASCII-8BIT
Summary: incompatible character encodings: UTF-8 and ASCII-8BIT
Status: CLOSED WONTFIX
Alias: None
Product: Sisyphus
Classification: Development
Component: ruby-actionpack (show other bugs)
Version: unstable
Hardware: all Linux
: P3 critical
Assignee: Andrey Cherepanov
QA Contact: qa-sisyphus
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-12-29 19:13 MSK by ttrgr
Modified: 2010-06-10 13:46 MSD (History)
10 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ttrgr 2009-12-29 19:13:21 MSK
До сих пор не решена проблема с UTF-8 кодировкой (висит тут: https://rails.lighthouseapp.com/projects/8994/tickets/2188-i18n-fails-with-multibyte-strings-in-ruby-19-similar-to-2038) при попадании в шаблон UTF-8 символа вне диапазона ASCII-8

Приходится править  /usr/share/ruby/vendor_ruby/1.9/action_view/renderable.rb для форсирования кодировки исходника

 72             self.output_buffer = old_output_buffer
 73           end
 74         end_src
+ 75 
+ 76         source.force_encoding('utf-8') if '1.9'.respond_to?(:force_encoding)
Comment 1 Sir Raorn 2009-12-30 03:56:25 MSK
Спасибо, приложу когда прочитаю дифф от 2-3-stable.
Comment 2 Sir Raorn 2009-12-30 16:06:29 MSK
А какие используются версии биндингов к mysql/pg/sqlite и ruby-rack?
Comment 3 ttrgr 2009-12-30 18:39:36 MSK
(In reply to comment #2)
> А какие используются версии биндингов к mysql/pg/sqlite и ruby-rack?

Name        : ruby-rack
Version     : 1.0.1
Release     : alt1

Name        : ruby-activerecord-sqlite3-adapter
Version     : 2.3.5
Release     : alt1
Comment 4 ttrgr 2009-12-30 19:41:26 MSK
(In reply to comment #2)
> А какие используются версии биндингов к mysql/pg/sqlite и ruby-rack?

Вобщем БД в данном случае ни при чем, но и с БД раньше были теже проблемы, не знаю как сейчас.
Баг вылазит при рендеринге шаблонов так:

$ cat app/views/home/index.html.erb 
<h1>Home#index</h1>
Русский
<%= render 'utfhalt.html.erb' %>

$ cat app/views/home/_utfhalt.html.erb 
<%= 'Ы' %>



Processing HomeController#index (for 127.0.0.1 at 2009-12-30 23:34:53) [GET]
Rendering home/index
Rendered home/_utfhalt (2.2ms)

ActionView::TemplateError (incompatible character encodings: UTF-8 and ASCII-8BIT) on line #3 of app/views/home/index.html.erb:
1: <h1>Home#index</h1>
2: Русский
3: <%= render 'utfhalt.html.erb' %>

    /usr/share/ruby/vendor_ruby/1.9/active_support/core_ext/string/output_safety.rb:34:in `concat'
    /usr/share/ruby/vendor_ruby/1.9/active_support/core_ext/string/output_safety.rb:34:in `concat_with_safety'
    app/views/home/index.html.erb:3
    /usr/share/ruby/vendor_ruby/1.9/action_view/renderable.rb:34:in `block in render'
    /usr/share/ruby/vendor_ruby/1.9/action_view/base.rb:306:in `with_template'
    /usr/share/ruby/vendor_ruby/1.9/action_view/renderable.rb:30:in `render'
    /usr/share/ruby/vendor_ruby/1.9/action_view/template.rb:205:in `render_template'
    /usr/share/ruby/vendor_ruby/1.9/action_view/base.rb:265:in `render'
    /usr/share/ruby/vendor_ruby/1.9/action_controller/base.rb:1250:in `render_for_file'
    /usr/share/ruby/vendor_ruby/1.9/action_controller/base.rb:945:in `render'
    /usr/share/ruby/vendor_ruby/1.9/action_controller/benchmarking.rb:51:in `block in render_with_benchmark'
    /usr/share/ruby/vendor_ruby/1.9/action_controller/benchmarking.rb:51:in `render_with_benchmark'
    /usr/share/ruby/vendor_ruby/1.9/action_controller/base.rb:1326:in `default_render'
    /usr/share/ruby/vendor_ruby/1.9/action_controller/base.rb:1332:in `perform_action'
    /usr/share/ruby/vendor_ruby/1.9/action_controller/filters.rb:617:in `call_filters'
    /usr/share/ruby/vendor_ruby/1.9/action_controller/filters.rb:610:in `perform_action_with_filters'
    /usr/share/ruby/vendor_ruby/1.9/action_controller/benchmarking.rb:68:in `block in perform_action_with_benchmark'
    /usr/share/ruby/vendor_ruby/1.9/action_controller/benchmarking.rb:68:in `perform_action_with_benchmark'
    /usr/share/ruby/vendor_ruby/1.9/action_controller/rescue.rb:160:in `perform_action_with_rescue'
    /usr/share/ruby/vendor_ruby/1.9/action_controller/flash.rb:146:in `perform_action_with_flash'
    /usr/share/ruby/vendor_ruby/1.9/action_controller/base.rb:532:in `process'
    /usr/share/ruby/vendor_ruby/1.9/action_controller/filters.rb:606:in `process_with_filters'
    /usr/share/ruby/vendor_ruby/1.9/action_controller/base.rb:391:in `process'
    /usr/share/ruby/vendor_ruby/1.9/action_controller/base.rb:386:in `call'
    /usr/share/ruby/vendor_ruby/1.9/action_controller/routing/route_set.rb:437:in `call'
    /usr/share/ruby/vendor_ruby/1.9/action_controller/dispatcher.rb:87:in `dispatch'
    /usr/share/ruby/vendor_ruby/1.9/action_controller/dispatcher.rb:121:in `_call'
    /usr/share/ruby/vendor_ruby/1.9/action_controller/dispatcher.rb:130:in `block in build_middleware_stack'
    /usr/share/ruby/vendor_ruby/1.9/active_record/query_cache.rb:29:in `call'
    /usr/share/ruby/vendor_ruby/1.9/active_record/query_cache.rb:29:in `block in call'
    /usr/share/ruby/vendor_ruby/1.9/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'
    /usr/share/ruby/vendor_ruby/1.9/active_record/query_cache.rb:9:in `cache'
    /usr/share/ruby/vendor_ruby/1.9/active_record/query_cache.rb:28:in `call'
    /usr/share/ruby/vendor_ruby/1.9/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call'
    /usr/share/ruby/vendor_ruby/1.9/action_controller/string_coercion.rb:25:in `call'
    /usr/share/ruby/vendor_ruby/1.9/rack/head.rb:9:in `call'
    /usr/share/ruby/vendor_ruby/1.9/rack/methodoverride.rb:24:in `call'
    /usr/share/ruby/vendor_ruby/1.9/action_controller/params_parser.rb:15:in `call'
    /usr/share/ruby/vendor_ruby/1.9/action_controller/session/cookie_store.rb:93:in `call'
    /usr/share/ruby/vendor_ruby/1.9/action_controller/failsafe.rb:26:in `call'
    /usr/share/ruby/vendor_ruby/1.9/rack/lock.rb:11:in `block in call'
    <internal:prelude>:8:in `synchronize'
    /usr/share/ruby/vendor_ruby/1.9/rack/lock.rb:11:in `call'
    /usr/share/ruby/vendor_ruby/1.9/action_controller/dispatcher.rb:114:in `block in call'
    /usr/share/ruby/vendor_ruby/1.9/action_controller/reloader.rb:34:in `run'
    /usr/share/ruby/vendor_ruby/1.9/action_controller/dispatcher.rb:108:in `call'
    /usr/share/ruby/vendor_ruby/1.9/rails/rack/static.rb:31:in `call'
    /usr/share/ruby/vendor_ruby/1.9/rack/urlmap.rb:46:in `block in call'
    /usr/share/ruby/vendor_ruby/1.9/rack/urlmap.rb:40:in `each'
    /usr/share/ruby/vendor_ruby/1.9/rack/urlmap.rb:40:in `call'
    /usr/share/ruby/vendor_ruby/1.9/rails/rack/log_tailer.rb:17:in `call'
    /usr/share/ruby/vendor_ruby/1.9/rack/content_length.rb:13:in `call'
    /usr/share/ruby/vendor_ruby/1.9/rack/handler/webrick.rb:50:in `service'
    /usr/share/ruby/1.9/webrick/httpserver.rb:111:in `service'
    /usr/share/ruby/1.9/webrick/httpserver.rb:70:in `run'
    /usr/share/ruby/1.9/webrick/server.rb:183:in `block in start_thread'

Rendered rescues/_trace (401.5ms)
Rendered rescues/_request_and_response (5.8ms)
Rendering rescues/layout (internal_server_error)
Comment 5 Sir Raorn 2010-06-10 13:46:00 MSD
При запуске rails приложений надо выставлять LC_CTYPE в *.UTF-8.  В mongrel_cluster ручки для этого есть.