diff options
Diffstat (limited to 'pygments/formatter.py')
-rw-r--r-- | pygments/formatter.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/pygments/formatter.py b/pygments/formatter.py index a577a4e3..d6c75a01 100644 --- a/pygments/formatter.py +++ b/pygments/formatter.py @@ -9,6 +9,8 @@ :license: BSD, see LICENSE for details. """ +import codecs + from pygments.util import get_bool_opt from pygments.styles import get_style_by_name @@ -84,4 +86,7 @@ class Formatter(object): Format ``tokensource``, an iterable of ``(tokentype, tokenstring)`` tuples and write it into ``outfile``. """ - raise NotImplementedError() + if self.encoding: + # wrap the outfile in a StreamWriter + outfile = codecs.lookup(self.encoding)[3](outfile) + return self.format_unencoded(tokensource, outfile) |