Skip to content
This repository has been archived by the owner on Dec 12, 2019. It is now read-only.

invalid byte sequence in UTF-8 #7

Open
dbarison opened this issue Jul 15, 2010 · 2 comments
Open

invalid byte sequence in UTF-8 #7

dbarison opened this issue Jul 15, 2010 · 2 comments

Comments

@dbarison
Copy link

problem with rails 2.3.8 and ruby 1.9.1

@mclark
Copy link

mclark commented Oct 5, 2010

It looks like I'm having the same issue with rails 2.3.8 and ruby 1.9.2.pre2. Here is the stack trace to reproduce:

invalid byte sequence in UTF-8

/home/mclark/projects/tunstall-2.0/vendor/plugins/translate/lib/translate/keys.rb:135:in `scan'
/home/mclark/projects/tunstall-2.0/vendor/plugins/translate/lib/translate/keys.rb:135:in `block in extract_files'
/home/mclark/projects/tunstall-2.0/vendor/plugins/translate/lib/translate/keys.rb:134:in `each'
/home/mclark/projects/tunstall-2.0/vendor/plugins/translate/lib/translate/keys.rb:134:in `inject'
/home/mclark/projects/tunstall-2.0/vendor/plugins/translate/lib/translate/keys.rb:134:in `extract_files'
/home/mclark/projects/tunstall-2.0/vendor/plugins/translate/lib/translate/keys.rb:15:in `files'
/home/mclark/projects/tunstall-2.0/vendor/plugins/translate/lib/translate/keys.rb:6:in `files'
/home/mclark/projects/tunstall-2.0/vendor/plugins/translate/lib/translate_controller.rb:37:in `initialize_keys'
/home/mclark/projects/tunstall-2.0/vendor/plugins/translate/lib/translate_controller.rb:12:in `index'
/home/mclark/.rvm/gems/ruby-1.9.2-head/gems/actionpack-2.3.8/lib/action_controller/base.rb:1331:in `perform_action'
/home/mclark/.rvm/gems/ruby-1.9.2-head/gems/actionpack-2.3.8/lib/action_controller/filters.rb:617:in `call_filters'

@mclark
Copy link

mclark commented Oct 5, 2010

For the record, this was caused by most source files in my app being in iso-8859-1 encoding, while the extract_files method loads the file assuming it is in utf-8 by default (not sure where this comes from, it could be a system default. I've fixed the issue locally by just changing the line to the following. I don't know enough about this stuff to make a proper fix, but this should do for me, for now.

IO.read(file, :encoding => 'iso-8859-1' ).scan(i18n_lookup_pattern).flatten.map(&:to_sym).each do |key|

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants