def unicode_to_char_p(string):
    """Return ``(pointer, bytestring)``.

    The byte string must live at least as long as the pointer is used.

    """
    bytestring = string.encode().replace(b'\x00', b'')
    return ffi.new('char[]', bytestring), bytestring
Return ``(pointer, bytestring)``.

The byte string must live at least as long as the pointer is used.
weasyprint/text/ffi.py