Encoding Issues Seeds.rb

67 views
Skip to first unread message

Maxus

unread,
Mar 5, 2012, 3:21:44 AM3/5/12
to rubyonra...@googlegroups.com
Hi People,
 
Im running the seed.rd for the countries from here: https://github.com/wdblair/Rails-Seed-All-Countries-and-All-States/downloads the author states that the file is UTF.
 
When I execute the import I recieve the error: invalid multibyte char (UTF-8)' (from instructions here: http://stackoverflow.com/questions/1739836/invalid-multibyte-char-us-ascii-with-rails-and-ruby-1-9)
 
I tried adding this to the top of the file: # encoding: utf-8 but still no luck.
 
 
Still the same error occours.
 
Im using ruby: 1.9.2p290 (2011-07-09) [i386-mingw32] and rails: 3.1.3 running on windows.
 
Any ideas what I have wrong?
Thanks,
Maxus
 

Maxus

unread,
Mar 12, 2012, 6:38:24 AM3/12/12
to rubyonra...@googlegroups.com
Hi All,
 
I rebuilt my enviroment on linux, still the same issue occours. Any one have any idea whats going on?
 
Thanks!
Maxus

Juan Pablo Avello

unread,
Mar 12, 2012, 6:55:32 AM3/12/12
to rubyonra...@googlegroups.com


El lunes 12 de marzo de 2012 11:38:24 UTC+1, Maxus escribió:
Hi All,
 
I rebuilt my enviroment on linux, still the same issue occours. Any one have any idea whats going on?
 
Thanks!
Maxus
 
 

On Monday, March 5, 2012 4:21:44 PM UTC+8, Maxus wrote:
Hi People,
 
 
When I execute the import I recieve the error: invalid multibyte char (UTF-8)' (from instructions here: http://stackoverflow.com/questions/1739836/invalid-multibyte-char-us-ascii-with-rails-and-ruby-1-9)
 
I tried adding this to the top of the file: # encoding: utf-8 but still no luck.
 
 
Still the same error occours.
 
Im using ruby: 1.9.2p290 (2011-07-09) [i386-mingw32] and rails: 3.1.3 running on windows.
 
Any ideas what I have wrong?
Thanks,
Maxus
 

Your problem will probably go away if you write the following comment at the top of the .rb file:

# encoding: utf-8

Regards.

Maxus

unread,
Mar 12, 2012, 7:25:36 AM3/12/12
to rubyonra...@googlegroups.com
 
Hi Juan,
 
I have tried that, still recieve the same error. Also noticed running the seed on heroku also throws the same error.
 
Any other suggestions?
 
Thanks!
Maxus

Miquel Cubel

unread,
Mar 12, 2012, 7:35:03 AM3/12/12
to rubyonra...@googlegroups.com
Hi,

    Try to reconvert the file with "iconv -f UTF-8" and add "# encoding: utf-8" to the first line....

    In case isn't working I will suggest to review the encoding of the database and maybe to force it with "encoding: UTF8"

    Regards,   
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/EvKS3-ci_wcJ.
To post to this group, send email to rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

-- 
Miquel Cubel Escarré
http://railsdynamics.blogspot.com
+34 699 73 22 46 
mcu...@gmail.com

Maxus

unread,
Mar 13, 2012, 4:59:08 AM3/13/12
to rubyonra...@googlegroups.com
Hi All,
I tried everything and was going mad. I discovered redownloading the file and replacing my existing one fixed it after putting the utf header in. My guess is editing the file on windows somehow stuffed up the encoding (surprise surprise!).
Thank you everyone for their help!
-M
 
On Monday, March 5, 2012 4:21:44 PM UTC+8, Maxus wrote:
On Monday, March 5, 2012 4:21:44 PM UTC+8, Maxus wrote:
Reply all
Reply to author
Forward
0 new messages