Unable to encode the output with cp1252 encoding. Unsupported characters are discarded.
See original GitHub issueDescribe the bug
I don’t know if this is specific to the command that I am about to reference, but whenever I run the command
az ad sp list --all
in a powershell console, the console window will return the message “Unable to encode the output with cp1252 encoding. Unsupported characters are discarded” to the console before processing the command. To be more specific, the message does NOT appear if I run the command as displayed about and just output the result to the console. The error occurs when I attempt to integrate it with powershell in some way. For example, the error will display if I attempt to assign the output to a variable:
$output = az ad sp list --all
Another example is if I attempt to pipe the output from the command to the “Convertfrom-Json” cmdlet (since the output is a json string):
az ad sp list --all | Convertfrom-json
Just so that we are 100% clear here, it does not appear that the command is failing in its entirety. It does return output when I run the above two commands, but, as the error itself states, I don’t know if what I am seeing is the entire return. And if it is, then the error message shouldn’t give that impression by being displayed in the first place.
To Reproduce
- login to azure using az login in a powershell console
- Run either of these commands
$output = az ad sp list --all
az ad sp list --all | Convertfrom-json
Expected behavior The azure cli should not be returning an error indicating that certain characters might have been dropped from the results of a command just because it was run in a powershell console. And if no characters were dropped, then the azure cli should not display the error in the first place.
Environment summary Running on a windows 10 pro computer and installed using the msi installer downloaded from Microsoft’s website
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (4 by maintainers)
Top GitHub Comments
Workaround until issue is fixed (https://github.com/microsoft/knack/pull/178): Control Panel > Region > Administrative > Change system local -> Check the ‘Beta: Use Unicode UTF-8 for worldwide language support’ option
@cgtheflash glad to know it works for you. Using non-ASCII (Unicode) hyphen-minus
-
(002D
) is definitely a problem for downstream tools running on systems with no UTC-8 support.It seems you are using Visual Studio subscriptions offered to partners in the Microsoft Partner Network (MPN). I don’t have MPN subscription so can’t repro this issue or provide further information about my subscription.
Could you open the above link and click Feedback -> This product to open the Visual Studio feedback website:
Then report a problem following How to report a problem for Visual Studio and Visual Studio Installer.
Then you may paste the link here. I will follow up with this issue and provide available information from Azure CLI side. Thanks for your help.