def encodeString(string):
 encodedString = ''
 try:
  for char in string:
   octal = ('%o' % ord(char))
   encodedString += (('\\' + ((3 - len(octal)) * '0')) + octal)
 except:
  return ((-1), 'Error encoding string')
 return (0, encodedString)

def encodeString ( string ) : encodedString = '' try : for char in string : octal = ( '%o' % ord ( char ) ) encodedString += ( ( '\\' + ( ( 3 - len ( octal ) ) * '0' ) ) + octal ) except : return ( ( - 1 ) , 'Error encoding string' ) return ( 0 , encodedString )
encode the given pdf string .