diff options
author | Doug Hellmann <doug.hellmann@gmail.com> | 2013-08-14 08:13:12 -0700 |
---|---|---|
committer | Doug Hellmann <doug.hellmann@gmail.com> | 2013-08-14 08:13:12 -0700 |
commit | aed63e03e94d3edffec5f9e43a948b72d719be2d (patch) | |
tree | b2147abb5f79c5b0bdaabfb2d07c41c6b6004f29 /demoapp/cliffdemo | |
parent | f46c867f3b700fe51b82b00c0cad44722480f0bf (diff) | |
parent | 852a729fbb9601f18454b7329480dc367ce9d2b4 (diff) | |
download | cliff-aed63e03e94d3edffec5f9e43a948b72d719be2d.tar.gz |
Merge pull request #40 from dhellmann/bug/handle-encoding
Fix default encoding issue with python 2.6
Diffstat (limited to 'demoapp/cliffdemo')
-rw-r--r-- | demoapp/cliffdemo/encoding.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/demoapp/cliffdemo/encoding.py b/demoapp/cliffdemo/encoding.py new file mode 100644 index 0000000..6c6c751 --- /dev/null +++ b/demoapp/cliffdemo/encoding.py @@ -0,0 +1,23 @@ +# -*- encoding: utf-8 -*- + +import logging + +from cliff.lister import Lister + + +class Encoding(Lister): + """Show some unicode text + """ + + log = logging.getLogger(__name__) + + def take_action(self, parsed_args): + messages = [ + u'pi: π', + u'GB18030:鼀丅㐀ٸཌྷᠧꌢ€', + ] + return ( + ('UTF-8', 'Unicode'), + [(repr(t.encode('utf-8')), t) + for t in messages], + ) |