1.1 --- a/lib/__builtins__/unicode.py Wed Dec 14 00:00:21 2016 +0100
1.2 +++ b/lib/__builtins__/unicode.py Wed Dec 14 00:03:08 2016 +0100
1.3 @@ -21,7 +21,7 @@
1.4
1.5 from __builtins__.str import basestring
1.6 from posix.iconv import Converter
1.7 -from native import str_add, isinstance as _isinstance
1.8 +from native import str_add, unicode_len, isinstance as _isinstance
1.9
1.10 class utf8string(basestring):
1.11
1.12 @@ -36,6 +36,7 @@
1.13
1.14 get_using(basestring.__init__, self)(other)
1.15 self.encoding = encoding
1.16 + self.length = None
1.17
1.18 def _binary_op(self, op, other):
1.19
1.20 @@ -100,6 +101,15 @@
1.21
1.22 return self._convert(self._binary_op_rev(str_add, other), other)
1.23
1.24 + def __len__(self):
1.25 +
1.26 + "Return the length of this string in characters."
1.27 +
1.28 + if self.length is None:
1.29 + self.length = unicode_len(self.__data__)
1.30 +
1.31 + return self.length
1.32 +
1.33 def encode(self, encoding=None):
1.34
1.35 """