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



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

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

Postby skumar77 » Mon Apr 22, 2013 3:41 am

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
skumar77
 
Posts: 3
Joined: Mon Apr 22, 2013 3:15 am
Has thanked: 0 time
Been thanked: 0 time

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

 

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

Postby Anuj Dhawan » Tue Apr 30, 2013 6:29 pm

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
Anuj
Anuj Dhawan
 
Posts: 274
Joined: Mon Feb 25, 2008 3:53 am
Location: Mumbai, India
Has thanked: 6 times
Been thanked: 4 times

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

Postby Anuj Dhawan » Tue Apr 30, 2013 6:33 pm

The explanation here is also good : http://docs.oracle.com/cd/E24150_01/pt8 ... tgbl09.htm
Anuj
Anuj Dhawan
 
Posts: 274
Joined: Mon Feb 25, 2008 3:53 am
Location: Mumbai, India
Has thanked: 6 times
Been thanked: 4 times

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

Postby skumar77 » Wed May 01, 2013 8:30 am

Thanks Anuj. Looking into it
skumar77
 
Posts: 3
Joined: Mon Apr 22, 2013 3:15 am
Has thanked: 0 time
Been thanked: 0 time

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

Postby Anuj Dhawan » Wed May 01, 2013 9:30 am

Sure; Good Luck! :)
Anuj
Anuj Dhawan
 
Posts: 274
Joined: Mon Feb 25, 2008 3:53 am
Location: Mumbai, India
Has thanked: 6 times
Been thanked: 4 times

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

Postby skumar77 » Wed May 01, 2013 9:35 am

Thx Anuj,

String function PTPSTRFN is there in COBOL?
skumar77
 
Posts: 3
Joined: Mon Apr 22, 2013 3:15 am
Has thanked: 0 time
Been thanked: 0 time

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

Postby NicC » Wed May 01, 2013 11:27 am

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.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2690
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post