** Convert EBCDIC to clear text **

** Convert EBCDIC to clear text **

2
NewbieNewbie
2

    Nov 15, 2007#1

    hi guys.

    i was wondering how could i convert EBCDIC value to clear text using UltraEdit.

    E.g. If EBCDIC value E7E2C3E3 is converted to clear text, it'd be XSCT.

    appreciate your valuable expertise.

    :)

    10310
    Power UserPower User
    10310

      Nov 16, 2007#2

      If you do an ASCII FTP of the EBCDIC file into UltraEdit, it will automatically convert into clear text. Alternatively, if you already have the binary EBCDIC file on your PC, simply select the File/Conversions/EBCDIC to ASCII option from the UE menu.

      Cheers...

      Frank

      2
      NewbieNewbie
      2

        Nov 18, 2007#3

        Frank,
        In mainframe host CICS dump screen, the info is all in EBCDIC.
        I saved the CICS dump info & download it locally to my PC.
        After that, I did the following :

        ) open UE, go to File -> New
        b) paste "E7 E2 C3 E3" where it was copied from CICS dump info
        c) go to File -> Conversions -> EBCDIC To ASCII

        I got ¤€¤€¢“€¤“ instead of XSCT.

        At what point did I go wrong?

        262
        MasterMaster
        262

          Nov 18, 2007#4

          Ok, you are in fact not dealing with "real" EBCDIC data but with hex escaped EBCDIC data. And out of the box UE cannot do conversions of that.

          First you have to change the hex escaped EBCDIC back into "normal" EBCDIC. Then you can use UE's conversion EBCDIC to ASCII.

          But you need a script to do this in UE, so you have to have at least version 13 of UE ? (If not upgrade to UE version 13 - or find another tool for this task).

          The script in the following will first "un-escape" your EBCDIC dump data and then convert into ASCII.

          Before data:

          Code: Select all

          E7E2C3E3
          E7 E2 C3 E3
          
          After the script has run:

          Code: Select all

          XSCT
          XSCT
          
          The script itself:

          Code: Select all

          // First select the entire contents of the active document:
          UltraEdit.activeDocument.selectAll();
          
          // Next retrieve the selected data into a variable:
          var iLines = UltraEdit.activeDocument.selection;
          
          // Delete contents of active file:
          UltraEdit.activeDocument.deleteText();
          
          // Remove spaces
          iLines = iLines.replace(/[ ]/g,"");
          
          // Split into lines - assume DOS format line endings
          var iLineArr = iLines.split("\r\n");
          
          // outputvariable:
          var oStr = "";
          
          // Run through all lines
          for (i=0;i<iLineArr.length;i++) {
             // Drop empty lines
             if(iLineArr[i].length < 2) {
                continue;
             }
          
             // Run through single line
             for (j=0;j<iLineArr[i].length;j=j+2) {
                var iChr = iLineArr[i].substr(j,2); /* read a single hex escaped character */
          
                if(iChr=="00") { /* hex 00 is suppressed as blank */
                   iChr="40"; /* hex 40 = blank in EBCDIC */
                }
          
                // Un-escape two character hex into single character EBCDIC
                oStr = oStr + String.fromCharCode(parseInt( iChr, 16 ));
             }
             // 0D=>CR  25=>LF i EBCDIC
             oStr = oStr + String.fromCharCode(parseInt( "0D", 16 ));
             oStr = oStr + String.fromCharCode(parseInt( "25", 16 ));
          
             // Write un-escaped line back into the active UE document
             UltraEdit.activeDocument.write(oStr);
             oStr = "";
          }
          
          // Convert from EBCDIC to ASCII:
          UltraEdit.activeDocument.fromEBCDIC();
          
          Have fun with this

          25
          Basic UserBasic User
          25

            Nov 20, 2007#5

            Very, very slick, jorrasdk!