Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows 下使用出现中文乱码 #135

Closed
0xffffharry opened this issue Sep 2, 2022 · 9 comments
Closed

windows 下使用出现中文乱码 #135

0xffffharry opened this issue Sep 2, 2022 · 9 comments

Comments

@0xffffharry
Copy link

未加:

PS C:\Users\Admin> ping 240c::6644
正在 Ping 240c::6644 具有 32 字节的数据:
来自 240c::6644 的回复: 时间=161ms
来自 240c::6644 的回复: 时间=47ms
来自 240c::6644 的回复: 时间=46ms
来自 240c::6644 的回复: 时间=46ms

240c::6644 的 Ping 统计信息:
    数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
    最短 = 46ms,最长 = 161ms,平均 = 75ms

已加:

PS C:\Users\Admin> ping 240c::6644 | nali

?? Ping 240c::6644 [中国        北京市 北京天地互连信息技术有限公司]  ?? 32 ?????:
?? 240c::6644 [中国     北京市 北京天地互连信息技术有限公司]  ???: ??=47ms
?? 240c::6644 [中国     北京市 北京天地互连信息技术有限公司]  ???: ??=45ms
?? 240c::6644 [中国     北京市 北京天地互连信息技术有限公司]  ???: ??=48ms
?? 240c::6644 [中国     北京市 北京天地互连信息技术有限公司]  ???: ??=46ms

240c::6644 [中国        北京市 北京天地互连信息技术有限公司]  ? Ping ????:
    ???: ??? = 4???? = 4??? = 0 (0% ??)?
?????????(??????):
    ?? = 45ms??? = 48ms??? = 46ms
@zu1k
Copy link
Owner

zu1k commented Sep 3, 2022

请查看历史issue
#59 #76 #82

@zu1k zu1k closed this as completed Sep 3, 2022
@0xffffharry
Copy link
Author

0xffffharry commented Sep 3, 2022

依然乱码

PS C:\Users\Admin> nslookup baidu.com | nali --gbk
非权威应答:
???:  UnKnown
Address:  fd25:2020:c3::1 [局域网 局部单播地址]

??:    baidu.com
Addresses:  39.156.66.10 [北京市 移动]
          110.242.68.66 [河北省保定市 联通]
PS C:\Users\Admin> ping 240c::6644 | nali --gbk

?? Ping 240c::6644 [中国        北京市 北京天地互连信息技术有限公司]  ?? 32 ?????:
????????
????????
????????
????????

240c::6644 [中国        北京市 北京天地互连信息技术有限公司]  ? Ping ????:
    ???: ??? = 4???? = 0??? = 4 (100% ??)?

@zu1k
Copy link
Owner

zu1k commented Sep 3, 2022

换一个旧版试一下,旧版会出现这种情况吗

@zu1k zu1k reopened this Sep 3, 2022
@zu1k
Copy link
Owner

zu1k commented Sep 4, 2022

已经确定在历史版本中也出现此问题

@zu1k
Copy link
Owner

zu1k commented Sep 4, 2022

可以确定使用 cmd 配合 --gbk 可以暂时正常使用,应该是 powershell 的问题

@0xffffharry
Copy link
Author

还有一点:powershell下命令不能实时输出,需要等命令结束后才能输出

@0xffffharry
Copy link
Author

还有就是建议增加gbk环境变量,不需要每次都加上--gbk

@zu1k
Copy link
Owner

zu1k commented Sep 4, 2022

查看一下你使用的 PowerShell 版本:$psversiontable

我测试 v5 版本有这个问题,主要是因为 PowerShell v5 默认使用 Unicode UTF-16LE 编码,并且带有 BOM

这里我的建议是升级到 v6/v7 版本,即可不经任何修改解决该问题(无需使用 gbk 参数,只有cmd需要改参数),v6 版本开始使用 utf8NoBOM 编码方式作为默认输出格式,可以与其它 unix 程序兼容

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_character_encoding?view=powershell-7.2

@zu1k
Copy link
Owner

zu1k commented Sep 4, 2022

Microsoft Store 搜索 powershell 直接安装即 v7 版本

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants