def _string_width(string, *, _IS_ASCII=_IS_ASCII):
match = _IS_ASCII.match(string)<EOL>if match:<EOL><INDENT>return match.endpos<EOL><DEDENT>UNICODE_WIDE_CHAR_TYPE = '<STR_LIT>'<EOL>width = <NUM_LIT:0><EOL>func = unicodedata.east_asian_width<EOL>for char in string:<EOL><INDENT>width += <NUM_LIT:2> if func(char) in UNICODE_WIDE_CHAR_TYPE else <NUM_LIT:1><EOL><DEDENT>return width<EOL>
Returns string's width.