Skip to content

fix: PowerShell not working with username having Unicode #251534

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

Merged
merged 1 commit into from
Jun 16, 2025

Conversation

liuxingbaoyu
Copy link
Contributor

Fixes #251478
On some computers, the default encoding of PowerShell is not utf8, which will cause the Unicode characters in the obtained environment variables to become garbled. Here we first set the encoding to utf8 to fix this issue.

@lszomoru
Copy link
Member

@Tyriar, could you please take a look at this fix? Thanks!

@Tyriar Tyriar added this to the June 2025 milestone Jun 16, 2025
@Tyriar Tyriar enabled auto-merge June 16, 2025 19:01
@Tyriar Tyriar merged commit 480485f into microsoft:main Jun 16, 2025
7 checks passed
@@ -139,7 +139,7 @@ async function doResolveShellEnv(logService: ILogService, token: CancellationTok
// Older versions of PowerShell removes double quotes sometimes
// so we use "double single quotes" which is how you escape single
// quotes inside of a single quoted string.
command = `Write-Output '${mark}'; [System.Environment]::GetEnvironmentVariables() | ConvertTo-Json -Compress; Write-Output '${mark}'`;
command = `chcp 65001; Write-Output '${mark}'; [System.Environment]::GetEnvironmentVariables() | ConvertTo-Json -Compress; Write-Output '${mark}'`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...wait does this run on macOS & Linux as well with PowerShell 7+? If so chcp is not available there and this will break.

Copy link
Contributor Author

@liuxingbaoyu liuxingbaoyu Jun 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I tested chcp and it doesn't work on linux.
I noticed @Tyriar already fixed it, thanks!

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

Successfully merging this pull request may close these issues.

VS Code has operational problems when you have an user folder with special characters.
4 participants