예제 #1
0
 def test_as_bytes(self):
     ords = [0, 1, 0x7F, 0x80, 0xC3, 0x20, 0xC3, 0xB6, 0xFF]
     s = ''.join([chr(i) for i in ords])
     self.failUnlessEqual(len(s), len(ords))
     b = compat.as_bytes(s)
     self.failUnless(isinstance(b, compat.bytes_))
     self.failUnlessEqual([compat.ord_(i) for i in b], ords)
예제 #2
0
def test_magic(f, magic_hex):
    """ tests a given file to see if the magic hex matches.
    """
    data = f.read(len(magic_hex))

    if len(data) != len(magic_hex):
        return 0

    for i in range(len(magic_hex)):
        if magic_hex[i] != ord_(data[i]):
            return 0
    
    return 1
예제 #3
0
파일: font.py 프로젝트: vavilon/pygame_cffi
def utf_8_needs_UCS_4(text):
    first = ord(b'\xF0')
    for ch in text:
        if ord_(ch) >= first:
            return True
    return False
예제 #4
0
 def test_ord_(self):
     self.failUnless(isinstance(compat.ord_(compat.bytes_(1)[0]), int))
예제 #5
0
 def test_ord_(self):
     self.assertIsInstance(compat.ord_(compat.bytes_(1)[0]), int)
예제 #6
0
파일: font.py 프로젝트: berteaa/pygame_cffi
def utf_8_needs_UCS_4(text):
    first = ord(b'\xF0')
    for ch in text:
        if ord_(ch) >= first:
            return True
    return False
예제 #7
0
 def test_ord_(self):
     self.assertTrue(isinstance(compat.ord_(compat.bytes_(1)[0]), int))