aws-cli icon indicating copy to clipboard operation
aws-cli copied to clipboard

'charmap' codec can't encode character (Windows 7)

Open JamesBromberger opened this issue 11 years ago • 5 comments

Platform: Windows 7 Entreprise SP1. installed from MSI.

C:>aws --profile lg-sec --region ap-southeast-2 cloudtrail create-trail help

'charmap' codec can't encode character u'\u2019' in position 1686: character maps to

C:>aws --version aws-cli/1.6.10 Python/2.7.5 Windows/7

JamesBromberger avatar Dec 22 '14 00:12 JamesBromberger

Looks like this is a known issue with windows/cmd/python, which goes pretty far back: http://bugs.python.org/issue1602

This is going to be difficult to solve, especially if some of the underlying issues stem from python. Perhaps the best interim solution would be to add a config option to escape the non-ascii unicode sequences, similar to what JSON can do, e.g. "foo\u2713bar". This will at least be better than crashing mid way through formatting the output.

jamesls avatar Dec 23 '14 20:12 jamesls

Although we don't have the --debug output to confirm, the symptom is most likely caused by some non-ascii character (in this case, it is the u'\u2019', single quote) can not be displayed on the current locale. For example, if your locale is using CP437 encoding, you will see the same symptom.

>>> u'\u2019'.encode('cp437')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/rayluo/py27/lib/python2.7/encodings/cp437.py", line 12, in encode
    return codecs.charmap_encode(input,errors,encoding_map)
UnicodeEncodeError: 'charmap' codec can't encode character u'\u2019' in position 0: character maps to <undefined>

We haven't implemented the interim solution yet. But I believe the symptom has gone for a while, because the problematic single quote in our service model at that time has long been changed to normal single quote already. I think we can close this issue for now.

rayluo avatar Nov 02 '15 13:11 rayluo

Using s3 for backups, I am powerless to the encoding of the file names. This is frustrating.

gpickin avatar Dec 29 '15 05:12 gpickin

Yes, what's the status on this - I can't control the files names and am running into this as well

marchello2000 avatar Jan 06 '16 03:01 marchello2000

+status

adamfortuno avatar Jul 01 '19 02:07 adamfortuno