You could write a little assembler routine like this. This one translate everything except “a” thru “z”, “A” thru “Z” and “0” thru “9” to spaces. To add more “exempt” characters, add more ORGs to the table. One caveat, no warranty, expressed or implied, with this code. Use at your own risk as I have not tested it.
TRCHARS CSECT
STM 14,12,12(13) save caller’s registers
LM 2,3,0(1) load length and data address
LARL 4,TRTABLE point to translate table
CHI 2,256 256 chars or less?
JH USELOOP
BCTR 2,0 less one for effective length
LASTBIT DS 0H
EXRL 2,TRINST translate short style
LM 14,12,12(13) reload caller’s registers
SR 15,15 return code 0
BR 14 return to caller
*
TRINST TR 0(0,3),0(4) translate according to needs
*
USELOOP DS 0H
AHI 2,-256 subtract 256 from remaining length
JM DOLAST if less than 256, we went < 0
TR 0(256,3),0(4) translate next 256 bytes
LA 3,256(,3) advance to next 256 bytes
J USELOOP go do it again
*
DOLAST DS 0H
AHI 2,255 add back to get byte count
JM ALLDONE count was zero, we’re done
J LASTBIT go do final translate
*
TRTABLE DS 0H
DC 256C' '
ORG TRTABLE+C'a'
DC X'818283848586878889'
ORG TRTABLE+C'j'
DC X'919293949596979899'
ORG TRTABLE+C's'
DC X'A2A3A4A5A6A7A8A9'
ORG TRTABLE+C'A'
DC X'C1C2C3C4C5C6C7C8C9'
ORG TRTABLE+C'J'
DC X'D1D2D3D4D5D6D7D8D9'
ORG TRTABLE+C'S'
DC X'E2E3E4E5E6E7E8E9'
ORG TRTABLE+C'0'
DC X'F0F1F2F3F4F5F6F7F8F9'
Charles (Chuck) Hardee
Senior Systems Engineer
Database Administration
Information Technology Services
Thermo Fisher Scientific
300 Industry Drive
Pittsburgh, PA 15275
Direct: 724-517-2633
FAX: 412-490-9230
Chuck.Hardee@ThermoFisher.com
From: CA IDMS (IUA EIUA) Global User Community [mailto:
CommunityAdmin@communities-mail.ca.com]
Sent: Thursday, April 18, 2013 1:23 PM
To:
mb.15281481.100827143@myca-email.ca.com
Subject: [DBA Issues - Open Forum] COBOL question
I need to clean up a large string of data so that it does not contain any non-displayable characters. The goal is to make it XML-compatible. It's more than just alpha and numeric - I need to allow all displayable characters, and change the rest to spaces.
This is in an on-line program, so I am concerned about performance. I will need to compare each byte to the list of 95 allowable characters. What would be the most efficient way to do this: table lookup, large 88-level field, other?
We had discussed converting the data to base 64 while in flight, which would get it through the XML generator and parser on both ends. But that doesn't really clean it up.
All suggestions welcome!
Kay Rozeboom
Information Technology Enterprise
Iowa Department of Administrative Services
Telephone: 515.281.6139 Fax: 515.281.6137
Email:
Kay.Rozeboom@iowa.gov
Posted by:Kay.Rozeboom
--
CA Communities Message Boards
100829683
mb.15281481.100827143@myca-email.ca.com
https://communities.ca.com