Skip to content

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

Merged
merged 3 commits into from
Apr 20, 2019
Merged

str: proper titlecase support #832

merged 3 commits into from
Apr 20, 2019

Conversation

OddCoincidence
Copy link
Contributor

Follow-up to #827 that adds proper titlecase support using a new crate https://github.com/OddCoincidence/unicode-casing.

@codecov-io
Copy link

codecov-io commented Apr 14, 2019

Codecov Report

Merging #832 into master will decrease coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
vm/src/obj/objstr.rs 70.48% <100%> (+0.04%) ⬆️
vm/src/vm.rs 71.88% <0%> (-0.34%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 19be5c9...ae8ea1d. Read the comment docs.

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" }
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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());
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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! :)

@OddCoincidence OddCoincidence merged commit 01f143e into master Apr 20, 2019
@windelbouwman windelbouwman deleted the joey/proper-titlecase branch July 6, 2019 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants