Skip to content

Commit f5d5035

Browse files
committed
Add support for more special characters
1 parent 32b8ffa commit f5d5035

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

seleniumbase/console_scripts/sb_print.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,17 @@ def invalid_run_command(msg=None):
3333

3434

3535
def sc_ranges():
36-
# Get the ranges of special characters of Chinese, Japanese, and Korean.
36+
# Get the ranges of special double-width characters.
3737
special_char_ranges = [
3838
{"from": ord("\u4e00"), "to": ord("\u9FFF")},
3939
{"from": ord("\u3040"), "to": ord("\u30ff")},
4040
{"from": ord("\uac00"), "to": ord("\ud7a3")},
41+
{"from": ord("\uff01"), "to": ord("\uff60")},
4142
]
4243
return special_char_ranges
4344

4445

45-
def is_cjk(char):
46+
def is_char_wide(char):
4647
# Returns True if the special character is Chinese, Japanese, or Korean.
4748
sc = any(
4849
[range["from"] <= ord(char) <= range["to"] for range in sc_ranges()]
@@ -52,10 +53,10 @@ def is_cjk(char):
5253

5354
def get_width(line):
5455
# Return the true width of the line. Not the same as line length.
55-
# Chinese/Japanese/Korean characters take up double width visually.
56+
# Chinese/Japanese/Korean characters take up two spaces of width.
5657
line_length = len(line)
5758
for char in line:
58-
if is_cjk(char):
59+
if is_char_wide(char):
5960
line_length += 1
6061
return line_length
6162

0 commit comments

Comments
 (0)