PDA

View Full Version : convert ebcdic to ascii



jaca
17th June 2008, 13:33
Hi!
I'm trying to convert ebcdic to ascii with the code below. But not converting.
Someone knows how to convert?
Thanks.


int main(int argc, char *argv[])
{
FILE* in;
FILE* out;

char dummy[3201];
char input[200];
char output[200];
strcpy(input, argv[1]);
strcpy(output,argv[2]);

if ((in = fopen(input,"r")) == NULL) {
printf("\nERROR: cannot find input file %s\n\n",input);
exit(1);
}

if ((out = fopen(output,"w")) == NULL) {
printf("\nERROR: cannot open output file %s\n\n",output);
exit(1);
}

fread (&dummy, 3200, 1, in);

QString texto = QString::fromAscii(dummy);
qDebug() << text;
fprintf(out, "%s\n", dummy);

return 0;
}

marcel
17th June 2008, 20:49
I only see you reading the file but you're not converting anything.
As I am sure you know, there isn't a 1:1 correspondence between ASCII and EBCDIC.

There are a lot of resources on the internet about the two encoding methods...
Just search google for "ascii to ebcdic".

As a hint, you would need a conversion table, that maps ebcdic codes to ascii codes.