英文:
How to fix codepage in nuget package manager console?
问题
When I'm executing dotnet command in the nuget package manager, the output displayed in ANSI codepage instead of UTF8.
Where can I find Visual Studio settings to change the characters encoding in that console?
PM> [System.Console]::OutputEncoding
IsSingleByte : True
BodyName : koi8-r
EncodingName : Кириллица (Windows)
HeaderName : windows-1251
WebName : windows-1251
WindowsCodePage : 1251
IsBrowserDisplay : True
IsBrowserSave : True
IsMailNewsDisplay : True
IsMailNewsSave : True
EncoderFallback : System.Text.InternalEncoderBestFitFallback
DecoderFallback : System.Text.InternalDecoderBestFitFallback
IsReadOnly : True
CodePage : 1251
PM> dotnet tool install -g try-convert
dotnet : Рнструмент "try-convert" уже установлен.
строка:1 знак:1
+ dotnet tool install -g try-convert
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (РнструмР...ановлен.:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
PM> dotnet tool update -g try-convert
Рнструмент "try-convert" был переустановлен СЃ последней стабильной версией (версией "0.9.232202").
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/bUxNd.png
The issue is present in Visual Studio 2019 and 2022, fully updated.
OS: Windows 10 with Russian locale.
The only working solution I found was to set "UTF8 experimental feature" in the system locale settings. However, this feature broke some apps for me (like highlighting based on filenames in file manager).
<details>
<summary>英文:</summary>
When I'm executing dotnet command in the nuget package manager, the output displayed in ANSI codepage instead of UTF8.
Where can I find Visual Studio settings to change the characters encoding in that console?
PM> [System.Console]::OutputEncoding
IsSingleByte : True
BodyName : koi8-r
EncodingName : Кириллица (Windows)
HeaderName : windows-1251
WebName : windows-1251
WindowsCodePage : 1251
IsBrowserDisplay : True
IsBrowserSave : True
IsMailNewsDisplay : True
IsMailNewsSave : True
EncoderFallback : System.Text.InternalEncoderBestFitFallback
DecoderFallback : System.Text.InternalDecoderBestFitFallback
IsReadOnly : True
CodePage : 1251
PM> dotnet tool install -g try-convert
dotnet : Рнструмент "try-convert" уже установлен.
строка:1 знак:1
- dotnet tool install -g try-convert
-
+ CategoryInfo : NotSpecified: (РнструмР...ановлен.:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError
PM> dotnet tool update -g try-convert
Рнструмент "try-convert" был переустановлен СЃ последней стабильной версией (версией "0.9.232202").
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/bUxNd.png
The issue is present in Visual Studio 2019 and 2022, fully updated.
OS: Windows 10 with Russian locale.
The only working solution I found was to set "UTF8 experimental feature" in the system locale settings. However, this feature broke some apps for me (like highlighting based on filenames in file manager).
</details>
# 答案1
**得分**: 1
# Update:
我认为我知道你想要什么,你想要包管理器控制台输出俄语,但不影响整个VS工具,对吗?
运行以下命令:
$null = cmd /c ''
$Global:OutputEncoding = [Console]::InputEncoding = [Console]::OutputEncoding = [System.Text.UTF8Encoding]::new()
然后查看结果:
[![点击查看图片描述][1]][1]
你可以看到,在我的端口,包管理器控制台成功输出了俄语。
顺便说一下,如果你想要在VS工具的语言为俄语时默认在包管理器控制台中输出俄语,你可以在这里报告:
https://developercommunity.visualstudio.com/VisualStudio/suggest
# 原始回答:
我能够复现你的问题:
[![点击查看图片描述][2]][2]
对于这个问题,只需在此处更改设置应该就可以了:
[![点击查看图片描述][3]][3]
[![点击查看图片描述][4]][4]
完成以上步骤后,重新启动VS。然后VS将能够在包管理器控制台中接受UTF8编码。
[1]: https://i.stack.imgur.com/pjTTZ.png
[2]: https://i.stack.imgur.com/rxumy.png
[3]: https://i.stack.imgur.com/OWAzd.png
[4]: https://i.stack.imgur.com/jHW4a.png
<details>
<summary>英文:</summary>
# Update:
I think I know what you want, you want the package manager console output Russian but don't effect whole VS Tool, right?
run the below command:
`$null = cmd /c ''`
`$Global:OutputEncoding = [Console]::InputEncoding = [Console]::OutputEncoding = [System.Text.UTF8Encoding]::new()`
And see the result:
[![enter image description here][1]][1]
You can see that the PM console output Russian on my side successfully.
By the way, if you want VS output Russian by default in PM console when the language of VS Tool is Russian, you can report it here:
https://developercommunity.visualstudio.com/VisualStudio/suggest
# Original Answer:
I am able to reproduce your issue:
[![enter image description here][2]][2]
For this issue, just change the settings in this place should be ok:
[![enter image description here][3]][3]
[![enter image description here][4]][4]
After the above steps, restart the VS. Then the VS will be able to take utf8 in package manager console.
[1]: https://i.stack.imgur.com/pjTTZ.png
[2]: https://i.stack.imgur.com/rxumy.png
[3]: https://i.stack.imgur.com/OWAzd.png
[4]: https://i.stack.imgur.com/jHW4a.png
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论