Is there any way to write something like this in Powershell? (Linux would be with Perl)
char foo = '\x41';
I need to input some non-printable characters to one of my programs
Description. The Format-Hex cmdlet displays a file or other input as hexadecimal values. To determine the offset of a character from the output, add the number at the leftmost of the row to the number at the top of the column for that character.
To convert decimal to Hex in PowerShell app, use '{0:x}' -f to format strings by using the format method of string objects and decimal number. It will convert decimal to hex string in PowerShell.
The [char[]] is simply an explicit declaration of a character array to over ride any odd default PowerShell behavior.
You can do it by casting an int to char.
With a decimal number :
$foo = (65 -as [char])
And from hexa :
$foo = (0x41 -as [char])
Both will set $foo
to A
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With