The NLS Library provides several functions that are the exact equivalents of Fortran 90 functions except that the MBCS equivalents allow character strings to contain multibyte characters. These routines are summarized in the following table.
MBCS Fortran Equivalent Routines
Name | Procedure Type | Description |
---|---|---|
MBINCHARQQ | Function | Same as INCHARQQ but can read a single multibyte character at once and returns the number of bytes read |
MBINDEX | Function | Same as INDEX except that multibyte characters can be included in its arguments |
MBLGE, MBLGT, MBLLE, MBLLT, MBLEQ, MBLNE | Functions | Same as LGE, LGT, LLE, LLT and the operators .EQ. and .NE. except that multibyte characters can be included in their arguments |
MBSCAN | Function | Same as SCAN except that multibyte characters can be included in its arguments |
MBVERIFY | Function | Same as VERIFY except that multibyte characters can be included in its arguments |
The following example is included in Visual Fortran Samples
in the ...\DF98\SAMPLES\TUTORIAL
folder as MBCOMP.FOR:
USE DFNLS
INTEGER(4) i, len(7), infotype(7)
CHARACTER(10) str(7)
LOGICAL(4) log4
data infotype / NLS$LI_SDAYNAME1, NLS$LI_SDAYNAME2, &
& NLS$LI_SDAYNAME3, NLS$LI_SDAYNAME4, &
& NLS$LI_SDAYNAME5, NLS$LI_SDAYNAME6, &
& NLS$LI_SDAYNAME7 /
WRITE(*,*) 'NLSGetLocaleInfo'
WRITE(*,*) '----------------'
WRITE(*,*) ' '
WRITE(*,*) 'Getting the names of the days of the week...'
DO i = 1, 7
len(i) = NLSGetLocaleInfo(infotype(i), str(i))
WRITE(*, 11) 'len/str/hex = ', len(i), str(i), str(i)
END DO
11 FORMAT (1X, A, I2, 2X, A10, 2X, '[', Z20, ']')
WRITE(*,*) ' '
WRITE(*,*) 'Lexically comparing the names of the days...'
DO i = 1, 6
log4 = MBLGE(str(i), str(i+1), NLS$IgnoreCase)
WRITE(*, 12) 'Is day ', i, ' GT day ', i+1, '? Answer = ', log4
END DO
12 FORMAT (1X, A, I1, A, I1, A, L1)
WRITE(*,*) ' '
WRITE(*,*) 'Done.'
END
This code produces the following output when the locale is Japan: