-
Notifications
You must be signed in to change notification settings - Fork 21.9k
Deprecate Unicode#downcase/upcase/swapcase. #34123
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
Deprecate Unicode#downcase/upcase/swapcase. #34123
Conversation
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @sgrif (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review. Please see the contribution instructions for more information. |
The intent is to deprecate the wrappers for the String methods (upcase, downcase, swapcase) in AS::Multibyte::Unicode. These methods are used in AS::Multibyte::Chars so I changed those to just use the String methods directly. The warning only appears if you use the Unicode methods directly. I added a test case to show this behavior, but here is the output in irb:
I think these could be the wrapper methods referred here: #26743 (comment) |
That sounds good. Let's deprecate these methods together as a group and change the warning message to suggest using String directly since the ActiveSupport::Multibyte::Unicode wrapper is no longer needed. |
+1 from me! |
👍 |
@jeremy I made the changes. I hope I got it right :) ... I also removed the method definitions from |
I'm also removing the wrapper around String#capitalize after discussing this with @mtsmfm (#26743 (comment)) |
|
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 @frodsan. For those interested, let's look at deprecating Unicode.normalize
and changing Chars#reverse
implementation in new PRs.
Looks like a failing test remains:
|
Use String methods directly instead.
@jeremy I fixed the failing test. I just found that the bang version of these methods will raise FrozenError when the wrapped string is frozen. I think that should be expected:
I'll work on the Unicode#normalize deprecation. |
Use \X meta character directly to get grapheme clusters. Thanks to @mtsmfm for the tip: #34123 (comment) r? @jeremy
Deprecate Unicode#downcase/upcase/swapcase rails/rails#34123
ActiveSupport::Multibyte::Unicode#downcase/upcase/swapcase
in favor of using String methods directly.ActiveSupport::Multibyte::Chars
wrappers around the following String methods:#downcase
,#upcase
,#swapcase
, and#capitalize
.