
This change addresses issue #38: "fix unicode handling issues". The issue was originally reported against neutron client (https://bugs.launchpad.net/python-neutronclient/+bug/1189112) but was tracked down to the fact that python 2.6 does not set the default encoding for sys.stdout properly. A change to python 2.7 fixes the problem there and later (http://hg.python.org/cpython/rev/e60ef17561dc/), but since cliff supports python 2.6 it needs to handle the case explicitly. Change-Id: Id06507d78c7c82b25f39366ea4a6dfa4ef3a3a97
24 lines
457 B
Python
24 lines
457 B
Python
# -*- 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],
|
|
)
|