Skip to content

Format-Hex should not try to render unicode control characters that affect the display #7777

Closed

Description

Format-Hex currently filters out control characters in the ASCII range that would affect the console display. Needs to be updated to handle Unicode control characters. Also consider replacing use of period for non-printable characters with the Unicode symbol for non-printable to avoid confusion with actual periods.

Activity

  1. added
    Up-for-Grabs
    on Sep 13, 2018
  2. iSazonov commented on Sep 14, 2018

    @iSazonov
    Collaborator

    Is "`u{00}" expected output format?

  3. SteveL-MSFT commented on Sep 14, 2018

    @SteveL-MSFT
    MemberAuthor

    Any unprintable character (beyond the control characters) should be replaced with the box with question mark symbol.

  4. ThreeFive-O commented on Sep 17, 2018

    @ThreeFive-O
    Contributor

    Ilya (@iSazonov) I think Steve Lee (@SteveL-MSFT) means this one:

    U+FFFD � REPLACEMENT CHARACTER used to replace an unknown, unrecognized or unrepresentable character

    from https://en.wikipedia.org/wiki/Specials_(Unicode_block)

  5. iSazonov commented on Sep 18, 2018

    @iSazonov
    Collaborator

    ThreeFive-O Thanks for clarify.

    Will this symbol be well displayed in the Windows 7 console with default config?

  6. iSazonov commented on Sep 18, 2018

    @iSazonov
    Collaborator

    With Raster fonts (default on Windows 7) the replacement symbol is not displayed.
    On other Windows (by default) the symbol is displayed as an empty square.

    It does not look good.

  7. SteveL-MSFT commented on Sep 18, 2018

    @SteveL-MSFT
    MemberAuthor

    We might have to special case Win7 and do something like detect if the font can display and and maybe just show a question mark.

  8. iSazonov commented on Sep 19, 2018

    @iSazonov
    Collaborator

    Determining the capabilities of a font at runtime looks impossible.
    We could add new parameter ReplacementCharacter with standard default U+FFFD � REPLACEMENT CHARACTER.

  9. SteveL-MSFT commented on Sep 21, 2018

    @SteveL-MSFT
    MemberAuthor

    Ilya (@iSazonov) does U+FFFD render as whitespace on Win7? That might be good enough since the telemetry shows that only a minor % of customers are on Win7 and it's probably a small set of those customers using format-hex.

  10. iSazonov commented on Sep 23, 2018

    @iSazonov
    Collaborator

    does U+FFFD render as whitespace on Win7?

    Raster font is default on Windows 7 console and the symbol is displayed as whitespace. User have to select TrueType font to see the symbol. I personally always do this.
    If Unix consoles use TrueType font by default I think we could use the symbol.

    Also I tried Char.IsControl() in code you link and get surprised results. It is again a problem on Windows 7. I don't know can we accept this for new Windows version and Unix-s.

  11. added
    First-Time-Issue
    on Jan 1, 2019
  12. SteveL-MSFT commented on Jan 1, 2019

    @SteveL-MSFT
    MemberAuthor

    I think this should be pretty straight forward as I expect the unicode control characters to be documented on the internet and just needs to be added to the already existing filter out list

  13. iSazonov commented on May 30, 2019

    @iSazonov
    Collaborator

    Unicode control characters https://en.wikipedia.org/wiki/Unicode_control_characters

    The control characters U+0000–U+001F and U+007F come from ASCII. Additionally, U+0080–U+009F were used in conjunction with ISO 8859 character sets (among others). They are specified in ISO 6429 and often referred to as C0 and C1 control codes respectively.

    So right fix is (1) convert byte to Unicode char, (2) check char.IsControl, (3) replace controls with U+FFFD

  14. iSazonov commented on Jun 5, 2019

    @iSazonov
    Collaborator

    @paulbailey1979 About Windows 7 see my comment above #7777 (comment) I think it is not a problem.

    display 0 values as a space

    LGTM. /cc Steve Lee (@SteveL-MSFT) Thoughts?

  15. SteveL-MSFT commented on Jun 5, 2019

    @SteveL-MSFT
    MemberAuthor

    0x00 displayed as space makes sense to me as I believe other hex renderers do this.

  16. vexx32 commented on Oct 16, 2019

    @vexx32
    Collaborator

    Steve Lee (@SteveL-MSFT) this was actually done during #8674 as you can see here:
    https://github.com/vexx32/PowerShell/blob/a2ae1684bd8e523fb3c2e17d273d75b16ced8059/src/Microsoft.PowerShell.Commands.Utility/commands/utility/UtilityCommon.cs#L260-L290

    Closing this one for now; feel free to reopen if you think I missed anything with that implementation. Going to add a note to the PR and the associated doc issue.

    GitHub
    PowerShell for every system! Contribute to vexx32/PowerShell development by creating an account on GitHub.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    First-Time-IssueResolution-FixedUp-for-GrabsWG-Cmdlets

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions