Skip to content

Commit 5be154b

Browse files
committed
Fixes diplaying of non-ASCII chars on Windows OS
1 parent 112356a commit 5be154b

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

lib/core/convert.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,14 @@ def stdoutEncode(value):
637637

638638
kb.codePage = kb.codePage or ""
639639

640-
encoding = kb.get("codePage") or getattr(sys.stdout, "encoding", None) or UNICODE_ENCODING
640+
# Python 3.6+ writes to the Windows console via WriteConsoleW (PEP 528), so sys.stdout.encoding
641+
# (typically 'utf-8') renders Unicode that the legacy OEM/ANSI code page from 'chcp' would replace
642+
# with '?'; prefer it there. The chcp-derived code page stays as the fallback (older interpreters,
643+
# PYTHONLEGACYWINDOWSSTDIO, or a console encoding Python could not determine) and for Python 2.
644+
if six.PY3:
645+
encoding = getattr(sys.stdout, "encoding", None) or kb.get("codePage") or UNICODE_ENCODING
646+
else:
647+
encoding = kb.get("codePage") or getattr(sys.stdout, "encoding", None) or UNICODE_ENCODING
641648

642649
if six.PY3:
643650
if isinstance(value, (bytes, bytearray)):

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from thirdparty import six
2121

2222
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
23-
VERSION = "1.10.7.251"
23+
VERSION = "1.10.7.252"
2424
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2525
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2626
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

0 commit comments

Comments
 (0)