Skip to content

echo, printf: UTF-8 sensitivity in arguments #6804

@andrewliebenow

Description

@andrewliebenow
❯ coreutils echo "$(coreutils printf 'A \xFF Z')"
error: invalid UTF-8 was detected in one or more arguments

Usage: coreutils echo [OPTIONS]... [STRING]...

For more information, try '--help'.

❯ /usr/bin/echo "$(coreutils printf 'A \xFF Z')"
A � Z
❯ coreutils printf "$(coreutils printf 'A \xFF Z')\n"
error: invalid UTF-8 was detected in one or more arguments

Usage: coreutils printf FORMATSTRING [ARGUMENT]...
       coreutils printf FORMAT [ARGUMENT]...
       coreutils printf OPTION

For more information, try '--help'.

❯ /usr/bin/printf "$(coreutils printf 'A \xFF Z')\n"
A � Z

I'm not sure if this is practically relevant. You can't print arbitrary binary data with echo/printf anyway, because the arguments are C strings (null terminated).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions