Return the default standard input encoding. If sys.stdin has no encoding, 'ascii' is returned.
()
| 262 | |
| 263 | |
| 264 | def get_input_encoding(): |
| 265 | """Return the default standard input encoding. |
| 266 | |
| 267 | If sys.stdin has no encoding, 'ascii' is returned.""" |
| 268 | # There are strange environments for which sys.stdin.encoding is None. We |
| 269 | # ensure that a valid encoding is returned. |
| 270 | encoding = getattr(sys.stdin, 'encoding', None) |
| 271 | if encoding is None: |
| 272 | encoding = 'ascii' |
| 273 | return encoding |
| 274 | |
| 275 | #----------------------------------------------------------------------------- |
| 276 | # Classes and functions for normal Python syntax handling |