FS#59229 - Misaligned columns in pacman table display with Chinese

Attached to Project: Pacman
Opened by Chih-Hsuan Yen (yan12125) - Wednesday, 04 July 2018, 12:49 GMT
Last edited by Allan McRae (Allan) - Wednesday, 23 September 2020, 07:26 GMT
Task Type Bug Report
Category Output
Status Closed
Assigned To No-one
Architecture All
Severity Low
Priority Normal
Reported Version 5.1.0
Due in Version 6.0.0
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Summary and Info:
For example, running `sudo pacman -Su` results in: (Copy to text editors with monospace fonts to see exactly what happened)

```
:: 正在進行全系統更新…
正在解決依賴關係…
正在檢查衝突的軟體包…

軟體包 (2) 舊版本 新版本 淨更動 下載大小

testing/linux 4.17.3-1 4.17.4-1 0.01 MiB 70.38 MiB
testing/linux-headers 4.17.3-1 4.17.4-1 0.00 MiB 8.25 MiB

總計下載大小: 78.63 MiB
總計安裝大小: 157.30 MiB
淨升級大小: 0.01 MiB

:: 進行安裝嗎? [Y/n] n
```

The term 舊版本 does not align with 4.17.3-1. In comparison, the English version is correctly aligned:
```
:: Starting full system upgrade...
resolving dependencies...
looking for conflicting packages...

Package (2) Old Version New Version Net Change Download Size

testing/linux 4.17.3-1 4.17.4-1 0.01 MiB 70.38 MiB
testing/linux-headers 4.17.3-1 4.17.4-1 0.00 MiB 8.25 MiB

Total Download Size: 78.63 MiB
Total Installed Size: 157.30 MiB
Net Upgrade Size: 0.01 MiB

:: Proceed with installation? [Y/n] n
```

The problem here is that pacman uses printf to align columns, but such an approach does not work well with some non-ASCII characters [1]

[1] https://stackoverflow.com/questions/35427491/the-width-specifier-in-printf-does-not-work-properly-with-accented-characters/35427692

Steps to Reproduce:
1. Enable `VerbosePkgLists` in pacman.conf
2. Downgrade some random packages
3. `sudo pacman -Su`
This task depends upon

Closed by  Allan McRae (Allan)
Wednesday, 23 September 2020, 07:26 GMT
Reason for closing:  Fixed
Additional comments about closing:  git commit 4533c6a8e0f39c7707e671b7f9687607b46f1417
Comment by Chih-Hsuan Yen (yan12125) - Wednesday, 04 July 2018, 12:52 GMT
Oops, FlySpray turns multiple spaces into one. See https://gitlab.com/snippets/1730355 for unmodified Chinese and English outputs.
Comment by Chih-Hsuan Yen (yan12125) - Saturday, 12 September 2020, 08:27 GMT

Loading...