-
-
Notifications
You must be signed in to change notification settings - Fork 419
[BUG] UTF-8 YAML files with accents in version 1.9.0 raise incompatible character encodings: UTF-8 and ASCII-8BIT #606
Copy link
Copy link
Open
msgpack/msgpack-ruby
#246Milestone
Description
For long time I have a code like this:
STATES = I18n.t('states').with_indifferent_access.freeze
The yaml file is in UTF-8 and it has accents in some words:
pt-BR:
states:
Acre: AC
Amapá: AP
Ceará: CE
Piauí: PI
Paraná: PR
with new release 1.9.0
It starts failing in our CI in a lot of places:
ActionView::Template::Error incompatible character encodings: UTF-8 and ASCII-8BIT
Failure/Error: = f.select(:state, City::STATES,
ActionView::Template::Error:
incompatible character encodings: UTF-8 and ASCII-8BIT
./app/views/customers/_form.html.slim:86:in `block in
Downgrade to 1.8.11 make everything works again.
With 1.9.0 use rails console it loads like:
rails c
Running via Spring preloader in process 4964
Loading development environment (Rails 6.1.4.4)
[1] pry(main)> I18n.t('states').with_indifferent_access.freeze
=> {"Acre"=>"AC",
"Alagoas"=>"AL",
"Amazonas"=>"AM",
"Amap\xC3\xA1"=>"AP",
"Bahia"=>"BA",
"Cear\xC3\xA1"=>"CE",
"Distrito Federal"=>"DF",
"Esp\xC3\xADrito Santo"=>"ES",
"Goi\xC3\xA1s"=>"GO",
"Maranh\xC3\xA3o"=>"MA",
"Minas Gerais"=>"MG",
"Mato Grosso do Sul"=>"MS",
"Mato Grosso"=>"MT",
"Par\xC3\xA1"=>"PA",
"Para\xC3\xADba"=>"PB",
"Pernambuco"=>"PE",
"Piau\xC3\xAD"=>"PI",
"Paran\xC3\xA1"=>"PR",
"Rio de Janeiro"=>"RJ",
"Rio Grande do Norte"=>"RN",
"Rond\xC3\xB4nia"=>"RO",
"Roraima"=>"RR",
"Rio Grande do Sul"=>"RS",
"Santa Catarina"=>"SC",
"Sergipe"=>"SE",
"S\xC3\xA3o Paulo"=>"SP",
"Tocantins"=>"TO"}
With 1.8.11 use rails console it loads like:
rails c
Running via Spring preloader in process 3411
Loading development environment (Rails 6.1.4.4)
[1] pry(main)> I18n.t('states').with_indifferent_access.freeze
=> {"Acre"=>"AC",
"Alagoas"=>"AL",
"Amazonas"=>"AM",
"Amap\xC3\xA1"=>"AP",
"Bahia"=>"BA",
"Cear\xC3\xA1"=>"CE",
"Distrito Federal"=>"DF",
"Esp\xC3\xADrito Santo"=>"ES",
"Goi\xC3\xA1s"=>"GO",
"Maranh\xC3\xA3o"=>"MA",
"Minas Gerais"=>"MG",
"Mato Grosso do Sul"=>"MS",
"Mato Grosso"=>"MT",
"Par\xC3\xA1"=>"PA",
"Para\xC3\xADba"=>"PB",
"Pernambuco"=>"PE",
"Piau\xC3\xAD"=>"PI",
"Paran\xC3\xA1"=>"PR",
"Rio de Janeiro"=>"RJ",
"Rio Grande do Norte"=>"RN",
"Rond\xC3\xB4nia"=>"RO",
"Roraima"=>"RR",
"Rio Grande do Sul"=>"RS",
"Santa Catarina"=>"SC",
"Sergipe"=>"SE",
"S\xC3\xA3o Paulo"=>"SP",
"Tocantins"=>"TO"}
The output seems exactly the same.
Is that a bug in new version?
Probably something between new version and load in rails.
This is just a sample
I have others files with accents and all of them are raising same exception.
Versions of i18n, rails, and anything else you think is necessary
ruby: 3.0.3
i18n: 1.9.0
rails: 6.1.4.3
rspec-rails: 5.1.0
rspec: 3.10.0
and # frozen_string_literal: true in ruby files.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels