Example #1
0
 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()
Example #2
0
 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()
Example #3
0
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]))
Example #4
0
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]))
Example #5
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
Example #6
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
Example #7
0
 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())))
Example #8
0
def lower_case(a):
    a = rt.name(a)
    res = ""
    for ch in a:
        res += chr(unicodedb.tolower(ord(ch)))
    return rt.wrap(res)
Example #9
0
def string_lower(string):
    b = UnicodeBuilder()
    for ch in string:
        b.append(unichr(unicodedb.tolower(ord(ch))))
    return b.build()
Example #10
0
 def lower(a, b):
     return op(unichr(unicodedb.tolower(ord(a))),
               unichr(unicodedb.tolower(ord(b))))
Example #11
0
def char_downcase(v):
    return values.W_Character(unichr(unicodedb.tolower(ord(v.value))))
Example #12
0
 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())))
Example #13
0
File: string.py Project: 8l/pycket
 def lower(a, b):
     return op(unichr(unicodedb.tolower(ord(a))),
               unichr(unicodedb.tolower(ord(b))))
Example #14
0
File: string.py Project: 8l/pycket
def char_downcase(v):
    return values.W_Character(unichr(unicodedb.tolower(ord(v.value))))
Example #15
0
def lower_case(a):
    a = rt.name(a)
    res = ""
    for ch in a:
        res += chr(unicodedb.tolower(ord(ch)))
    return rt.wrap(res)