Is there a way to detect characters in a python string which require utf8mb4 encoding to store in a mysql/mariadb database?
Asked
Active
Viewed 113 times
0
-
Why do you think you need to detect such characters? **All** of Unicode can be stored with that codec. – Martijn Pieters Feb 26 '15 at 21:04
-
Closed before I could answer... utf8mb4 character ranges all start with 11110xxx as the first byte, so you could use: "any(ord(c)>=240 for c in value)". If True, then it requires utf8mb4. If False, then it fits in 1-3 bytes. – swstephe Feb 26 '15 at 21:18