Skip to content

Commit c3b794f

Browse files
committed
feat!: Make wcwidth the default
1 parent 9d22a78 commit c3b794f

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

Diff for: table2ascii/table_to_ascii.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ def table2ascii(
396396
alignments: list[Alignment] | None = None,
397397
cell_padding: int = 1,
398398
style: TableStyle = PresetStyle.double_thin_compact,
399-
use_wcwidth: bool = False,
399+
use_wcwidth: bool = True,
400400
) -> str:
401401
"""Convert a 2D Python table to ASCII text
402402
@@ -424,10 +424,10 @@ def table2ascii(
424424
style: Table style to use for styling (preset styles can be imported).
425425
Defaults to :ref:`PresetStyle.double_thin_compact <PresetStyle.double_thin_compact>`.
426426
use_wcwidth: Whether to use :func:`wcwidth.wcswidth` to determine the width of each cell instead of
427-
:func:`len`. This is useful when dealing with double-width characters
428-
(East Asian Wide and East Asian Fullwidth) or zero-width characters
429-
(combining characters, zero-width space, etc.) which are not properly handled by :func:`len`.
430-
Defaults to :py:obj:`False`.
427+
:func:`len`. The :func:`~wcwidth.wcswidth` function takes into account double-width characters
428+
(East Asian Wide and East Asian Fullwidth) and zero-width characters (combining characters,
429+
zero-width space, etc.), whereas :func:`len` determines the width solely based on the number of
430+
characters in the string. Defaults to :py:obj:`True`.
431431
432432
Returns:
433433
The generated ASCII table

Diff for: tests/test_convert.py

+1
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ def test_east_asian_wide_characters_and_zero_width():
254254
header=["日期", "test"],
255255
body=[["2022/12/11", "test"], ["2022/1/1", "測試"]],
256256
cell_padding=5,
257+
use_wcwidth=False,
257258
)
258259
expected = (
259260
"╔═══════════════════════════════════╗\n"

0 commit comments

Comments
 (0)