mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-04 08:56:19 +00:00
Use built-in isascii instead of regex
This commit is contained in:
@ -764,14 +764,10 @@ class SnowflakeList(_SnowflakeListBase):
|
|||||||
return i != len(self) and self[i] == element
|
return i != len(self) and self[i] == element
|
||||||
|
|
||||||
|
|
||||||
_IS_ASCII = re.compile(r'^[\x00-\x7f]+$')
|
def _string_width(string: str) -> int:
|
||||||
|
|
||||||
|
|
||||||
def _string_width(string: str, *, _IS_ASCII=_IS_ASCII) -> int:
|
|
||||||
"""Returns string's width."""
|
"""Returns string's width."""
|
||||||
match = _IS_ASCII.match(string)
|
if string.isascii():
|
||||||
if match:
|
return len(string)
|
||||||
return match.endpos
|
|
||||||
|
|
||||||
UNICODE_WIDE_CHAR_TYPE = 'WFA'
|
UNICODE_WIDE_CHAR_TYPE = 'WFA'
|
||||||
func = unicodedata.east_asian_width
|
func = unicodedata.east_asian_width
|
||||||
|
Reference in New Issue
Block a user