-
Notifications
You must be signed in to change notification settings - Fork 1.3k
str: proper titlecase support #832
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #832 +/- ##
==========================================
- Coverage 62.89% 62.88% -0.02%
==========================================
Files 88 88
Lines 14547 14548 +1
Branches 3288 3288
==========================================
- Hits 9150 9149 -1
Misses 3238 3238
- Partials 2159 2161 +2
Continue to review full report at Codecov.
|
vm/Cargo.toml
Outdated
@@ -23,6 +23,7 @@ regex = "1" | |||
rustc_version_runtime = "0.1.*" | |||
statrs = "0.10.0" | |||
caseless = "0.2.1" | |||
unicode-casing = { git = "https://github.com/OddCoincidence/unicode-casing" } |
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 create a release from this package, so we can refer to a pinned version?
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.
You mean on crates.io? I was going to see if the rust unicode folks wanted control over this package before submitting. It's fine if you want to wait for that, but I can also add the commit sha here if that makes you feel better.
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.
Ah, okay, yes, rust unicode group having this package would be good. Let's keep it like this, until this is effect. Maybe add a todo?
@@ -413,12 +414,12 @@ impl PyString { | |||
for c in self.value.chars() { | |||
if c.is_lowercase() { | |||
if !previous_is_cased { | |||
title.extend(c.to_uppercase()); | |||
title.extend(c.to_titlecase()); |
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.
How can a single character be title cases? I guess something else is meant than python's titlecase function?
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.
This surprised me too, but there indeed exist single codepoint titlecase characters (I realized this from reading the cpython tests for title
/ istitle
). Some examples.
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.
"Latin Capital Letter D with Small Letter Z with Caron". Unicode is never boring! :)
Follow-up to #827 that adds proper titlecase support using a new crate https://github.com/OddCoincidence/unicode-casing.