Fixed some unicode encoding mixups.
This commit is contained in:
parent
59f1ce5609
commit
9ebd2d76ce
1 changed files with 2 additions and 3 deletions
|
|
@ -358,12 +358,11 @@ class ANSIString(unicode):
|
||||||
string = args[0]
|
string = args[0]
|
||||||
if not isinstance(string, basestring):
|
if not isinstance(string, basestring):
|
||||||
string = str(string)
|
string = str(string)
|
||||||
args = args[1:]
|
|
||||||
parser = kwargs.get('parser', ANSI_PARSER)
|
parser = kwargs.get('parser', ANSI_PARSER)
|
||||||
decoded = kwargs.get('decoded', False) or hasattr(string, 'raw_string')
|
decoded = kwargs.get('decoded', False) or hasattr(string, 'raw_string')
|
||||||
if not decoded:
|
if not decoded:
|
||||||
string = parser.parse_ansi(string)
|
string = parser.parse_ansi(string)
|
||||||
return super(ANSIString, cls).__new__(ANSIString, string, *args)
|
return super(ANSIString, cls).__new__(ANSIString, string, 'utf-8')
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "ANSIString(%s, decoded=True)" % repr(self.raw_string)
|
return "ANSIString(%s, decoded=True)" % repr(self.raw_string)
|
||||||
|
|
@ -373,7 +372,7 @@ class ANSIString(unicode):
|
||||||
super(ANSIString, self).__init__(*args, **kwargs)
|
super(ANSIString, self).__init__(*args, **kwargs)
|
||||||
self.raw_string = unicode(self)
|
self.raw_string = unicode(self)
|
||||||
self.clean_string = unicode(self.parser.parse_ansi(
|
self.clean_string = unicode(self.parser.parse_ansi(
|
||||||
self.raw_string, strip_ansi=True))
|
self.raw_string, strip_ansi=True), 'utf-8')
|
||||||
self._code_indexes, self._char_indexes = self._get_indexes()
|
self._code_indexes, self._char_indexes = self._get_indexes()
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue