惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
The Exploit Database - CXSecurity.com
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Spread Privacy
Spread Privacy
Hacker News - Newest:
Hacker News - Newest: "LLM"
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Google Online Security Blog
Google Online Security Blog
S
Security Affairs
Help Net Security
Help Net Security
Simon Willison's Weblog
Simon Willison's Weblog
N
News and Events Feed by Topic
P
Palo Alto Networks Blog
P
Privacy International News Feed
T
Threat Research - Cisco Blogs
P
Proofpoint News Feed
N
News and Events Feed by Topic
C
Cyber Attacks, Cyber Crime and Cyber Security
TaoSecurity Blog
TaoSecurity Blog
T
Tor Project blog
Schneier on Security
Schneier on Security
WordPress大学
WordPress大学
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
V
Visual Studio Blog
F
Fortinet All Blogs
大猫的无限游戏
大猫的无限游戏
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tenable Blog
M
MIT News - Artificial intelligence
T
Threatpost
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
N
News | PayPal Newsroom
P
Privacy & Cybersecurity Law Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Microsoft Azure Blog
Microsoft Azure Blog
小众软件
小众软件
Cyberwarzone
Cyberwarzone
雷峰网
雷峰网
云风的 BLOG
云风的 BLOG
量子位
Google DeepMind News
Google DeepMind News
O
OpenAI News
爱范儿
爱范儿
H
Hackread – Cybersecurity News, Data Breaches, AI and More
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
F
Full Disclosure
B
Blog
Cloudbric
Cloudbric
MyScale Blog
MyScale Blog
阮一峰的网络日志
阮一峰的网络日志

敖苛记

甜甜圈的数学:donut.c 是如何工作的 | 敖苛记 如何让 AI Agent 工具帮助你清理 C 盘,让 C 盘不再报红? | 敖苛记 如何安装 Claude Code 并用 cc-switch 配置国内大模型 | 敖苛记 如何在 Windows 安装 Git | 敖苛记 如何安装 Windows 的包管理器 scoop 并配置国内镜像 | 敖苛记 给 Deepseek 发 <think> 之后,它就串台了? | 敖苛记 敖苛记 敖苛记 如何使用 ollama 和 open-webui 搭建自己的本地 AI 助手 | 敖苛记 如何使用 archinstall 安装 Arch Linux | 敖苛记 如何使用 Ventoy 制作一个便捷的 Arch Linux to go | 敖苛记
如何处理 PowerShell 中文乱码问题 | 敖苛记
敖苛, i@kayro.cn · 2026-05-11 · via 敖苛记

设置一些命令默认使用UTF-8编码,解决 PowerShell 中的中文乱码问题,保证读写文件正确。

一次让ai写代码时
AI

除了这个文件有一些乱码行,没其他问题了

一些乱码行?没有呀?

AI

可能是编码问题

AI 修不好,我上网去搜

如果你在使用 PowerShell 时遇到了中文乱码问题,或者你的 Agent 工具不可以正常使用 PowerShell 读写中文文件,你可以尝试一下方法。

PS>

notepad $PROFILE

这将打开 PowerShell 的配置文件。如果文件不存在,Notepad 会提示你创建一个新的文件。

在打开的文件中,添加以下内容:

Microsoft.PowerShell_profile.ps1ps1
[Console]::InputEncoding = [System.Text.Encoding]::UTF8
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
$OutputEncoding = [System.Text.Encoding]::UTF8
$PSDefaultParameterValues['Get-Content:Encoding'] = 'UTF8'
$PSDefaultParameterValues['Set-Content:Encoding'] = 'UTF8'
$PSDefaultParameterValues['Add-Content:Encoding'] = 'UTF8'
$PSDefaultParameterValues['Out-File:Encoding'] = 'UTF8'
$PSDefaultParameterValues['Export-Csv:Encoding'] = 'UTF8'

title

代码说明

default

  • 设置 PowerShell 的输入编码为 UTF-8,这样 PowerShell 就可以正确地读取中文输入。
  • 设置 PowerShell 的输出编码为 UTF-8,这样 PowerShell 就可以正确地显示中文输出。
  • 设置 PowerShell 的默认输出编码为 UTF-8,这样 PowerShell 在输出到文件或管道时也会使用 UTF-8 编码。
  • 设置 Get-Content 命令的默认编码为 UTF-8,这样在使用 Get-Content 读取文件时会默认使用 UTF-8 编码。
  • 设置 Set-Content 命令的默认编码为 UTF-8,这样在使用 Set-Content 写入文件时会默认使用 UTF-8 编码。
  • 设置 Add-Content 命令的默认编码为 UTF-8,这样在使用 Add-Content 追加内容到文件时会默认使用 UTF-8 编码。
  • 设置 Out-File 命令的默认编码为 UTF-8,这样在使用 Out-File 输出到文件时会默认使用 UTF-8 编码。
  • 设置 Export-Csv 命令的默认编码为 UTF-8,这样在使用 Export-Csv 导出 CSV 文件时会默认使用 UTF-8 编码。

重启 PowerShell

保存文件后,关闭并重新打开 PowerShell。现在,你应该能够正确地处理中文输入和输出了。