home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / TRSICAT.LZX / CATS_CD2_TRSI / Inc&AD2.1 / Text_Autodocs / locale.doc < prev    next >
Encoding:
Text File  |  1992-09-11  |  32.0 KB  |  947 lines

  1. TABLE OF CONTENTS
  2.  
  3. locale.library/--rexxhost--
  4. locale.library/--structures--
  5. locale.library/CloseCatalog
  6. locale.library/CloseLocale
  7. locale.library/ConvToLower
  8. locale.library/ConvToUpper
  9. locale.library/FormatDate
  10. locale.library/FormatString
  11. locale.library/GetCatalogStr
  12. locale.library/GetLocaleStr
  13. locale.library/IsXXXX
  14. locale.library/OpenCatalog
  15. locale.library/OpenLocale
  16. locale.library/ParseDate
  17. locale.library/StrConvert
  18. locale.library/StrnCmp
  19. locale.library/--rexxhost--                       locale.library/--rexxhost--
  20.  
  21.    HOST INTERFACE
  22.     locale.library provides an ARexx function host interface that enables
  23.     ARexx programs to take advantage of system localization. The
  24.     functions provided by the interface are directly related to the
  25.     functions described herein, with the differences mostly being
  26.     in the way they are called.
  27.  
  28.     The function host library vector is located at offset -30 from the
  29.     library. This is the value you provide to ARexx in the AddLib()
  30.     function call.
  31.  
  32.    FUNCTIONS
  33.     CloseCatalog (CATALOG/N/A)
  34.     ConvToLower (CHARACTER/A)
  35.     ConvToUpper (CHARACTER/A)
  36.     GetCatalogStr (CATALOG/A,STRING/N/A,DEFAULT/A)
  37.     IsAlNum (CHARACTER/A)
  38.     IsAlpha (CHARACTER/A)
  39.     IsCntrl (CHARACTER/A)
  40.     IsDigit (CHARACTER/A)
  41.     IsGraph (CHARACTER/A)
  42.     IsLower (CHARACTER/A)
  43.     IsPrint (CHARACTER/A)
  44.     IsPunct (CHARACTER/A)
  45.     IsSpace (CHARACTER/A)
  46.     IsUpper (CHARACTER/A)
  47.     IsXDigit (CHARACTER/A)
  48.     OpenCatalog (NAME/A,BUILTINLANGUAGE/A,VERSION/N/A)
  49.     Strncmp (STRING1/A,STRING2/A,TYPE/N/A)
  50.  
  51.    EXAMPLE
  52.     /* localetest.rexx */
  53.  
  54.     /* Make sure locale is loaded as a function host */
  55.     IF ~SHOW(L,'locale.library') THEN DO
  56.       CALL ADDLIB('locale.library',0,-30)
  57.     END;
  58.  
  59.     say ConvToLower("A");
  60.     say ConvToUpper("b");
  61.     say IsAlpha("1");
  62.  
  63.     catalog = OpenCatalog("sys/workbench.catalog","english",0);
  64.     say GetCatalogStr(catalog,34,"default");
  65.     say CloseCatalog(catalog);
  66.     say StrnCmp("test","test",2);
  67.  
  68. locale.library/--structures--                   locale.library/--structures--
  69.  
  70.     The Locale structure is the main public structure provided by
  71.     locale.library. The structure is defined in <libraries/locale.h>
  72.     and consists of the following fields:
  73.  
  74.     STRPTR loc_LocaleName
  75.         Locale's name.
  76.  
  77.     STRPTR loc_LanguageName
  78.         The language of the driver bound to this locale.
  79.  
  80.     STRPTR loc_PrefLanguages[10]
  81.         The ordered list of preferred languages for this locale.
  82.  
  83.     ULONG loc_Flags
  84.         Locale flags. Currently always 0.
  85.  
  86.     ULONG loc_CodeSet
  87.         Specifies the code set required by this locale. Currently, this
  88.         value is always 0.
  89.  
  90.     ULONG loc_CountryCode
  91.         The international country code.
  92.  
  93.     ULONG loc_TelephoneCode
  94.         The international telephone code for the country.
  95.  
  96.     LONG loc_GMTOffset
  97.         The offset in minutes of the current location from GMT.
  98.  
  99.     UBYTE loc_MeasuringSystem
  100.         The measuring system being used.
  101.  
  102.     STRPTR loc_DateTimeFormat
  103.         The date and time format string, ready to pass to FormatDate()
  104.  
  105.     STRPTR loc_DateFormat
  106.         The date format string.
  107.  
  108.     STRPTR loc_TimeFormat
  109.         The time format string.
  110.  
  111.     STRPTR loc_ShortDateTimeFormat
  112.         The short date and time format string, ready to pass to
  113.         FormatDate()
  114.  
  115.     STRPTR loc_ShortDateFormat
  116.         The short date format string.
  117.  
  118.     STRPTR loc_ShortTimeFormat
  119.         The short time format string.
  120.  
  121.     STRPTR loc_DecimalPoint
  122.         The decimal point character used to format non-monetary quantities.
  123.  
  124.     STRPTR loc_GroupSeparator
  125.         The characters used to separate groups of digits before the
  126.         decimal-point character in formatted non-monetary quantities.
  127.  
  128.     STRPTR loc_FracGroupSeparator
  129.         The characters used to separate groups of digits after the
  130.         decimal-point character in formatted non-monetary quantities.
  131.  
  132.     STRPTR loc_Grouping
  133.         A string whose elements indicate the size of each group of digits
  134.         before the decimal-point character in formatted non-monetary
  135.         quantities.
  136.  
  137.     STRPTR loc_FracGrouping
  138.         A string whose elements indicate the size of each group of digits
  139.         after the decimal-point character in formatted non-monetary
  140.         quantities.
  141.  
  142.     STRPTR loc_MonDecimalPoint
  143.         The decimal-point used to format monetary quantities.
  144.  
  145.     STRPTR loc_MonGroupSeparator
  146.         The separator for groups of digits before the decimal-point in
  147.         monetary quantities.
  148.  
  149.     STRPTR loc_MonFracGroupSeparator
  150.         The separator for groups of digits after the decimal-point in
  151.         monetary quantities.
  152.  
  153.     STRPTR loc_MonGrouping
  154.         A string whose elements indicate the size of each group of digits
  155.         before the decimal-point character in monetary quantities.
  156.  
  157.     STRPTR loc_MonFracGrouping
  158.         A string whose elements indicate the size of each group of digits
  159.         after the decimal-point character in monetary quantities.
  160.  
  161.     UBYTE loc_MonFracDigits
  162.         The number of fractional digits (those after the decimal-point)
  163.         to be displayed in a formatted monetary quantity.
  164.  
  165.     UBYTE loc_MonIntFracDigits
  166.         The number of fractional digits (those after the decimal-point)
  167.         to be displayed in an internationally formatted monetary quantity.
  168.  
  169.     STRPTR loc_MonCS
  170.         The local currency symbol applicable to the current locale.
  171.  
  172.     STRPTR loc_MonSmallCS
  173.         The currency symbol for small amounts.
  174.  
  175.     STRPTR loc_MonIntCS
  176.         The international currency symbol applicable to the current
  177.         locale. The first three characters contain the alphabetic
  178.         international currency symbol in accordance with those specified
  179.         in ISO 4217 Codes for the Representation of Currency and Funds.
  180.         The fourth character (immediately preceding the NULL) is the
  181.         character used to separate the international currency symbol from
  182.         the monetary quantity.
  183.  
  184.     STRPTR loc_MonPositiveSign
  185.         The string used to indicate a non-negative monetary quantity.
  186.  
  187.     UBYTE loc_MonPositiveSpaceSep
  188.         Specifies the number of spaces separating the currency symbol from
  189.         the non-negative monetary quantity.
  190.  
  191.     UBYTE loc_MonPositiveSignPos
  192.         Set to a value indicating the positioning of loc_MonPositiveSign
  193.         for a non-negative monetary quantity.
  194.  
  195.     UBYTE loc_MonPositiveCSPos
  196.         Set to 1 or 0 if loc_MonCS respectively precedes or succeeds
  197.         the value for a non-negative monetary quantity.
  198.  
  199.     STRPTR loc_MonNegativeSign
  200.         The string used to indicate a negative monetary quantity.
  201.  
  202.     UBYTE loc_MonNegativeSpaceSep
  203.         Specifies the number of spaces separating the currency symbol from
  204.         the negative monetary quantity.
  205.  
  206.     UBYTE loc_MonNegativeSignPos
  207.         Set to a value indicating the positioning of loc_MonNegativeSign
  208.         for a negative monetary quantity.
  209.  
  210.     UBYTE loc_MonNegativeCSPos
  211.         Set to 1 or 0 if loc_MonCS respectively precedes or succeeds
  212.         the value for a negative monetary quantity.
  213.  
  214.  
  215.     The grouping tables pointed to by loc_Grouping, loc_FracGrounping,
  216.     loc_MonGrouping, and loc_MonFracGrouping contain a stream of bytes
  217.     with the following values:
  218.  
  219.         255        No further grouping is to be performed.
  220.  
  221.         0        The previous element is to be repeatedly used for the
  222.             remainder of the digits.
  223.  
  224.         1..254    The integer value is the number of digits that comprise
  225.             the current group. The next element is examined to
  226.             determine the size of the next group of digits before
  227.             the current group.
  228.  
  229.     The values of loc_MonPositiveSignPos and loc_MonNegativeSignPos are
  230.     interpreted according to the following:
  231.  
  232.         0        Parentheses surround the quantity and currency symbol
  233.  
  234.         1        The sign string precedes the quantity and
  235.             currency symbol
  236.  
  237.         2        The sign string succeeds the quantity and
  238.             currency symbol
  239.  
  240.         3        The sign string immediately precedes the
  241.             currency symbol
  242.  
  243.         4        The sign string immediately succeeds the
  244.             currency symbol.
  245.  
  246. locale.library/CloseCatalog                       locale.library/CloseCatalog
  247.  
  248.    NAME
  249.     CloseCatalog -- close a message catalog. (V38)
  250.  
  251.    SYNOPSIS
  252.     CloseCatalog(catalog);
  253.                  A0
  254.  
  255.     VOID CloseCatalog(struct Catalog *);
  256.  
  257.    FUNCTION
  258.     Concludes access to a message catalog. The usage count of the
  259.     catalog is decremented. When this count reaches 0, the catalog
  260.     can be expunged from system memory whenever a memory panic occurs.
  261.  
  262.    INPUTS
  263.     catalog - the message catalog to close. A NULL catalog is a valid
  264.           parameter and is simply ignored.
  265.  
  266.    SEE ALSO
  267.     OpenCatalog(), GetCatalogStr()
  268.  
  269. locale.library/CloseLocale                         locale.library/CloseLocale
  270.  
  271.    NAME
  272.     CloseLocale -- close a locale. (V38)
  273.  
  274.    SYNOPSIS
  275.     CloseLocale(locale);
  276.                 A0
  277.  
  278.     VOID CloseLocale(struct Locale *);
  279.  
  280.    FUNCTION
  281.     Concludes access to a locale.
  282.  
  283.    INPUTS
  284.     locale - an opened locale. A NULL locale is a valid
  285.          parameter and is simply ignored.
  286.  
  287.    SEE ALSO
  288.     OpenLocale(), <libraries/locale.h>
  289.  
  290. locale.library/ConvToLower                         locale.library/ConvToLower
  291.  
  292.    NAME
  293.     ConvToLower -- convert a character to lower case. (V38)
  294.  
  295.    SYNOPSIS
  296.     char = ConvToLower(locale,character);
  297.     D0               A0     D0
  298.  
  299.     ULONG ConvToLower(struct Locale *,ULONG);
  300.  
  301.    FUNCTION
  302.     This function tests if the character specified is upper case. If it is
  303.     then the lower case version of that character is returned, and if it
  304.     isn't then the original character is returned.
  305.  
  306.    INPUTS
  307.     locale - the locale to use for the conversion
  308.     character - the character to convert
  309.  
  310.    RESULT
  311.     char - a (possibly) converted character
  312.  
  313.    NOTE
  314.     This function requires a full 32-bit character be passed-in in order
  315.     to support multi-byte character sets.
  316.  
  317. locale.library/ConvToUpper                         locale.library/ConvToUpper
  318.  
  319.    NAME
  320.     ConvToUpper -- convert a character to upper case. (V38)
  321.  
  322.    SYNOPSIS
  323.     char = ConvToUpper(locale,character);
  324.     D0               A0     D0
  325.  
  326.     ULONG ConvToUpper(struct Locale *,ULONG);
  327.  
  328.    FUNCTION
  329.     This function tests if the character specified is lower case. If it is
  330.     then the upper case version of that character is returned, and if it
  331.     isn't then the original character is returned.
  332.  
  333.    INPUTS
  334.     locale - the locale to use for the conversion
  335.     character - the character to convert
  336.  
  337.    RESULT
  338.     char - a (possibly) converted character
  339.  
  340.    NOTE
  341.     This function requires a full 32-bit character be passed-in in order
  342.     to support multi-byte character sets.
  343.  
  344. locale.library/FormatDate                           locale.library/FormatDate
  345.  
  346.    NAME
  347.     FormatDate -- generate a date string based on a date formatting
  348.               template. (V38)
  349.  
  350.    SYNOPSIS
  351.     FormatDate(locale,string,date,putCharFunc);
  352.                A0     A1     A2   A3
  353.  
  354.     VOID FormatDate(struct Locale *,STRPTR,struct DateStamp *,
  355.                     struct Hook *);
  356.  
  357.    FUNCTION
  358.     This function processes a formatting template and generates
  359.     a stream of bytes that's sent one character at a time to the
  360.     putCharFunc callback hook.
  361.  
  362.    INPUTS
  363.     locale - the locale to use for the formatting
  364.     string - the NULL-terminated template describing the desired format
  365.          for the date. This is constructed just like C-language
  366.          printf() statements, except that different formatting codes
  367.              are used. Just like in C, formatting codes start with a
  368.              % followed by the formatting command. The following
  369.          commands are accepted by this function:
  370.  
  371.                  %a - abbreviated weekday name
  372.                  %A - weekday name
  373.                  %b - abbreviated month name
  374.                  %B - month name
  375.                  %c - same as "%a %b %d %H:%M:%S %Y"
  376.                  %C - same as "%a %b %e %T %Z %Y"
  377.                  %d - day number with leading 0s
  378.                  %D - same as "%m/%d/%y"
  379.                  %e - day number with leading spaces
  380.                  %h - abbreviated month name
  381.                  %H - hour using 24-hour style with leading 0s
  382.                  %I - hour using 12-hour style with leading 0s
  383.                  %j - julian date
  384.                  %m - month number with leading 0s
  385.                  %M - the number of minutes with leading 0s
  386.                  %n - insert a linefeed
  387.                  %p - AM or PM strings
  388.                  %q - hour using 24-hour style
  389.                  %Q - hour using 12-hour style
  390.                  %r - same as "%I:%M:%S %p"
  391.                  %R - same as "%H:%M"
  392.                  %S - number of seconds with leadings 0s
  393.                  %t - insert a tab character
  394.                  %T - same as "%H:%M:%S"
  395.                  %U - week number, taking Sunday as first day of week
  396.                  %w - weekday number
  397.                  %W - week number, taking Monday as first day of week
  398.                  %x - same as "%m/%d/%y"
  399.                  %X - same as "%H:%M:%S"
  400.                  %y - year using two digits with leading 0s
  401.                  %Y - year using four digits with leading 0s
  402.  
  403.              If the template parameter is NULL, a single NULL byte
  404.          is sent to putCharFunc.
  405.     date - the date to format into a string
  406.     putCharFunc - a callback hook invoked for every character generated,
  407.               including for the terminating NULL character. The hook
  408.               is called with:
  409.  
  410.              A0 - address of Hook structure
  411.             A1 - character for hook to process (not a pointer!)
  412.                     A2 - locale pointer
  413.  
  414.    SEE ALSO
  415.     ParseDate(), <libraries/locale.h>, <dos/dos.h>
  416.  
  417. locale.library/FormatString                       locale.library/FormatString
  418.  
  419.    NAME
  420.     FormatString -- format data into a character stream. (V38)
  421.  
  422.    SYNOPSIS
  423.     next = FormatString(locale,string,dataStream,putCharFunc);
  424.     D0                  A0     A1     A2         A3
  425.  
  426.     APTR FormatString(struct Locale *,STRPTR,APTR,struct Hook *);
  427.  
  428.    FUNCTION
  429.     This function performs C-language-like formatting of a data stream,
  430.     outputting the result a character at a time. Where % formatting
  431.     commands are found in the string, they are replaced with the
  432.     corresponding elements in 'dataStream'. %% must be used in the
  433.     string if a % is desired in the output.
  434.  
  435.     An extension to the standard C-language printf() conventions used
  436.     by FormatString() is argument position specification. Specifying the
  437.     argument position lets the order of the % commands change while the
  438.     arguments provided remain the same. Using the C printf() call as an
  439.     example:
  440.         printf("%d eyes, %d feet and %d ears",eyes,feet,ears);
  441.         printf("%3$d ears, %1$d eyes and %2$d feet",eyes,feet,ears);
  442.     These two statements would produce the following output:
  443.         "2 eyes, 3 feet and 4 ears" for the first
  444.             "4 ears, 2 eyes and 3 feet" for the second
  445.  
  446.     The argument positioning feature lets you change the format string
  447.     being processed while keeping the data stream the same. This is
  448.     an invaluable tool when translating strings to different languages.
  449.  
  450.    INPUTS
  451.     locale - the locale to use for the formatting
  452.     string - a C-language-like NULL-terminated format string,
  453.          with the following supported % options:
  454.  
  455.       %[arg_pos$][flags][width][.limit][length]type
  456.  
  457.       arg_pos - ordinal position of the argument for this command within
  458.             the array of arguments pointed to by 'dataStream'
  459.         $     - must follow the arg_pos value, if specified
  460.       flags   - only one allowed. '-' specifies left justification.
  461.       width   - field width. If the first character is a '0', the
  462.                 field is padded with leading 0s.
  463.         .     - must precede the field limit value, if specified
  464.       limit   - maximum number of characters to output from a string.
  465.                 (only valid for %s or %b).
  466.       length  - size of input data defaults to word (16-bit) for types c,
  467.             d, u and x, 'l' changes this to long (32-bit).
  468.       type    - supported types are:
  469.                       b - BSTR, data is 32-bit BPTR to byte count followed
  470.                           by a byte string. A NULL BPTR is treated as an
  471.                   empty string.
  472.                       d - signed decimal
  473.               D - signed decimal using the locale's formatting
  474.                   conventions
  475.               u - unsigned decimal
  476.               U - unsigned decimal using the locale's formatting
  477.                   conventions
  478.                       x - hexadecimal with hex digits in uppercase
  479.               X - hexadecimal with hex digits in lowercase
  480.                       s - string, a 32-bit pointer to a NULL-terminated
  481.                           byte string. A NULL pointer is treated
  482.                           as an empty string.
  483.                       c - character
  484.  
  485.              If the string parameter is NULL, the function returns without
  486.          outputting anything. Note the meaning of %x and %X are
  487.          swapped with respect to standard C conventions. This is for
  488.          compatibility with exec.library/RawDoFmt().
  489.  
  490.     dataStream - a stream of data that is interpreted according to
  491.              the format string. Often this is a pointer into
  492.              the task's stack.
  493.     putCharFunc - a callback hook invoked for every character generated,
  494.               including for the terminating NULL character. The hook
  495.               is called with:
  496.  
  497.              A0 - address of Hook structure
  498.             A1 - character for hook to process (not a pointer!)
  499.                     A2 - locale pointer
  500.  
  501.              the function is called with a NULL char at the end of
  502.              the format string.
  503.  
  504.    RESULT
  505.     next - A pointer to beyond the last data element used in 'dataStream'
  506.            (the next argument that would have been processed).
  507.            This allows multiple formatting passes to be made using the
  508.            same data.
  509.  
  510.    WARNING
  511.     This function formats word values in the data stream. If your compiler
  512.     defaults to longs, you must add an "l" to your specifications. This
  513.     can get strange for characters, which might look like "%lc".
  514.  
  515.    SEE ALSO
  516.     exec.library/RawDoFmt()
  517.  
  518. locale.library/GetCatalogStr                     locale.library/GetCatalogStr
  519.  
  520.    NAME
  521.     GetCatalogStr -- get a string from a message catalog. (V38)
  522.  
  523.    SYNOPSIS
  524.     string = GetCatalogStr(catalog,stringNum,defaultString);
  525.     D0                     A0      D0        A1
  526.  
  527.     STRPTR GetCatalogStr(struct Catalog *,LONG,STRPTR);
  528.  
  529.    FUNCTION
  530.     This function returns a specific string within a message catalog.
  531.     If the catalog parameter is NULL, or the requested message does not
  532.     exist, then defaultString is returned.
  533.  
  534.    INPUTS
  535.     catalog - a message catalog as obtained from OpenCatalog(), or NULL
  536.     stringNum - a message number within the catalog
  537.     defaultString - string to return in case "catalog" is NULL or
  538.                     "stringNum" can't be found
  539.  
  540.    RESULT
  541.     string - a pointer to a NULL-terminated string. The returned string
  542.          is READ-ONLY, do NOT modify! This string pointer is valid
  543.          only as long as the catalog remains open.
  544.  
  545.    SEE ALSO
  546.     OpenCatalog(), CloseCatalog()
  547.  
  548. locale.library/GetLocaleStr                       locale.library/GetLocaleStr
  549.  
  550.    NAME
  551.     GetLocaleStr -- get a standard string from a locale. (V38)
  552.  
  553.    SYNOPSIS
  554.     string = GetLocaleStr(locale,stringNum);
  555.     D0                    A0     D0
  556.  
  557.     STRPTR GetLocaleStr(struct Locale *,ULONG);
  558.  
  559.    FUNCTION
  560.     This function returns a specific string associated with the given
  561.     locale.
  562.  
  563.    INPUTS
  564.     locale - a valid locale
  565.     stringNum - the number of the string to get a pointer to. See the
  566.             constants defined in <libraries/locale.h> for the
  567.             possible values.
  568.  
  569.    RESULT
  570.     string - a pointer to a NULL-terminated string, or NULL if the
  571.          requested string number was out of bounds. The returned
  572.          string is READ-ONLY, do NOT modify! This string pointer
  573.          is valid only as long as the locale remains open.
  574.  
  575.    SEE ALSO
  576.     OpenLocale(), CloseLocale(), <libraries/locale.h>
  577.  
  578. locale.library/IsXXXX                                   locale.library/IsXXXX
  579.  
  580.    NAME
  581.     IsXXXX -- determine whether a character is of a certain type. (V38)
  582.  
  583.    SYNOPSIS
  584.     state = IsXXXX(locale,character);
  585.     D0           A0     D0
  586.  
  587.     BOOL IsXXXX(struct Locale *,ULONG);
  588.  
  589.    FUNCTION
  590.     These functions determine whether the character specified is of a
  591.     certain type, according to the supplied locale.
  592.  
  593.     IsAlNum() - test if alphanumeric character
  594.     IsAlpha() - test if alphabetical character
  595.     IsCntrl() - test if control character
  596.     IsDigit() - test if decimal digit character
  597.     IsGraph() - test if visible character
  598.     IsLower() - test if lower case character
  599.     IsPrint() - test if blank
  600.     IsPunct() - test if punctuation character
  601.     IsSpace() - test if white space character
  602.     IsUpper() - test if upper case character
  603.     IsXDigit() - test if hexadecimal digit
  604.  
  605.    INPUTS
  606.     locale - the locale to use for the test
  607.     character - the character to test
  608.  
  609.    RESULT
  610.     state - TRUE if the character is of the required type, FALSE otherwise
  611.  
  612.    NOTE
  613.     These functions require full 32-bit characters be passed-in in order
  614.     to support multi-byte character sets.
  615.  
  616. locale.library/OpenCatalog                         locale.library/OpenCatalog
  617.  
  618.    NAME
  619.     OpenCatalogA -- open a message catalog. (V38)
  620.     OpenCatalog -- varargs stub for OpenCatalogA(). (V38)
  621.  
  622.    SYNOPSIS
  623.     catalog = OpenCatalogA(locale,name,tagList);
  624.     D0                     A0     A1   A2
  625.  
  626.     struct Catalog *OpenCatalogA(struct Locale *,STRPTR,struct TagItem *);
  627.  
  628.     catalog = OpenCatalog(locale,name,firstTag, ...);
  629.  
  630.     struct Catalog *OpenCatalog(struct Locale *,STRPTR,Tag, ...);
  631.  
  632.    FUNCTION
  633.     This function opens a message catalog. Catalogs contain all the
  634.     text strings that an application uses. These strings can easily
  635.     be replaced by strings in a different language, which causes the
  636.     application to magically start operating in that new language.
  637.  
  638.     Catalogs originally come from disk files. This function searches for
  639.     them in the following places:
  640.  
  641.         PROGDIR:Catalogs/languageName/name
  642.         LOCALE:Catalogs/languageName/name
  643.  
  644.     where languageName is the name of the language associated with the
  645.     locale parameter. So assuming an application called WizPaint:
  646.  
  647.         catalog = OpenCatalog(NULL,
  648.                       "WizPaint.catalog",
  649.                       OC_BuiltInLanguage,"english",
  650.                       TAG_DONE);
  651.  
  652.     Passing NULL as first parameter to OpenCatalog() indicates you
  653.     wish to use the system's default locale. Assuming the default locale
  654.     specifies "deutsch" as language, OpenCatalog() tries to open the
  655.     catalog as:
  656.  
  657.         PROGDIR:Catalogs/deutsch/WizPaint.catalog
  658.  
  659.     and if that file is not found, then OpenCatalog() tries to open it
  660.     as:
  661.  
  662.         LOCALE:Catalogs/deutsch/WizPaint.catalog
  663.  
  664.     PROGDIR: is not always checked before LOCALE: is. If the volume which
  665.     PROGDIR: is assigned to is NOT currently mounted, and if the one
  666.     which LOCALE: is assigned to IS mounted, then LOCALE: is checked
  667.     first, followed by PROGDIR: if needed. This is done in order to
  668.     minimize the number of disk swaps on floppy systems.
  669.  
  670.     The OC_BuiltInLanguage tag specifies the language of the strings
  671.     that are built into the application. If the language of the
  672.     built-in strings matches that of the locale, then no catalog
  673.     need be loaded from disk and the built-in strings can be used
  674.     directly.
  675.  
  676.     locale.library caches text catalogs in order to minimize disk
  677.     access. As such, OpenCatalog() may or may not cause disk access.
  678.     This fact should be taken into consideration. Unused catalogs are
  679.     automatically flushed from the system when there is not enough
  680.     memory. When there is disk access, it is possible a DOS requester
  681.     may be opened asking for a volume to be inserted. You can avoid this
  682.     requester opening by setting your process' pr_WindowPtr field to -1.
  683.  
  684.    INPUTS
  685.     locale - the locale for which the catalog should be opened, or NULL.
  686.          When NULL, then the system's default locale is used. This
  687.          should generally be NULL
  688.     name - the NULL-terminated name of the catalog to open, typically
  689.            the application name with a ".catalog" extension
  690.     tagList - pointer to an array of tags providing optional extra
  691.           parameters, or NULL
  692.  
  693.    TAGS
  694.     OC_BuiltInLanguage (STRPTR) - language of built-in strings of the
  695.                       application. That is, this tag identifies
  696.                       the language used for the "defaultString"
  697.                       parameter used in the GetCatalogStr()
  698.                       function. Default is "english". Providing
  699.                       this tag and setting its value to NULL
  700.                       indicates that there are no built-in
  701.                       strings.
  702.  
  703.     OC_BuiltInCodeSet (ULONG) - code set of built-in strings. Default is 0.
  704.                     THIS TAG SHOULD ALWAYS BE SET TO 0 FOR NOW.
  705.  
  706.     OC_Language (STRPTR) - language explicitly requested for the catalog.
  707.                    A catalog of this language will be returned if
  708.                    possible, otherwise a catalog in one of the
  709.                    user's preferred languages. This tag should
  710.                    normally not be provided as it overrides the
  711.                    user's preferences.
  712.  
  713.     OC_Version (UWORD) - catalog version number required. Default is 0
  714.                  which means to accept any version of the catalog
  715.                  that is found. Note that if a version is
  716.                  specified, the catalog's version much match it
  717.                  exactly. This is different from version numbers
  718.                  used by OpenLibrary().
  719.  
  720.    RESULT
  721.     catalog - a message catalog to use with GetCatalogStr() or NULL.
  722.           A NULL result does not necessarily indicate an error.
  723.           If OpenCatalog() determines that the built-in strings of
  724.           the application can be used instead of an external catalog
  725.           from disk, then NULL is returned. To determine whether
  726.           a NULL result actually indicates an error, look at the
  727.           return value of dos.library/IoErr(). 0 means no error.
  728.  
  729.           GetCatalogStr() interprets a NULL catalog as meaning to use
  730.           the built-in strings.
  731.  
  732.    NOTE
  733.     In most cases, failing to open a catalog should not be considered a
  734.     fatal error, and the application should continue operating and
  735.     simply use the built-in set of strings instead of the disk-based
  736.     catalog. Note that GetCatalogStr() accepts a NULL catalog pointer for
  737.     this very reason.
  738.  
  739.     Also note that displaying an error message when a catalog fails to
  740.     open can be a meaningless endeavor as the message is likely in a
  741.     language the user does not understand.
  742.  
  743.    SEE ALSO
  744.     CloseCatalog(), GetCatalogStr()
  745.  
  746. locale.library/OpenLocale                           locale.library/OpenLocale
  747.  
  748.    NAME
  749.     OpenLocale -- open a locale. (V38)
  750.  
  751.    SYNOPSIS
  752.     locale = OpenLocale(name);
  753.     D0                  A0
  754.  
  755.     struct Locale *OpenLocale(STRPTR);
  756.  
  757.    FUNCTION
  758.     This function opens a named locale. Locales contain many parameters
  759.     that an application needs to consider when being integrated into
  760.     different languages, territories and customs. Using the information
  761.     stored in a locale instead of hard-coding it into an application,
  762.     lets the application dynamically adapt to the user's environment.
  763.  
  764.     Locales originally come from disk files which are created by the
  765.     user using the Locale preferences editor. Passing a NULL instead of
  766.     a name causes this function to return the current default locale.
  767.     This is what most applications will do.
  768.  
  769.     Every locale specifies a language, and special language drivers
  770.     must be loaded from disk depending on which language is being used.
  771.     These files include for example:
  772.  
  773.         LOCALE:Languages/français.language
  774.         LOCALE:Languages/dansk.language
  775.         LOCALE:Languages/italiano.language
  776.  
  777.    INPUTS
  778.     name - the NULL-terminated name of the locale to open, or NULL to open
  779.            the current default locale. This should generally be NULL.
  780.  
  781.    RESULT
  782.     locale - a pointer to an initialized Locale structure, or NULL if the
  783.          locale could not be loaded. In the case of a NULL return, the
  784.          DOS IoErr() function can be called to obtain more information
  785.          on the failure.
  786.  
  787.          When passing a NULL name parameter to this function, you are
  788.          guaranteed a valid return.
  789.  
  790.    SEE ALSO
  791.     CloseLocale(), <libraries/locale.h>
  792.  
  793. locale.library/ParseDate                             locale.library/ParseDate
  794.  
  795.    NAME
  796.     ParseDate -- interpret a string according to the date formatting
  797.              template and convert it into a DateStamp. (V38)
  798.  
  799.    SYNOPSIS
  800.     state = ParseDate(locale,date,template,getCharFunc);
  801.     D0              A0     A1   A2       A3
  802.  
  803.     BOOL ParseDate(struct Locale *,struct DateStamp *,STRPTR,struct Hook *);
  804.  
  805.    FUNCTION
  806.     This function converts a stream of characters into an AmigaDOS
  807.     DateStamp structure. The characters are obtained from the
  808.     getCharFunc callback hook and the formatting template is used
  809.     to direct the parse.
  810.  
  811.    INPUTS
  812.     locale - the locale to use for the formatting
  813.     date - place to put the converted date, this may be NULL in which
  814.            case this routine can be used to simply validate a date
  815.     template - the date template describing the expected format of the
  816.            data. See FormatDate() documentation for a description of
  817.            date templates. The following formatting controls from
  818.            FormatDate() can be used in ParseDate():
  819.                  %a %A %b %B %d %e %h %H %I %m %M %p %S %y %Y
  820.     getCharFunc - a callback hook invoked whenever a character is required.
  821.               The hook should return the next character to process,
  822.               with a NULL character to indicate the end of the string.
  823.               The hook is called with:
  824.  
  825.              A0 - address of Hook structure
  826.                     A1 - locale pointer
  827.             A2 - NULL
  828.  
  829.                   The hook returns the character to process in D0. Note
  830.               that a complete 32-bit result is expected in D0, not
  831.               just 8 bits.
  832.  
  833.    RESULT
  834.     state - TRUE if the parsing went OK, or FALSE if the input did not
  835.         match the template
  836.  
  837.    SEE ALSO
  838.     FormatDate(), <dos/dos.h>
  839.  
  840. locale.library/StrConvert                           locale.library/StrConvert
  841.  
  842.    NAME
  843.     StrConvert -- transform a string according to collation information.
  844.               (V38)
  845.  
  846.    SYNOPSIS
  847.     length = StrConvert(locale,string,buffer,bufferSize,type);
  848.     D0                  A0     A1     A2     D0         D1
  849.  
  850.     ULONG StrConvert(struct Locale *,STRPTR,APTR,ULONG,ULONG);
  851.  
  852.    FUNCTION
  853.     This function transforms the passed string and places the resulting
  854.     into the supplied buffer. No more than bufferSize bytes are copied
  855.     into the buffer.
  856.  
  857.     The transformation is such that if the C strcmp() function is applied
  858.     to two transformed strings, it returns a value corresponding to
  859.     the result returned by the StrnCmp() function applied to the two
  860.     original strings.
  861.  
  862.    INPUTS
  863.     locale - the locale to use for the transformation
  864.     string - NULL-terminated string to transform
  865.     buffer - buffer where to put the transformed string
  866.     bufferSize - maximum number of bytes to deposit in the buffer
  867.                  StrConvert() may require more storage than
  868.              the unconverted string does
  869.     type - describes how the transformation is to be performed. See
  870.            the documentation on StrnCmp() for more information on the
  871.            comparison types available
  872.  
  873.    RESULT
  874.     length - length of the transformed string which is the number of bytes
  875.          deposited in the buffer minus 1 (since strings are NULL-
  876.          terminated)
  877.  
  878.    SEE ALSO
  879.     StrnCmp(), <libraries/locale.h>
  880.  
  881. locale.library/StrnCmp                                 locale.library/StrnCmp
  882.  
  883.    NAME
  884.     StrnCmp -- localized string comparison. (V38)
  885.  
  886.    SYNOPSIS
  887.     result = StrnCmp(locale,string1,string2,length,type);
  888.     D0               A0     A1      A2      D0     D1
  889.  
  890.     LONG StrnCmp(struct Locale *,STRPTR,STRPTR,LONG,ULONG);
  891.  
  892.    FUNCTION
  893.     Compares string1 to string2 according to the collation information
  894.     provided by the locale and returns an integer greater than,
  895.     equal to, or less than zero, accordingly as the string pointed to
  896.     by string1 is greater than, equal to, or less than the string
  897.     pointed to by string2.
  898.  
  899.     The length parameter specifies how many characters to compare, or if
  900.     the length is specified as -1 then the strings are compared until
  901.     a NULL is encountered.
  902.  
  903.     The type parameter dictates how the comparison is to be performed.
  904.  
  905.    INPUTS
  906.     locale - the locale to use for this comparison
  907.     string1    - NULL-terminated string
  908.     string2    - NULL-terminated string
  909.     length - the maximum number of characters to be compared, or -1 to
  910.          compare all characters until a NULL is encountered
  911.     type - describes how the comparison is to be performed. The following
  912.            values can be passed:
  913.          SC_ASCII causes an ASCII-based case-insensitive comparison
  914.          to be performed. SC_ASCII is the fastest of the comparison
  915.          types, but it uses ASCII ordering and considers accented
  916.          characters different than their non-accented counterparts.
  917.  
  918.          SC_COLLATE1 causes the characters to be compared using their
  919.          primary sorting order. This effectively produces a comparison
  920.          that ignores letter case and diacritical marks. That is,
  921.          letters such as "e" and "é" are treated as if they were both
  922.          "e".
  923.  
  924.          SC_COLLATE2 causes the characters to be compared using both
  925.          their primary and secondary sorting order. SC_COLLATE2 is
  926.          slower than SC_COLLATE1. This is the type of comparison to
  927.          use when sorting data to be presented to the user. It operates
  928.          in two passes. First it performs a comparison equivalent to
  929.          SC_COLLATE1. If both strings compare the same, then a second
  930.          pass is made using the secondary sorting order, which gives
  931.          finer resolution to the comparison. For example, SC_COLLATE1
  932.          would return the following strings as identical:
  933.             "père"  and  "pere"
  934.          since SC_COLLATE1 ignores diacritical marks. SC_COLLATE2
  935.          would make a second pass over the string comparing
  936.          diacritical marks instead of actual characters.
  937.  
  938.    RESULT
  939.     result - relationship between string1 and string2
  940.             <0 means string1 < string2
  941.             =0 means string1 = string2
  942.             >0 means string1 > string2
  943.  
  944.    SEE ALSO
  945.     OpenLocale(), CloseLocale(), StrConvert()
  946.  
  947.