Intel® Fortran Compiler 17.0 Developer Guide and Reference

Overview of NLS and MCBS Routines (Windows*)

The NLS and MCBS routines are only available on Windows* systems. These library routines for handling extended and multibyte character sets are divided into three categories:

Examples

The following example uses Locale Setting and Inquiry routines:


    USE IFNLS
    INTEGER(4) strlen, status
    CHARACTER(40) str
    strlen = NLSGetLocaleInfo(NLS$LI_SDAYNAME1, str)
    print *, str    ! prints Monday
    strlen = NLSGetLocaleInfo(NLS$LI_SDAYNAME2, str)
    print *, str    ! prints Tuesday
    strlen = NLSGetLocaleInfo(NLS$LI_SDAYNAME3, str)
    print *, str    ! prints Wednesday
! Change locale to Spanish, Mexico
    status = NLSSetLocale("Spanish", "Mexico")
    strlen = NLSGetLocaleInfo(NLS$LI_SDAYNAME1, str)
    print *, str    ! prints lunes
    strlen = NLSGetLocaleInfo(NLS$LI_SDAYNAME2, str)
    print *, str    ! prints martes
    strlen = NLSGetLocaleInfo(NLS$LI_SDAYNAME3, str)
    print *, str    ! prints miércoles
    END

The following example uses NLS Formatting routines:


USE IFNLS
INTEGER(4) strlen, status
CHARACTER(40) str
strlen = NLSFormatTime(str)
print *, str             ! prints               11:42:24 AM
strlen = NLSFormatDate(str, flags= NLS$LongDate)
print *, str             ! prints        Friday, July 14, 2000
status = NLSSetLocale ("Spanish", "Mexico")
strlen = NLSFormatTime(str)
print *, str             ! prints               11:42:24
print *, str             ! prints viernes 14 de julio de 2000

The following example uses Multibyte Character Set (MBCS) inquiry routines:


   USE IFNLS
   CHARACTER(4) str
   INTEGER status
   status = NLSSetLocale ("Japan")
   str = " ·, " ¿"
   PRINT '(1X,''String by char = '',\)'
   DO i = 1, len(str)
      PRINT '(A2,\)',str(i:i)
   END DO
   PRINT '(/,1X,''MBLead = '',\)'
   DO i = 1, len(str)
      PRINT '(L2,\)',mblead(str(i:i))
   END DO
   PRINT '(/,1X,''String as whole = '',A,\)',str
   PRINT '(/,1X,''MBStrLead = '',\)'
   DO i = 1, len(str)
      PRINT '(L1,\)',MBStrLead(str,i)
   END DO
   END

This code produces the following output for str = · , " ¿



The following example uses Multibyte Character Set (MBCS) Fortran equivalent routines:


   USE IFNLS
   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:



See Also