K
K
Konstantin Bozhkov2017-02-18 21:15:55
Node.js
Konstantin Bozhkov, 2017-02-18 21:15:55

Where could be the encoding error?

I'm trying to write a query to Dydra (graph database). Using curl from the linux console, the request is executed as it should, in response I get json. Latin is displayed.

$ curl -H 'Accept: application/json' \http://dydra.com/ybiks/testmylib/sparql?query=select%20*%20where%20%7B%20%7B%20graph%20%3Fg%20%7B%3Fs%20%3Fp%20%3Fo%7D%20%7D%20union%20%7B%3Fs%20%3Fp%20%3Fo%7D%20%7D%20limit%2010
But if you make a request from Node.js, then the Latin characters are replaced by question marks.
var curl = require('curlrequest');

var url = 'http://dydra.com/ybiks/testmylib/sparql?query=';
url += encodeURIComponent('select * where { { graph ?g {?s ?p ?o} } union {?s ?p ?o} } limit 10');//SPARQL запрос,  SQL для онтологий

//Сам запрос
curl.request({url: url, headers: { accept: 'application/json' }, include: true}, function(err, parts){
  if(err) throw err;
  console.log(parts)
});
PS I changed the encoding in the curl module, it did not help

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ro37A, 2017-02-19
@ybiks

Pass these headers:

headers: { accept: 'application/json', 'accept-charset': 'utf-8' }

curlrequest first asks for ISO-8859-1, so latin1 is the answer.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question