473,398 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

File encoding strategy question

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
May 21 '06 #1
2 1360
Andrew Robert schrieb:
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
May 21 '06 #2
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=C 6=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

May 21 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: David Buchan | last post by:
Hi guys, This may be a dumb question; I'm just getting into C language here. I wrote a program to unpack a binary file and write out the contents to a new file as a list of unsigned integers....
5
by: Julia | last post by:
Strategy to read part of XML log file Hi, My log file will contains entries formatted as XML(i use this format since some time i would like to log entire objects) I am going to use ...
12
by: Brian Henry | last post by:
first question... I have a flat file which unfortinuatly has columns seperated by nulls instead of spaces (a higher up company created it this way for us) is there anyway to do a readline with this...
1
by: ujjwaltrivedi | last post by:
Hey guys, Can anyone tell me how to create a text file with Unicode Encoding. In am using FileStream Finalfile = new FileStream("finalfile.txt", FileMode.Append, FileAccess.Write); ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.