z/OS TSO/E REXX Reference
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


DBCS function handling

z/OS TSO/E REXX Reference
SA32-0972-00

Some built-in functions can handle DBCS. The functions that deal with word delimiting and length determining conform with the following rules under OPTIONS EXMODE:

  1. Counting characters—Logical character lengths are used when counting the length of a string (that is, 1 byte for one SBCS logical character, 2 bytes for one DBCS logical character). In EBCDIC, SO and SI are considered to be transparent, and are not counted, for every string operation.
  2. Character extraction from a string—Characters are extracted from a string on a logical character basis. In EBCDIC, leading SO and trailing SI are not considered as part of one DBCS character. For instance, .A and .B are extracted from <.A.B>, and SO and SI are added to each DBCS character when they are finally preserved as completed DBCS characters. When multiple characters are consecutively extracted from a string, SO and SI that are between characters are also extracted. For example, .A><.B is extracted from <.A><.B>, and when the string is finally used as a completed string, the SO prefixes it and the SI suffixes it to give <.A><.B>.
    Here are some EBCDIC examples:
    S1 = 'abc<>def'
    
    SUBSTR(S1,3,1)      ->    'c'
    SUBSTR(S1,4,1)      ->    'd'
    SUBSTR(S1,3,2)      ->    'c<>d'
    
    S2 = '<><.A.B><>'
    
    SUBSTR(S2,1,1)      ->    '<.A>'
    SUBSTR(S2,2,1)      ->    '<.B>'
    SUBSTR(S2,1,2)      ->    '<.A.B>'
    SUBSTR(S2,1,3,'x')  ->    '<.A.B><>x'
    
    S3 = 'abc<><.A.B>'
    
    SUBSTR(S3,3,1)      ->    'c'
    SUBSTR(S3,4,1)      ->    '<.A>'
    SUBSTR(S3,3,2)      ->    'c<><.A>'
    DELSTR(S3,3,1)      ->    'ab<><.A.B>'
    DELSTR(S3,4,1)      ->    'abc<><.B>'
    DELSTR(S3,3,2)      ->    'ab<.B>'
  3. Character concatenation—String concatenation can only be done with valid mixed strings. In EBCDIC, adjacent SI and SO (or SO and SI) that are a result of string concatenation are removed. Even during implicit concatenation as in the DELSTR function, unnecessary SO and SI are removed.
  4. Character comparison—Valid mixed strings are used when comparing strings on a character basis. A DBCS character is always considered greater than an SBCS one if they are compared. In all but the strict comparisons, SBCS blanks, DBCS blanks, and leading and trailing contiguous SO and SI (or SI and SO) in EBCDIC are removed. SBCS blanks may be added if the lengths are not identical.

    In EBCDIC, contiguous SO and SI (or SI and SO) between nonblank characters are also removed for comparison.

    Note: The strict comparison operators do not cause syntax errors even if you specify mixed strings that are not valid.
    In EBCDIC:
          '<.A>' = '<.A. >'     ->    1     /* true  */
      '<><><.A>' = '<.A><><>'   ->    1     /* true  */
      '<>  <.A>' = '<.A>'       ->    1     /* true  */
    '<.A><><.B>' = '<.A.B>'     ->    1     /* true  */
           'abc' < 'ab<. >'     ->    0     /* false */
  5. Word extraction from a string—“Word” means that characters in a string are delimited by an SBCS or a DBCS blank.

    In EBCDIC, leading and trailing contiguous SO and SI (or SI and SO) are also removed when words are separated in a string, but contiguous SO and SI (or SI and SO) in a word are not removed or separated for word operations. Leading and trailing contiguous SO and SI (or SI and SO) of a word are not removed if they are among words that are extracted at the same time.

    In EBCDIC:
    W1 = '<><. .A. . .B><.C. .D><>'
    
    SUBWORD(W1,1,1)      ->    '<.A>'
    SUBWORD(W1,1,2)      ->    '<.A. . .B><.C>'
    SUBWORD(W1,3,1)      ->    '<.D>'
    SUBWORD(W1,3)        ->    '<.D>'
    
    W2 = '<.A. .B><.C><> <.D>'
    
    SUBWORD(W2,2,1)      ->    '<.B><.C>'
    SUBWORD(W2,2,2)      ->    '<.B><.C><> <.D>'
     

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014