I was really behind the times, and just recently converted my MySQL (v5.7.30) database tables to support utf8mb4
(emojis, symbols, etc). I'm using Devise 3.5.10 for user authentication in my Rails 4 app.
To validate email, I rely on Devise's default email_regexp
.
Since emojis are permitted in email addresses, I want to make sure I get my validation right. The current regex I'm using lets them through, and when signing up with something like example@test.com
, in the database it's actually saved as example@xn--test-r625f.com
.
I logged out and logged back in with example@test.com
, and sure enough it worked. So:
1) Should I continue using the default Devise email regex to allow symbols and emoji? /\A[^@\s]+@([^@\s]+\.)+[^@\W]+\z/
2) Why did it save in the database with the r625f
text instead of the actual emoji? Elsewhere in my database where an emoji appears in a VARCHAR
field I just see it as the actual emoji.