Page MenuHomeFreeBSD

ed: add unicode support for the l (list) command
ClosedPublic

Authored by bapt on Feb 19 2026, 10:03 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, May 20, 9:54 AM
Unknown Object (File)
Wed, May 20, 9:54 AM
Unknown Object (File)
Sun, May 17, 10:05 PM
Unknown Object (File)
Sun, May 17, 10:01 PM
Unknown Object (File)
Sat, May 16, 2:51 AM
Unknown Object (File)
Sat, May 16, 2:51 AM
Unknown Object (File)
Sat, May 16, 2:50 AM
Unknown Object (File)
Fri, May 1, 8:22 AM
Subscribers

Details

Summary

Use mbrtowc()/iswprint()/wcwidth() in put_tty_line() so that
the l command displays valid multibyte characters as-is instead
of escaping each byte as octal.

Column wrapping now correctly accounts for character display
width (including double-width CJK characters).

Invalid or incomplete UTF-8 sequences and non-printable
characters are still escaped as octal.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 70778
Build 67661: arc lint + arc unit

Event Timeline

Do regexps addresses and commands like 's' correctly operate on mb strings?

yes it does, all the tests in https://reviews.freebsd.org/D55364 are passing with this patch.

I may be missing some idea on what to test

I may be missing some idea on what to test

Might be add some tests for e.g. ru_RU.UTF-8? What do you need for this?

In D55365#1266404, @kib wrote:

I may be missing some idea on what to test

Might be add some tests for e.g. ru_RU.UTF-8? What do you need for this?

In D55365#1266404, @kib wrote:

I may be missing some idea on what to test

Might be add some tests for e.g. ru_RU.UTF-8? What do you need for this?

juste provide me a set of command you would expect to work in ru_RU.UTF-8 and and expected output and I will add it to the test suite.

In D55365#1266404, @kib wrote:

I may be missing some idea on what to test

Might be add some tests for e.g. ru_RU.UTF-8? What do you need for this?

In D55365#1266404, @kib wrote:

I may be missing some idea on what to test

Might be add some tests for e.g. ru_RU.UTF-8? What do you need for this?

juste provide me a set of command you would expect to work in ru_RU.UTF-8 and and expected output and I will add it to the test suite.

exa% LANG=ru_RU.UTF-8 ./ed
a
Привет
.
s/ривет/ока/
1p
Пока
a
Строка
.
1      
Пока
/а/p
Строка
1,$p
Пока
Строка
Q

(GNU ed)

https://reviews.freebsd.org/D55364 now has your tests and they pass

Thank you. Looks good for me, but I am not qualified to review.

This revision was not accepted when it landed; it landed in state Needs Review.Mar 1 2026, 11:30 AM
This revision was automatically updated to reflect the committed changes.