summaryrefslogtreecommitdiff
path: root/pygments/cmdline.py
diff options
context:
space:
mode:
Diffstat (limited to 'pygments/cmdline.py')
-rw-r--r--pygments/cmdline.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/pygments/cmdline.py b/pygments/cmdline.py
index 0801eab0..5d0ba922 100644
--- a/pygments/cmdline.py
+++ b/pygments/cmdline.py
@@ -333,6 +333,18 @@ def main(args):
return 2
code = sys.stdin.read()
+ # No encoding given? Use latin1 if output file given,
+ # stdin/stdout encoding otherwise.
+ # (This is a compromise, I'm not too happy with it...)
+ if 'encoding' not in O_opts and 'outencoding' not in O_opts:
+ if outfn:
+ # encoding pass-through
+ fmter.encoding = 'latin1'
+ else:
+ # use terminal encoding
+ lexer.encoding = sys.stdin.encoding
+ fmter.encoding = sys.stdout.encoding
+
# ... and do it!
try:
# process filters