ruby-rdf / sparql-client

SPARQL client for Ruby.
http://rubygems.org/gems/sparql-client
The Unlicense
112 stars 58 forks source link

utf-8 characters raise errors in URI/common #55

Closed apohllo closed 9 years ago

apohllo commented 9 years ago

Performing the following query:

select * where {<http://pl.dbpedia.org/resource/Ch%C5%82opi_%28powie%C5%9B%C4%87%29> <http://pl.dbpedia.org/property/językOrygWyd> ?value}

an exception is raised

incompatible character encodings: ASCII-8BIT and UTF-8
/home/fox/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/uri/common.rb:331:in `gsub'
/home/fox/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/uri/common.rb:331:in `unescape'
/home/fox/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/uri/common.rb:649:in `unescape'
/home/fox/.rvm/gems/ruby-2.1.2/gems/rdf-1.1.6/lib/rdf/model/uri.rb:1276:in `normalize_segment'
/home/fox/.rvm/gems/ruby-2.1.2/gems/rdf-1.1.6/lib/rdf/model/uri.rb:1240:in `block (2 levels) in query_values='
/home/fox/.rvm/gems/ruby-2.1.2/gems/rdf-1.1.6/lib/rdf/model/uri.rb:1236:in `map'
/home/fox/.rvm/gems/ruby-2.1.2/gems/rdf-1.1.6/lib/rdf/model/uri.rb:1236:in `block in query_values='
/home/fox/.rvm/gems/ruby-2.1.2/gems/rdf-1.1.6/lib/rdf/model/uri.rb:1231:in `each'
/home/fox/.rvm/gems/ruby-2.1.2/gems/rdf-1.1.6/lib/rdf/model/uri.rb:1231:in `map'
/home/fox/.rvm/gems/ruby-2.1.2/gems/rdf-1.1.6/lib/rdf/model/uri.rb:1231:in `query_values='
/home/fox/.rvm/gems/ruby-2.1.2/gems/sparql-client-0.0.11/lib/sparql/client.rb:294:in `get'
/home/fox/.rvm/gems/ruby-2.1.2/gems/sparql-client-0.0.11/lib/sparql/client.rb:124:in `response'
/home/fox/.rvm/gems/ruby-2.1.2/gems/sparql-client-0.0.11/lib/sparql/client.rb:111:in `query'
./lib/download_authors.rb:12:in `get_values'
./lib/download_authors.rb:25:in `<main>'

The reason for that is the presence of ę in the result which is passed to URI library.

gkellogg commented 9 years ago

Thanks for the report. It looks like the endpoint you're using is returning ASCII with UTF-8 characters in it. Can you provide a few more details, such as the endpoint you're running this against?

gkellogg commented 9 years ago

Also, it looks like you're running an old version of sparql-client. The current release is 1.1.3.1.

apohllo commented 9 years ago

Ok, I'll try with the latest version. I'm issuing these queries against http://pl.dbpedia.org/sparql