示例#1
0
 def __str__(self):
     # __str__ is used for serialization
     if self.value == self.original_value:
         # If unchanged, return the raw original value without decoding/encoding.
         return PdfString.from_bytes(self.raw_original_value)
     else:
         # If the value changed, encode it from Unicode according to the encoding
         # of the font that is active at the location of this token.
         return PdfString.from_bytes(fromUnicode(self.value, self.font, fontcache))
示例#2
0
 def encode(self, value):
     x = PdfString.encode(value)
     if isinstance(value, type(u'')):
         y = PdfString.from_unicode(value)
     else:
         y = PdfString.from_bytes(value)
     self.assertEqual(x, y)
     return x