예제 #1
0
파일: utf_32.py 프로젝트: Asemco/Arrowbots
 def encode(self, input, errors='strict'):
     self.bom_written = True
     result = codecs.utf_32_encode(input, errors)
     if sys.byteorder == 'little':
         self.encode = codecs.utf_32_le_encode
     else:
         self.encode = codecs.utf_32_be_encode
     return result
예제 #2
0
 def encode(self, input, errors='strict'):
     self.bom_written = True
     result = codecs.utf_32_encode(input, errors)
     if sys.byteorder == 'little':
         self.encode = codecs.utf_32_le_encode
     else:
         self.encode = codecs.utf_32_be_encode
     return result
예제 #3
0
 def encode(self, input, final=False):
     if self.encoder is None:
         result = codecs.utf_32_encode(input, self.errors)[0]
         if sys.byteorder == 'little':
             self.encoder = codecs.utf_32_le_encode
         else:
             self.encoder = codecs.utf_32_be_encode
         return result
     return self.encoder(input, self.errors)[0]
예제 #4
0
 def encode(self, input, final=False):
     if self.encoder is None:
         result = codecs.utf_32_encode(input, self.errors)[0]
         if sys.byteorder == 'little':
             self.encoder = codecs.utf_32_le_encode
         else:
             self.encoder = codecs.utf_32_be_encode
         return result
     return self.encoder(input, self.errors)[0]
예제 #5
0
 def encode(self, input, errors='strict'):
     if self.encoder is None:
         result = codecs.utf_32_encode(input, errors)
         if sys.byteorder == 'little':
             self.encoder = codecs.utf_32_le_encode
         else:
             self.encoder = codecs.utf_32_be_encode
         return result
     return self.encoder(input, errors)
예제 #6
0
 def encode(self, input, errors="strict"):
     if self.encoder is None:
         result = codecs.utf_32_encode(input, errors)
         if sys.byteorder == "little":
             self.encoder = codecs.utf_32_le_encode
         else:
             self.encoder = codecs.utf_32_be_encode
         return result
     else:
         return self.encoder(input, errors)
         return
예제 #7
0
    def test_codecs_builtins(self):
        s = "abc"

        encoded = codecs.utf_8_encode(s)
        self.assertEqual(s, codecs.utf_8_decode(encoded[0])[0])

        encoded = codecs.utf_7_encode(s)
        self.assertEqual(s, codecs.utf_7_decode(encoded[0])[0])

        encoded = codecs.utf_16_encode(s)
        self.assertEqual(s, codecs.utf_16_decode(encoded[0])[0])

        encoded = codecs.utf_16_le_encode(s)
        self.assertEqual(s, codecs.utf_16_le_decode(encoded[0])[0])

        encoded = codecs.utf_16_be_encode(s)
        self.assertEqual(s, codecs.utf_16_be_decode(encoded[0])[0])

        encoded = codecs.utf_32_encode(s)
        self.assertEqual(s, codecs.utf_32_decode(encoded[0])[0])

        encoded = codecs.utf_32_le_encode(s)
        self.assertEqual(s, codecs.utf_32_le_decode(encoded[0])[0])

        encoded = codecs.utf_32_be_encode(s)
        self.assertEqual(s, codecs.utf_32_be_decode(encoded[0])[0])

        encoded = codecs.utf_32_be_encode(s)
        self.assertEqual(s, codecs.utf_32_be_decode(encoded[0])[0])

        encoded = codecs.raw_unicode_escape_encode(s)
        self.assertEqual(s, codecs.raw_unicode_escape_decode(encoded[0])[0])

        encoded = codecs.unicode_escape_encode(s)
        self.assertEqual(s, codecs.unicode_escape_decode(encoded[0])[0])

        encoded = codecs.latin_1_encode(s)
        self.assertEqual(s, codecs.latin_1_decode(encoded[0])[0])

        encoded = codecs.ascii_encode(s)
        self.assertEqual(s, codecs.ascii_decode(encoded[0])[0])
예제 #8
0
 def test_utf_32_encode(self):
     # On little-endian systems, UTF-32 encodes in UTF-32-LE prefixed with BOM
     data, num_processed = codecs.utf_32_encode("abc")
     self.assertEqual(data, codecs.BOM_UTF32 + b'a\0\0\0b\0\0\0c\0\0\0')
     self.assertEqual(num_processed, 3)
예제 #9
0
파일: nodes.py 프로젝트: xxoolm/Ryven
 def update_event(self, inp=-1):
     self.set_output_val(
         0, codecs.utf_32_encode(self.input(0), self.input(1),
                                 self.input(2)))