Skip to content

Commit

Permalink
Normalizes all language tags to lower case
Browse files Browse the repository at this point in the history
  • Loading branch information
Tpt committed Apr 4, 2020
1 parent f131f0e commit 3c445e0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions api/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ impl<'a> fmt::Display for BlankNode<'a> {
///
/// The default string formatter is returning a N-Triples, Turtle and SPARQL compatible representation.
///
/// The language tags should be lowercased [as suggested by the RDF specification](https://www.w3.org/TR/rdf11-concepts/#dfn-language-tagged-string).
///
/// ```
/// use rio_api::model::NamedNode;
/// use rio_api::model::Literal;
Expand Down Expand Up @@ -88,14 +90,14 @@ pub enum Literal<'a> {
LanguageTaggedString {
/// The [lexical form](https://www.w3.org/TR/rdf11-concepts/#dfn-lexical-form).
value: &'a str,
/// The [language tag](https://www.w3.org/TR/rdf11-concepts/#dfn-datatype-iri).
/// The [language tag](https://www.w3.org/TR/rdf11-concepts/#dfn-language-tag).
language: &'a str,
},
/// A literal with an explicit datatype
Typed {
/// The [lexical form](https://www.w3.org/TR/rdf11-concepts/#dfn-lexical-form).
value: &'a str,
/// The [datatype IRI](https://www.w3.org/TR/rdf11-concepts/#dfn-language-tag).
/// The [datatype IRI](https://www.w3.org/TR/rdf11-concepts/#dfn-datatype-iri).
datatype: NamedNode<'a>,
},
}
Expand Down
2 changes: 1 addition & 1 deletion turtle/src/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ pub fn parse_langtag(
while let Some(c) = read.current() {
match c {
b'a'..=b'z' | b'A'..=b'Z' | b'0'..=b'9' | b'-' => {
buffer.push(char::from(c));
buffer.push(char::from(c).to_ascii_lowercase());
read.consume()?;
}
_ => {
Expand Down
3 changes: 2 additions & 1 deletion xml/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,8 @@ impl<R: BufRead> RdfXmlReader<R> {
LanguageTag::parse(
attribute
.unescape_and_decode_value(&self.reader)
.map_err(RdfXmlError::from)?,
.map_err(RdfXmlError::from)?
.to_ascii_lowercase(),
)
.map_err(RdfXmlError::from)?,
);
Expand Down

0 comments on commit 3c445e0

Please sign in to comment.