Jump to content

DosGetCtryInfo: Difference between revisions

From EDM2
No edit summary
Ak120 (talk | contribs)
mNo edit summary
Line 3: Line 3:


==Syntax==
==Syntax==
  DosGetCtryInfo (Length, Country, MemoryBuffer, DataLength)  
DosGetCtryInfo (Length, Country, MemoryBuffer, DataLength)


==Parameters==
==Parameters==
; Length (USHORT) - input : Length, in bytes, of the data area (MemoryBuffer). This length should be at least 38 bytes.  
;Length (USHORT) - input : Length, in bytes, of the data area (MemoryBuffer). This length should be at least 38 bytes.
 
;Country (PCOUNTRYCODE) - input : Address of the country information structure:
 
::country (USHORT) - Country code identifier; 0 is the default country code.  
; Country (PCOUNTRYCODE) - input : Address of the country information structure:
::codepage (USHORT) - Code page identifier; 0 is the code page of the current process.  
 
; MemoryBuffer (PCOUNTRYINFO) - output : Address of the buffer where the country-dependent data is returned. The application must request enough space in memory, a minimum of 38 bytes, to hold the returned data. If the requested space is not large enough, the system fills the allocated space with as much data as it can hold. If the requested space is too large, the extra memory requested is set to 0.
        country (USHORT)
            Country code identifier; 0 is the default country code.  
        codepage (USHORT)
            Code page identifier; 0 is the code page of the current process.  
 
; MemoryBuffer (PCOUNTRYINFO) - output : Address of the buffer where the country-dependent data is returned. The application must request enough space in memory, a minimum of 38 bytes, to hold the returned data. If the requested space is not large enough, the system fills the allocated space with as much data as it can hold. If the requested space is too large, the extra memory requested is set to 0.  


The data is returned in the buffer in the following format:
The data is returned in the buffer in the following format:
::country (USHORT) - Country code identifier.
::codepage (USHORT) -  Code page identifier.
::dateformat (USHORT) - Date format.


            country (USHORT)
Value
                Country code identifier.
  Definition 0
            codepage (USHORT)
  mm/dd/yy 1
                Code page identifier.
  dd/mm/yy 2
            dateformat (USHORT)
  yy/mm/dd currency (CHAR)
                Date format.
  Currency identifier, terminated with a null. thousandsep (CHAR)
 
  Thousands separator, terminated with a null. decimalsep (CHAR)
                Value
  Decimal separator, terminated with a null. datesep (CHAR)
                    Definition 0
  Date separator, terminated with a null. timesep (CHAR)
                    mm/dd/yy 1
  Time separator, terminated with a null. currencyformat (UCHAR)
                    dd/mm/yy 2
  The currency bit fields in the following format:
                    yy/mm/dd currency (CHAR)
                    Currency identifier, terminated with a null. thousandsep (CHAR)
                    Thousands separator, terminated with a null. decimalsep (CHAR)
                    Decimal separator, terminated with a null. datesep (CHAR)
                    Date separator, terminated with a null. timesep (CHAR)
                    Time separator, terminated with a null. currencyformat (UCHAR)
                    The currency bit fields in the following format:
 
                    Bit
                        Description 7-3
                        Reserved 2
                        0 = Bits 0 and 1 are used.
 
                        1 = Bits 0 and 1 are ignored; the currency indicator replaces the decimal indicator.
                    1
                        0 = No space between the currency indicator and money value.
 
                        1 = One space between the currency indicator and money value.
                    0
                        0 = Currency indicator precedes the money value.
 
                        1 = Currency indicator follows the money value.
                    decimalspace (UCHAR)
                        Number (in binary) of decimal spaces used to indicate currency value. timeformat (UCHAR)
                        Time format for presentation in file directory:
 
                        Bit
                            Description 7-1
                            Reserved 0
                            0 = 12-hour format
 
                            1 = 24-hour format.
                        reserved (USHORT)
                            Reserved, set to zero.
                        datalistsep (CHAR)
                            Data list separator, terminated with a null.
                        reserved (USHORT)
                            Reserved, set to zero.
 


Bit  Description
7-3  Reserved 2
      0 = Bits 0 and 1 are used.
      1 = Bits 0 and 1 are ignored; the currency indicator replaces the decimal indicator.
1
      0 = No space between the currency indicator and money value.
      1 = One space between the currency indicator and money value.
0
      0 = Currency indicator precedes the money value.
      1 = Currency indicator follows the money value.
decimalspace (UCHAR)
  Number (in binary) of decimal spaces used to indicate currency value.
timeformat (UCHAR)
  Time format for presentation in file directory:
  Bit  Description
  7-1  Reserved
  0    0 = 12-hour format
        1 = 24-hour format.
reserved (USHORT) Reserved, set to zero.
datalistsep (CHAR) Data list separator, terminated with a null.
reserved (USHORT) Reserved, set to zero.
; DataLength (PUSHORT) - output : Address of the length, in bytes, of the country dependent information. rc (USHORT) - return
; DataLength (PUSHORT) - output : Address of the length, in bytes, of the country dependent information. rc (USHORT) - return
                            
                            
==Returns==
==Returns==
Return code descriptions are:
Return code descriptions are:
* NO_ERROR  
* NO_ERROR  
* 396 ERROR_NLS_NO_COUNTRY_FILE  
* 396 ERROR_NLS_NO_COUNTRY_FILE  
Line 84: Line 62:
==Remarks==
==Remarks==
The returned country dependent information may be for the default country and current process code page, or for a specific country and code page. For more information on code page, see DosSetCp.
The returned country dependent information may be for the default country and current process code page, or for a specific country and code page. For more information on code page, see DosSetCp.


===Family API Considerations===
===Family API Considerations===
Line 91: Line 68:
==C Binding==
==C Binding==
<PRE>
<PRE>
typedef struct _COUNTRYCODE {  /* ctryc */
typedef struct _COUNTRYCODE {  /* ctryc */
   
   
Line 132: Line 107:


===Example===
===Example===
<PRE>
<PRE>
This example gets country-dependent information.
This example gets country-dependent information.
Line 149: Line 123:
   Country.codepage = NLS_CODEPAGE;
   Country.codepage = NLS_CODEPAGE;


   rc = DosGetCtryInfo(sizeof(CtryBuffer),       /* Length of data area
   rc = DosGetCtryInfo(sizeof(CtryBuffer), /* Length of data area provided */
                                                    provided */
                       &Country,           /* Input data structure */
                       &Country,                 /* Input data structure */
                       &CtryBuffer,       /* Data area to be filled by function */
                       &CtryBuffer,             /* Data area to be filled
                       &Length);           /* Length of data returned */
                                                        by function */
                       &Length);                 /* Length of data
                                                        returned */
 
 
</PRE>
</PRE>


Line 163: Line 132:
<PRE>
<PRE>
COUNTRYCODE struc
COUNTRYCODE struc
   ctryc_country  dw  ? ;country code
   ctryc_country  dw  ? ;country code
   ctryc_codepage  dw  ? ;code page
   ctryc_codepage  dw  ? ;code page
COUNTRYCODE ends
COUNTRYCODE ends


COUNTRYINFO struc
COUNTRYINFO struc
   ctryi_country              dw  ? ;country code
   ctryi_country              dw  ? ;country code
   ctryi_codepage            dw  ? ;code page
   ctryi_codepage            dw  ? ;code page
Line 185: Line 151:
   ctryi_szDataSeparator      db  2 dup (?) ;Data list separator
   ctryi_szDataSeparator      db  2 dup (?) ;Data list separator
   ctryi_abReserved2          dw  5 dup (?) ;reserved (0)
   ctryi_abReserved2          dw  5 dup (?) ;reserved (0)
COUNTRYINFO ends
COUNTRYINFO ends


Line 200: Line 165:
</PRE>
</PRE>


[[Category:The OS/2 API Project]]
[[Category:Dos]]

Revision as of 23:01, 4 December 2016

Description

This call obtains country-dependent formatting information that resides in the country information file.

Syntax

DosGetCtryInfo (Length, Country, MemoryBuffer, DataLength)

Parameters

Length (USHORT) - input
Length, in bytes, of the data area (MemoryBuffer). This length should be at least 38 bytes.
Country (PCOUNTRYCODE) - input
Address of the country information structure:
country (USHORT) - Country code identifier; 0 is the default country code.
codepage (USHORT) - Code page identifier; 0 is the code page of the current process.
MemoryBuffer (PCOUNTRYINFO) - output
Address of the buffer where the country-dependent data is returned. The application must request enough space in memory, a minimum of 38 bytes, to hold the returned data. If the requested space is not large enough, the system fills the allocated space with as much data as it can hold. If the requested space is too large, the extra memory requested is set to 0.

The data is returned in the buffer in the following format:

country (USHORT) - Country code identifier.
codepage (USHORT) - Code page identifier.
dateformat (USHORT) - Date format.
Value
 Definition 0
 mm/dd/yy 1
 dd/mm/yy 2
 yy/mm/dd currency (CHAR)
 Currency identifier, terminated with a null. thousandsep (CHAR)
 Thousands separator, terminated with a null. decimalsep (CHAR)
 Decimal separator, terminated with a null. datesep (CHAR)
 Date separator, terminated with a null. timesep (CHAR)
 Time separator, terminated with a null. currencyformat (UCHAR)
 The currency bit fields in the following format:
Bit  Description
7-3  Reserved 2
     0 = Bits 0 and 1 are used.
     1 = Bits 0 and 1 are ignored; the currency indicator replaces the decimal indicator. 
1
     0 = No space between the currency indicator and money value.
     1 = One space between the currency indicator and money value. 
0
     0 = Currency indicator precedes the money value.
     1 = Currency indicator follows the money value. 
decimalspace (UCHAR)
 Number (in binary) of decimal spaces used to indicate currency value.
timeformat (UCHAR)
 Time format for presentation in file directory:
  Bit  Description
  7-1  Reserved
  0    0 = 12-hour format 
       1 = 24-hour format.
reserved (USHORT) Reserved, set to zero. 
datalistsep (CHAR) Data list separator, terminated with a null.
reserved (USHORT) Reserved, set to zero.
DataLength (PUSHORT) - output
Address of the length, in bytes, of the country dependent information. rc (USHORT) - return

Returns

Return code descriptions are:

  • NO_ERROR
  • 396 ERROR_NLS_NO_COUNTRY_FILE
  • 397 ERROR_NLS_OPEN_FAILED
  • 398 ERROR_NO_COUNTRY_OR_CODEPAGE
  • 399 ERROR_NLS_TABLE_TRUNCATED

Remarks

The returned country dependent information may be for the default country and current process code page, or for a specific country and code page. For more information on code page, see DosSetCp.

Family API Considerations

Some options operate differently in DOS mode than in OS/2 mode. Note that not all country information is available in DOS 3.3.

C Binding

typedef struct _COUNTRYCODE {   /* ctryc */
 
  USHORT country;               /* country code */
  USHORT codepage;              /* code page */
 
} COUNTRYCODE;

typedef struct _COUNTRYINFO {   /* ctryi */
 
  USHORT country;                   /* country code */
  USHORT codepage;                  /* code page */
  USHORT fsDateFmt;                 /* date format */
  CHAR   szCurrency[5];             /* currency indicator */
  CHAR   szThousandsSeparator[2];   /* thousands separator */
  CHAR   szDecimal[2];              /* decimal separator *  /
  CHAR   szDateSeparator[2];        /* date separator */
  CHAR   szTimeSeparator[2];        /* time separator */
  UCHAR  fsCurrencyFmt;             /* bit fields for currency format */
  UCHAR  cDecimalPlace;             /* currency decimal places */
  UCHAR  fsTimeFmt;                 /* Time format (AM/PM or 24 hr) */
  USHORT abReserved1[2];            /* reserved (0) */
  CHAR   szDataSeparator[2];        /* Data list separator */
  USHORT abReserved2[5];            /* reserved (0) */
 
} COUNTRYINFO;

#define INCL_DOSNLS

USHORT  rc = DosGetCtryInfo(Length, Structure, MemoryBuffer, DataLength);

USHORT           Length;        /* Length of data area provided */
PCOUNTRYCODE     Structure;     /* Input data structure */
PCOUNTRYINFO     MemoryBuffer;  /* Country information (returned) */
PUSHORT          DataLength;    /* Length of data (returned) */

USHORT           rc;            /* return code */

Example

This example gets country-dependent information.

#define INCL_DOSNLS

#define CURRENT_COUNTRY 0
#define NLS_CODEPAGE 850

COUNTRYCODE Country;
COUNTRYINFO CtryBuffer;
USHORT      Length;
USHORT      rc;

   Country.country = CURRENT_COUNTRY;
   Country.codepage = NLS_CODEPAGE;

   rc = DosGetCtryInfo(sizeof(CtryBuffer), /* Length of data area provided */
                       &Country,           /* Input data structure */
                       &CtryBuffer,        /* Data area to be filled by function */
                       &Length);           /* Length of data returned */

MASM Binding

COUNTRYCODE struc
  ctryc_country   dw  ? ;country code
  ctryc_codepage  dw  ? ;code page
COUNTRYCODE ends

COUNTRYINFO struc
  ctryi_country              dw  ? ;country code
  ctryi_codepage             dw  ? ;code page
  ctryi_fsDateFmt            dw  ? ;date format
  ctryi_szCurrency           db  5 dup (?) ;currency indicator
  ctryi_szThousandsSeparator db  2 dup (?) ;thousands separator
  ctryi_szDecimal            db  2 dup (?) ;decimal separator
  ctryi_szDateSeparator      db  2 dup (?) ;date separator
  ctryi_szTimeSeparator      db  2 dup (?) ;time separator
  ctryi_fsCurrencyFmt        db  ? ;bit fields for currency format
  ctryi_cDecimalPlace        db  ? ;currency decimal places
  ctryi_fsTimeFmt            db  ? ;Time format (AM/PM or 24 hr)
  ctryi_abReserved1          dw  2 dup (?) ;reserved (0)
  ctryi_szDataSeparator      db  2 dup (?) ;Data list separator
  ctryi_abReserved2          dw  5 dup (?) ;reserved (0)
COUNTRYINFO ends

EXTRN  DosGetCtryInfo:FAR
INCL_DOSNLS         EQU 1

PUSH   WORD    Length        ;Length of data area provided
PUSH@  OTHER   Structure     ;Input data structure
PUSH@  OTHER   MemoryBuffer  ;Country information (returned)
PUSH@  WORD    DataLength    ;Length of data (returned)
CALL   DosGetCtryInfo

Returns WORD