在PowerShell中编写十六进制转义字符

人气:1,239 发布:2022-10-16 标签: powershell-3.0

问题描述

有没有办法在PowerShell中编写这样的代码?(Linux将与Perl一起使用)

char foo = 'x41';

我需要在其中一个程序中输入一些不可打印的字符

推荐答案

我想提供一种不同于强制转换为十六进制的方法。PowerShell7不使用十六进制,而是支持Unicode字符编码(请参阅文章about_special_characters>;Unicode Characters)。因此,如果将x041作为拉丁文大写A,则Unicode的等价物将是"`u{41}"。该示例演示了Microsoft Docs示例:"`u{2195}"(注意字母前面的反号)。

Helpful table for coding is here。

895