In this section: |
The following functions manipulate strings of DBCS and SBCS characters when your configuration uses a DBCS code page.
How to: |
The DCTRAN function translates a single-byte or double-byte character within a character string to another character based on its decimal value. To use DCTRAN, you need to know the decimal equivalent of the characters in internal machine representation.
To use DCTRAN, you need to know the decimal equivalent of the characters in internal machine representation.
DCTRAN(length, source_string, inhexchar, outhexchar, output_format)
where:
Double
Is the number of characters in the source_string field.
Alphanumeric
Is the character string to be translated.
Double
Is the ASCII or EBCDIC decimal value of the character to be translated.
Double
Is the ASCII or EBCDIC decimal value of the character to be used as a substitute for inhexchar.
Alphanumeric
Is the name of the field that contains the result, or the format of the output value enclosed in single quotation marks.
In the following:
How to: |
If your configuration uses a DBCS code page, you can use the DEDIT function to extract characters from or add characters to a string.
DEDIT works by comparing the characters in a mask to the characters in a source field. When it encounters a nine (9) in the mask, DEDIT copies the corresponding character from the source field to the new field. When it encounters a dollar sign ($) in the mask, DEDIT ignores the corresponding character in the source field. When it encounters any other character in the mask, DEDIT copies that character to the corresponding position in the new field.
DEDIT(inlength, source_string, mask_length, mask, outfield)
where:
Integer
Is the number of bytes in source_string. The string can have a mixture of DBCS and SBCS characters. Therefore, the number of bytes represents the maximum number of characters possible in the source string.
Alphanumeric
Is the string to edit enclosed in single quotation marks, or the field containing the string.
Integer
Is the number of characters in mask.
Alphanumeric
Is the string of mask characters.
Each nine (9) in the mask causes the corresponding character from the source field to be copied to the new field.
Each dollar sign ($) in the mask causes the corresponding character in the source field to be ignored.
Any other character in the mask is copied to the new field.
Alphanumeric
Is the field to which the result is returned, or the format of the output value enclosed in single quotation marks.
The following example copies alternate characters from the source string to the new field, starting with the first character in the source string, and then adds several new characters at the end of the extracted string:
The following example copies alternate characters from the source string to the new field, starting with the second character in the source string, and then adds several new characters at the end of the extracted string:
How to: |
The DSTRIP function removes all occurrences of a specific single-byte or double-byte character from a string. The resulting character string has the same length as the original string but is padded on the right with spaces.
DSTRIP(length, source_string, char, output_format)
where:
Double
Is the number of characters in source_string and outfield.
Alphanumeric
Is the string from which the character will be removed.
Alphanumeric
Is the character to be removed from the string. If more than one character is provided, the left-most character will be used as the strip character.
Note: To remove single quotation marks, use two consecutive quotation marks. You must then enclose this character combination in single quotation marks.
Alphanumeric
Is the name of the field that contains the result, or the format of the output value enclosed in single quotation marks.
In the following:
How to: |
If your configuration uses a DBCS code page, you can use the DSUBSTR function to extract a substring based on its length and position in the parent string.
DSUBSTR(inlength, parent, start, end, sublength, outfield)
where:
Integer
Is the length of the parent string in bytes, or a field that contains the length. The string can have a mixture of DBCS and SBCS characters. Therefore, the number of bytes represents the maximum number of characters possible in the parent string.
Alphanumeric
Is the parent string enclosed in single quotation marks, or the field containing the parent string.
Integer
Is the starting position (in number of characters) of the substring in the parent string. If this argument is less than one or greater than end, the function returns spaces.
Integer
Is the ending position (in number of characters) of the substring. If this argument is less than start or greater than inlength, the function returns spaces.
Integer
Is the length of the substring in characters (normally end - start + 1). If sublength is longer than end - start +1, the substring is padded with trailing spaces. If it is shorter, the substring is truncated. This value should be the declared length of outfield. Only sublength characters will be processed.
Alphanumeric
Is the field to which the result is returned, or the format of the output value enclosed in single quotation marks.
The following example extracts the 3-character substring in positions 4 through 6 from a 15-byte string of characters:
How to: Reference: |
The JPTRANS function converts Japanese specific characters.
JPTRANS ('type_of_conversion', length, source_string, 'output_format')
where:
Is one of the following options indicating the type of conversion you want to apply to Japanese specific characters. These are the single component input types:
Conversion Type | Description |
---|---|
'UPCASE' | Converts Zenkaku (Fullwidth) alphabets to Zenkaku uppercase. |
'LOCASE' | Converts Zenkaku alphabets to Zenkaku lowercase. |
'HNZNALPHA' | Converts alphanumerics from Hankaku (Halfwidth) to Zenkaku. |
'HNZNSIGN' | Converts ASCII symbols from Hankaku to Zenkaku. |
'HNZNKANA' | Converts Katakana from Hankaku to Zenkaku. |
'HNZNSPACE' | Converts space (blank) from Hankaku to Zenkaku. |
'ZNHNALPHA' | Converts alphanumerics from Zenkaku to Hankaku. |
'ZNHNSIGN' | Converts ASCII symbols from Zenkaku to Hankaku. |
'ZNHNKANA' | Converts Katakana from Zenkaku to Hankaku. |
'ZNHNSPACE' | Converts space from Zenkaku to Hankaku. |
'HIRAKATA' | Converts Hiragana to Zenkaku Katakana. |
'KATAHIRA' | Converts Zenkaku Katakana to Hiragana. |
'930TO939' | Converts codepage from 930 to 939. |
'939TO930' | Converts codepage from 939 to 930. |
Integer
Is the number of characters in the source_string.
Alphanumeric
Is the string to convert.
Alphanumeric
Is the name of the field that contains the output, or the format enclosed in single quotation marks.
JPTRANS('UPCASE', 20, Alpha_DBCS_Field, 'A20')
JPTRANS('LOCASE', 20, Alpha_DBCS_Field, 'A20')
JPTRANS('HNZNALPHA', 20, Alpha_SBCS_Field, 'A20')
JPTRANS('HNZNSIGN', 20, Symbol_SBCS_Field, 'A20')
JPTRANS('HNZNKANA', 20, Hankaku_Katakana_Field, 'A20')
JPTRANS('HNZNSPACE', 20, Hankaku_Katakana_Field, 'A20')
JPTRANS('ZNHNALPHA', 20, Alpha_DBCS_Field, 'A20')
JPTRANS('ZNHNSIGN', 20, Symbol_DBCS_Field, 'A20')
JPTRANS('ZNHNKANA', 20, Zenkaku_Katakana_Field, 'A20')
JPTRANS('ZNHNSPACE', 20, Zenkaku_Katakana_Field, 'A20')
JPTRANS('HIRAKATA', 20, Hiragana_Field, 'A20')
JPTRANS('KATAHIRA', 20, Zenkaku_Katakana_Field, 'A20')
In the following, codepoints 0x62 0x63 0x64 are converted to 0x81 0x82 0x83, respectively:
JPTRANS('930TO939', 20, CP930_Field, 'A20')
In the following, codepoints 0x59 0x62 0x63 are converted to 0x81 0x82 0x83, respectively:
JPTRANS('939TO930', 20, CP939_Field, 'A20')
Many symbols have a one-to-one relation between Japanese Fullwidth characters and ASCII symbols, whereas some characters have one-to-many relations. For example, the Japanese punctuation character (U+3001) and Fullwidth comma , (U+FF0C) will be converted to the same comma , (U+002C). We have the following EXTRA rule for those special cases.
HNZNSIGN:
ZNHNSIGN:
They convert not only letters but also punctuation symbols on the following list:
For example, text data may contain fullwidth numbers and fullwidth symbols. In some situations, they should be cleaned up for ASCII numbers and symbols.
JPTRANS('ZNHNALPHA', 20, JPTRANS('ZNHNSIGN', 20, Symbol_DBCS_Field, 'A20'), 'A20')
Currently only conversion between U+0020 and U+3000 is supported.
WebFOCUS |