def toLowerCase(self): # Use current size as a size hint. In the best case, characters # are one-to-one; in the next-best case, we overestimate and end # up with a couple bytes of slop. ub = UnicodeBuilder(len(self._s)) for char in self._s: ub.append(unichr(unicodedb.tolower(ord(char)))) return ub.build()
def char_foldcase(w_char): char = ord(w_char.value) folded = unicodedb.casefold_lookup(char) if folded is None: lower = unicodedb.tolower(char) return values.W_Character(unichr(lower)) # XXX: What to do if the case folded character consists of more than one code point? return values.W_Character(unichr(folded[0]))
def cmp_case_insensitive(self, w_str, w_other): # base implementations, subclasses should do better ones len1 = self.length(w_str) len2 = w_other.length() if len1 < len2: cmplen = len1 else: cmplen = len2 otherstrategy = w_other.get_strategy() for i in range(cmplen): ch1 = unicodedb.tolower(ord(self.getitem(w_str, i))) ch2 = unicodedb.tolower(ord(otherstrategy.getitem(w_other, i))) diff = ch1 - ch2 if diff: return diff i += 1 return len1 - len2
def lower(self, w_str): value = self.unerase(w_str.get_storage()) builder = UnicodeBuilder(len(value)) for i, ch in enumerate(value): builder.append(unichr(unicodedb.tolower(ord(ch)))) return W_MutableString(self, self.erase(list(builder.build())))
def lower_case(a): a = rt.name(a) res = "" for ch in a: res += chr(unicodedb.tolower(ord(ch))) return rt.wrap(res)
def string_lower(string): b = UnicodeBuilder() for ch in string: b.append(unichr(unicodedb.tolower(ord(ch)))) return b.build()
def lower(a, b): return op(unichr(unicodedb.tolower(ord(a))), unichr(unicodedb.tolower(ord(b))))
def char_downcase(v): return values.W_Character(unichr(unicodedb.tolower(ord(v.value))))