1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 **********************************************************************
5 * Copyright (c) 2003, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 **********************************************************************
9 * Created: March 19 2003
11 **********************************************************************
13 #include "unicode/ucat.h"
14 #include "unicode/ustring.h"
18 /* Separator between set_num and msg_num */
19 static const char SEPARATOR
= '%';
21 /* Maximum length of a set_num/msg_num key, incl. terminating zero.
22 * Longest possible key is "-2147483648%-2147483648" */
23 #define MAX_KEY_LEN (24)
26 * Fill in buffer with a set_num/msg_num key string, given the numeric
27 * values. Numeric values must be >= 0. Buffer must be of length
28 * MAX_KEY_LEN or more.
31 _catkey(char* buffer
, int32_t set_num
, int32_t msg_num
) {
33 i
= T_CString_integerToString(buffer
, set_num
, 10);
34 buffer
[i
++] = SEPARATOR
;
35 T_CString_integerToString(buffer
+i
, msg_num
, 10);
39 U_CAPI u_nl_catd U_EXPORT2
40 u_catopen(const char* name
, const char* locale
, UErrorCode
* ec
) {
41 return (u_nl_catd
) ures_open(name
, locale
, ec
);
45 u_catclose(u_nl_catd catd
) {
46 ures_close((UResourceBundle
*) catd
); /* may be NULL */
49 U_CAPI
const UChar
* U_EXPORT2
50 u_catgets(u_nl_catd catd
, int32_t set_num
, int32_t msg_num
,
52 int32_t* len
, UErrorCode
* ec
) {
54 char key
[MAX_KEY_LEN
];
57 if (ec
== NULL
|| U_FAILURE(*ec
)) {
61 result
= ures_getStringByKey((const UResourceBundle
*) catd
,
62 _catkey(key
, set_num
, msg_num
),
71 /* In case of any failure, return s */