(data)
| 14 | |
| 15 | |
| 16 | def 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 |
no test coverage detected