Page 1 of 1

How to identify and replace a spl/DBCS UTF8char with 1/2byte

PostPosted: Mon Apr 22, 2013 3:41 am
by skumar77
Hi Guys,

I am new to Unicode processing in COBOL.
Need help on COBOL coding

Background:
1. I need to fetch (name field) set of records from the table which is UTF8 format to a COBOL program.
2. Read a record and identify specific special/DBCS and replace with one or byte char defined for each special/DBCS char.

3. convert to UTF8 and write it to a file.

E.g.
Special/DBCS - Replace Char (1/2 Bytes)
Æ - AE
Ð - D
É - E
ij - IJ
Ŋ - NJ
ñ - n
ƕ - hv
DŽ - DZ
ȸ (U+0238) - AB

For example
1. Name: Nuño Iñaki Iñigo BeDŽat

Identify above special/DBCS in the string 'Nuño Iñaki Iñigo BeDŽat' and replace with respective characters.
expected Output is 'Nuno Inaki Inigo BeDZat'

Questions:
1. How can Identify a DBCS (UTF8) character in a string (UTF8 format) in COBOL
2. How can I replace two/three bytes UTF8 character with EBCDIC 1 byte character (Here the length of the string might change)

Please advice.

Thanks,
Kumar

Re: How to identify and replace a spl/DBCS UTF8char with 1/2

PostPosted: Tue Apr 30, 2013 6:29 pm
by Anuj Dhawan
Start from here: http://pic.dhe.ibm.com/infocenter/dzich ... acobol.htm

If you're interested in customization: http://pic.dhe.ibm.com/infocenter/pdthe ... yc1uni.htm

2. How can I replace two/three bytes UTF8 character with EBCDIC 1 byte character (Here the length of the string might change)
Try something like this:

MOVE FUNCTION DISPLAY-OF (FUNCTION NATIONAL-OF   
             (UTF8-VARIABLE , 1208), 500)
                       TO EBCDIC-VARIABLE

Re: How to identify and replace a spl/DBCS UTF8char with 1/2

PostPosted: Tue Apr 30, 2013 6:33 pm
by Anuj Dhawan
The explanation here is also good : http://docs.oracle.com/cd/E24150_01/pt8 ... tgbl09.htm

Re: How to identify and replace a spl/DBCS UTF8char with 1/2

PostPosted: Wed May 01, 2013 8:30 am
by skumar77
Thanks Anuj. Looking into it

Re: How to identify and replace a spl/DBCS UTF8char with 1/2

PostPosted: Wed May 01, 2013 9:30 am
by Anuj Dhawan
Sure; Good Luck! :)

Re: How to identify and replace a spl/DBCS UTF8char with 1/2

PostPosted: Wed May 01, 2013 9:35 am
by skumar77
Thx Anuj,

String function PTPSTRFN is there in COBOL?

Re: How to identify and replace a spl/DBCS UTF8char with 1/2

PostPosted: Wed May 01, 2013 11:27 am
by NicC
Why not look in the manual for your version of COBOL? You could have found the answer in less time than it took to write your post.