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)
Sun, Mar 15, 5:43 AM
Unknown Object (File)
Wed, Mar 11, 10:08 AM
Unknown Object (File)
Mon, Mar 9, 6:53 PM
Unknown Object (File)
Mon, Mar 9, 2:47 PM
Unknown Object (File)
Sun, Mar 8, 8:47 PM
Unknown Object (File)
Sun, Mar 8, 8:47 PM
Unknown Object (File)
Sun, Mar 8, 6:57 PM
Unknown Object (File)
Sat, Mar 7, 2:46 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 Not Applicable
Unit
Tests Not Applicable

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.Sun, Mar 1, 11:30 AM
This revision was automatically updated to reflect the committed changes.