记录一下Windows解决codex中文乱码&Windows安装PowerShell7

2026-04-13 12:371阅读0评论SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐
问题描述:

最近电脑重装了win11系统,忘记了codex还有中文乱码问题,之前使用的方案是修改系统设置,改编码为utf-8。这个方案一直认为不太好,正好这次改成PowerShell7。顺便记录一下,方便下次配置。

  1. 安装PowerShell7

winget install --id Microsoft.PowerShell -e

验证:

pwsh -v


  1. 设置utf-8编码

打开PowerShell 7,执行:

notepad $PROFILE

如果提示不存在:

New-Item -Type File -Path $PROFILE -Force notepad $PROFILE

在文件中写入以下内容:

$OutputEncoding = [Console]::InputEncoding = [Console]::OutputEncoding = New-Object System.Text.UTF8Encoding $PSDefaultParameterValues['*:Encoding'] = 'UTF8'

保存后重启

一个小疑问 :
image845×693 49.4 KB


  1. 设置Codex使用PS7

– cli中直接使用PS7即可。
– vscode中Ctrl + Shift + P 搜索 Open User Settings (JSON)
添加配置:

{ "terminal.integrated.defaultProfile.windows": "PowerShell", "terminal.integrated.profiles.windows": { "PowerShell": { "source": "PowerShell", "icon": "terminal-powershell" } } }

验证codex使用的是不是PS7:
让codex执行:

$PSVersionTable.PSVersion

[Console]::OutputEncoding

image700×723 24.3 KB


  1. 设置终端(Windows Terminal)默认PS7

打开终端,设置,先看下拉选项是否有刚安装的PS7:

image849×375 20.7 KB

我刚开始是没有的,在左下角的打开JSON文件中打开配置文件list中加入下面配置,替换用户名:

{ "name": "PowerShell 7", "commandline": "C:\\Users\\用户名\\AppData\\Local\\Microsoft\\WindowsApps\\pwsh.exe", "icon": "ms-appx:///ProfileIcons/pwsh.png", "startingDirectory": "%USERPROFILE%" }

保存后,电脑自己也识别到了安装的,于是有了两个,又把加上的删掉了。

网友解答:
--【壹】--:

最近电脑重装了win11系统,忘记了codex还有中文乱码问题,之前使用的方案是修改系统设置,改编码为utf-8。这个方案一直认为不太好,正好这次改成PowerShell7。顺便记录一下,方便下次配置。

  1. 安装PowerShell7

winget install --id Microsoft.PowerShell -e

验证:

pwsh -v


  1. 设置utf-8编码

打开PowerShell 7,执行:

notepad $PROFILE

如果提示不存在:

New-Item -Type File -Path $PROFILE -Force notepad $PROFILE

在文件中写入以下内容:

$OutputEncoding = [Console]::InputEncoding = [Console]::OutputEncoding = New-Object System.Text.UTF8Encoding $PSDefaultParameterValues['*:Encoding'] = 'UTF8'

保存后重启

一个小疑问 :
image845×693 49.4 KB


  1. 设置Codex使用PS7

– cli中直接使用PS7即可。
– vscode中Ctrl + Shift + P 搜索 Open User Settings (JSON)
添加配置:

{ "terminal.integrated.defaultProfile.windows": "PowerShell", "terminal.integrated.profiles.windows": { "PowerShell": { "source": "PowerShell", "icon": "terminal-powershell" } } }

验证codex使用的是不是PS7:
让codex执行:

$PSVersionTable.PSVersion

[Console]::OutputEncoding

image700×723 24.3 KB


  1. 设置终端(Windows Terminal)默认PS7

打开终端,设置,先看下拉选项是否有刚安装的PS7:

image849×375 20.7 KB

我刚开始是没有的,在左下角的打开JSON文件中打开配置文件list中加入下面配置,替换用户名:

{ "name": "PowerShell 7", "commandline": "C:\\Users\\用户名\\AppData\\Local\\Microsoft\\WindowsApps\\pwsh.exe", "icon": "ms-appx:///ProfileIcons/pwsh.png", "startingDirectory": "%USERPROFILE%" }

保存后,电脑自己也识别到了安装的,于是有了两个,又把加上的删掉了。

问题描述:

最近电脑重装了win11系统,忘记了codex还有中文乱码问题,之前使用的方案是修改系统设置,改编码为utf-8。这个方案一直认为不太好,正好这次改成PowerShell7。顺便记录一下,方便下次配置。

  1. 安装PowerShell7

winget install --id Microsoft.PowerShell -e

验证:

pwsh -v


  1. 设置utf-8编码

打开PowerShell 7,执行:

notepad $PROFILE

如果提示不存在:

New-Item -Type File -Path $PROFILE -Force notepad $PROFILE

在文件中写入以下内容:

$OutputEncoding = [Console]::InputEncoding = [Console]::OutputEncoding = New-Object System.Text.UTF8Encoding $PSDefaultParameterValues['*:Encoding'] = 'UTF8'

保存后重启

一个小疑问 :
image845×693 49.4 KB


  1. 设置Codex使用PS7

– cli中直接使用PS7即可。
– vscode中Ctrl + Shift + P 搜索 Open User Settings (JSON)
添加配置:

{ "terminal.integrated.defaultProfile.windows": "PowerShell", "terminal.integrated.profiles.windows": { "PowerShell": { "source": "PowerShell", "icon": "terminal-powershell" } } }

验证codex使用的是不是PS7:
让codex执行:

$PSVersionTable.PSVersion

[Console]::OutputEncoding

image700×723 24.3 KB


  1. 设置终端(Windows Terminal)默认PS7

打开终端,设置,先看下拉选项是否有刚安装的PS7:

image849×375 20.7 KB

我刚开始是没有的,在左下角的打开JSON文件中打开配置文件list中加入下面配置,替换用户名:

{ "name": "PowerShell 7", "commandline": "C:\\Users\\用户名\\AppData\\Local\\Microsoft\\WindowsApps\\pwsh.exe", "icon": "ms-appx:///ProfileIcons/pwsh.png", "startingDirectory": "%USERPROFILE%" }

保存后,电脑自己也识别到了安装的,于是有了两个,又把加上的删掉了。

网友解答:
--【壹】--:

最近电脑重装了win11系统,忘记了codex还有中文乱码问题,之前使用的方案是修改系统设置,改编码为utf-8。这个方案一直认为不太好,正好这次改成PowerShell7。顺便记录一下,方便下次配置。

  1. 安装PowerShell7

winget install --id Microsoft.PowerShell -e

验证:

pwsh -v


  1. 设置utf-8编码

打开PowerShell 7,执行:

notepad $PROFILE

如果提示不存在:

New-Item -Type File -Path $PROFILE -Force notepad $PROFILE

在文件中写入以下内容:

$OutputEncoding = [Console]::InputEncoding = [Console]::OutputEncoding = New-Object System.Text.UTF8Encoding $PSDefaultParameterValues['*:Encoding'] = 'UTF8'

保存后重启

一个小疑问 :
image845×693 49.4 KB


  1. 设置Codex使用PS7

– cli中直接使用PS7即可。
– vscode中Ctrl + Shift + P 搜索 Open User Settings (JSON)
添加配置:

{ "terminal.integrated.defaultProfile.windows": "PowerShell", "terminal.integrated.profiles.windows": { "PowerShell": { "source": "PowerShell", "icon": "terminal-powershell" } } }

验证codex使用的是不是PS7:
让codex执行:

$PSVersionTable.PSVersion

[Console]::OutputEncoding

image700×723 24.3 KB


  1. 设置终端(Windows Terminal)默认PS7

打开终端,设置,先看下拉选项是否有刚安装的PS7:

image849×375 20.7 KB

我刚开始是没有的,在左下角的打开JSON文件中打开配置文件list中加入下面配置,替换用户名:

{ "name": "PowerShell 7", "commandline": "C:\\Users\\用户名\\AppData\\Local\\Microsoft\\WindowsApps\\pwsh.exe", "icon": "ms-appx:///ProfileIcons/pwsh.png", "startingDirectory": "%USERPROFILE%" }

保存后,电脑自己也识别到了安装的,于是有了两个,又把加上的删掉了。