Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* |
michael@0 | 2 | ********************************************************************** |
michael@0 | 3 | * Copyright (c) 2004, International Business Machines |
michael@0 | 4 | * Corporation and others. All Rights Reserved. |
michael@0 | 5 | ********************************************************************** |
michael@0 | 6 | * Author: Alan Liu |
michael@0 | 7 | * Created: January 16 2004 |
michael@0 | 8 | * Since: ICU 2.8 |
michael@0 | 9 | ********************************************************************** |
michael@0 | 10 | */ |
michael@0 | 11 | #include "locbased.h" |
michael@0 | 12 | #include "cstring.h" |
michael@0 | 13 | |
michael@0 | 14 | U_NAMESPACE_BEGIN |
michael@0 | 15 | |
michael@0 | 16 | Locale LocaleBased::getLocale(ULocDataLocaleType type, UErrorCode& status) const { |
michael@0 | 17 | const char* id = getLocaleID(type, status); |
michael@0 | 18 | return Locale((id != 0) ? id : ""); |
michael@0 | 19 | } |
michael@0 | 20 | |
michael@0 | 21 | const char* LocaleBased::getLocaleID(ULocDataLocaleType type, UErrorCode& status) const { |
michael@0 | 22 | if (U_FAILURE(status)) { |
michael@0 | 23 | return NULL; |
michael@0 | 24 | } |
michael@0 | 25 | |
michael@0 | 26 | switch(type) { |
michael@0 | 27 | case ULOC_VALID_LOCALE: |
michael@0 | 28 | return valid; |
michael@0 | 29 | case ULOC_ACTUAL_LOCALE: |
michael@0 | 30 | return actual; |
michael@0 | 31 | default: |
michael@0 | 32 | status = U_ILLEGAL_ARGUMENT_ERROR; |
michael@0 | 33 | return NULL; |
michael@0 | 34 | } |
michael@0 | 35 | } |
michael@0 | 36 | |
michael@0 | 37 | void LocaleBased::setLocaleIDs(const char* validID, const char* actualID) { |
michael@0 | 38 | if (validID != 0) { |
michael@0 | 39 | uprv_strcpy(valid, validID); |
michael@0 | 40 | } |
michael@0 | 41 | if (actualID != 0) { |
michael@0 | 42 | uprv_strcpy(actual, actualID); |
michael@0 | 43 | } |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | U_NAMESPACE_END |