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:
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>'
In EBCDIC, contiguous SO and SI (or SI and SO) between nonblank characters are also removed for comparison.
In EBCDIC:
'<.A>' = '<.A. >' -> 1 /* true */
'<><><.A>' = '<.A><><>' -> 1 /* true */
'<> <.A>' = '<.A>' -> 1 /* true */
'<.A><><.B>' = '<.A.B>' -> 1 /* true */
'abc' < 'ab<. >' -> 0 /* false */
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>'
Examples for built-in functions, those that support DBCS and follow the rules defined, are given in this section. For full function descriptions and the syntax diagrams, refer to Functions.
In EBCDIC:
ABBREV('<.A.B.C>','<.A.B>') -> 1
ABBREV('<.A.B.C>','<.A.C>') -> 0
ABBREV('<.A><.B.C>','<.A.B>') -> 1
ABBREV('aa<>bbccdd','aabbcc') -> 1
Applying the character comparison and character extraction from a string rules.
In EBCDIC:
COMPARE('<.A.B.C>','<.A.B><.C>') -> 0
COMPARE('<.A.B.C>','<.A.B.D>') -> 3
COMPARE('ab<>cde','abcdx') -> 5
COMPARE('<.A><>','<.A>','<. >') -> 0
Applying the character concatenation for padding, character extraction from a string, and character comparison rules.
In EBCDIC:
COPIES('<.A.B>',2) -> '<.A.B.A.B>'
COPIES('<.A><.B>',2) -> '<.A><.B.A><.B>'
COPIES('<.A.B><>',2) -> '<.A.B><.A.B><>'
Applying the character concatenation rule.
DATATYPE('<.A.B>') -> 'CHAR'
DATATYPE('<.A.B>','D') -> 1
DATATYPE('<.A.B>','C') -> 1
DATATYPE('a<.A.B>b','D') -> 0
DATATYPE('a<.A.B>b','C') -> 1
DATATYPE('abcde','C') -> 0
DATATYPE('<.A.B','C') -> 0
DATATYPE('<.A.B>','S') -> 1 /* if ETMODE is on */
Note: If string is not a valid mixed string and C or D is specified as type, 0 is returned.
FIND('<.A. .B.C> abc','<.B.C> abc') -> 2
FIND('<.A. .B><.C> abc','<.B.C> abc') -> 2
FIND('<.A. . .B> abc','<.A> <.B>') -> 1
Applying the word extraction from a string and character comparison rules.
INDEX('<.A><.B><><.C.D.E>','<.D.E>') -> 4
POS('<.A>','<.A><.B><><.A.D.E>') -> 1
LASTPOS('<.A>','<.A><.B><><.A.D.E>') -> 3
Applying the character extraction from a string and character comparison rules.
In EBCDIC:
INSERT('a','b<><.A.B>',1) -> 'ba<><.A.B>'
INSERT('<.A.B>','<.C.D><>',2) -> '<.C.D.A.B><>'
INSERT('<.A.B>','<.C.D><><.E>',2) -> '<.C.D.A.B><><.E>'
INSERT('<.A.B>','<.C.D><>',3,,'<.E>') -> '<.C.D><.E.A.B>'
OVERLAY('<.A.B>','<.C.D><>',2) -> '<.C.A.B>'
OVERLAY('<.A.B>','<.C.D><><.E>',2) -> '<.C.A.B>'
OVERLAY('<.A.B>','<.C.D><><.E>',3) -> '<.C.D><><.A.B>'
OVERLAY('<.A.B>','<.C.D><>',4,,'<.E>') -> '<.C.D><.E.A.B>'
OVERLAY('<.A>','<.C.D><.E>',2) -> '<.C.A><.E>'
Applying the character extraction from a string and character comparison rules.
JUSTIFY('<><. .A. . .B><.C. .D>',10,'p')
-> '<.A>ppp<.B><.C>ppp<.D>'
JUSTIFY('<><. .A. . .B><.C. .D>',11,'p')
-> '<.A>pppp<.B><.C>ppp<.D>'
JUSTIFY('<><. .A. . .B><.C. .D>',10,'<.P>')
-> '<.A.P.P.P.B><.C.P.P.P.D>'
JUSTIFY('<><.X. .A. . .B><.C. .D>',11,'<.P>')
-> '<.X.P.P.A.P.P.B><.C.P.P.D>'
Applying the character concatenation for padding and character extraction from a string rules.
In EBCDIC:
LEFT('<.A.B.C.D.E>',4) -> '<.A.B.C.D>'
LEFT('a<>',2) -> 'a<> '
LEFT('<.A>',2,'*') -> '<.A>*'
RIGHT('<.A.B.C.D.E>',4) -> '<.B.C.D.E>'
RIGHT('a<>',2) -> ' a'
CENTER('<.A.B>',10,'<.E>') -> '<.E.E.E.E.A.B.E.E.E.E>'
CENTER('<.A.B>',11,'<.E>') -> '<.E.E.E.E.A.B.E.E.E.E.E>'
CENTER('<.A.B>',10,'e') -> 'eeee<.A.B>eeee'
Applying the character concatenation for padding and character extraction from a string rules.
In EBCDIC:
LENGTH('<.A.B><.C.D><>') -> 4
Applying the counting characters rule.
In EBCDIC:
REVERSE('<.A.B><.C.D><>') -> '<><.D.C><.B.A>'
Applying the character extraction from a string and character concatenation rules.
In EBCDIC:
SPACE('a<.A.B. .C.D>',1) -> 'a<.A.B> <.C.D>'
SPACE('a<.A><><. .C.D>',1,'x') -> 'a<.A>x<.C.D>'
SPACE('a<.A><. .C.D>',1,'<.E>') -> 'a<.A.E.C.D>'
Applying the word extraction from a string and character concatenation rules.
In EBCDIC:
STRIP('<><.A><.B><.A><>',,'<.A>') -> '<.B>'
Applying the character extraction from a string and character concatenation rules.
In EBCDIC:
SUBSTR('<><.A><><.B><.C.D>',1,2) -> '<.A><><.B>'
DELSTR('<><.A><><.B><.C.D>',1,2) -> '<><.C.D>'
SUBSTR('<.A><><.B><.C.D>',2,2) -> '<.B><.C>'
DELSTR('<.A><><.B><.C.D>',2,2) -> '<.A><><.D>'
SUBSTR('<.A.B><>',1,2) -> '<.A.B>'
SUBSTR('<.A.B><>',1) -> '<.A.B><>'
Applying the character extraction from a string and character concatenation rules.
In EBCDIC:
SUBWORD('<><. .A. . .B><.C. .D>',1,2) -> '<.A. . .B><.C>'
DELWORD('<><. .A. . .B><.C. .D>',1,2) -> '<><. .D>'
SUBWORD('<><.A. . .B><.C. .D>',1,2) -> '<.A. . .B><.C>'
DELWORD('<><.A. . .B><.C. .D>',1,2) -> '<><.D>'
SUBWORD('<.A. .B><.C><> <.D>',1,2) -> '<.A. .B><.C>'
DELWORD('<.A. .B><.C><> <.D>',1,2) -> '<.D>'
Applying the word extraction from a string and character concatenation rules.
In EBCDIC:
Drop A.3 ; <.A.B>=3 /* if ETMODE is on */
SYMBOL('<.A.B>') -> 'VAR'
SYMBOL(<.A.B>) -> 'LIT' /* has tested "3" */
SYMBOL('a.<.A.B>') -> 'LIT' /* has tested A.3 */
In EBCDIC:
TRANSLATE('abcd','<.A.B.C>','abc') -> '<.A.B.C>d'
TRANSLATE('abcd','<><.A.B.C>','abc') -> '<.A.B.C>d'
TRANSLATE('abcd','<><.A.B.C>','ab<>c') -> '<.A.B.C>d'
TRANSLATE('a<>bcd','<><.A.B.C>','ab<>c') -> '<.A.B.C>d'
TRANSLATE('a<>xcd','<><.A.B.C>','ab<>c') -> '<.A>x<.C>d'
Applying the character extraction from a string, character comparison, and character concatenation rules.
In EBCDIC:
Drop A3 ; <.A.B>=3 ; fred='<.A.B>'
VALUE('fred') -> '<.A.B>' /* looks up FRED */
VALUE(fred) -> '3' /* looks up <.A.B> */
VALUE('a'<.A.B>) -> 'A3' /* if ETMODE is on */
In EBCDIC:
VERIFY('<><><.A.B><><.X>','<.B.A.C.D.E>') -> 3
Applying the character extraction from a string and character comparison rules.
In EBCDIC:
W = '<><. .A. . .B><.C. .D>'
WORD(W,1) -> '<.A>'
WORDINDEX(W,1) -> 2
WORDLENGTH(W,1) -> 1
Y = '<><.A. . .B><.C. .D>'
WORD(Y,1) -> '<.A>'
WORDINDEX(Y,1) -> 1
WORDLENGTH(Y,1) -> 1
Z = '<.A .B><.C> <.D>'
WORD(Z,2) -> '<.B><.C>'
WORDINDEX(Z,2) -> 3
WORDLENGTH(Z,2) -> 2
Applying the word extraction from a string and (for WORDINDEX and WORDLENGTH) counting characters rules.
In EBCDIC:
W = '<><. .A. . .B><.C. .D>'
WORDS(W) -> 3
Applying the word extraction from a string rule.
In EBCDIC:
WORDPOS('<.B.C> abc','<.A. .B.C> abc') -> 2
WORDPOS('<.A.B>','<.A.B. .A.B><. .B.C. .A.B>',3) -> 4
Applying the word extraction from a string and character comparison rules.