Skip to content

Consider extending \x to support non-ASCII characters #1352

Closed

Description

@ridiculousfish

Currently \x escapes an ASCII value, and \X escapes a byte value. \x is "safe", because it cannot be used to generate invalid sequences: echo \xE4 is a syntax error. \X is "dangerous" because it can, e.g. echo \XE4 is accepted and results in an invalid UTF-8 sequence.

This bug tracks whether we should extend \x to allow escaping non-ASCII characters. An open question is whether it should escape byte values or characters. That is, does \xE4 generate the literal byte 0xE4, or the unichar U+00E4.

Spun off from #1225 . See that bug for more discussion.

Activity

  1. added this to the fish-future milestone on Mar 22, 2014
  2. ddevault commented on Mar 27, 2014

    @ddevault

    I just ran into this issue, and came here to report a bug. Expressing support for proper \x support, as defined in POSIX. That is, echo -ne "\xFF" should output a literal 0xFF to stdout.

  3. faho commented on Sep 26, 2022

    @faho
    Member

    Yeah, I don't see a use for a "checking-hex" escape - you already decided to use hex values, so you probably know what you are doing or want the actual bytes!

    I would just make \x and \X the same. Unless anyone disagrees, I'm going to implement that.

  4. krobelus commented on Sep 29, 2022

    @krobelus
    Contributor

    sounds good, thanks. Both \xe4 and \Xe4 should produce that byte. For Unicode characters we already have \u00e4

  5. added a commit that references this issue on Sep 29, 2022
    95b2611
  6. added 2 commits that reference this issue on Oct 9, 2022
    6be3fc3
    061a87b
  7. added a commit that references this issue on Oct 9, 2022
    52dcfe1
  8. modified the milestones: fish-future, fish 3.6.0 on Oct 11, 2022
  9. locked as resolved and limited conversation to collaborators on Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions