From fd09b2d910ca410d69579f725dc8e4b9bba79597 Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Sat, 30 Oct 2004 09:46:11 +0000 Subject: [PATCH] ICU-3591 acceptLanguage API X-SVN-Rev: 16686 --- icu4c/source/common/uloc.c | 20 +++++++++++++ icu4c/source/common/unicode/uloc.h | 45 ++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/icu4c/source/common/uloc.c b/icu4c/source/common/uloc.c index bc23d9a6503..a8bae34ea99 100644 --- a/icu4c/source/common/uloc.c +++ b/icu4c/source/common/uloc.c @@ -2770,4 +2770,24 @@ uloc_getISOCountries() return COUNTRIES; } +U_CAPI int32_t U_EXPORT2 +uloc_acceptLanguageFromHTTP(char *result, int32_t *resultAvailable, UAcceptResult *outResult, + const char *httpAcceptLanguage, + UEnumeration* availableLocales, + UErrorCode *status) +{ + *status = U_INTERNAL_PROGRAM_ERROR; + return -1; +} + +U_CAPI int32_t U_EXPORT2 +uloc_acceptLanguage(char *result, int32_t resultAvailable, + UAcceptResult *outResult, const char *acceptList[], + UEnumeration* availableLocales, + UErrorCode *status) { + *status = U_INTERNAL_PROGRAM_ERROR; + return -1; +} + + /*eof*/ diff --git a/icu4c/source/common/unicode/uloc.h b/icu4c/source/common/unicode/uloc.h index ddb9aff7891..7e8903dab54 100644 --- a/icu4c/source/common/unicode/uloc.h +++ b/icu4c/source/common/unicode/uloc.h @@ -859,6 +859,51 @@ uloc_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_VALID = 0, /* An exact match was found. */ + ULOC_ACCEPT_FALLBACK = 1 /* 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_EXPORT2 +uloc_acceptLanguageFromHTTP(char *result, int32_t *resultAvailable, UAcceptResult *outResult, + const char *httpAcceptLanguage, + UEnumeration* availableLocales, + UErrorCode *status); + +/** + * @param acceptList -list of accceptable languages + * @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_EXPORT2 +uloc_acceptLanguage(char *result, int32_t resultAvailable, + UAcceptResult *outResult, const char *acceptList[], + UEnumeration* availableLocales, + UErrorCode *status); + /*eof*/