Issue #18
resolved
At https://bitbucket.org/whosaysni/elaphe/issue/5/cant-create-a-pdf417-code#comment-7143415 , Terry said:
Might I suggest modifying the invocation of BWIPP so that the PostScript uses hex strings <> for the data and options fields rather than normal strings ().
0 0 moveto ... <{hexdata}> <{hexoptions}> /{encoder} /uk.co.terryburton.bwipp findresource exec
Comments (4)
-
-
reporter Sounds great, thanks!
-
I suggest the following:
import binascii, textwrap string = 'test testtesttesttest test test testtesttest test \n sdfojsodfj oij 3240987u098rusipdjf948325u test' wrapper=textwrap.TextWrapper(subsequent_indent=' ', width=72) print wrapper.fill('<' + binascii.hexlify(string) + '>')
This generates neatly indented output as follows:
<74657374207465737474657374746573747465737420746573742074657374207465737 474657374746573742074657374200a207364666f6a736f64666a206f696a2033323430 393837753039387275736970646a66393438333235752074657374>
-
reporter - changed status to resolved
Hexadecimal stringification and stabilization. close
#18→ <<cset b174b6a0d04f>>
- Log in to comment
Ok, so, I think we could use textwrap :
http://docs.python.org/2/library/textwrap.html#textwrap.TextWrapper.wrap
import binascii, textwrap
string = 'test testtesttesttest test test testtesttest test \n sdfojsodfj oij 3240987u098rusipdjf948325u test'
print '<%s>' % textwrap.fill(binascii.hexlify(string), 72)
There is also TextWrapper class that could let us set "global" width and other parameters...
Richard