在 PowerShell 中显示 Unicode 表情符号

Pet*_*rXX 6 unicode powershell

我想在 PowerShell 中显示像 U+1F4A9 这样的 Unicode 表情符号。我知道这仅在 ISE 控制台内有效,但我不知道如何。

到目前为止我尝试过的:

$CharBytes = [System.Text.Encoding]::Unicode.GetBytes("")
Run Code Online (Sandbox Code Playgroud)

这将返回 61, 216, 169, 220。但这不能是 0x1F4A9 的表示吗?

当我尝试

[BitConverter]::GetBytes(0x1F4A9)
Run Code Online (Sandbox Code Playgroud)

我会得到一组不同的字节:169、244、1、0。将它们转换为 Unicode 字符结果为

所以我的问题是:如何在 PowerShell ISE 中显示任何 Unicode 字符(也可能在控制台窗口中)?

Pet*_*rXX 5

好的,这很简单:我必须使用 UTF32 而不是 Unicode:

$CharBytes = 169, 244, 1, 0
[System.Text.Encoding]::UTF32.GetString($CharBytes)
Run Code Online (Sandbox Code Playgroud)