Skip to content
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

Improve the AsciiStr trait #17790

Closed
nodakai opened this issue Oct 5, 2014 · 6 comments
Closed

Improve the AsciiStr trait #17790

nodakai opened this issue Oct 5, 2014 · 6 comments
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup.

Comments

@nodakai
Copy link
Contributor

nodakai commented Oct 5, 2014

AsciiStr::to_lower() and AsciiStr::to_upper() should be renamed to AsciiStr::to_lowercase() and AsciiStr::to_uppercase(), respectively, when Ascii::to_lower() and Ascii::to_upper() are deprecated in favor of Ascii::to_lowercase() and Ascii::to_uppercase().

Incidentally, we should perhaps import capitalize() and capwords() from Python.

@kmcallister kmcallister added A-libs C-cleanup Category: PRs that clean code up or issues documenting cleanup. labels Oct 5, 2014
@kmcallister
Copy link
Contributor

cc #16801

@aturon
Copy link
Member

aturon commented Oct 6, 2014

cc me

bors added a commit that referenced this issue Oct 16, 2014
AsciiStr::to_lower is now AsciiStr::to_lowercase and AsciiStr::to_upper is AsciiStr::to_uppercase to match Ascii trait.

Part of issue #17790.

This is my first pull request so let me know if anything is incorrect.

Thanks!

[breaking-changes]
@orium
Copy link
Member

orium commented Nov 26, 2014

#17947 fixes the AsciiStr::{to_lower,to_upper}().

Incidentally, we should perhaps import capitalize() and capwords() from Python.

This should probably be a new RFC. If so this issue can be closed.

@nodakai
Copy link
Contributor Author

nodakai commented Nov 27, 2014

Close this issue hoping capitalize() can be piggybacked to #19350

@nodakai nodakai closed this as completed Nov 27, 2014
@SimonSapin
Copy link
Contributor

I assume that capitalize means “make upper case the first letter of the string”, and capwords means “make upper case the first letter of each word of the string”.

The problem is that the concepts of “upper case”, “letter”, and “words” are not easy to define for international text. For example, the upper case of i in Turkish is İ, instead of I in other languages. Some languages don’t use spaces to separate words, or don’t have case. And a single string might contain text in multiple languages.

Variations of capitalize and capwords that only operate in the ASCII range are easy to define, but they’re not that useful. Many languages are mostly but not entirely ASCII, so ASCII-only is just wrong for them. E.g the upper case of é is É.

The Unicode Standard and the Unicode Common Locale Data Repository can help do this right, but there are still many possible variations. It’s not obvious which and how many of these should be included in Rust’s standard library.

Because this is a complex topic, I did not include it in rust-lang/rfcs#486. I suggest starting a separate discussion or RFC.

@nodakai
Copy link
Contributor Author

nodakai commented Nov 27, 2014

@SimonSapin Right, I should have thought in the framework of Unicode from the beginning 😛

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup.
Projects
None yet
Development

No branches or pull requests

5 participants