def encodeName(name):
 encodedName = ''
 if (name[0] == '/'):
  name = name[1:]
 for char in name:
  if (char == '\x00'):
   encodedName += char
  else:
   try:
    hex = ('%x' % ord(char))
    encodedName += ('#' + hex)
   except:
    return ((-1), 'Error encoding name')
 return (0, ('/' + encodedName))

def encodeName ( name ) : encodedName = '' if ( name [ 0 ] == '/' ) : name = name [ 1 : ] for char in name : if ( char == '\x00' ) : encodedName += char else : try : hex = ( '%x' % ord ( char ) ) encodedName += ( '#' + hex ) except : return ( ( - 1 ) , 'Error encoding name' ) return ( 0 , ( '/' + encodedName ) )
encode the given pdf name .