Inconsistency between tr and cut on multibyte character
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 24.1k
- Forks
- 2k
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 365
Description
Hi,
I downloaded the last release and have a strange behaviour.
I have the following test.txt file (utf8 encoded)
zone1§zone2§zone3
$ ./coreutils cut -d§ -f2 test.txt
zone2
$ cat test.txt | ./coreutils tr '§' ';'
zone1;;zone2;;zone3
the cut command behave as I would expect (although the output is different from the gnu cut)
However, tr should not double ;
Basically, it seems to work fine when tr replace n byte(s) character by another n byte(s) character, but is broken if I try to replace a n byte(s) character by a m byte(s) character.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported behavior through the tr command entry point with the UTF-8 test.txt content containing §, then compare its output with cut and the expected single-character replacement. The issue is done when replacing the multibyte character with ; produces one ; per occurrence rather than duplicates, with the behavior covered by a regression test if the relevant test location is found.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 55/100