Skip to content

Returns all strings encoded as US_ASCII? #7

@andy-twosticks

Description

@andy-twosticks

I get this behaviour when connected to a database encoded as UTF-8.

Example Code:

require 'postgres-pr/connection'
c = PostgresPR::Connection.new('blah', 'blah', 'blah')

row = c.query("select name, cost from remedium.prescription").rows.last
row.each do |f|
  #f.force_encoding(Encoding::UTF_8) #-- uncomment this to 'fix' everything ;/

  enc = f.kind_of?(String) ? f.encoding : ''
  puts [f.class, f, f.inspect, enc].join(' ')
end

Output:

String Paracelsium "Paracelsium" ASCII-8BIT
String £0.00 "\xC2\xA30.00" ASCII-8BIT

I don't know what you can do to resolve this -- but other adapters don't appear to have this problem, so I suppose it must be technically possible to resolve it. [Ruby 2.3; Postgres 9.2]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions