Can I force AWS CLI to use UTF encoding?

I am using git bash on windows 10 and set PYTHONIOENCODING=UTF-8 was not actually did env change. Used export PYTHONIOENCODING=UTF-8 then overcame the charmap error


Since you're using the command line interface, a change to the terminal's encoding scheme should fix the issue.

Type:

chcp 65001

in the console (for UTF-8; you may also try different encodings) and retry your operations.


I've reinstalled AWS CLI using upgraded MSI installers which now use Python 3 instead of Python 2 and the unknown encoding error is now gone.


Maybe it could help as well - the issue with translation from AWS and storing results to the file (or powershell variable): With error:

aws translate translate-text --text "Investigation" --source-language-code "auto" --target-language-code "PL" >> a.txt

'charmap' codec can't encode character '\u015a' in position 1: character maps to

Adding env. variable fixes the problem

set PYTHONIOENCODING=UTF-8

aws translate translate-text --text "Investigation" --source-language-code "auto" --target-language-code "PL" >> a.txt

The same in powershell:

PS C:\Users\???\Documents> $aws = aws translate translate-text --text "Request" --source-language-code "auto"--target-language-code "PL"

'charmap' codec can't encode character '\u015b' in position 4: character maps to <undefined>

    PS C:\Users\???\Documents> exit

    C:\Users\???\Documents>set PYTHONIOENCODING=UTF-8

    C:\Users\???\Documents>powershell
    Windows PowerShell
    Copyright (C) 2016 Microsoft Corporation. All rights reserved.

    PS C:\Users\???\Documents> $aws = aws translate translate-text --text "Request" --source-language-code "auto"
    --target-language-code "PL"

    PS C:\Users\???\Documents> $aws

    {
        "TranslatedText": "Prośba",
        "SourceLanguageCode": "en",
        "TargetLanguageCode": "pl"
    }