Bug#782228: busybox sh: parameter expansion: string length ${#parameter} is incorrect on multibyte character
Package: busybox
Version: 1:1.22.0-15
Severity: normal
In UTF-8 based locales:
$ busybox sh -c 'a=$(/usr/bin/printf \\u00e9); echo $a ${#a}'
é 2
while POSIX says[*]:
${#parameter}
String Length. The length in characters of the value of parameter
shall be substituted.
[*] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02
This the length in *characters*, not in bytes!
So, the output should be "é 1" like with bash, ksh93 and zsh.
-- System Information:
Debian Release: 8.0
APT prefers unstable
APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 3.16.0-4-amd64 (SMP w/8 CPU cores)
Locale: LANG=POSIX, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)
Versions of packages busybox depends on:
ii libc6 2.19-17
busybox recommends no packages.
busybox suggests no packages.
-- no debconf information
--
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
Reply to: