MCPcopy
hub / github.com/Xyntax/POC-T / stdoutencode

Function stdoutencode

lib/core/convert.py:16–42  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

14
15
16def stdoutencode(data):
17 retVal = None
18
19 try:
20 data = data or ""
21
22 # Reference: http://bugs.python.org/issue1602
23 if IS_WIN:
24 output = data.encode(sys.stdout.encoding, "replace")
25
26 if '?' in output and '?' not in data:
27 warnMsg = "cannot properly display Unicode characters "
28 warnMsg += "inside Windows OS command prompt "
29 warnMsg += "(http://bugs.python.org/issue1602). All "
30 warnMsg += "unhandled occurances will result in "
31 warnMsg += "replacement with '?' character. Please, find "
32 warnMsg += "proper character representation inside "
33 warnMsg += "corresponding output files. "
34 singleTimeWarnMessage(warnMsg)
35
36 retVal = output
37 else:
38 retVal = data.encode(sys.stdout.encoding)
39 except Exception:
40 retVal = data.encode(UNICODE_ENCODING) if isinstance(data, unicode) else data
41
42 return retVal

Callers 2

emitMethod · 0.90
dataToStdoutFunction · 0.90

Calls 1

singleTimeWarnMessageFunction · 0.85

Tested by

no test coverage detected