I have this function:
def decomposition():
"""
Вызов модуля oval_decomposition.py для разложения OVAL xml на
составные части - определения, объекты и т.д.
Для корректного сбора модулем build необходима следующая секция
внутри каждого <definition>:
<oval_repository>
<dates>
<submitted date="YYYY-MM-DDTHH:MM:SS.000+00:00">
<contributor organization="ORGANISATION">JOHN WICK</contributor>
</submitted>
</dates>
</oval_repository>
"""
oval_decomposition.main()
And this is what i get in Powershell, when i use help(decomposition):
JavaScript113131┬√чют ьюфєы oval_decomposition.py фы Ёрчыюцхэш OVAL xml эр
2ёюёЄртэ√х ўрёЄш - юяЁхфхыхэш , юс·хъЄ√ ш Є.ф.
3
4─ы ъюЁЁхъЄэюую ёсюЁр ьюфєыхь build эхюсїюфшьр ёыхфє■∙р ёхъЎш
5тэєЄЁш ърцфюую <definition>:
6<oval_repository>
7<dates>
8<submitted date="YYYY-MM-DDTHH:MM:SS.000+00:00">
9<contributor organization="ORGANISATION">JOHN WICK</contributor>
10</submitted>
11</dates>
12</oval_repository>
13
When i use Cyrillic alphabet in print it works. It also works normally in Linux when i add “# coding: utf-8” in the beginning of file. However, this does not help in Windows. I also tried this to change Powershell encoding:
PS C:UsersdenisDocumentsdevOVALRepo> "$OutputEncoding = [Console]::OutputEncoding = [Text.UTF8Encoding]::UTF8"
System.Text.UTF8Encoding = [Console]::OutputEncoding = [Text.UTF8Encoding]::UTF8
I can’t find methods to change help function encoding manually like we can do in print function.
Advertisement
Answer
Solved definitely after applying UTF-8 Everywhere rigorously in Windows.
Tried using different alphabet combination (Latin, Cyrillic and Greek scripts) as follows: type .testHelp.py
# -*- coding: utf-8 -*-
def foo():
"""
help in Czech, Greek, Russian
nápověda česky, řecky, rusky
βοήθεια στα Τσεχικά, Ελληνικά, Ρωσικά (¹)
помощь на чешском, греческом, русском языках (¹)
(¹) from Google Translate
"""
return ''
help(foo)
Result if run from pure cmd
or from PowerShell
(version 5.1) or from pwsh
(version 7):
python .testHelp.py
JavaScript191Help on function foo in module __main__:
2
3foo()
4help in Czech, Greek, Russian
5nápověda česky, řecky, rusky
6βοήθεια στα Τσεχικά, Ελληνικά, Ρωσικά (¹)
7помощь на чешском, греческом, русском языках (¹)
8(¹) from Google Translate
9
(or Copy&Paste
the above code in an open python
prompt).
Settings:
- Set Beta: Use Unicode UTF-8 for worldwide language support in Administrative language settings:
Addendum: You met a mojibake case; for instance, Вызов
(the 1st word in your example) is shown as ┬√чют
due to the following mojibake mechanism:
>>> 'Вызов'.encode('cp1251').decode('cp866') == '┬√чют'
True
>>> 'Вызов' == '┬√чют'.encode('cp866').decode('cp1251')
True