On Tuesday 19 May 2009 05:35:09 am Michal Frackowiak wrote:
> Hi there,
>
> it is possible now to run Ruby 1.9.1 with Squel and PostgreSQL and use
> UTF-8 encoding?
>
> The problem is that I can easily force UTF to be written into the
> database (when running "pg" gem, ruby1.9 -U -E utf-8 ...), but Sequel
> interprets all strings as ASCII-8BIT when fetching them back. When
> doing force_encoding('utf-8') strings are back ok.
>
> try to run the following with e.g. irb1.9 -U -E utf-8:
>
> require 'sequel'
>
> # connect to any database
>
> s = DB["SELECT 'ąść' AS string"].first[:string]
> puts s.encoding # => 'ASCII-8BIT'
> puts s # this can fail, or produces garbage
> s.force_encoding!('utf-8')
> puts s # => 'ąść'
>
> Any idea how to fix it? Needless to say, multi-encoding in Ruby 1.9
> somehow sucks.
>
> Thanks - Michal
>
You can set the encoding by adding this magic comment to the top of your
script:
# coding: utf-8
More information:
http://blog.grayproductions.net/articles/ruby_19s_three_default_encodings
- spox
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---