You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to use "⚔️" as a favicon for my app, and finding that it gives me the error "ValueError: invalid favicon: ⚔️", coming out of line 61 of favicon.py.
The issue here is that the crossed-swords emoji is made out of two unicode code points: \u2694 ("Crossed Swords") and \uFE0F ("Variation Selector-16" i.e. "display as emoji"). Python's len() gives 2 for this when it's a string, which means favicon.py's _is_char() returns false for this sort of emoji.
Solving this in a general way, i.e. "how can we determine whether a given string is actually a single emoji" seems way more difficult than this problem deserves, so my suggestion would simply be to rewrite the test in _is_char() to something like return len(favicon) == 1 or "\ufe0f" in favicon - this feels like it'll catch a bunch more cases.
The text was updated successfully, but these errors were encountered:
Solving this in a general way, i.e. "how can we determine whether a given string is actually a single emoji" seems way more difficult than this problem deserves
I totally agree. Adding "\ufe0f" in favicon would be a good quick fix - until someone wants to use something like 👍🏻 as a favicon. But I guess a general solution would require something like emoji. We can think about using it in the future.
Would you like to create a pull request handling \ufe0f? 🙂
Description
Trying to use "⚔️" as a favicon for my app, and finding that it gives me the error "ValueError: invalid favicon: ⚔️", coming out of line 61 of favicon.py.
The issue here is that the crossed-swords emoji is made out of two unicode code points: \u2694 ("Crossed Swords") and \uFE0F ("Variation Selector-16" i.e. "display as emoji"). Python's len() gives 2 for this when it's a string, which means favicon.py's _is_char() returns false for this sort of emoji.
Solving this in a general way, i.e. "how can we determine whether a given string is actually a single emoji" seems way more difficult than this problem deserves, so my suggestion would simply be to rewrite the test in _is_char() to something like
return len(favicon) == 1 or "\ufe0f" in favicon
- this feels like it'll catch a bunch more cases.The text was updated successfully, but these errors were encountered: