code: def smart_encode_str(s):
      
      try:
          utf16 = s.encode('utf_16_be')
      except AttributeError:  # ints and floats
          utf16 = str(s).encode('utf_16_be')
      safe = utf16.replace(b'\x00)', b'\x00\\)').replace(b'\x00(', b'\x00\\(')
      return b''.join((codecs.BOM_UTF16_BE, safe))
docs: Create a UTF-16 encoded PDF string literal for `s`.