|
||||
Warning, file /include/unicode/ucat.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 // © 2016 and later: Unicode, Inc. and others. 0002 // License & terms of use: http://www.unicode.org/copyright.html 0003 /* 0004 ********************************************************************** 0005 * Copyright (c) 2003-2004, International Business Machines 0006 * Corporation and others. All Rights Reserved. 0007 ********************************************************************** 0008 * Author: Alan Liu 0009 * Created: March 19 2003 0010 * Since: ICU 2.6 0011 ********************************************************************** 0012 */ 0013 #ifndef UCAT_H 0014 #define UCAT_H 0015 0016 #include "unicode/utypes.h" 0017 #include "unicode/ures.h" 0018 0019 /** 0020 * \file 0021 * \brief C API: Message Catalog Wrappers 0022 * 0023 * This C API provides look-alike functions that deliberately resemble 0024 * the POSIX catopen, catclose, and catgets functions. The underlying 0025 * implementation is in terms of ICU resource bundles, rather than 0026 * POSIX message catalogs. 0027 * 0028 * The ICU resource bundles obey standard ICU inheritance policies. 0029 * To facilitate this, sets and messages are flattened into one tier. 0030 * This is done by creating resource bundle keys of the form 0031 * <set_num>%<msg_num> where set_num is the set number and msg_num is 0032 * the message number, formatted as decimal strings. 0033 * 0034 * Example: Consider a message catalog containing two sets: 0035 * 0036 * Set 1: Message 4 = "Good morning." 0037 * Message 5 = "Good afternoon." 0038 * Message 7 = "Good evening." 0039 * Message 8 = "Good night." 0040 * Set 4: Message 14 = "Please " 0041 * Message 19 = "Thank you." 0042 * Message 20 = "Sincerely," 0043 * 0044 * The ICU resource bundle source file would, assuming it is named 0045 * "greet.txt", would look like this: 0046 * 0047 * greet 0048 * { 0049 * 1%4 { "Good morning." } 0050 * 1%5 { "Good afternoon." } 0051 * 1%7 { "Good evening." } 0052 * 1%8 { "Good night." } 0053 * 0054 * 4%14 { "Please " } 0055 * 4%19 { "Thank you." } 0056 * 4%20 { "Sincerely," } 0057 * } 0058 * 0059 * The catgets function is commonly used in combination with functions 0060 * like printf and strftime. ICU components like message format can 0061 * be used instead, although they use a different format syntax. 0062 * There is an ICU package, icuio, that provides some of 0063 * the POSIX-style formatting API. 0064 */ 0065 0066 U_CDECL_BEGIN 0067 0068 /** 0069 * An ICU message catalog descriptor, analogous to nl_catd. 0070 * 0071 * @stable ICU 2.6 0072 */ 0073 typedef UResourceBundle* u_nl_catd; 0074 0075 /** 0076 * Open and return an ICU message catalog descriptor. The descriptor 0077 * may be passed to u_catgets() to retrieve localized strings. 0078 * 0079 * @param name string containing the full path pointing to the 0080 * directory where the resources reside followed by the package name 0081 * e.g. "/usr/resource/my_app/resources/guimessages" on a Unix system. 0082 * If NULL, ICU default data files will be used. 0083 * 0084 * Unlike POSIX, environment variables are not interpolated within the 0085 * name. 0086 * 0087 * @param locale the locale for which we want to open the resource. If 0088 * NULL, the default ICU locale will be used (see uloc_getDefault). If 0089 * strlen(locale) == 0, the root locale will be used. 0090 * 0091 * @param ec input/output error code. Upon output, 0092 * U_USING_FALLBACK_WARNING indicates that a fallback locale was 0093 * used. For example, 'de_CH' was requested, but nothing was found 0094 * there, so 'de' was used. U_USING_DEFAULT_WARNING indicates that the 0095 * default locale data or root locale data was used; neither the 0096 * requested locale nor any of its fallback locales were found. 0097 * 0098 * @return a message catalog descriptor that may be passed to 0099 * u_catgets(). If the ec parameter indicates success, then the caller 0100 * is responsible for calling u_catclose() to close the message 0101 * catalog. If the ec parameter indicates failure, then NULL will be 0102 * returned. 0103 * 0104 * @stable ICU 2.6 0105 */ 0106 U_CAPI u_nl_catd U_EXPORT2 0107 u_catopen(const char* name, const char* locale, UErrorCode* ec); 0108 0109 /** 0110 * Close an ICU message catalog, given its descriptor. 0111 * 0112 * @param catd a message catalog descriptor to be closed. May be NULL, 0113 * in which case no action is taken. 0114 * 0115 * @stable ICU 2.6 0116 */ 0117 U_CAPI void U_EXPORT2 0118 u_catclose(u_nl_catd catd); 0119 0120 /** 0121 * Retrieve a localized string from an ICU message catalog. 0122 * 0123 * @param catd a message catalog descriptor returned by u_catopen. 0124 * 0125 * @param set_num the message catalog set number. Sets need not be 0126 * numbered consecutively. 0127 * 0128 * @param msg_num the message catalog message number within the 0129 * set. Messages need not be numbered consecutively. 0130 * 0131 * @param s the default string. This is returned if the string 0132 * specified by the set_num and msg_num is not found. It must be 0133 * zero-terminated. 0134 * 0135 * @param len fill-in parameter to receive the length of the result. 0136 * May be NULL, in which case it is ignored. 0137 * 0138 * @param ec input/output error code. May be U_USING_FALLBACK_WARNING 0139 * or U_USING_DEFAULT_WARNING. U_MISSING_RESOURCE_ERROR indicates that 0140 * the set_num/msg_num tuple does not specify a valid message string 0141 * in this catalog. 0142 * 0143 * @return a pointer to a zero-terminated UChar array which lives in 0144 * an internal buffer area, typically a memory mapped/DLL file. The 0145 * caller must NOT delete this pointer. If the call is unsuccessful 0146 * for any reason, then s is returned. This includes the situation in 0147 * which ec indicates a failing error code upon entry to this 0148 * function. 0149 * 0150 * @stable ICU 2.6 0151 */ 0152 U_CAPI const UChar* U_EXPORT2 0153 u_catgets(u_nl_catd catd, int32_t set_num, int32_t msg_num, 0154 const UChar* s, 0155 int32_t* len, UErrorCode* ec); 0156 0157 U_CDECL_END 0158 0159 #endif /*UCAT_H*/ 0160 /*eof*/
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |