TRANSLATE Function

Purpose

Replaces occurrences of a character in a string with a corresponding translation character and returns the resulting string.

Syntax

TRANSLATE(s,t)

or

TRANSLATE(s,t,x)

Parameters

s, t, and x are all character strings.

Description

Given a character string argument, the TRANSLATE function replaces occurrences of a character with a corresponding translation character and returns the resulting string. If x is not given, it is assumed to be COLLATE(). (The TRANSLATE function uses a 256-byte collating string.) If x is the null string, s is returned without translation.

If t is shorter than x, t is padded on the right with blanks until the length of t is equal to the length of x. If t is longer than x, the rightmost extra characters of t are ignored.

The occurrence of an element of x in the string s is replaced by the corresponding element in the string t.

If s is the null string, the result is the null string. If s is not the null string, for each character of s, s(k), the value I is calculated to be equal to INDEX(x,s(k)). If the value of I is 0, the corresponding character of the result is s(k); otherwise, the corresponding character of the result is t(I).

Examples

TRANSLATE('TEXT','abcdefghijklmnopqrstuvwxyz', 
        'ABCDEFGHIJKLMNOPQRSTUVWXYZ')    /*returns 'text'*/

boxes

Restrictions

None.