R
R
rootik112020-07-16 16:18:07
Python
rootik11, 2020-07-16 16:18:07

How to decode a string into Russian text?

I categorically welcome, colleagues.
There is a server:

while True:
  cmd = input('#> ')
  conn.send(cmd.encode())

  cmd_process = conn.recv(5000)
  cmd_process = str(cmd_process)
  print(cmd_process)

Customer:
while True:
  cmd = s.recv(1024)
  cmd = cmd.decode()
  #cmd_process = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
  cmd_process = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 
  cmd_process = cmd_process.stdout + cmd_process.stderr
  s.send(cmd_process)

The output of the first command, for example "mac", the terminal displays an error , as it should be, because such a command does not exist:
b'"mac" \xad\xa5 \xef\xa2\xab\xef\xa5\xe2\xe1\xef \xa2\xad\xe3\xe2\xe0\xa5\xad\xad\xa5\xa9 \xa8\xab\xa8 \xa2\xad\xa5\xe8\xad\xa5\xa9\r\n\xaa\xae\xac\xa0\xad\xa4\xae\xa9, \xa8\xe1\xaf\xae\xab\xad\xef\xa5\xac\xae\xa9 \xaf\xe0\xae\xa3\xe0\xa0\xac\xac\xae\xa9 \xa8\xab\xa8 \xaf\xa0\xaa\xa5\xe2\xad\xeb\xac \xe4\xa0\xa9\xab\xae\xac.\r\n'

How can I make a normal, readable output with the help of tools or libraries?
Tried a lot of solutions - nothing helped.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Kuts, 2020-07-16
@rootik11

>>> print(b'"mac" \xad\xa5 \xef\xa2\xab\xef\xa5\xe2\xe1\xef \xa2\xad\xe3\xe2\xe0\xa5\xad\xad\xa5\xa9 \xa8\xab\xa8 \xa2\xad\xa5\xe8\xad\xa5\xa9\r\n\xaa\xae\xac\xa0\xad\xa4\xae\xa9, \xa8\xe1\xaf\xae\xab\xad\xef\xa5\xac\xae\xa9 \xaf\xe0\xae\xa3\xe0\xa0\xac\xac\xae\xa9 \xa8\xab\xa8 \xaf\xa0\xaa\xa5\xe2\xad\xeb\xac \xe4\xa0\xa9\xab\xae\xac.\r\n'.decode('cp866'))

"mac" не является внутренней или внешней
командой, исполняемой программой или пакетным файлом.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question