You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Format-Hex should not try to render unicode control characters that affect the display #7777
First-Time-IssueEasy issues first time contributors can work on to learn about this projectResolution-FixedThe issue is fixed.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdletsgeneral cmdlet issues
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.
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.
Determining the capabilities of a font at runtime looks impossible.
We could add new parameter ReplacementCharacter with standard default U+FFFD � REPLACEMENT CHARACTER.
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.
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.
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
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
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.
First-Time-IssueEasy issues first time contributors can work on to learn about this projectResolution-FixedThe issue is fixed.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdletsgeneral cmdlet issues
Activity
iSazonov commentedon Sep 14, 2018
Is "`u{00}" expected output format?
SteveL-MSFT commentedon Sep 14, 2018
Any unprintable character (beyond the control characters) should be replaced with the box with question mark symbol.
ThreeFive-O commentedon Sep 17, 2018
Ilya (@iSazonov) I think Steve Lee (@SteveL-MSFT) means this one:
from https://en.wikipedia.org/wiki/Specials_(Unicode_block)
iSazonov commentedon Sep 18, 2018
ThreeFive-O Thanks for clarify.
Will this symbol be well displayed in the Windows 7 console with default config?
iSazonov commentedon Sep 18, 2018
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.
SteveL-MSFT commentedon Sep 18, 2018
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.
iSazonov commentedon Sep 19, 2018
Determining the capabilities of a font at runtime looks impossible.
We could add new parameter
ReplacementCharacterwith standard default U+FFFD � REPLACEMENT CHARACTER.SteveL-MSFT commentedon Sep 21, 2018
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.
iSazonov commentedon Sep 23, 2018
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.SteveL-MSFT commentedon Jan 1, 2019
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
iSazonov commentedon May 30, 2019
Unicode control characters https://en.wikipedia.org/wiki/Unicode_control_characters
So right fix is (1) convert byte to Unicode char, (2) check char.IsControl, (3) replace controls with U+FFFD
iSazonov commentedon Jun 5, 2019
@paulbailey1979 About Windows 7 see my comment above #7777 (comment) I think it is not a problem.
LGTM. /cc Steve Lee (@SteveL-MSFT) Thoughts?
SteveL-MSFT commentedon Jun 5, 2019
0x00 displayed as space makes sense to me as I believe other hex renderers do this.
vexx32 commentedon Oct 16, 2019
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.