473,698 Members | 2,392 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

convert binary file to txt file

Can I fullfill this task? Using fred and fwrite?
Jul 23 '08
22 11764
Keith Thompson wrote:
[...]
Finally, you only store information in disp, your huge array, in two places:

sprintf(disp, "%d \n", numn);
...
sprintf(disp, "%d \n", xx);

In both cases, you're unlikely to write more than a dozen or so
characters to your buffer. 100 million seems like overkill.
Even that many won't be enough if his system's `short' is
wider than 332,192,796 bits. Memory's cheap, but safety is
priceless.

--
Er*********@sun .com
Jul 23 '08 #11
On Jul 23, 3:37 pm, Eric Sosman <Eric.Sos...@su n.comwrote:
Keith Thompson wrote:
[...]
Finally, you only store information in disp, your huge array, in two places:
sprintf(disp, "%d \n", numn);
...
sprintf(disp, "%d \n", xx);
In both cases, you're unlikely to write more than a dozen or so
characters to your buffer. 100 million seems like overkill.

Even that many won't be enough if his system's `short' is
wider than 332,192,796 bits. Memory's cheap, but safety is
priceless.

--
Eric.Sos...@sun .com
Yup , I tried to change the 100 million to 100000 and it works....but
i am not sure if the result is right....Becaus e i did not changed
antthing else.... Sign....
Jul 23 '08 #12
On Jul 23, 2:40 pm, Richard Heathfield <r...@see.sig.i nvalidwrote:
xiao said:

<snip>
Here is my program: I just want to converted the input file to see
the content of it. But seems something wrong with opnning the file.

I'll give you six.
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define MAX_PATH_LENGTH 100000000
/* Define the data structure for the file header information */
typedef struct
{
short num;
} HEADER;
typedef struct
{
short x;
} DATA;
int main(void)
{
short xx,numn;
char disp[MAX_PATH_LENGTH];

1) You're asking for an object 100,000,000 bytes in size. C only guarantees
you an object 32,767 bytes in size (65,535 if you have a C99
implementation, which you probably don't).
int i;
FILE *in, *out;
HEADER nscrdh;
DATA nscrd;
/* Determine the file names to be read from and written to */
/* Open the files to be read from and written to*/
in = fopen("CldTotal Stats_8.dat","r ");

2) You don't check that this call succeeded. If it fails, the behaviour of
your program is undefined.

3) If you wanted to open this file in binary mode, you should specify "rb"
as the mode, not just "r".
out = fopen("newstats .txt","wt");

4) You don't check that this call succeeded. If it fails, the behaviour of
your program is undefined.

5) The fopen function has no "wt" mode. If you mean you want a text file,
specify "w".
/* Read necessary header data into local variables & confirm file
format */
for (i=0; i<84; i++)
{
fread(&nscrdh,s izeof(short),1, in);

6) Here, you show confusion about whether you're reading a HEADER (you're
passing a pointer to a HEADER object) or a short (you use sizeof(short) in
the call). Clearer: fread(&nscrdh, sizeof nscrdh, 1, in);

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999

:)Thank you for your grading :) haha~
Jul 23 '08 #13
xiao wrote:
On Jul 23, 3:37 pm, Eric Sosman <Eric.Sos...@su n.comwrote:
>Keith Thompson wrote:
>>[...]
Finally, you only store information in disp, your huge array, in two places:
sprintf(disp, "%d \n", numn);
...
sprintf(disp, "%d \n", xx);
In both cases, you're unlikely to write more than a dozen or so
characters to your buffer. 100 million seems like overkill.
Even that many won't be enough if his system's `short' is
wider than 332,192,796 bits. Memory's cheap, but safety is
priceless.

Yup , I tried to change the 100 million to 100000 and it works....but
i am not sure if the result is right....Becaus e i did not changed
antthing else.... Sign....
Xiao, Xiao, you're working too hard. Step back and think a moment:
What's the very next thing you do after each of the sprintf(disp,.. .)
calls? fputs(disp,out) , that's what. And is the disp array used for
any other purpose? No, it's not: You don't actually need it for
anything except to hold some characters before writing them to the
output. Xiao, I suggest you crack open your C reference and look up
the fprintf() function; using it, you can get rid of disp altogether
and stop worrying about its size.

Similar remarks apply to the two struct types you define. Each
contains just one thing, a short, and as soon as you read a value
into the struct's short the very next thing you do is pluck it out
into a free-standing short variable. Why bother with the struct
types at all?

Pointless complications do not improve programs, unless they're
IOCCC entries.

--
Er*********@sun .com

Jul 23 '08 #14
On Jul 23, 4:21 pm, Eric Sosman <Eric.Sos...@su n.comwrote:
xiao wrote:
On Jul 23, 3:37 pm, Eric Sosman <Eric.Sos...@su n.comwrote:
Keith Thompson wrote:
[...]
Finally, you only store information in disp, your huge array, in two places:
sprintf(disp, "%d \n", numn);
...
sprintf(disp, "%d \n", xx);
In both cases, you're unlikely to write more than a dozen or so
characters to your buffer. 100 million seems like overkill.
Even that many won't be enough if his system's `short' is
wider than 332,192,796 bits. Memory's cheap, but safety is
priceless.
Yup , I tried to change the 100 million to 100000 and it works....but
i am not sure if the result is right....Becaus e i did not changed
antthing else.... Sign....

Xiao, Xiao, you're working too hard. Step back and think a moment:
What's the very next thing you do after each of the sprintf(disp,.. .)
calls? fputs(disp,out) , that's what. And is the disp array used for
any other purpose? No, it's not: You don't actually need it for
anything except to hold some characters before writing them to the
output. Xiao, I suggest you crack open your C reference and look up
the fprintf() function; using it, you can get rid of disp altogether
and stop worrying about its size.

Similar remarks apply to the two struct types you define. Each
contains just one thing, a short, and as soon as you read a value
into the struct's short the very next thing you do is pluck it out
into a free-standing short variable. Why bother with the struct
types at all?

Pointless complications do not improve programs, unless they're
IOCCC entries.

--
Eric.Sos...@sun .com
haha .thank you~ i changed my mind here , If I define it like this:

short xx[800][800];
or
typedef struct
{
short x[800][800];
} NSC_RAY_DATA
how can I access the data in fread and fprintf?
I tried this:

fread(xx,sizeof (xx),14,in);
for(i=0; i<14 ;i++)
{ fprintf(out,"%h d", xx[i]);}

and
fread(&nscrd,si zeof(nscrd),14, in);
for(a=0; a<800 ;a++){
for(b=0; b<800 ;b++){
xx[a][b]=nscrd.x[a][b];
}
}
fprintf(out,"%h d", xx);
And both of them remind me that :

warning: int format, pointer arg (arg 3)
Jul 24 '08 #15
xiao said:
On Jul 23, 4:21 pm, Eric Sosman <Eric.Sos...@su n.comwrote:
<snip>
> Pointless complications do not improve programs, unless they're
IOCCC entries.

haha .thank you~ i changed my mind here , If I define it like this:

short xx[800][800];
....then you are still working way too hard.

Look, this is really, really, really easy.

Your spec appears to be an input binary file comprising short ints, which
you want to output in decimal form with no spaces between them or anything
like that, no newlines, just raw data.

Fine.

The following has full error-checking, but no error-reporting. Feel free to
add it.

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
int rc = EXIT_FAILURE;
if(argc 2)
{
FILE *fin = fopen(argv[1], "rb");
if(fin != NULL)
{
FILE *fout = fopen(argv[2], "w");
if(fout != NULL)
{
short sh = 0;
while(fread(&sh , sizeof sh, 1, fin) 0)
{
fprintf(fout, "%hd", sh);
}
if(!ferror(fin) && !ferror(fout))
{
rc = EXIT_SUCCESS;
}
fclose(fout);
}
fclose(fin);
}
}
return rc;
}

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jul 24 '08 #16
xiao <li*********@gm ail.comwrote:
Can I fullfill this task?
"This" task? What is "this" task you speak of?

*Looks up*

Oh. Don't do that; put your complete _question_ in your post, and a
_summary_ in the subject.
Using fred and fwrite?
You can do it much simpler using frhed, if you know where to find it.

But yes, you can, and guess what? It's quite straightforward . You do it
the way you would think you do: open binary file for reading, open text
file for writing, read byte from binary file, write text representation
of byte to text file (easier done using fprintf() than fwrite(), btw),
repeat until you run out of bytes. Improvements involving reading more
than one byte at a time are left as an exercise for the homework
cheater.

Richard
Jul 24 '08 #17
please include the subject in the body of your text
Subject: convert binary file to txt file

On 23 Jul, 17:46, xiao <littledd...@gm ail.comwrote:
On Jul 23, 11:20 am, CBFalconer <cbfalco...@yah oo.comwrote:
xiao wrote:
Can I fullfill this task? Using fred and fwrite?
what format is the binary file? What do you want the text to look
like.
For instance the binary could be an executable and the text file
might be a hex dump or the binary might be a word processor
document and the text an ASCII dump of the text of the document.
The possibilities are endless. But the answer is yes in princple.
If you can find fred.
--
*[mail]: Chuck F (cbfalconer at maineline dot net)
*[page]: <http://cbfalconer.home .att.net>
* * * * * * Try the download section.
don't quote sigs (the bit after --)

haha, I made a mistake here, I mean fread....but it seems fread does
not working....
fread() will almost certainly work on any reasonable
implementation. Please post your code and explain
why you think fread() is "not working".
--
Nick Keighley

A man's most valuable trait is a judicious sense of
what not to believe.
-- Euripides
Jul 24 '08 #18
On Jul 24, 3:41 am, Nick Keighley <nick_keighley_ nos...@hotmail. com>
wrote:
please include the subject in the body of your text
Subject: convert binary file to txt file

On 23 Jul, 17:46, xiao <littledd...@gm ail.comwrote:
On Jul 23, 11:20 am, CBFalconer <cbfalco...@yah oo.comwrote:
xiao wrote:
Can I fullfill this task? Using fred and fwrite?

what format is the binary file? What do you want the text to look
like.
For instance the binary could be an executable and the text file
might be a hex dump or the binary might be a word processor
document and the text an ASCII dump of the text of the document.
The possibilities are endless. But the answer is yes in princple.
If you can find fred.
--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home .att.net>
Try the download section.

don't quote sigs (the bit after --)
haha, I made a mistake here, I mean fread....but it seems fread does
not working....

fread() will almost certainly work on any reasonable
implementation. Please post your code and explain
why you think fread() is "not working".

--
Nick Keighley

A man's most valuable trait is a judicious sense of
what not to believe.
-- Euripides

Thank you guys~ I modified the program like the below but the new
generated txt file is a little less then the original dat file. Is
that reasonalble? I think it is not right Thank you ~~~

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

typedef struct
{
double CentLat;
double CentLon;
double DeltaX;
double DeltaY;
long ProjectionID;
double ProjectionParam eters1;
double ProjectionParam eters2;
double ProjectionParam eters3;
double ProjectionParam eters4;
double ProjectionParam eters5;
double ProjectionParam eters6;
double ProjectionParam eters7;
double ProjectionParam eters8;
double ProjectionParam eters9;
double ProjectionParam eters10;
double ProjectionParam eters11;
double ProjectionParam eters12;
double ProjectionParam eters13;
double ProjectionParam eters14;
double ProjectionParam eters15;
long MapZone;
int NumX;
int NumY;
// The number of rays in
} NSC_RAY_DATA_HE ADER;

/* Define the data structure for the ray information */

int main( )
{

double CentLat1;
double CentLon1;
double DeltaX1;
double DeltaY1;
long ProjectionID1;
double ProjectionParam eters11;
double ProjectionParam eters12;
double ProjectionParam eters13;
double ProjectionParam eters14;
double ProjectionParam eters15;
double ProjectionParam eters16;
double ProjectionParam eters17;
double ProjectionParam eters18;
double ProjectionParam eters19;
double ProjectionParam eters110;
double ProjectionParam eters111;
double ProjectionParam eters112;
double ProjectionParam eters113;
double ProjectionParam eters114;
double ProjectionParam eters115;

long MapZone1;
int NumX1;
int NumY1;
int rc = EXIT_FAILURE;
FILE *in, *out;
NSC_RAY_DATA_HE ADER nscrdh;
/* Determine the file names to be read from and written to */

/* Open the files to be read from and written to*/
in = fopen("CldTotal Stats_8.dat","r b");
out = fopen("newstats .txt","w");

if ( in != NULL )

{ printf ("Opened the file successfully\n" );}

/* Read necessary header data into local variables & confirm file
format */

fread(&nscrdh,s izeof(nscrdh),1 ,in);

CentLat1=nscrdh .CentLat;
CentLon1=nscrdh .CentLon;
DeltaX1=nscrdh. DeltaX;
DeltaY1=nscrdh. DeltaY;
ProjectionID1=n scrdh.Projectio nID;
ProjectionParam eters11= nscrdh.Projecti onParameters1;
ProjectionParam eters12= nscrdh.Projecti onParameters2;
ProjectionParam eters13= nscrdh.Projecti onParameters3;
ProjectionParam eters14= nscrdh.Projecti onParameters4;
ProjectionParam eters15= nscrdh.Projecti onParameters5;
ProjectionParam eters16= nscrdh.Projecti onParameters6;
ProjectionParam eters17= nscrdh.Projecti onParameters7;
ProjectionParam eters18= nscrdh.Projecti onParameters8;
ProjectionParam eters19= nscrdh.Projecti onParameters9;
ProjectionParam eters110= nscrdh.Projecti onParameters10;
ProjectionParam eters111= nscrdh.Projecti onParameters11;
ProjectionParam eters112= nscrdh.Projecti onParameters12;
ProjectionParam eters113= nscrdh.Projecti onParameters13;
ProjectionParam eters114= nscrdh.Projecti onParameters14;
ProjectionParam eters115= nscrdh.Projecti onParameters15;
MapZone1=nscrdh .MapZone;
NumX1=nscrdh.Nu mX;
NumY1=nscrdh.Nu mY;

fprintf(out, "%lf %lf %lf %lf %ld %ld %d %d",CentLat1,
CentLon1,DeltaX 1, DeltaY1,Project ionID1,MapZone1 ,NumX1,NumY1);

/* for(i=0; i<14 ;i++){
fprintf(out,"%l d",ProjectionID 1[i]);
}*/

fprintf(out,"%l d",ProjectionID 1);
/* Write header, ray information into output file */

printf("The center latitude and cent longtitute are %lf %lf
\n",CentLat1,Ce ntLon1);
printf("The deltax and deltay are %lf %lf \n",DeltaX1, DeltaY1);
printf("The projection ID is %ld \n",ProjectionI D1);
printf("The MapZone is %ld \n",MapZone1) ;

printf("The projection parameter are %lf
\n",ProjectionP arameters11);
printf("The projection parameter are %lf
\n",ProjectionP arameters12);
printf("The projection parameter are %lf
\n",ProjectionP arameters13);
printf("The projection parameter are %lf \n",ProjectionP arameters14);
printf("The projection parameter are %lf \n",ProjectionP arameters15);
printf("The projection parameter are %lf \n",ProjectionP arameters16);
printf("The projection parameter are %lf \n",ProjectionP arameters17);
printf("The projection parameter are %lf \n",ProjectionP arameters18);
printf("The projection parameter are %lf \n",ProjectionP arameters19);
printf("The projection parameter are %lf
\n",ProjectionP arameters110);
printf("The projection parameter are %lf
\n",ProjectionP arameters111);
printf("The projection parameter are %lf
\n",ProjectionP arameters112);
printf("The projection parameter are %lf
\n",ProjectionP arameters113);
printf("The projection parameter are %lf
\n",ProjectionP arameters114);

printf("The projection parameter are %lf
\n",ProjectionP arameters115);

printf("The numy and numx are %d %d \n",NumX1,NumY1 );
/* fread(&nscrd,si zeof(nscrd),14, in);
xx= nscrd.x;
for(a=0; a<800 ;a++){
for(b=0; b<800 ;b++){
xx[a][b]=nscrd.x[a][b];
}
}
fprintf(out,"%h d", xx);
printf("The numbers are %d \n",xx);
}*/

/* Close files and exit the program */
if(out != NULL)
{
short sh = 0;
while(fread(&sh , sizeof( sh), 1, in) 0)
{
fprintf(out, "%hd", sh);
}
printf("The itams read in the file are %d\n",fread(&sh ,
sizeof( sh),1,in));
if(!ferror(in) && !ferror(out))
{
rc = EXIT_SUCCESS;
}
fclose(out);
}
fclose(in);
return rc;

}
Jul 24 '08 #19
xiao <li*********@gm ail.comwrites:

<snip>
Thank you guys~ I modified the program like the below but the new
generated txt file is a little less then the original dat file. Is
that reasonalble?
It might be. I don't know the data so I can't really say. Writing
loads of "0 0 0 0 0" is shorter than the equivalent binary floating
point, for example. For 800x800 shorts it is much less likely,
although since you have no separators in you output you are in with a
chance that the output will be smaller than the input.
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

typedef struct
{
double CentLat;
double CentLon;
double DeltaX;
double DeltaY;
long ProjectionID;
double ProjectionParam eters1;
double ProjectionParam eters2;
double ProjectionParam eters3;
double ProjectionParam eters4;
double ProjectionParam eters5;
double ProjectionParam eters6;
double ProjectionParam eters7;
double ProjectionParam eters8;
double ProjectionParam eters9;
double ProjectionParam eters10;
double ProjectionParam eters11;
double ProjectionParam eters12;
double ProjectionParam eters13;
double ProjectionParam eters14;
double ProjectionParam eters15;
<fx: comedy screeching of brakes>

Hold on. This is what arrays are for.
long MapZone;
int NumX;
int NumY;
// The number of rays in
} NSC_RAY_DATA_HE ADER;

/* Define the data structure for the ray information */

int main( )
{

double CentLat1;
double CentLon1;
double DeltaX1;
double DeltaY1;
long ProjectionID1;
double ProjectionParam eters11;
double ProjectionParam eters12;
double ProjectionParam eters13;
double ProjectionParam eters14;
double ProjectionParam eters15;
double ProjectionParam eters16;
double ProjectionParam eters17;
double ProjectionParam eters18;
double ProjectionParam eters19;
double ProjectionParam eters110;
double ProjectionParam eters111;
double ProjectionParam eters112;
double ProjectionParam eters113;
double ProjectionParam eters114;
double ProjectionParam eters115;
I see point to all these variables.
long MapZone1;
int NumX1;
int NumY1;
int rc = EXIT_FAILURE;
FILE *in, *out;
NSC_RAY_DATA_HE ADER nscrdh;
/* Determine the file names to be read from and written to */

/* Open the files to be read from and written to*/
in = fopen("CldTotal Stats_8.dat","r b");
out = fopen("newstats .txt","w");

if ( in != NULL )

{ printf ("Opened the file successfully\n" );}

/* Read necessary header data into local variables & confirm file
format */

fread(&nscrdh,s izeof(nscrdh),1 ,in);

CentLat1=nscrdh .CentLat;
CentLon1=nscrdh .CentLon;
DeltaX1=nscrdh. DeltaX;
DeltaY1=nscrdh. DeltaY;
ProjectionID1=n scrdh.Projectio nID;
ProjectionParam eters11= nscrdh.Projecti onParameters1;
ProjectionParam eters12= nscrdh.Projecti onParameters2;
ProjectionParam eters13= nscrdh.Projecti onParameters3;
ProjectionParam eters14= nscrdh.Projecti onParameters4;
ProjectionParam eters15= nscrdh.Projecti onParameters5;
ProjectionParam eters16= nscrdh.Projecti onParameters6;
ProjectionParam eters17= nscrdh.Projecti onParameters7;
ProjectionParam eters18= nscrdh.Projecti onParameters8;
ProjectionParam eters19= nscrdh.Projecti onParameters9;
ProjectionParam eters110= nscrdh.Projecti onParameters10;
ProjectionParam eters111= nscrdh.Projecti onParameters11;
ProjectionParam eters112= nscrdh.Projecti onParameters12;
ProjectionParam eters113= nscrdh.Projecti onParameters13;
ProjectionParam eters114= nscrdh.Projecti onParameters14;
ProjectionParam eters115= nscrdh.Projecti onParameters15;
What is the point of copying all these values from one convenient
structure into a whole load of variables?
MapZone1=nscrdh .MapZone;
NumX1=nscrdh.Nu mX;
NumY1=nscrdh.Nu mY;

fprintf(out, "%lf %lf %lf %lf %ld %ld %d %d",CentLat1,
CentLon1,DeltaX 1, DeltaY1,Project ionID1,MapZone1 ,NumX1,NumY1);

/* for(i=0; i<14 ;i++){
fprintf(out,"%l d",ProjectionID 1[i]);
}*/
Ah, there was an array once...
fprintf(out,"%l d",ProjectionID 1);
This is a problem. See later...
/* Write header, ray information into output file */

printf("The center latitude and cent longtitute are %lf %lf
\n",CentLat1,Ce ntLon1);
printf("The deltax and deltay are %lf %lf \n",DeltaX1, DeltaY1);
printf("The projection ID is %ld \n",ProjectionI D1);
printf("The MapZone is %ld \n",MapZone1) ;

printf("The projection parameter are %lf
\n",ProjectionP arameters11);
printf("The projection parameter are %lf
\n",ProjectionP arameters12);
printf("The projection parameter are %lf
\n",ProjectionP arameters13);
printf("The projection parameter are %lf \n",ProjectionP arameters14);
printf("The projection parameter are %lf \n",ProjectionP arameters15);
printf("The projection parameter are %lf \n",ProjectionP arameters16);
printf("The projection parameter are %lf \n",ProjectionP arameters17);
printf("The projection parameter are %lf \n",ProjectionP arameters18);
printf("The projection parameter are %lf \n",ProjectionP arameters19);
printf("The projection parameter are %lf
\n",ProjectionP arameters110);
printf("The projection parameter are %lf
\n",ProjectionP arameters111);
printf("The projection parameter are %lf
\n",ProjectionP arameters112);
printf("The projection parameter are %lf
\n",ProjectionP arameters113);
printf("The projection parameter are %lf
\n",ProjectionP arameters114);

printf("The projection parameter are %lf
\n",ProjectionP arameters115);

printf("The numy and numx are %d %d \n",NumX1,NumY1 );
/* fread(&nscrd,si zeof(nscrd),14, in);
xx= nscrd.x;
for(a=0; a<800 ;a++){
for(b=0; b<800 ;b++){
xx[a][b]=nscrd.x[a][b];
}
}
fprintf(out,"%h d", xx);
printf("The numbers are %d \n",xx);
}*/

/* Close files and exit the program */
if(out != NULL)
{
short sh = 0;
while(fread(&sh , sizeof( sh), 1, in) 0)
{
fprintf(out, "%hd", sh);
This is a very unusual format. The two numbers 12 and 3 are
represented in the same way as 1 and 23. I think you need to re-think
this part.
}
printf("The itams read in the file are %d\n",fread(&sh ,
sizeof( sh),1,in));
if(!ferror(in) && !ferror(out))
{
rc = EXIT_SUCCESS;
}
fclose(out);
}
fclose(in);
return rc;

}

--
Ben.
Jul 24 '08 #20

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

Similar topics

4
6108
by: David Lawson | last post by:
I know how to conver a string to an array of strings, but I need to convert an ascii string to an array of integers (really unsigned chars). Eg, $str ="ABC"; needs to convert to something like this: $buf = array(0x41, 0x42, 0x43); Anyone know how? I haven't been able to find a way.
2
11207
by: Joey Lee | last post by:
Hi, Does anyone know how I am able to write a utf-8 encoded binary string into binary file? Currently I am given a UTF-8 string which was read from a gif image. Here are my functions... public Byte GetDocument(string DocumentName) { string strdocPath;
4
79643
by: Julia | last post by:
Hi, I need to convert unicode string to ansi string Thanks in adavance.
0
1584
by: Andy | last post by:
Hi, I have a MS Word binary data file that is sent from my .NET webservice in response to an XMLHTTP request from an Internet Explorer client. This data has to be base64 encoded to tunnel through a firewall. I've used the .NET Convert.ToBase64String() method to encode the data. I understand that the Convert.FromBase64String only runs on the server. How can I decode the data using jscript that's running on the browser?
7
19216
by: elliotng.ee | last post by:
I have a text file that contains a header 32-bit binary. For example, the text file could be: %%This is the input text %%test.txt Date: Tue Dec 26 14:03:35 2006 00000000000000001111111111111111 11111111111111111111111111111111 00000000000000000000000000000000 11111111111111110000000000000000
29
5080
by: Harlin Seritt | last post by:
Hi... I would like to take a string like 'supercalifragilisticexpialidocius' and write it to a file in binary forms -- this way a user cannot read the string in case they were try to open in something like ascii text editor. I'd also like to be able to read the binary formed data back into string format so that it shows the original value. Is there any way to do this in Python? Thanks!
5
1289
by: sweeet_addiction16 | last post by:
im coding in c....i need to accept an integer value(decimal) and then after converting it into hexadecimal value i need to write it into a file.i do not need to print it..so using fprintf along with %lx would not help me.for eg..if i have a decimal value of 60 to be passed to a function ..i need that function to convert it into hexadecimal value(eg 3c) and then write it into a file
4
22237
by: Mason | last post by:
I have tried and tried... I'd like to read in a binary file, convert it's 4 byte values into floats, and then save as a .txt file. This works from the command line (import struct); In : f = open("test2.pc0", "rb") In : tagData = f.read(4) In : tagData
1
3580
by: Man4ish | last post by:
I have sent one thread about the use of binary file for file indexing and got some very good reply and which helped me a lot. Now I am proceeding ahead. But facing one pblm of converting text file into binary file of fixed length. example: input file 34134 43214 1 + A/G 44134 43214 1 + A/G 346134 4323214 1 + A/G Here file should not only be tab separated but each value in column should take...
0
8678
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8609
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9030
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7737
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4621
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.