Locale Setting and Inquiry Routines

At program startup, the current language and country setting is retrieved from the operating system. The user can change this setting through the Control Panel Regional Settings icon. The current codepage is also retrieved from the system.

There is a system default console codepage and a system default Windows codepage. Console programs retrieve the system console codepage, while Windows programs (including QuickWin applications) retrieve the system Windows codepage.

The NLS Library provides routines to determine the current locale (local code set), to return parameters of the current locale, to provide a list of all the system supported locales, and to set the locale to another language, country and/or codepage. These routines are summarized in the following table. Note that the locales and codepages set with these routines affect only the program or console that calls the routine. They do not change the system defaults or affect other programs or consoles.

Routines to Set and Inquire about the Locales

Name Procedure Type Description
NLSSetLocale Function Sets the language, country and codepage
NLSGetLocale Subroutine Retrieves the current language, country and codepage
NLSGetLocaleInfo Function Retrieves requested information about the current local code set
NLSEnumLocales Function Returns all the languages and country combinations supported by the system
NLSEnumCodepages Function Returns all the supported codepages on the system
NLSSetEnvironmentCodepage Function Changes the codepage for the current console
NLSGetEnvironmentCodepage Function Returns the codepage number for the system (Window) codepage or the console codepage

As an example:

     USE DFNLS
     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