-
-
Notifications
You must be signed in to change notification settings - Fork 19
Add lexicographic versioning scheme #160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Kunz, Immanuel <[email protected]>
Signed-off-by: Kunz, Immanuel <[email protected]>
Signed-off-by: Kunz, Immanuel <[email protected]>
13e36ad
to
9064438
Compare
return remove_spaces(str(string)) | ||
|
||
def __lt__(self, other): | ||
return self.value.encode("utf-8") < other.value.encode("utf-8") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there some reference docs that explain how two UTF-8 byte strings are compared, so we can get that working beyond Python?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this conforms with rfc 3629 which states
UTF-8 encodes UCS characters as a varying number of octets, where the number of octets, and the value of each, depend on the integer value assigned to the character in ISO/IEC 10646 (the character number, a.k.a. code position, code point or Unicode scalar value). This encoding form has the following characteristics (all values are in hexadecimal):
...
- The byte-value lexicographic sorting order of UTF-8 strings is the same as if ordered by character numbers. Of course this is of limited interest since a sort order based on character numbers is almost never culturally valid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you for checking!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also consider using JSON tests in the same style as https://github.com/package-url/vers-spec/blob/main/tests/conan_version_cmp_test.json
It is now further specified here: package-url/vers-spec#37 |
This PR introduces a simple string versioning scheme that compares strings based on lexicographical order (UTF-8 encoded).
Addresses package-url/vers-spec#24