powershell 如何将字符串编码为GBK


PowerShell交流中心分类: Powershell基础powershell 如何将字符串编码为GBK
0
awang asked 4年 ago

我在用powershell的Invoke-RestMethod 模块调用一个发送短信的API,现在问题是发送中文乱码。检查了对方API使用的是GBK编码。
我尝试过这个方法https://www.pstips.net/invoke-restmethod-charset-issue.html  指定ContentType ‘application/json;charset=GBK‘ 但是无效。

1 Answers
-1
铁打的流水 answered 4年 ago

[array]$data =[System.Text.Encoding]::GetEncoding(“GBK”).GetBytes(“字符串”)

KiYouMi replied 3年 ago

#不能发帖提问,不知道能不能回帖。如能回帖,有看到问题的朋友指点一下,谢谢
#Invoke-WebRequest获取的数据乱码怎么解决
(Invoke-WebRequest -Uri \’https://www.dzwzzz.com/jingxuan\’).Links|out-file E:\\news\\m.txt

KiYouMi replied 3年 ago

(Invoke-WebRequest -Uri ‘https://www.dzwzzz.com/jingxuan’).Links|out-file E:\news\m.txt

KiYouMi replied 3年 ago

发布提问时:Your question is waiting moderator.
发布了贴,为什么?
一次都没发过,每次总是这段英文 :Your question is waiting moderator.