📄 uloc.h
字号:
const char* displayLocale, UChar* variant, int32_t variantCapacity, UErrorCode* status);/** * Gets the keyword name suitable for display for the specified locale. * E.g: for the locale string de_DE\@collation=PHONEBOOK, this API gets the display * string for the keyword collation. * Usage: * <code> * UErrorCode status = U_ZERO_ERROR; * const char* keyword =NULL; * int32_t keywordLen = 0; * int32_t keywordCount = 0; * UChar displayKeyword[256]; * int32_t displayKeywordLen = 0; * UEnumeration* keywordEnum = uloc_openKeywords("de_DE@collation=PHONEBOOK;calendar=TRADITIONAL", &status); * for(keywordCount = uenum_count(keywordEnum, &status); keywordCount > 0 ; keywordCount--){ * if(U_FAILURE(status)){ * ...something went wrong so handle the error... * break; * } * // the uenum_next returns NUL terminated string * keyword = uenum_next(keywordEnum, &keywordLen, &status); * displayKeywordLen = uloc_getDisplayKeyword(keyword, "en_US", displayKeyword, 256); * ... do something interesting ..... * } * uenum_close(keywordEnum); * </code> * @param keyword The keyword whose display string needs to be returned. * @param displayLocale Specifies the locale to be used to display the name. In other words, * if the locale's language code is "en", passing Locale::getFrench() for * inLocale would result in "Anglais", while passing Locale::getGerman() * for inLocale would result in "Englisch". NULL may be used to specify the default. * @param dest the buffer to which the displayable keyword should be written. * @param destCapacity The size of the buffer (number of UChars). If it is 0, then * dest may be NULL and the function will only return the length of the * result without writing any of the result string (pre-flighting). * @param status error information if retrieving the displayable string failed. * Should not be NULL and should not indicate failure on entry. * @return the actual buffer size needed for the displayable variant code. * @see #uloc_openKeywords * @draft ICU 2.8 */U_DRAFT int32_t U_EXPORT2uloc_getDisplayKeyword(const char* keyword, const char* displayLocale, UChar* dest, int32_t destCapacity, UErrorCode* status);/** * Gets the value of the keyword suitable for display for the specified locale. * E.g: for the locale string de_DE\@collation=PHONEBOOK, this API gets the display * string for PHONEBOOK, in the display locale, when "collation" is specified as the keyword. * * @param locale The locale to get the displayable variant code with. NULL may be used to specify the default. * @param keyword The keyword for whose value should be used. * @param displayLocale Specifies the locale to be used to display the name. In other words, * if the locale's language code is "en", passing Locale::getFrench() for * inLocale would result in "Anglais", while passing Locale::getGerman() * for inLocale would result in "Englisch". NULL may be used to specify the default. * @param dest the buffer to which the displayable keyword should be written. * @param destCapacity The size of the buffer (number of UChars). If it is 0, then * dest may be NULL and the function will only return the length of the * result without writing any of the result string (pre-flighting). * @param status error information if retrieving the displayable string failed. * Should not be NULL and must not indicate failure on entry. * @return the actual buffer size needed for the displayable variant code. * @draft ICU 2.8 */U_DRAFT int32_t U_EXPORT2uloc_getDisplayKeywordValue( const char* locale, const char* keyword, const char* displayLocale, UChar* dest, int32_t destCapacity, UErrorCode* status);/** * Gets the full name suitable for display for the specified locale. * * @param localeID the locale to get the displayable name with. NULL may be used to specify the default. * @param inLocaleID Specifies the locale to be used to display the name. In other words, * if the locale's language code is "en", passing Locale::getFrench() for * inLocale would result in "Anglais", while passing Locale::getGerman() * for inLocale would result in "Englisch". NULL may be used to specify the default. * @param result the displayable name for localeID * @param maxResultSize the size of the name buffer to store the * displayable full name with * @param err error information if retrieving the displayable name failed * @return the actual buffer size needed for the displayable name. If it's greater * than maxResultSize, the returned displayable name will be truncated. * @stable ICU 2.0 */U_STABLE int32_t U_EXPORT2uloc_getDisplayName(const char* localeID, const char* inLocaleID, UChar* result, int32_t maxResultSize, UErrorCode* err);/** * Gets the specified locale from a list of all available locales. * The return value is a pointer to an item of * a locale name array. Both this array and the pointers * it contains are owned by ICU and should not be deleted or written through * by the caller. The locale name is terminated by a null pointer. * @param n the specific locale name index of the available locale list * @return a specified locale name of all available locales * @stable ICU 2.0 */U_STABLE const char* U_EXPORT2uloc_getAvailable(int32_t n);/** * Gets the size of the all available locale list. * * @return the size of the locale list * @stable ICU 2.0 */U_STABLE int32_t U_EXPORT2 uloc_countAvailable(void);/** * * Gets a list of all available language codes defined in ISO 639. This is a pointer * to an array of pointers to arrays of char. All of these pointers are owned * by ICU-- do not delete them, and do not write through them. The array is * terminated with a null pointer. * @return a list of all available language codes * @stable ICU 2.0 */U_STABLE const char* const* U_EXPORT2uloc_getISOLanguages(void);/** * * Gets a list of all available 2-letter country codes defined in ISO 639. This is a * pointer to an array of pointers to arrays of char. All of these pointers are * owned by ICU-- do not delete them, and do not write through them. The array is * terminated with a null pointer. * @return a list of all available country codes * @stable ICU 2.0 */U_STABLE const char* const* U_EXPORT2uloc_getISOCountries(void);/** * Truncate the locale ID string to get the parent locale ID. * Copies the part of the string before the last underscore. * The parent locale ID will be an empty string if there is no * underscore, or if there is only one underscore at localeID[0]. * * @param localeID Input locale ID string. * @param parent Output string buffer for the parent locale ID. * @param parentCapacity Size of the output buffer. * @param err A UErrorCode value. * @return The length of the parent locale ID. * @stable ICU 2.0 */U_STABLE int32_t U_EXPORT2uloc_getParent(const char* localeID, char* parent, int32_t parentCapacity, UErrorCode* err);/** * Gets the full name for the specified locale. * Note: This has the effect of 'canonicalizing' the string to * a certain extent. Upper and lower case are set as needed, * and if the components were in 'POSIX' format they are changed to * ICU format. It does NOT map aliased names in any way. * See the top of this header file. * This API strips off the keyword part, so "de_DE\@collation=phonebook" * will become "de_DE". * This API supports preflighting. * * @param localeID the locale to get the full name with * @param name fill in buffer for the name without keywords. * @param nameCapacity capacity of the fill in buffer. * @param err error information if retrieving the full name failed * @return the actual buffer size needed for the full name. If it's greater * than nameCapacity, the returned full name will be truncated. * @draft ICU 2.8 */U_DRAFT int32_t U_EXPORT2uloc_getBaseName(const char* localeID, char* name, int32_t nameCapacity, UErrorCode* err);/** * Gets an enumeration of keywords for the specified locale. Enumeration * must get disposed of by the client using uenum_close function. * * @param localeID the locale to get the variant code with * @param status error information if retrieving the keywords failed * @return enumeration of keywords or NULL if there are no keywords. * @draft ICU 2.8 */U_DRAFT UEnumeration* U_EXPORT2uloc_openKeywords(const char* localeID, UErrorCode* status);/** * Get the value for a keyword. Locale name does not need to be normalized. * * @param localeID locale name containing the keyword ("de_DE@currency=EURO;collation=PHONEBOOK") * @param keywordName name of the keyword for which we want the value. Case insensitive. * @param buffer receiving buffer * @param bufferCapacity capacity of receiving buffer * @param status containing error code - buffer not big enough. * @return the length of keyword value * @draft ICU 2.8 */U_DRAFT int32_t U_EXPORT2uloc_getKeywordValue(const char* localeID, const char* keywordName, char* buffer, int32_t bufferCapacity, UErrorCode* status);/** * Set the value of the specified keyword. * NOTE: Unlike almost every other ICU function which takes a * buffer, this function will NOT truncate the output text. If a * BUFFER_OVERFLOW_ERROR is received, it means that the original * buffer is untouched. This is done to prevent incorrect or possibly * even malformed locales from being generated and used. * * @param keywordName name of the keyword to be set. Case insensitive. * @param keywordValue value of the keyword to be set. If 0-length or * NULL, will result in the keyword being removed. No error is given if * that keyword does not exist. * @param buffer input buffer containing locale to be modified. * @param bufferCapacity capacity of receiving buffer * @param status containing error code - buffer not big enough. * @return the length needed for the buffer * @see uloc_getKeywordValue * @draft ICU 3.2 */U_DRAFT int32_t U_EXPORT2uloc_setKeywordValue(const char* keywordName, const char* keywordValue, char* buffer, int32_t bufferCapacity, UErrorCode* status);/** * enums for the 'outResult' parameter return value * @see uloc_acceptLanguageFromHTTP * @see uloc_acceptLanguage * @draft ICU 3.2 */typedef enum { ULOC_ACCEPT_FAILED = 0, /* No exact match was found. */ ULOC_ACCEPT_VALID = 1, /* An exact match was found. */ ULOC_ACCEPT_FALLBACK = 2 /* A fallback was found, for example, Accept list contained 'ja_JP' which matched available locale 'ja'. */} UAcceptResult;/** * @param httpAcceptLanguage - "Accept-Language:" header as per HTTP. * @param result - buffer to accept the result locale * @param resultAvailable the size of the result buffer. * @param availableLocales - list of available locales to match * @param status Error status, may be BUFFER_OVERFLOW_ERROR * @return length needed for the locale. * @draft ICU 3.2 */U_DRAFT int32_t U_EXPORT2uloc_acceptLanguageFromHTTP(char *result, int32_t resultAvailable, UAcceptResult *outResult, const char *httpAcceptLanguage, UEnumeration* availableLocales, UErrorCode *status);/** * @param acceptList -list of acceptable languages * @param acceptListCount - count of acceptList items * @param result - buffer to accept the result locale * @param resultAvailable the size of the result buffer. * @param availableLocales - list of available locales to match * @param status Error status, may be BUFFER_OVERFLOW_ERROR * @return length needed for the locale. * @draft ICU 3.2 */U_DRAFT int32_t U_EXPORT2uloc_acceptLanguage(char *result, int32_t resultAvailable, UAcceptResult *outResult, const char **acceptList, int32_t acceptListCount, UEnumeration* availableLocales, UErrorCode *status);/*eof*/#endif /*_ULOC*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -