def encodeName(name):
    """
        Encode the given PDF name

        @param name: A PDFName string to encode
        @return: A tuple (status,statusContent), where statusContent is the encoded PDF name in case status = 0 or an error in case status = -1
    """
    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
