Guardian Procedure Calls Reference Manual (G06.25+)

Guardian Procedure Calls (M)
Guardian Procedure Calls Reference Manual522629-013
9-51
MBCS_TESTBYTE_ Procedure
Considerations
A simple range check is not adequate to establish positive identification of MBCS
byte usages.
The set of second-byte values used by Shift-JIS Kanji characters overlaps the byte
value ranges of ASCII, 1-byte Katakana, and the set of byte values used for the
first byte of Shift-JIS Kanji characters. Taken out of context, the second byte of a
Shift-JIS character could be mistaken as an ASCII character, a 1-byte Katakana
character, or the first byte of a Kanji character.
A combination of relative position and value range analysis is required to correctly
establish usage identity as a 1-byte character or as a particular MBCS byte identity.
This is the basic purpose of the MBCS_TESTBYTE_ procedure.
To obtain proper results from the use of this procedure, the caller must ensure that
the string referenced by the
buffer parameter is a properly formed text string. A
properly formed text string meets the following criteria:
The first byte (buffer[0]) is either a 1-byte character or the first byte of an
MBCS character. It can be assumed that a displayable line of text input from a
terminal meets this requirement. Do not assume that an arbitrarily selected
extract from a text string meets this requirement.
The last byte in a properly formed text string is either a 1-byte character or an
MBCS final byte. A line of text typed at a terminal in conversational mode does
not necessarily meet this requirement. (See the MBCS_TRIMFRAGMENT_
procedure.) Do not assume that an arbitrarily selected extract from a text
string meets this requirement.
This procedure does not alter the contents of the text string.
The MBCS_TESTBYTE_ procedure tests isolated bytes in a text string for MBCS
characteristics. On each call to this procedure, the
buffer text string is analyzed
from the beginning up to a point just past
buffer[testindex].
Repetitive analysis of a text string from the beginning is not particularly efficient.
This procedure is not the function of choice for iterative operations where each
byte or character in a text string is to be tested and processed. For operations
where it is necessary to test and process each byte in a text string, greater
efficiency can be achieved by using a user-coded procedure which progressively
tests and processes as it works its way through the target text string. Refer to the
MBCS_CHAR_ procedure considerations for a sample user-coded procedure.
Related Programming Manual
For programming information about the MBCS_TESTBYTE_ procedure, refer to the
Guardian Programmer’s Guide.