def _swapcase(ordch): if unicodedb.islower(ordch): return unichr(unicodedb.toupper(ordch)) elif unicodedb.isupper(ordch): return unichr(unicodedb.tolower(ordch)) else: return unichr(ordch)
def unicode_capitalize__Unicode(space, w_self): input = w_self._value if len(input) == 0: return W_UnicodeObject.EMPTY builder = UnicodeBuilder(len(input)) builder.append(unichr(unicodedb.toupper(ord(input[0])))) for i in range(1, len(input)): builder.append(unichr(unicodedb.tolower(ord(input[i])))) return W_UnicodeObject(builder.build())
def unicode_capitalize__Unicode(space, w_self): input = w_self._value if len(input) == 0: return W_UnicodeObject.EMPTY result = [u'\0'] * len(input) result[0] = unichr(unicodedb.toupper(ord(input[0]))) for i in range(1, len(input)): result[i] = unichr(unicodedb.tolower(ord(input[i]))) return W_UnicodeObject(u''.join(result))
def unicode_capitalize__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) result[0] = unichr(unicodedb.toupper(iter.nextint())) for i in range(1, length): result[i] = unichr(unicodedb.tolower(iter.nextint())) return W_RopeUnicodeObject(rope.rope_from_unicharlist(result))
def unicode_swapcase__Unicode(space, w_self): input = w_self._value builder = UnicodeBuilder(len(input)) for i in range(len(input)): unichar = ord(input[i]) if unicodedb.islower(unichar): builder.append(unichr(unicodedb.toupper(unichar))) elif unicodedb.isupper(unichar): builder.append(unichr(unicodedb.tolower(unichar))) else: builder.append(input[i]) return W_UnicodeObject(builder.build())
def unicode_swapcase__Unicode(space, w_self): input = w_self._value result = [u'\0'] * len(input) for i in range(len(input)): unichar = ord(input[i]) if unicodedb.islower(unichar): result[i] = unichr(unicodedb.toupper(unichar)) elif unicodedb.isupper(unichar): result[i] = unichr(unicodedb.tolower(unichar)) else: result[i] = input[i] return W_UnicodeObject(u''.join(result))
def Py_UNICODE_TOUPPER(space, ch): """Return the character ch converted to upper case.""" return unichr(unicodedb.toupper(ord(ch)))
def _upper(self, ch): return unichr(unicodedb.toupper(ord(ch)))
def unicode_upper__Unicode(space, w_self): input = w_self._value builder = UnicodeBuilder(len(input)) for i in range(len(input)): builder.append(unichr(unicodedb.toupper(ord(input[i])))) return W_UnicodeObject(builder.build())
def descr_upper_s(s): builder = StringBuilder(len(s)) for i in range(len(s)): ch = s[i] builder.append(chr(unicodedb.toupper(ord(ch)))) return builder.build()
def _toupper(ordch): return unichr(unicodedb.toupper(ordch))
def unicode_upper__Unicode(space, w_self): input = w_self._value result = [u'\0'] * len(input) for i in range(len(input)): result[i] = unichr(unicodedb.toupper(ord(input[i]))) return W_UnicodeObject(u''.join(result))
def descr_upper_u(s): builder = UnicodeBuilder(len(s)) for ch in s: builder.append(unichr(unicodedb.toupper(ord(ch)))) return builder.build()
def descr_upper(s): builder = rutf8.Utf8StringBuilder(len(s)) for ch in rutf8.Utf8StringIterator(s): ch = unicodedb.toupper(ch) builder.append_code(ch) return builder.build()