question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to encode the output with cp1252 encoding. Unsupported characters are discarded.

See original GitHub issue

Describe 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.

image

To Reproduce

  1. login to azure using az login in a powershell console
  2. 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:closed
  • Created 3 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
kwill-MSFTcommented, Aug 7, 2020

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

0reactions
jiaslicommented, Apr 19, 2021

@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:

image

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to encode the output with cp1252 encoding ...
Unsupported characters are discarded." We have a release pipeline which invoke a powershell script task to call a file (.
Read more >
The problem with Cp1252 encoding in my python code
First of all, I thought, that I had used wrong terminal encoding, then I typed locale in my terminal, and got the following...
Read more >
Understanding file encoding in VS Code and PowerShell
The problem occurs when assuming the encoding of BOM-less formats (like UTF-8 with no BOM and Windows-1252). The PowerShell extension defaults ...
Read more >
Some characters cannot be mapped using "Cp1252 ... - Drupal
However, when I tried to save the file, I got the error "Some characters cannot be mapped using "Cp1252" character encoding" (see ...
Read more >
iconv: Convert Character Vector between Encodings - Rdrr.io
A character string describing the current encoding. ... and the same attributes as x whose elements are either NULL (if conversion fails) or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found