hermes - 💡(How to fix) Fix Terminal ASCII tables misalign with mixed Chinese/ASCII content [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#17698Fetched 2026-04-30 06:46:00
View on GitHub
Comments
0
Participants
1
Timeline
5
Reactions
0
Author
Participants
Timeline (top)
labeled ×3closed ×1cross-referenced ×1

Root Cause

When rendering ASCII tables with mixed Chinese and ASCII characters, column alignment breaks because Chinese characters are counted as 1 column width instead of 2 in terminal output.

Code Example

| Name               | Stars | Lang   | License         | Notes                             |
| Open-Generative-AI | 12.3k | Python | MIT             | 聚合多模型 API,支持图片/音频生成 |
| Vicuna             | 8.1k  | Python | CC BY-NC-SA 4.0 | 基于 LLaMA 的对话模型             |

---

import unicodedata

def display_width(s):
    return sum(2 if unicodedata.east_asian_width(c) in ('W', 'F') else 1 for c in s)
RAW_BUFFERClick to expand / collapse

Bug Description

When rendering ASCII tables with mixed Chinese and ASCII characters, column alignment breaks because Chinese characters are counted as 1 column width instead of 2 in terminal output.

Steps to Reproduce

  1. Use any tool that outputs an ASCII table with Chinese characters
  2. Observe that columns do not align

Example output (misaligned):

| Name               | Stars | Lang   | License         | Notes                             |
| Open-Generative-AI | 12.3k | Python | MIT             | 聚合多模型 API,支持图片/音频生成 |
| Vicuna             | 8.1k  | Python | CC BY-NC-SA 4.0 | 基于 LLaMA 的对话模型             |

Expected Behavior

Columns should be visually aligned in any standard terminal (macOS Terminal, iTerm2, etc.) that supports Unicode East Asian Width (WAEW). Chinese characters should occupy 2 columns in monospace rendering.

Environment

  • OS: macOS
  • Terminal: standard terminal with Unicode support
  • Hermes Agent v0.11.0

Suggested Fix

Consider adding a utility function that uses Python's unicodedata.east_asian_width() to calculate proper display width:

import unicodedata

def display_width(s):
    return sum(2 if unicodedata.east_asian_width(c) in ('W', 'F') else 1 for c in s)

This is a cosmetic issue but affects readability of tables with multilingual content.

extent analysis

TL;DR

Implement a utility function to calculate the proper display width of characters, considering Unicode East Asian Width (WAEW), to fix column alignment issues in ASCII tables with mixed Chinese and ASCII characters.

Guidance

  • Use the unicodedata.east_asian_width() function from Python's standard library to determine the display width of each character.
  • Create a function, such as the suggested display_width(s) function, to calculate the total display width of a string.
  • Apply this function to the column data before rendering the ASCII table to ensure proper alignment.
  • Test the solution with different combinations of Chinese and ASCII characters to verify its effectiveness.

Example

import unicodedata

def display_width(s):
    return sum(2 if unicodedata.east_asian_width(c) in ('W', 'F') else 1 for c in s)

# Example usage:
column_data = "聚合多模型 API,支持图片/音频生成"
width = display_width(column_data)
print(f"Display width: {width}")

Notes

This solution assumes that the terminal supports Unicode East Asian Width (WAEW) and that the unicodedata module is available. The provided display_width(s) function may need to be adapted to fit the specific requirements of the project.

Recommendation

Apply the suggested workaround by implementing the display_width(s) function to calculate the proper display width of characters, as it directly addresses the identified issue and improves the readability of tables with multilingual content.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - 💡(How to fix) Fix Terminal ASCII tables misalign with mixed Chinese/ASCII content [1 participants]