Test for a lead-byte value
- Last Updated: February 11, 2026
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
The next technique involves testing a byte for a lead-byte value. Lead bytes (and trail bytes) often have special values to distinguish them. The following table lists the lead-byte and trail-byte values for the multi-byte code pages OpenEdge supports.
| Code page | Language or standard | Lead-byte values | Trail-byte values |
|---|---|---|---|
| BIG-5 | Traditional Chinese | 161 through 254 | 64 through 126161 through 254 |
| CP949 | Korean | 129 through 254 | 65 through 9097 through 122129 through 254 |
| CP950 | Traditional Chinese | 129 through 254 | 64 through 126128 through 254 |
| CP936 | Simplified Chinese | 129 through 254 | 64 through 126128 through 254 |
| CP1361 | Korean | 132 through 211216 through 222224 through 249 | 65 through 127129 through 254 |
| EUCJIS | Japanese | 142164 through 254 | 161 through 254 |
| GB2312 | Simplified Chinese | 161 through 254 | 161 through 254 |
| GB180301 | Extended Chinese | - | - |
| KSC5601 | Korean | 161 through 254 | 161 through 254 |
| SHIFT-JIS | Japanese | 129 through 159224 through 252 | 64 through 126128 through 252 |
| UTF-8 | Unicode | 193 through 239 | 128 through 191 |
You cannot always assume a byte with a lead-byte value is a lead byte, or a byte with a trail-byte value is a trail byte. This is because the possible values for trail bytes overlap those of lead bytes and single bytes. For example, the value 164 can correspond to a lead byte or a trail byte. To determine which it is, you must inspect the string.
To determine if a byte has a lead-byte value, use the IS-LEAD-BYTE function,
which evaluates a character expression and returns YES if
the first byte of the first character of the character string has
a value within the range permitted for lead bytes. Otherwise, IS-LEAD-BYTE returns NO. IS-LEAD-BYTE has
the following syntax:
|
- string
- A character expression (a constant, field name, variable name, or any combination of these) whose value is a character.
In the following example, IS-LEAD-BYTE examines a
string whose first character is single byte. Since the first byte
of the first character of the string is not a lead byte, its value
is not within the range permitted for lead bytes, IS-LEAD-BYTE returns NO,
and the example displays Lead: no:
|
|
The following example is identical to the preceding example except
that the first character of the string is double byte. Since the
first byte of the first character of the string is a lead byte,
its value falls within the range permitted for lead bytes, IS-LEAD-BYTE returns YES, and
the example displays Lead: yes:
|
|