diff options
author | Eike Rathke <erack@openoffice.org> | 2010-06-10 23:31:31 +0200 |
---|---|---|
committer | Eike Rathke <erack@openoffice.org> | 2010-06-10 23:31:31 +0200 |
commit | 17f9d3862b112b96787d06e11f983323f665cf18 (patch) | |
tree | 04bc00b47d35f4ef38ac773f5cec8e1727da6c1e /sal/osl/unx | |
parent | a6d2fd8975afc0c9c4bb4e2219a8d4b8d1317239 (diff) |
locales33a: #i111019# fixed locale parser/composer for three-letter language codes
Diffstat (limited to 'sal/osl/unx')
-rw-r--r-- | sal/osl/unx/nlsupport.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/sal/osl/unx/nlsupport.c b/sal/osl/unx/nlsupport.c index 0b09cf1ac2a4..c9f4fd18df21 100644 --- a/sal/osl/unx/nlsupport.c +++ b/sal/osl/unx/nlsupport.c @@ -105,7 +105,8 @@ _pair_search (const char *key, const _pair *base, unsigned int member ) static char * _compose_locale( rtl_Locale * pLocale, char * buffer, size_t n ) { /* check if a valid locale is specified */ - if( pLocale && pLocale->Language && (pLocale->Language->length == 2) ) + if( pLocale && pLocale->Language && + (pLocale->Language->length == 2 || pLocale->Language->length == 3) ) { size_t offset = 0; @@ -193,16 +194,20 @@ static rtl_Locale * _parse_locale( const char * locale ) rtl_Locale * ret; + /* language is a two or three letter code */ + if( (len > 3 && '_' == locale[3]) || (len == 3 && '_' != locale[2]) ) + offset = 3; + /* convert language code to unicode */ - rtl_string2UString( &pLanguage, locale, 2, RTL_TEXTENCODING_ASCII_US, OSTRING_TO_OUSTRING_CVTFLAGS ); + rtl_string2UString( &pLanguage, locale, offset, RTL_TEXTENCODING_ASCII_US, OSTRING_TO_OUSTRING_CVTFLAGS ); OSL_ASSERT(pLanguage != NULL); /* convert country code to unicode */ - if( len >= 5 && '_' == locale[2] ) + if( len >= offset+3 && '_' == locale[offset] ) { - rtl_string2UString( &pCountry, locale + 3, 2, RTL_TEXTENCODING_ASCII_US, OSTRING_TO_OUSTRING_CVTFLAGS ); + rtl_string2UString( &pCountry, locale + offset + 1, 2, RTL_TEXTENCODING_ASCII_US, OSTRING_TO_OUSTRING_CVTFLAGS ); OSL_ASSERT(pCountry != NULL); - offset = 5; + offset += 3; } /* convert variant code to unicode - do not rely on "." as delimiter */ |