Defect #10593

Error: 'incompatible character encodings: UTF-8 and ASCII-8BIT' (old annoing issue) on ruby-1.9.3

Added by Alexander Oryol almost 11 years ago. Updated about 10 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Jean-Philippe Lang% Done:


Target version:1.4.0
Resolution:Fixed Affected version:


My instance Redmine was gradually upgraded from 0.7 and older.
When I upgrade to ruby-1.9.3, some projects issues list crashes with 'incompatible character encodings: UTF-8 and ASCII-8BIT'.

The trouble be found in CustomField: Browser (type: list)
In DB possible_values was serialized as:

    - !binary |

and deserialized into string with #<Encoding:ASCII-8BIT>.


    $> script/console production
    c = CustomField.find(5)
    c.possible_values.each {|i| i.force_encoding('UTF-8')}

Now, value serialized as:

- "\xD0\x9D\xD0\xB5 \xD0\xBE\xD0\xBF\xD1\x80\xD0\xB5\xD0\xB4\xD0\xB5\xD0\xBB\xD0\xB5\xD0\xBD" 

and work fine!

Related issues

Related to Redmine - Feature #4050: Ruby 1.9 support Closed 2009-10-18

Associated revisions

Revision 9330
Added by Jean-Philippe Lang almost 11 years ago

Force encoding of custom field possible values (#10593).


#1 Updated by Etienne Massip almost 11 years ago

  • Status changed from Resolved to New
  • Target version set to 1.4.0
  • Affected version (unused) set to devel

Potential release blocker.

#2 Updated by Alexander Oryol almost 11 years ago

This error happen on ruby-1.8.7 too, when I try to edit affected custom field. CustomFieldsController#edit
Which version (Redmine|Ruby) serialize UTF-8 to YAML as binary?
My instance lived initially on ruby-1.8.6

#3 Updated by Jean-Philippe Lang almost 11 years ago

  • Status changed from New to Closed
  • Assignee set to Jean-Philippe Lang
  • Resolution set to Fixed

I was able to reproduce and fixed it in r9330.

#4 Updated by Rodrigo Macedo about 10 years ago


ActionView::Template::Error (incompatible character encodings: UTF-8 and ASCII-8BIT):
15: </tr></thead>
16: <% enumerations.each do |enumeration| >
17: <tr class="<%= cycle('odd', 'even') %>">
18: <td><%= link_to h(enumeration), edit_enumeration_path(enumeration) %></td>
19: <td class="center" style="width:15
;"><%= checked_image enumeration.is_default? ></td>
20: <td class="center" style="width:15
;"><%= checked_image ></td>
21: <td style="width:15
;"><%= reorder_links('enumeration', {:action => 'update', :id => enumeration}, :put) %></td>
app/views/enumerations/index.html.erb:18:in `block (2 levels) in app_views_enumerations_index_html_erb_76608041_28216668'
app/views/enumerations/index.html.erb:16:in `block in app_views_enumerations_index_html_erb_76608041_28216668'
app/views/enumerations/index.html.erb:3:in `each'
app/views/enumerations/index.html.erb:3:in `_app_views_enumerations_index_html_erb__76608041_28216668'
app/controllers/enumerations_controller.rb:30:in `index'

I'm using Português(Brasil)
This error occurrs only using Português(Brasil) when I using English this not occurrs.

#5 Updated by Rodrigo Macedo about 10 years ago


I solved this problem when I changed the driver of mysql.
The driver is here

#6 Updated by Rodrigo Macedo about 10 years ago

I'm using adpater mysql2.

#7 Updated by KK Kon about 10 years ago

I made migration task

ruby 1.9.3 change YAML engine default.

Column data that serialized lower ruby 1.9.2 not displayable on ruby 1.9.3

this happen at changed the version of ruby to 1.9.3 from older.

Also available in: Atom PDF