when I run console with ruby 1.9.1 and rails 2.3.2, and trying to do something like User.first.name.encoding I''m getting #<Encoding:ASCII-8BIT>, though I''ve set "encoding: utf8" in database.yml any suggestions? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Sat, Mar 21, 2009 at 7:52 AM, ruby.freeman <ruby.freeman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > when I run console with ruby 1.9.1 and rails 2.3.2, and trying to do > something like > > User.first.name.encoding > > I''m getting #<Encoding:ASCII-8BIT>, though I''ve set "encoding: utf8" > in database.yml > > any suggestions?The mysql driver is not encoding-aware yet. jeremy --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jeremy Kemper wrote:> On Sat, Mar 21, 2009 at 7:52 AM, ruby.freeman <ruby.freeman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: >> >> when I run console with ruby 1.9.1 and rails 2.3.2, and trying to do >> something like >> >> User.first.name.encoding >> >> I''m getting #<Encoding:ASCII-8BIT>, though I''ve set "encoding: utf8" >> in database.yml >> >> any suggestions? > > The mysql driver is not encoding-aware yet. > > jeremySame problem here with mysql and sqlite3. When will the mysql and sqlite3 drivers be encoding-aware? Is there a workaround? I have problems with this because I''m from germany and need utf8 for the german umlauts. If i save the templates as ANSI, the outputs from database with umlauts are working, but when i use umlauts directly in the templates i get this error: invalid byte sequence for encoding "ASCII-8BIT" If i save the templates as UTF8, the umlauts in the templates are working, but the outputs from the database with umlauts cause this error: invalid byte sequence for encoding "UTF-8" I''m using Ruby 1.9.1, Rails 2.3.2, mysql/ruby 2.8.1, sqlite3/ruby 1.2.4 slang17 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Mon, Mar 23, 2009 at 10:16 AM, Stefan La < rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Jeremy Kemper wrote: > > On Sat, Mar 21, 2009 at 7:52 AM, ruby.freeman <ruby.freeman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > >> > >> when I run console with ruby 1.9.1 and rails 2.3.2, and trying to do > >> something like > >> > >> User.first.name.encoding > >> > >> I''m getting #<Encoding:ASCII-8BIT>, though I''ve set "encoding: utf8" > >> in database.yml > >> > >> any suggestions? > > > > The mysql driver is not encoding-aware yet. > > > > jeremy > > Same problem here with mysql and sqlite3. > > When will the mysql and sqlite3 drivers be encoding-aware? > > Is there a workaround? > > I have problems with this because I''m from germany and need utf8 for the > german umlauts. > > If i save the templates as ANSI, the outputs from database with umlauts > are working, but when i use umlauts directly in the templates i get this > error: > > invalid byte sequence for encoding "ASCII-8BIT" > > If i save the templates as UTF8, the umlauts in the templates are > working, but the outputs from the database with umlauts cause this > error: > > invalid byte sequence for encoding "UTF-8" > > > I''m using Ruby 1.9.1, Rails 2.3.2, mysql/ruby 2.8.1, sqlite3/ruby 1.2.4 > > slang17Your question should also be posted to driver maintainers and possible the MySQL and SQLite projects. Furthermore, all these projects are open-source. Thus, please feel free to contribute/add these features if you need them. Good luck, -Conrad> > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> Your question should also be posted to driver maintainers and possible the > MySQL and SQLite projects. Furthermore, all these projects are open-source. > Thus, please feel free to contribute/add these features if you need them.It''s problem of rails, not mysql library. ActiveRecord should be encoding-aware now --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
ruby.freeman wrote:> It''s problem of rails, not mysql library. ActiveRecord should be > encoding-aware nowWhere did you get that information? Is there any workaround or patch for that problem with ActiveRecord? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> Where did you get that information? > Is there any workaround or patch for that problem with ActiveRecord?See, when I do some requests from rails console, I see that result is in utf-8 encoding, so mysql works correctly. But ActiveRecord sets encoding for all attributes as ASCII-8BIT. For now we can reencode all results in our views with "force_encoding" methods untill AcriveRecord is encoding-aware --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Mon, Apr 6, 2009 at 3:42 AM, ruby.freeman <ruby.freeman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Where did you get that information? > > Is there any workaround or patch for that problem with ActiveRecord? > > See, when I do some requests from rails console, I see that result is > in utf-8 encoding, so mysql works correctly. But ActiveRecord sets > encoding for all attributes as ASCII-8BIT. For now we can reencode all > results in our views with "force_encoding" methods untill AcriveRecord > is encoding-awareWhich requests do you perform in the rails console? -Conrad --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> Which requests do you perform in the rails console?any find request, like in first message --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I made a bug in lighhouse to track this problems, I have some patches for mysql and for the problem with the views in a related ticket https://rails.lighthouseapp.com/projects/8994/tickets/2476-ascii-8bit-encoding-of-query-results-in-rails-232-and-ruby-191#ticket-2476-2 On Apr 6, 8:00 am, "ruby.freeman" <ruby.free...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Which requests do you perform in the rails console? > > any find request, like in first message--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Postgresql v6.3.8.1 works with Ruby 1.9.1p0 and Rails 2.3.2 - my guess is the problem is with either the driver or the database itself. Can you tell what the actual encoding is of the database? How about setting the default? MySQL refers to this as the CHARACTER SET. For example, to set utf8 as the encoding for a table named "test_development" you could use: ALTER TABLE `test_development`.`pages` CHARACTER SET utf8; Noodle around with the MySQL user''s manual and I''m sure you''ll find the way to make utf8 the default for all new tables. For reference, I''ve got: mysql Ver 14.14 Distrib 5.1.31, for apple-darwin9.5.0 (powerpc) using readline 5.1 and gem list mysql == mysql (2.8.1) On Apr 10, 2:16 pm, Hector Gomez <hector...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I made a bug in lighhouse to track this problems, I have some patches > for mysql and for the problem with the views in a related tickethttps://rails.lighthouseapp.com/projects/8994/tickets/2476-ascii-8bit... > > On Apr 6, 8:00 am, "ruby.freeman" <ruby.free...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Which requests do you perform in the rails console? > > > any find request, like in first message--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> Postgresql v6.3.8.1 works with Ruby 1.9.1p0 and Rails 2.3.2 - my guess > is the problem is with either the driver or the database itself.Problem is not with database. As I said above, when I do something like User.first.name.encoding I''m getting #<Encoding:ASCII-8BIT>. If I do this one - User.first.name.force_encoding("utf-8") - I''m getting normal utf-8 string. The problem is that ActiveRecord gets all data from database as ASCII. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
right - somewhat slow on the uptake On Apr 11, 8:28 am, "ruby.freeman" <ruby.free...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Postgresql v6.3.8.1 works with Ruby 1.9.1p0 and Rails 2.3.2 - my guess > > is the problem is with either the driver or the database itself. > > Problem is not with database. As I said above, when I do something > like User.first.name.encoding I''m getting #<Encoding:ASCII-8BIT>. > If I do this one - User.first.name.force_encoding("utf-8") - I''m > getting normal utf-8 string. The problem is that ActiveRecord gets all > data from database as ASCII.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
ruby.freeman have you checked my fork of mysql-ruby? and the ticket in lighthouse? I think this will resolve your problem. Or have you checked it out and still got problems? On Apr 11, 1:28 pm, "ruby.freeman" <ruby.free...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Postgresql v6.3.8.1 works with Ruby 1.9.1p0 and Rails 2.3.2 - my guess > > is the problem is with either the driver or the database itself. > > Problem is not with database. As I said above, when I do something > like User.first.name.encoding I''m getting #<Encoding:ASCII-8BIT>. > If I do this one - User.first.name.force_encoding("utf-8") - I''m > getting normal utf-8 string. The problem is that ActiveRecord gets all > data from database as ASCII.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Sat, Apr 11, 2009 at 1:51 PM, Hector Gomez <hectoregm-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > ruby.freeman have you checked my fork of mysql-ruby? and the ticket > in lighthouse? > I think this will resolve your problem. > Or have you checked it out and still got problems? > > On Apr 11, 1:28 pm, "ruby.freeman" <ruby.free...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Postgresql v6.3.8.1 works with Ruby 1.9.1p0 and Rails 2.3.2 - my guess > > > is the problem is with either the driver or the database itself. > > > > Problem is not with database. As I said above, when I do something > > like User.first.name.encoding I''m getting #<Encoding:ASCII-8BIT>. > > If I do this one - User.first.name.force_encoding("utf-8") - I''m > > getting normal utf-8 string. The problem is that ActiveRecord gets all > > data from database as ASCII. >Is your update forked back into the main branch for the project? -Conrad --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I have not contacted upstream (tmtm) but he is working on a pure ruby adapter called ruby-mysql (is encoding aware, etc) it has a compat layer but is not functional now. I have made a gem of my fork hectoregm-mysql-ruby that you use to make tests, but I will try to get this changes merge upstream. On Apr 11, 5:31 pm, Conrad Taylor <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Sat, Apr 11, 2009 at 1:51 PM, Hector Gomez <hector...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > ruby.freeman have you checked my fork of mysql-ruby? and the ticket > > in lighthouse? > > I think this will resolve your problem. > > Or have you checked it out and still got problems? > > > On Apr 11, 1:28 pm, "ruby.freeman" <ruby.free...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Postgresql v6.3.8.1 works with Ruby 1.9.1p0 and Rails 2.3.2 - my guess > > > > is the problem is with either the driver or the database itself. > > > > Problem is not with database. As I said above, when I do something > > > like User.first.name.encoding I''m getting #<Encoding:ASCII-8BIT>. > > > If I do this one - User.first.name.force_encoding("utf-8") - I''m > > > getting normal utf-8 string. The problem is that ActiveRecord gets all > > > data from database as ASCII. > > Is your update forked back into the main branch for the project? > > -Conrad--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Apparently Analagous Threads
- Overview of Ruby 1.9 encoding problem tickets
- invalid byte sequence utf-8 OR best option to sanitize content brought in with net::http? single non-utf character causes rails to crash
- Encoding problems with Rails 3 + Ruby 1.9.1 (big surprise)
- win32-security, 1.9.x, encoding issue?
- Encoding error