Exemple #1
0
 def encode_string(cls, value):
     size = cls._encode_varint(bytelength(value))
     data = value.encode('utf-8')
     return size + data
Exemple #2
0
 def test_bytelength(self):
     self.assertEqual(0, bytelength(''))
     self.assertEqual(3, bytelength('foo'))
     self.assertEqual(3, bytelength(b'\xe2\x84\xa2'.decode('utf-8')))
     self.assertEqual(3, bytelength(u'\u2122'))
Exemple #3
0
 def test_bytelength(self):
     self.assertEqual(0, bytelength(''))
     self.assertEqual(3, bytelength('foo'))
     self.assertEqual(3, bytelength(b'\xe2\x84\xa2'.decode('utf-8')))
     self.assertEqual(3, bytelength(u'\u2122'))
Exemple #4
0
 def encode_string(cls, value):
     size = cls._encode_varint(bytelength(value))
     data = value.encode('utf-8')
     return size + data