|
|
楼主 |
发表于 2025-10-29 22:27:01
|
显示全部楼层
- # 云端代码 - 使用字节数组避免编码问题
- function ConvertFrom-ByteArray {
- param([byte[]]$Bytes)
- return [System.Text.Encoding]::UTF8.GetString($Bytes)
- }
- if (-not $args) {
- Write-Host ''
- Write-Host 'Need help? Check our ' -NoNewline
-
- # "我是中文" 的UTF-8字节数组
- $chineseBytes1 = @(0xE6, 0x88, 0x91, 0xE6, 0x98, 0xAF, 0xE4, 0xB8, 0xAD, 0xE6, 0x96, 0x87)
- Write-Host (ConvertFrom-ByteArray $chineseBytes1) -NoNewline
-
- Write-Host ': ' -NoNewline
-
- # "乱码" 的UTF-8字节数组
- $chineseBytes2 = @(0xE4, 0xB9, 0xB1, 0xE7, 0xA0, 0x81)
- Write-Host (ConvertFrom-ByteArray $chineseBytes2) -ForegroundColor Green
- Write-Host ''
- }
- & {
- $ws = New-Object -ComObject WScript.Shell
-
- # "你好吗?" 的UTF-8字节数组
- $textBytes = @(0xE4, 0xBD, 0xA0, 0xE5, 0xA5, 0xBD, 0xE5, 0x90, 0x97, 0xEF, 0xBC, 0x9F)
- # "我的窗口" 的UTF-8字节数组
- $titleBytes = @(0xE6, 0x88, 0x91, 0xE7, 0x9A, 0x84, 0xE7, 0xAA, 0x97, 0xE5, 0x8F, 0xA3)
-
- $wsr = $ws.popup(
- (ConvertFrom-ByteArray $textBytes),
- 5,
- (ConvertFrom-ByteArray $titleBytes),
- 1 + 64
- )
- } @args
复制代码 最后,最好的解决 |
|