Results 1 to 2 of 2

Thread: convert ebcdic to ascii

  1. #1
    Join Date
    Dec 2007
    Location
    Brazil
    Posts
    61
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    14

    Default convert ebcdic to ascii

    Hi!
    I'm trying to convert ebcdic to ascii with the code below. But not converting.
    Someone knows how to convert?
    Thanks.

    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. FILE* in;
    4. FILE* out;
    5.  
    6. char dummy[3201];
    7. char input[200];
    8. char output[200];
    9. strcpy(input, argv[1]);
    10. strcpy(output,argv[2]);
    11.  
    12. if ((in = fopen(input,"r")) == NULL) {
    13. printf("\nERROR: cannot find input file %s\n\n",input);
    14. exit(1);
    15. }
    16.  
    17. if ((out = fopen(output,"w")) == NULL) {
    18. printf("\nERROR: cannot open output file %s\n\n",output);
    19. exit(1);
    20. }
    21.  
    22. fread (&dummy, 3200, 1, in);
    23.  
    24. QString texto = QString::fromAscii(dummy);
    25. qDebug() << text;
    26. fprintf(out, "%s\n", dummy);
    27.  
    28. return 0;
    29. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 541 Times in 521 Posts

    Default Re: convert ebcdic to ascii

    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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.