Writing a hex escaped char in Powershell

这一生的挚爱 提交于 2019-12-23 15:23:57

问题


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


回答1:


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




回答2:


Short form is:

$foo = [char]0x41


来源:https://stackoverflow.com/questions/24626455/writing-a-hex-escaped-char-in-powershell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!