File encoding strategy question

A

Andrew Robert

Hi everyone,

I am in the process of creating a file transmit/receiver program using
MQSeries.

The way it works is through creation of an XML message.

Elements within the XML message contain things such as file name, size,
and the file contents.

The file contents are encoded, currently using Base64, for support of
both binary and text data.

This works great but there is a small rub to the problem.

I would like to be able to view the contents of the file if it is text
while still maintaining the ability to transmit binary data.

Does anyone know of an encoding format that would make this possible?

The viewing of the file contents does not need to be perfect, merely
enough that a particular in-transit file could be identified.

Thoughts on this would be greatly appreciated.

Thanks,
Andy
 
D

Dennis Benzinger

Andrew said:
Hi everyone,

I am in the process of creating a file transmit/receiver program using
MQSeries.

The way it works is through creation of an XML message.

Elements within the XML message contain things such as file name, size,
and the file contents.

The file contents are encoded, currently using Base64, for support of
both binary and text data.

This works great but there is a small rub to the problem.

I would like to be able to view the contents of the file if it is text
while still maintaining the ability to transmit binary data.

Does anyone know of an encoding format that would make this possible?
[...]

Yes. You could use the Quoted-Printable encoding. See RFC 2045
Multipurpose Internet Mail Extensions (MIME) Part One: Format of
Internet Message Bodies <ftp://ftp.rfc-editor.org/in-notes/rfc2045.txt>


Dennis
 
J

John Machin

Andrew > I would like to be able to view the contents of the file if it
is text
while still maintaining the ability to transmit binary data.

Like Dennis said ... and once you have read the RFC and understood it
thoroughly :) don't start writing code; it's one of the included
batteries -- but beware of file size expansion for binary data:
import quopri
a = ''.join(chr(x) for x in range(256))
b = quopri.encodestring(a)
c = quopri.decodestring(b)
[len(x) for x in a,b,c] [256, 530, 256]
a == c True
b
'\x00\x01\x02\x03\x04\x05\x06\x07\x08=09\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14
\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f
!"#$%&\'()*+,-./0123456789:;<=3D>?@
ABCDEFGHIJKLMNOPQRS=\nTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~=7F=80=81=82=8
3=84=85=86=87=88=\n=89=8A=8B=8C=8D=8E=8F=90=91=92=93=94=95=96=97=98=99=9A=9B=9C=
9D=9E=9F=A0=A1=\n=A2=A3=A4=A5=A6=A7=A8=A9=AA=AB=AC=AD=AE=AF=B0=B1=B2=B3=B4=B5=B6
=B7=B8=B9=BA=\n=BB=BC=BD=BE=BF=C0=C1=C2=C3=C4=C5=C6=C7=C8=C9=CA=CB=CC=CD=CE=CF=D
0=D1=D2=D3=\n=D4=D5=D6=D7=D8=D9=DA=DB=DC=DD=DE=DF=E0=E1=E2=E3=E4=E5=E6=E7=E8=E9=
EA=EB=EC=\n=ED=EE=EF=F0=F1=F2=F3=F4=F5=F6=F7=F8=F9=FA=FB=FC=FD=FE=FF'

HTH,
John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top