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

Fix Unicode regular expressions #33

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sutherland
Copy link

Slugifying strings containing Unicode characters can lead to invalid results:

iex(1)> Slugger.slugify("abc 😀")
<<97, 98, 99, 45, 159, 152, 128>>

Regular expressions do not match Unicode by default. Adding the unicode modifier seems to resolve the issue.

@etiennealbert
Copy link

+1 for the merge.
@sutherland you should use ~r/([^a-z0-9\p{Hangul}])+/u to correctly handle the Korean alphabet.

@inhji
Copy link

inhji commented Jan 5, 2022

I would love to see this merged. It causes Postgrex to fail with

** (Postgrex.Error) ERROR 22021 (character_not_in_repertoire) invalid byte sequence for encoding "UTF8": 0x9f

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.

None yet

3 participants