D
D
Dima Kl2017-05-26 12:06:26
Python
Dima Kl, 2017-05-26 12:06:26

The script receives data from the console in ascii encoding, how to fix it?

Good day.
There is a pyhton script, more precisely hook (post-commit).
In it, we receive data from the terminal, parse and send further.
The problem is that if you run the script manually, then the data encoding in the s utf-8 variable, and if the script is launched by svn, then the data encoding in the s ascii variable.
Please tell me where to dig all sorts of decode, encode tried nothing changes.
Script snippet:

#!/usr/bin/env python3.5
# coding: utf-8
import subprocess
...
s = subprocess.check_output(['svn', 'log', '-r', 'HEAD', '/reps_folder/rep/rep'])
s = str(s, 'utf-8')  #и дальше работаю с переменной как с обычной строкой

...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dima Kl, 2017-05-26
@Listo4eg

uh... if anyone has a similar situation, then... I do
n't know why, but s = subprocess.check_output(['svn', 'log', '-r', 'HEAD', '/reps_folder/rep/rep ']) this line when called "automatically" returns the text in ascii encoding, BUT if we return in xml format, i.e. s = subprocess.check_output(['svn', 'log', '--xml', '-r', 'HEAD', '/reps_folder/rep/rep']) then everything is fine with utf-8 encoding

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question