Re: Encoding of CSV results of a SELECT query

https://tools.ietf.org/html/rfc7231#section-5.3.3 <https://tools.ietf.org/html/rfc7231#section-5.3.3>

I think content negotiation allows the client to specify its charset capabilities separately from content type.

Note:
   The special value "*", if present in the Accept-Charset field,
   matches every charset that is not mentioned elsewhere in the
   Accept-Charset field.


and

   A request without any Accept-Charset header field implies that the
   user agent will accept any charset in response.



So, my answer is:

 the server respond with `text/csv; charset=utf-8` if this is compatible with the Accept-Charset header in the request.

Otherwise use the given charset and return an error if there are encoding problems



Jeremy J Carroll
Senior Principal Architect
Syapse, Inc.



> On Jan 19, 2018, at 3:31 PM, John Walker <john.walker@semaku.com> wrote:
> 
> Greetings SPARQLers,
>  
> I have an RDF dataset that contains Unicode UTF-8 characters in literal values (but theoretically could also be in an IRI).
>  
> I do a query against the dataset using SPARQL 1.1 Protocol and specify I want CSV results with this header:
>  
>     Accept: text/csv
>  
> The SPARQL 1.1 Query Results CSV and TSV Formats recommendation states:
>  
> > Systems providing these formats should note that the content types for CSV is text/csv and for TSV text/tab-separated-values.
> > Being text/*, the default character set is US-ASCII. The charset parameter should be used in conjunction with SPARQL Results;
> > UTF-8 is recommended: text/csv; charset=utf-8 and text/tab-separated-values; charset=utf-8.
>  
> As the Accept header in the request does not specify a charset, should the server respond with `text/csv; charset=utf-8` or default to `text/csv; charset=iso-8859-1`?
>  
> In case the latter, should the server return an error if the results include UTF-8 characters?
>  
> Regards,
>  
> John Walker
> Principal Consultant & co-founder
>  
> Semaku B.V. | Torenallee 20 (SFJ 3D) | 5617 BC Eindhoven | T +31 6 475 22030 | https://semaku.com/ <https://semaku.com/>
> KvK: 58031405 | BTW: NL852842156B01 | IBAN: NL94 INGB 0008 3219 95

Received on Monday, 22 January 2018 23:14:38 UTC