Guardian Programmer's Guide

Table Of Contents
Formatting and Manipulating Character Data
Guardian Programmer’s Guide 421922-014
19 - 53
Analyzing a Multibyte Character String
Any value that the pointer attains is a valid starting point for any other multibyte
operation.
The following example shows the intended use of the MBCS_CHAR_ procedure:
!Set up the pointer to address the first byte of the text
!string:
@TESTMBCSCHAR := @TEXT^STRING[0];
!Loop, checking each character, as long as you are processing
!a mixed text string:
WHILE... !while processing mixed text string
DO
BEGIN
!Indicate the number of bytes remaining in the text
!string:
CHARSIZE := number of bytes remaining in text string
!Check whether the pointer addresses a single-byte
!character or a multibyte character:
IF MBCS_CHAR_(TESTMBCSCHAR,CHARSET,CHARSIZE)
THEN
!Process the multibyte character and advance the pointer
!by length of character:
BEGIN
!add code for processing a multibyte character
.
.
!advance the pointer:
@TESTMBCSCHAR := @TESTMBCSCHAR + $DBL(CHARSIZE.<8:15>);
END;
ELSE
!Process single-byte character and advance pointer by one
!byte:
BEGIN
!add code for processing single-byte character
.
.
!Advance the pointer:
@TESTMBCSCHAR := @TESTMBCSCHAR + 1D;
END;
END;