A newer version of this document is available. Customers should click here to go to the newest version.
MBLead
NLS Function: Determines whether a given character is the lead (first) byte of a multibyte character sequence. This routine is only available for Windows.
Module
USE IFNLS
result = MBLead (char)
char  |  
      (Input) CHARACTER(1). Is a character to be tested for lead status.  |  
     
Results
The result type is LOGICAL(4). The result is .TRUE. if char is the first character of a multibyte character sequence; otherwise, .FALSE..
MBLead only works when stepping forward through a whole multibyte character string. For example:
       DO i = 1, LEN(str)  ! LEN returns the number of bytes, not the
                           !  number of characters in str
          WRITE(*, 100) MBLead (str(i:i))
       END DO
 100   FORMAT (L2, \) 
   MBLead is passed only one character at a time and must start on a lead byte and step through a string to establish context for the character. MBLead does not correctly identify a nonlead byte if it is passed only the second byte of a multibyte character because the status of lead byte or trail byte depends on context.
The function MBStrLead is passed a whole string and can identify any byte within the string as a lead or trail byte because it performs a context-sensitive test, scanning all the way back to the beginning of a string if necessary to establish context. So, MBStrLead can be much slower than MBLead (up to n times slower, where n is the length of the string).