[Bug 2137532] Re: tr handles UTF-8 wrong
Sylvestre Ledru
2137532 at bugs.launchpad.net
Wed Jan 21 21:05:14 UTC 2026
The Euro symbol (€) is encoded as the 3 bytes e2 82 ac in UTF-8.
The current tr implementation treats each byte separately, so:
1. When we do tr € E, it's actually mapping:
- byte e2 → E
- byte 82 → E
- byte ac → E
So the 3-byte Euro symbol becomes 3 Es → EEE
2. When we do tr E €, it's trying to map:
- byte E (0x45) → byte e2 (first byte of Euro)
But this creates invalid UTF-8, hence the replacement character �.
so, it is the expected behavior.
GNU coreutils is doing the same
$ echo € | gnutr € E
EEE
$ echo E | gnutr E €
�
** Changed in: rust-coreutils (Ubuntu)
Status: New => Invalid
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to rust-coreutils in Ubuntu.
https://bugs.launchpad.net/bugs/2137532
Title:
tr handles UTF-8 wrong
Status in rust-coreutils package in Ubuntu:
Invalid
Bug description:
```
medo at dev:~$ env | grep ^LANG
LANG=de_DE.UTF-8
medo at dev:~$ echo € | tr € E
EEE
medo at dev:~$ echo E | tr E €
�
```
should be
```
medo at dev:~$ env | grep ^LANG
LANG=de_DE.UTF-8
medo at dev:~$ echo € | tr € E
E
medo at dev:~$ echo E | tr E €
€
```
ProblemType: Bug
DistroRelease: Ubuntu 25.10
Package: coreutils-from-uutils 0.0.0~ubuntu24
ProcVersionSignature: Ubuntu 6.17.0-8.8-generic 6.17.2
Uname: Linux 6.17.0-8-generic x86_64
ApportVersion: 2.33.1-0ubuntu3
Architecture: amd64
CasperMD5CheckResult: unknown
CloudArchitecture: x86_64
CloudBuildName: minimal
CloudID: nocloud
CloudName: unknown
CloudPlatform: nocloud
CloudSerial: 20251210
CloudSubPlatform: seed-dir (dmi,/dev/sr0)
Date: Tue Jan 6 09:40:25 2026
PackageArchitecture: all
ProcEnviron:
LANG=de_DE.UTF-8
PATH=(custom, no user)
SHELL=/bin/bash
TERM=xterm-kitty
XDG_RUNTIME_DIR=<set>
SourcePackage: coreutils-from
UpgradeStatus: No upgrade log present (probably fresh install)
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/rust-coreutils/+bug/2137532/+subscriptions
More information about the foundations-bugs
mailing list