def unicode_title__Unicode(space, w_self): input = w_self._value if len(input) == 0: return w_self builder = UnicodeBuilder(len(input)) previous_is_cased = False for i in range(len(input)): unichar = ord(input[i]) if previous_is_cased: builder.append(unichr(unicodedb.tolower(unichar))) else: builder.append(unichr(unicodedb.totitle(unichar))) previous_is_cased = unicodedb.iscased(unichar) return W_UnicodeObject(builder.build())
def unicode_title__Unicode(space, w_self): input = w_self._value if len(input) == 0: return w_self result = [u'\0'] * len(input) previous_is_cased = False for i in range(len(input)): unichar = ord(input[i]) if previous_is_cased: result[i] = unichr(unicodedb.tolower(unichar)) else: result[i] = unichr(unicodedb.totitle(unichar)) previous_is_cased = unicodedb.iscased(unichar) return W_UnicodeObject(u''.join(result))
def unicode_title__RopeUnicode(space, w_self): input = w_self._node length = input.length() if length == 0: return w_self result = [u'\0'] * length iter = rope.ItemIterator(input) previous_is_cased = False for i in range(input.length()): unichar = iter.nextint() if previous_is_cased: result[i] = unichr(unicodedb.tolower(unichar)) else: result[i] = unichr(unicodedb.totitle(unichar)) previous_is_cased = unicodedb.iscased(unichar) return W_RopeUnicodeObject(rope.rope_from_unicharlist(result))
def Py_UNICODE_TOTITLE(space, ch): """Return the character ch converted to title case.""" return unichr(unicodedb.totitle(ord(ch)))
def _title(self, ch): return unichr(unicodedb.totitle(ord(ch)))