2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an ”AS IS” BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FUi_BidiUtils.cpp
20 * @brief This is the implementation file for the _BidiUtils class.
24 #include <FLclLocaleManager.h>
25 #include <FSysSettingInfo.h>
26 #include "FUi_BidiUtils.h"
28 using namespace Tizen::Base;
29 using namespace Tizen::Locales;
31 namespace Tizen { namespace Ui
34 _BidiUtils::_BidiUtils(void)
38 _BidiUtils::~_BidiUtils(void)
43 _BidiUtils::IsRTL(const Tizen::Base::String& text)
45 int length = text.GetLength();
46 wchar_t* pString = const_cast<wchar_t*>(text.GetPointer());
48 if (pString != null && length > 0)
50 for (int i = 0 ; i< length ; i++)
56 FriBidiChar bidiText[1] = { *pString };
57 FriBidiCharType type[1] = { 0 };
58 fribidi_get_bidi_types(bidiText, 1, type);
60 if ((type[0] & FRIBIDI_MASK_RTL) != 0)
64 else if (((type[0] & FRIBIDI_MASK_STRONG) != 0) && ((type[0] & FRIBIDI_MASK_LETTER) != 0))
73 if (IsBidiLanguage(GetDisplayLanguage()))
81 _BidiUtils::IsBidiLanguage(LanguageCode languageCode)
85 case LANGUAGE_ARA: // arabic
86 case LANGUAGE_FAS: // farsi (iran)
87 case LANGUAGE_HEB: // hebrew (israel)
88 case LANGUAGE_URD: // urdu (parkistan)
98 _BidiUtils::GetDisplayLanguage(void)
100 result r = E_SUCCESS;
101 LanguageCode languageCode = LANGUAGE_INVALID;
102 String displayLanguage;
103 String threeLetterLanguageCode;
104 String key(L"http://tizen.org/setting/locale.language");
106 r = Tizen::System::SettingInfo::GetValue(key, displayLanguage);
110 displayLanguage.SubString(0, 3, threeLetterLanguageCode);
111 languageCode = Locale::StringToLanguageCode(threeLetterLanguageCode);