'Return a POSIX.1-2008 extended or global header sequence
that contains a list of keyword, value pairs. The values
must be strings.'

@classmethod
def _create_pax_generic_header(cls, pax_headers, type, encoding):

    binary = False
    for (keyword, value) in pax_headers.items():
        try:
            value.encode('utf8', 'strict')
        except UnicodeEncodeError:
            binary = True
            break
    records = ''
    if binary:
        records += '21    hdrcharset=BINARY\n'
    for (keyword, value) in pax_headers.items():
        keyword = keyword.encode('utf8')
        if binary:
            value = value.encode(encoding, 'surrogateescape')
        else:
            value = value.encode('utf8')
        l = ((len(keyword) + len(value)) + 3)
        n = p = 0
        while True:
            n = (l + len(str(p)))
            if (n == p):
                break
            p = n
        records += (((((bytes(str(p), 'ascii') + '    ') + keyword) + '=') + value) + '\n')
    info = {}
    info['name'] = '././@PaxHeader'
    info['type'] = type
    info['size'] = len(records)
    info['magic'] = POSIX_MAGIC
    return (cls._create_header(info, USTAR_FORMAT, 'ascii', 'replace') + cls._create_payload(records))
