International Components for Unicode (ICU)

Start of change The International Components for Unicode (ICU), option 39, is a C and C++ library that provides Unicode services for writing global applications in ILE programming languages. ICU offers flexibility to extend and customize the supplied services, which include:

ICU is an open source development project sponsored, supported, and used by IBM(R). ICU provides over 200 APIs that you can use to process Unicode data in your ILE application. See the RPG example and COBOL example for example code that calls an ICU API.End of change

Additional information about ICU can be found at International Components for UnicodeLink outside Information Center.


Start of change Example of RPG program calling an ICU API

See Code disclaimer information for information pertaining to code examples.

This ILE RPG program example calls the u_isdigit ICU API to check whether the Unicode character is a digit.

 H DftActGrp(*NO) BndDir('QICU/QXICUAPIBD')                                  
 DIsDigit          pr            10i 0 extproc('u_isdigit')                  
 D                               10u 0 value                                 
 DMapping          ds                                                        
 D ch                            10u 0 inz(0)                                
 D UCSChar                 3      4c                                         
 DRtnCode          s             10i 0                                       
 DTrue             c                   1                                     
 C                   eval      UCSChar = %UCS2('A')                          
 C                   eval      RtnCode = IsDigit(ch)                         
 C                   exsr      Check                                         
 C                   eval      UCSChar = %UCS2('1')                          
 C                   eval      RtnCode = IsDigit(ch)                         
 C                   exsr      Check                                         
 C                   eval      *inlr = '1'                                   
 C                   return                                                  
 C     Check         begsr                                                   
 C     UCSChar       dsply                                                   
 C                   if        RtnCode = True                                
 C     'Is digit'    dsply                                                   
 C                   else                                                    
 C     'Not digit'   dsply                                                   
 C                   endif   
 C                   endsr 
 

Example of COBOL program calling an ICU API

See Code disclaimer information for information pertaining to code examples.

This ILE COBOL program example calls the u_isdigit ICU API to check whether the Unicode character is a digit.

       PROCESS NOMONOPRC NATIONAL.
       IDENTIFICATION DIVISION.
       PROGRAM-ID. ISDIGIT.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  char.
           05 filler           PIC S9(04) BINARY VALUE 0.
           05 UCSChar          PIC  N(01).
       01  Rtn                 PIC S9(09) BINARY.
       PROCEDURE DIVISION.
       MAIN-LINE.
           MOVE "A" to UCSChar.
           CALL LINKAGE PRC "u_isdigit" USING BY VALUE char GIVING Rtn.
           PERFORM CHECK.
           MOVE "1" to UCSChar.
           CALL LINKAGE PRC "u_isdigit" USING BY VALUE char GIVING Rtn.
           PERFORM CHECK.
           STOP RUN.
       CHECK.
           DISPLAY UCSChar.
           IF Rtn = 1
              DISPLAY "Is digit"
           ELSE
              DISPLAY "Not digit"
End of change

APIs by category