-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Add NFC support to String.normalize/2 #3805
Add NFC support to String.normalize/2 #3805
Conversation
1e29ba4
to
d46fd78
Compare
@@ -482,4 +496,50 @@ defmodule String.Normalizer do | |||
end | |||
|
|||
defp combining_class(_), do: 0 | |||
|
|||
def nfd_to_nfc("", acc), do: acc |
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.
Should those functions be private. :)
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.
Good catch! The irony is that I added syntax support for distinguishing private functions from public ones in Sublime Text, but I never bothered to utilize that distinction in my color scheme. 😆
@endersstocker curiosity, can you tell me how big is the String.Normalizer.beam in KB after this PR? |
168 KiB / 172 KB |
@josevalim I’ve optimized it to normalize NFC in a single pass. |
da81896
to
70c65f9
Compare
part = :binary.part(binary, 0, n) | ||
case n do | ||
1 -> normalize_nfc(rest, acc <> part) | ||
_ -> normalize_nfc(rest, acc <> compose(normalize(part, :nfd))) |
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.
let's call normalize_nfd(..., "")
This is great. I have added a tiny comment. Can you please address it and squashh your changes? ❤️ |
c11e090
to
4a42861
Compare
4a42861
to
07fedf6
Compare
It’s good to go. |
Add NFC support to String.normalize/2
❤️ 💚 💙 💛 💜 |
No description provided.