Closed althonos closed 5 years ago
Well spotted, thanks.
The funny thing is: I have been specifically working, in another context, on language-tagged literals and BCP47 in the last few days... but this bug in Sophia didn't even occur to me then! :-)
Thanks again.
Hi!
While toying with the library, I noticed that the comparison of language tags was case-sensitive. According to the RDF Concepts and Abstract Syntax, language tags are defined in BCP47, which states:
This can be found in the W3C RDF/XML syntax examples:
example08.rdf
hasen-US
whileexample08.nt
hasen-us
where both are supposed to be equal.This PR fixes
PartialEq
, but alsoHash
, to make comparison and hashing ofLiteralKind
case-insensitive. (*About theto_lowercase
call: this one allocates, while it could be possible to loop over all characters of thetag1
and hash their lowercase variant without allocating, but since language tags are extremely small strings I am not sure this would really be an improvement over allocating and hashing the buffered bytes directly).