2 **********************************************************************
3 * Copyright (c) 2003, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 **********************************************************************
7 * Created: March 19 2003
9 **********************************************************************
11 #include "unicode/ucat.h"
12 #include "unicode/ustring.h"
16 /* Separator between set_num and msg_num */
17 static const char SEPARATOR
= '%';
19 /* Maximum length of a set_num/msg_num key, incl. terminating zero.
20 * Longest possible key is "-2147483648%-2147483648" */
21 #define MAX_KEY_LEN (24)
24 * Fill in buffer with a set_num/msg_num key string, given the numeric
25 * values. Numeric values must be >= 0. Buffer must be of length
26 * MAX_KEY_LEN or more.
29 _catkey(char* buffer
, int32_t set_num
, int32_t msg_num
) {
31 i
= T_CString_integerToString(buffer
, set_num
, 10);
32 buffer
[i
++] = SEPARATOR
;
33 T_CString_integerToString(buffer
+i
, msg_num
, 10);
37 U_CAPI u_nl_catd U_EXPORT2
38 u_catopen(const char* name
, const char* locale
, UErrorCode
* ec
) {
39 return (u_nl_catd
) ures_open(name
, locale
, ec
);
43 u_catclose(u_nl_catd catd
) {
44 ures_close((UResourceBundle
*) catd
); /* may be NULL */
47 U_CAPI
const UChar
* U_EXPORT2
48 u_catgets(u_nl_catd catd
, int32_t set_num
, int32_t msg_num
,
50 int32_t* len
, UErrorCode
* ec
) {
52 char key
[MAX_KEY_LEN
];
55 if (ec
== NULL
|| U_FAILURE(*ec
)) {
59 result
= ures_getStringByKey((const UResourceBundle
*) catd
,
60 _catkey(key
, set_num
, msg_num
),
69 /* In case of any failure, return s */