[Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5 (original) (raw)
Victor Stinner victor.stinner at gmail.com
Fri Jan 10 23:12:52 CET 2014
- Previous message: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5
- Next message: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
2014/1/10 Juraj Sukop <juraj.sukop at gmail.com>:
In the case of PDF, the embedding of an image into PDF looks like:
10 0 obj << /Type /XObject_ _/Width 100_ _/Height 100_ _/Alternates 15 0 R_ _/Length 2167_ _>> stream ...binary image data... endstream endobj
What not building "10 0 obj ... stream" and "endstream endobj" in Unicode and then encode to ASCII? Example:
data = b''.join(( ("%d %d obj ... stream" % (10, 0)).encode('ascii'), binary_image_data, ("endstream endobj").encode('ascii'), ))
Victor
- Previous message: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5
- Next message: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]