diff --git a/clint/textui/colored.py b/clint/textui/colored.py index 10c8931..6b40942 100644 --- a/clint/textui/colored.py +++ b/clint/textui/colored.py @@ -61,7 +61,10 @@ class ColoredString(object): return "<%s-string: '%s'>" % (self.color, self.s) def __unicode__(self): - return self.color_str + value = self.color_str + if isinstance(value, basestring): + return ('%s' % value).decode('utf8') + return value if PY3: __str__ = __unicode__ diff --git a/examples/unicode.py b/examples/unicode.py new file mode 100644 index 0000000..3df92fc --- /dev/null +++ b/examples/unicode.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import os +import sys +sys.path.insert(0, os.path.abspath('..')) + +from clint import args +from clint.textui import colored, puts, indent + +if __name__ == '__main__': + + puts('Test:') + with indent(4): + puts('%s Fake test 1.' % colored.green('✔')) + puts('%s Fake test 2.' % colored.red('✖')) + + puts('') + puts('Greet:') + with indent(4): + puts(colored.red('Здравствуйте')) + puts(colored.green('你好。')) + puts(colored.yellow('سلام')) + puts(colored.magenta('안녕하세요')) + puts(colored.blue('नमस्ते')) + puts(colored.cyan('γειά σου')) + + puts('') + puts('Arguments:') + with indent(4): + for arg in args.all: + puts('%s' % colored.red(arg)) diff --git a/examples/unicode.sh b/examples/unicode.sh new file mode 100755 index 0000000..47a95e9 --- /dev/null +++ b/examples/unicode.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +python unicode.py こんにちは。