On 1 April 2018 at 04:15, Mikhail V <mikhail...@gmail.com> wrote: > MRAB writes: > > >> > UnicodeEncodeError: 'charmap' codec can't encode character >> > >> > when it meets a non-ascii char. >> > >> > e.g. tried this: >> > pip search pygame > a.txt >> > >> Well, _I_ didn't get an error! >> >> One of the lines is: >> >> kundalini (0.4) - LրVE-like PyGame API >> >> So it's down to what system encoding (active code page) is in use. > > Dunno, it gives me error regardless of active codepage, > my default is 866, i've set to 1252 or 65001, same error. > > The output itself is fine - I see correct glyphs, so the error > only appears when I redirect to file. > if I try some python script e.g. "a.py": > print ("абв") > > and run: > py a.py > a.txt > > I get some gibberish in the file. > So it is probably a global issue. Nothing works in this life :)
That actually sounds more like a redirection issue. Redirecting in the cmd shell uses the OEM codepage, I believe, and Python outputs to a pipe using the ANSI codepage, IIRC (I'd have to check to be certain). Paul -- https://mail.python.org/mailman/listinfo/python-list