Skip to content

Commit 7252bcc

Browse files
committed
GH-4856 include UTF-8 charset in CSV tuple MIME type
1 parent 0a5d5e3 commit 7252bcc

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

core/queryresultio/api/src/main/java/org/eclipse/rdf4j/query/resultio/TupleQueryResultFormat.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ public class TupleQueryResultFormat extends QueryResultFormat {
8181
/**
8282
* SPARQL Query Result CSV Format.
8383
*/
84-
public static final TupleQueryResultFormat CSV = new TupleQueryResultFormat("SPARQL/CSV", List.of("text/csv"),
85-
StandardCharsets.UTF_8, List.of("csv"), SPARQL_RESULTS_CSV_URI, NO_RDF_STAR);
84+
public static final TupleQueryResultFormat CSV = new TupleQueryResultFormat("SPARQL/CSV",
85+
List.of("text/csv;charset=UTF-8", "text/csv"), StandardCharsets.UTF_8, List.of("csv"),
86+
SPARQL_RESULTS_CSV_URI, NO_RDF_STAR);
8687

8788
/**
8889
* SPARQL Query Result TSV Format.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package org.eclipse.rdf4j.query.resultio;
2+
3+
import static org.assertj.core.api.Assertions.assertThat;
4+
5+
import org.junit.jupiter.api.DisplayName;
6+
import org.junit.jupiter.api.Test;
7+
8+
class TupleQueryResultFormatTest {
9+
10+
@Test
11+
@DisplayName("CSV default MIME type should include UTF-8 charset parameter as required by spec")
12+
void csvMimeTypeShouldIncludeCharsetParameter() {
13+
assertThat(TupleQueryResultFormat.CSV.getDefaultMIMEType())
14+
.as("MIME type should advertise UTF-8 charset")
15+
.isEqualTo("text/csv;charset=UTF-8");
16+
}
17+
}

0 commit comments

Comments
 (0)