Chu*_*rly 5 unicode powershell
这个堆栈溢出问题涉及 16 位 Unicode 字符。我想要一个支持 32 位字符的类似解决方案。有关各种 Unicode 图表的列表,请参阅此链接。例如,一系列 32 位字符是Musical Symbols。
上面链接的问题中的答案不起作用,因为它将 System.Int32 值转换为 System.Char,这是一种 16 位类型。
编辑:让我澄清一下,我并不特别关心显示 32 位 Unicode 字符,我只想将字符存储在字符串变量中。
编辑 #2:我写了一个 PowerShell 片段,它使用标记答案及其评论中的信息。我本来想把它放在另一个评论中,但评论不能是多行的。
$inputValue = '1D11E'
$hexValue = [int]"0x$inputValue" - 0x10000
$highSurrogate = [int]($hexValue / 0x400) + 0xD800
$lowSurrogate = $hexValue % 0x400 + 0xDC00
$stringValue = [char]$highSurrogate + [char]$lowSurrogate
Run Code Online (Sandbox Code Playgroud)
Dour High Arch 的答案仍然值得称赞,因为它帮助我最终理解了代理对。
恕我直言,在 PowerShell 中使用 Unicode 文字最优雅的方法是
[char]::ConvertFromUtf32(0x1D11E)
Run Code Online (Sandbox Code Playgroud)
有关更多详细信息,请参阅我的博文
假设 PowerShell 使用 UTF-16,32 位代码点表示为代理项。例如,U+10000 表示为:
0xD100 0xDC00
Run Code Online (Sandbox Code Playgroud)
即两个16位字符;十六进制 D100 和 DC00。
祝你好运找到带有代理字符的字体。
| 归档时间: |
|
| 查看次数: |
3900 次 |
| 最近记录: |