mirror of
https://gitee.com/openharmony/global_i18n
synced 2024-11-22 22:49:54 +00:00
fix internal source code specification problem
Signed-off-by: sunyaozu <sunyaozu@huawei.com>
This commit is contained in:
parent
0de5ef34eb
commit
4e340f1c1c
0
README_zh.md
Executable file → Normal file
0
README_zh.md
Executable file → Normal file
2
frameworks/intl/BUILD.gn
Executable file → Normal file
2
frameworks/intl/BUILD.gn
Executable file → Normal file
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
<!-- Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
<!-- Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
<!-- Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
<!-- Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -30,7 +30,7 @@ bool IsLetter(const std::string &character);
|
||||
bool IsLowerCase(const std::string &character);
|
||||
bool IsUpperCase(const std::string &character);
|
||||
std::string GetType(const std::string &character);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace I18n
|
||||
} // namespace Global
|
||||
} // namespace OHOS
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -28,11 +28,18 @@
|
||||
namespace OHOS {
|
||||
namespace Global {
|
||||
namespace I18n {
|
||||
typedef enum CompareResult {
|
||||
INVALID = -2,
|
||||
SMALLER,
|
||||
EQUAL,
|
||||
GREATER,
|
||||
} CompareResult;
|
||||
|
||||
class Collator {
|
||||
public:
|
||||
Collator(std::vector<std::string> &localeTags, std::map<std::string, std::string> &options);
|
||||
~Collator();
|
||||
int32_t Compare(const std::string &first, const std::string &second);
|
||||
CompareResult Compare(const std::string &first, const std::string &second);
|
||||
void ResolvedOptions(std::map<std::string, std::string> &options);
|
||||
|
||||
private:
|
||||
@ -61,8 +68,7 @@ private:
|
||||
void SetIgnorePunctuation(UErrorCode &status);
|
||||
bool InitCollator();
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // GLOBAL_I18N_STANDARD_COLLATOR_H
|
||||
} // namespace I18n
|
||||
} // namespace Global
|
||||
} // namespace OHOS
|
||||
#endif
|
||||
|
2
frameworks/intl/include/date_time_format.h
Executable file → Normal file
2
frameworks/intl/include/date_time_format.h
Executable file → Normal file
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -33,7 +33,7 @@ public:
|
||||
private:
|
||||
std::unique_ptr<icu::AlphabeticIndex> index;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace I18n
|
||||
} // namespace Global
|
||||
} // namespace OHOS
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -97,7 +97,7 @@ private:
|
||||
static bool listsInitialized;
|
||||
static bool InitializeLists();
|
||||
};
|
||||
} // I18n
|
||||
} // Global
|
||||
} // OHOS
|
||||
} // namespace I18n
|
||||
} // namespace Global
|
||||
} // namespace OHOS
|
||||
#endif
|
||||
|
0
frameworks/intl/include/locale_info.h
Executable file → Normal file
0
frameworks/intl/include/locale_info.h
Executable file → Normal file
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -37,8 +37,7 @@ private:
|
||||
std::string country;
|
||||
PhoneNumberUtil::PhoneNumberFormat phoneNumberFormat;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // OHOS_GLOBAL_I18N_PHONE_NUMBER_FORMAT_H
|
||||
} // namespace I18n
|
||||
} // namespace Global
|
||||
} // namespace OHOS
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -56,8 +56,7 @@ private:
|
||||
void InitPluralRules(std::vector<std::string> &localeTags, std::map<std::string, std::string> &options);
|
||||
void InitNumberFormatter();
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // GLOBAL_I18N_STANDARD_PLURAL_RULES_H
|
||||
} // namespace I18n
|
||||
} // namespace Global
|
||||
} // namespace OHOS
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -129,6 +129,6 @@ std::string GetType(const std::string &character)
|
||||
int8_t category = u_charType(char32);
|
||||
return categoryMap[UCharCategory(category)];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace I18n
|
||||
} // namespace Global
|
||||
} // namespace OHOS
|
@ -1,9 +1,5 @@
|
||||
//
|
||||
// Created by s00619675 on 2021/10/25.
|
||||
//
|
||||
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -70,7 +66,7 @@ Collator::Collator(std::vector<std::string> &localeTags, std::map<std::string, s
|
||||
ParseAllOptions(options);
|
||||
|
||||
UErrorCode status = UErrorCode::U_ZERO_ERROR;
|
||||
if (localeTags.size() == 0) {
|
||||
if (!localeTags.size()) {
|
||||
localeTags.push_back(LocaleConfig::GetSystemLocale());
|
||||
}
|
||||
for (size_t i = 0; i < localeTags.size(); i++) {
|
||||
@ -98,7 +94,7 @@ bool Collator::IsValidCollation(std::string &collation, UErrorCode &status)
|
||||
int length;
|
||||
const char *validCollations = enumeration->next(&length, status);
|
||||
while (validCollations != nullptr) {
|
||||
if (strcmp(validCollations, currentCollation) == 0) {
|
||||
if (!strcmp(validCollations, currentCollation)) {
|
||||
return true;
|
||||
}
|
||||
validCollations = enumeration->next(&length, status);
|
||||
@ -237,24 +233,25 @@ Collator::~Collator()
|
||||
}
|
||||
}
|
||||
|
||||
int32_t Collator::Compare(const std::string &first, const std::string &second)
|
||||
CompareResult Collator::Compare(const std::string &first, const std::string &second)
|
||||
{
|
||||
if (collatorPtr == nullptr) {
|
||||
return -2;
|
||||
return CompareResult::INVALID;
|
||||
}
|
||||
icu::Collator::EComparisonResult result = collatorPtr->compare(icu::UnicodeString(first.data(), first.length()),
|
||||
icu::UnicodeString(second.data(), second.length()));
|
||||
if (result == icu::Collator::EComparisonResult::LESS) {
|
||||
return -1;
|
||||
return CompareResult::SMALLER;
|
||||
} else if (result == icu::Collator::EComparisonResult::EQUAL) {
|
||||
return 0;
|
||||
return CompareResult::EQUAL;
|
||||
} else {
|
||||
return 1;
|
||||
return CompareResult::GREATER;
|
||||
}
|
||||
}
|
||||
|
||||
void Collator::ResolvedOptions(std::map<std::string, std::string> &options)
|
||||
{
|
||||
options.insert(std::pair<std::string, std::string>("localeMatcher", localeMatcher));
|
||||
options.insert(std::pair<std::string, std::string>("locale", localeStr));
|
||||
options.insert(std::pair<std::string, std::string>("usage", usage));
|
||||
options.insert(std::pair<std::string, std::string>("sensitivity", sensitivity));
|
||||
@ -263,6 +260,6 @@ void Collator::ResolvedOptions(std::map<std::string, std::string> &options)
|
||||
options.insert(std::pair<std::string, std::string>("caseFirst", caseFirst));
|
||||
options.insert(std::pair<std::string, std::string>("collation", collation));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace I18n
|
||||
} // namespace Global
|
||||
} // namespace OHOS
|
||||
|
12
frameworks/intl/src/date_time_format.cpp
Executable file → Normal file
12
frameworks/intl/src/date_time_format.cpp
Executable file → Normal file
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -50,7 +50,7 @@ DateTimeFormat::DateTimeFormat(const std::vector<std::string> &localeTags, std::
|
||||
}
|
||||
ComputeHourCycleChars();
|
||||
ComputeSkeleton();
|
||||
if (configs.size() == 0) {
|
||||
if (!configs.size()) {
|
||||
InitDateFormatWithoutConfigs(status);
|
||||
} else {
|
||||
InitDateFormat(status);
|
||||
@ -182,14 +182,14 @@ void DateTimeFormat::removeAmPmChar()
|
||||
if ((i + 1) < patternString.length() && patternString[i + 1] == 't') {
|
||||
continue;
|
||||
}
|
||||
if (i == 0) {
|
||||
if (!i) {
|
||||
amPmCharStartIdx = i;
|
||||
} else {
|
||||
amPmCharStartIdx = i - 1;
|
||||
while (amPmCharStartIdx > 0 && patternString[amPmCharStartIdx] == ' ') {
|
||||
amPmCharStartIdx -= 1;
|
||||
}
|
||||
if (amPmCharStartIdx != 0 || patternString[amPmCharStartIdx] != ' ') {
|
||||
if (amPmCharStartIdx || patternString[amPmCharStartIdx] != ' ') {
|
||||
amPmCharStartIdx += 1;
|
||||
}
|
||||
}
|
||||
@ -200,8 +200,8 @@ void DateTimeFormat::removeAmPmChar()
|
||||
break;
|
||||
}
|
||||
size_t length = amPmCharEndIdx - amPmCharStartIdx;
|
||||
if (length != 0) {
|
||||
if (amPmCharStartIdx == 0 || amPmCharEndIdx == patternString.length()) {
|
||||
if (length) {
|
||||
if (!amPmCharStartIdx || amPmCharEndIdx == patternString.length()) {
|
||||
patternString = patternString.replace(amPmCharStartIdx, length, "");
|
||||
} else {
|
||||
patternString = patternString.replace(amPmCharStartIdx, length, " ");
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -24,6 +24,7 @@
|
||||
#include "islamcal.h"
|
||||
#include "japancal.h"
|
||||
#include "persncal.h"
|
||||
#include "securec.h"
|
||||
#include "ureslocs.h"
|
||||
#include "ulocimp.h"
|
||||
#include "uresimp.h"
|
||||
@ -258,7 +259,7 @@ std::string I18nCalendar::GetDisplayName(std::string &displayLocale)
|
||||
if (status == U_ZERO_ERROR) {
|
||||
len = (length < destCapacity) ? length : destCapacity;
|
||||
if ((len > 0) && (str != nullptr)) {
|
||||
u_memcpy(buffer, str, len);
|
||||
memcpy_s((void *)buffer, (size_t)destCapacity, (void *)str, (size_t)len);
|
||||
}
|
||||
} else {
|
||||
return "";
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -77,6 +77,6 @@ std::string IndexUtil::GetIndex(const std::string &String)
|
||||
label.toUTF8String(result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace I18n
|
||||
} // namespace Global
|
||||
} // namespace OHOS
|
40
frameworks/intl/src/locale_config.cpp
Executable file → Normal file
40
frameworks/intl/src/locale_config.cpp
Executable file → Normal file
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -170,14 +170,14 @@ string Adjust(const string &origin)
|
||||
{
|
||||
for (auto iter = g_languageMap.begin(); iter != g_languageMap.end(); ++iter) {
|
||||
string key = iter->first;
|
||||
if (origin.compare(0, key.length(), key) == 0) {
|
||||
if (!origin.compare(0, key.length(), key)) {
|
||||
return iter->second;
|
||||
}
|
||||
}
|
||||
return origin;
|
||||
}
|
||||
|
||||
int32_t GetDialectName(const char *localeName, char *name, size_t nameCapacity, UErrorCode &status)
|
||||
size_t GetDialectName(const char *localeName, char *name, size_t nameCapacity, UErrorCode &status)
|
||||
{
|
||||
icu::Locale locale = icu::Locale::forLanguageTag(localeName, status);
|
||||
if (status != U_ZERO_ERROR) {
|
||||
@ -207,7 +207,7 @@ int32_t GetDialectName(const char *localeName, char *name, size_t nameCapacity,
|
||||
return temp.size();
|
||||
}
|
||||
|
||||
int32_t GetDisplayName(const char *locale, const char *displayLocale, UChar *dest, int32_t destCapacity,
|
||||
int32_t GetDisplayName(const char *locale, const char *displayLocale, UChar *dest, size_t destCapacity,
|
||||
UErrorCode &status)
|
||||
{
|
||||
if (status != U_ZERO_ERROR) {
|
||||
@ -218,17 +218,18 @@ int32_t GetDisplayName(const char *locale, const char *displayLocale, UChar *des
|
||||
return 0;
|
||||
}
|
||||
char localeBuffer[ULOC_FULLNAME_CAPACITY];
|
||||
int32_t length = GetDialectName(locale, localeBuffer, sizeof(localeBuffer), status);
|
||||
if (status != U_ZERO_ERROR || length == 0) {
|
||||
size_t length = GetDialectName(locale, localeBuffer, sizeof(localeBuffer), status);
|
||||
if (status != U_ZERO_ERROR || !length) {
|
||||
status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return 0;
|
||||
}
|
||||
int32_t length2 = static_cast<int32_t>(length);
|
||||
const UChar *str = uloc_getTableStringWithFallback(U_ICUDATA_LANG, displayLocale, "Languages",
|
||||
nullptr, localeBuffer, &length, &status);
|
||||
nullptr, localeBuffer, &length2, &status);
|
||||
if (status <= U_ZERO_ERROR) {
|
||||
int32_t len = (length < destCapacity) ? length : destCapacity;
|
||||
size_t len = (length < destCapacity) ? length : destCapacity;
|
||||
if ((len > 0) && (str != nullptr)) {
|
||||
u_memcpy(dest, str, len);
|
||||
memcpy_s((void *)dest, destCapacity, (void *)str, len);
|
||||
}
|
||||
} else {
|
||||
status = U_USING_DEFAULT_WARNING;
|
||||
@ -239,13 +240,14 @@ int32_t GetDisplayName(const char *locale, const char *displayLocale, UChar *des
|
||||
|
||||
void GetDisplayLanguageImpl(const char *locale, const char *displayLocale, icu::UnicodeString &result)
|
||||
{
|
||||
UChar *buffer = result.getBuffer(50); // size 50 is enough to hold language name
|
||||
if (buffer == 0) {
|
||||
size_t destCapacity = 50; // size 50 is enough to hold language name
|
||||
UChar *buffer = result.getBuffer((int32_t)destCapacity);
|
||||
if (!buffer) {
|
||||
result.truncate(0);
|
||||
return;
|
||||
}
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
int32_t length = GetDisplayName(locale, displayLocale, buffer, result.getCapacity(), status);
|
||||
int32_t length = GetDisplayName(locale, displayLocale, buffer, destCapacity, status);
|
||||
result.releaseBuffer(U_SUCCESS(status) ? length : 0);
|
||||
}
|
||||
|
||||
@ -253,7 +255,7 @@ string GetDisplayLanguageInner(const string &language, const string &displayLoca
|
||||
{
|
||||
icu::UnicodeString unistr;
|
||||
// 0 is the start position of language, 2 is the length of zh and fa
|
||||
if (language.compare(0, 2, "zh") == 0 || language.compare(0, 2, "fa") == 0) {
|
||||
if (!language.compare(0, 2, "zh") || !language.compare(0, 2, "fa")) {
|
||||
UErrorCode error = U_ZERO_ERROR;
|
||||
icu::Locale disLocale = icu::Locale::forLanguageTag(displayLocale, error);
|
||||
if (error != U_ZERO_ERROR) {
|
||||
@ -431,7 +433,7 @@ bool LocaleConfig::IsValidRegion(const string ®ion)
|
||||
|
||||
bool LocaleConfig::IsValidTag(const string &tag)
|
||||
{
|
||||
if (tag.size() == 0) {
|
||||
if (!tag.size()) {
|
||||
return false;
|
||||
}
|
||||
vector<string> splits;
|
||||
@ -562,7 +564,7 @@ void LocaleConfig::GetListFromFile(const char *path, const char *resourceName, u
|
||||
return;
|
||||
}
|
||||
xmlNodePtr cur = xmlDocGetRootElement(doc);
|
||||
if (cur == nullptr || (xmlStrcmp(cur->name, reinterpret_cast<const xmlChar *>(resourceName))) != 0) {
|
||||
if (cur == nullptr || xmlStrcmp(cur->name, reinterpret_cast<const xmlChar *>(resourceName))) {
|
||||
xmlFreeDoc(doc);
|
||||
return;
|
||||
}
|
||||
@ -850,7 +852,7 @@ bool LocaleConfig::Is24HourClock()
|
||||
if (code <= 0) {
|
||||
return false;
|
||||
}
|
||||
if (strcmp(value, "true") == 0) {
|
||||
if (!strcmp(value, "true")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -866,6 +868,6 @@ bool LocaleConfig::Set24HourClock(bool option)
|
||||
}
|
||||
return SetParameter(HOUR_KEY, optionStr.data()) == 0;
|
||||
}
|
||||
} // I18n
|
||||
} // Global
|
||||
} // OHOS
|
||||
} // namespace I18n
|
||||
} // namespace Global
|
||||
} // namespace OHOS
|
||||
|
0
frameworks/intl/src/locale_info.cpp
Executable file → Normal file
0
frameworks/intl/src/locale_info.cpp
Executable file → Normal file
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -22,6 +22,6 @@ bool LocaleUtil::IsRTL(const std::string &locale)
|
||||
icu::Locale curLocale(locale.c_str());
|
||||
return curLocale.isRightToLeft();
|
||||
}
|
||||
} // I18n
|
||||
} // Global
|
||||
} // OHOS
|
||||
} // namespace I18n
|
||||
} // namespace Global
|
||||
} // namespace OHOS
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -415,7 +415,7 @@ void GetRestPreferredUnit(const string ®ion, const string &usage, vector<stri
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (units.size() == 0) {
|
||||
if (!units.size()) {
|
||||
GetFallbackPreferredUnit(region, usage, units);
|
||||
}
|
||||
}
|
||||
@ -466,7 +466,7 @@ void GetPreferredUnit(const string ®ion, const string &usage, vector<string>
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (units.size() == 0) {
|
||||
if (!units.size()) {
|
||||
GetRestPreferredUnit(region, usage, units);
|
||||
}
|
||||
}
|
||||
@ -488,7 +488,7 @@ void ComputeFactorValue(const string &unit, const string &measSys, vector<double
|
||||
double ComputeSIPrefixValue(const string &unit)
|
||||
{
|
||||
for (auto& prefixValue : PREFIX_VALUE) {
|
||||
if (unit.rfind(prefixValue.first, 0) == 0) {
|
||||
if (!unit.rfind(prefixValue.first, 0)) {
|
||||
return prefixValue.second;
|
||||
}
|
||||
}
|
||||
@ -498,7 +498,7 @@ double ComputeSIPrefixValue(const string &unit)
|
||||
void ComputePowerValue(const string &unit, const string &measSys, vector<double> &factors)
|
||||
{
|
||||
for (auto& powerValue : POWER_VALUE) {
|
||||
if (unit.rfind(powerValue.first, 0) == 0) {
|
||||
if (!unit.rfind(powerValue.first, 0)) {
|
||||
string baseUnit = unit.substr(powerValue.first.length());
|
||||
double value = ComputeSIPrefixValue(baseUnit);
|
||||
double compare = 0.0;
|
||||
@ -518,12 +518,12 @@ int ComputeValue(const string &unit, const string &measSys, vector<double> &fact
|
||||
if (baseValues.size() == BASE_VALUE_SIZE) {
|
||||
vector<double> numerator = { 1.0, 0.0 };
|
||||
int status = ComputeValue(baseValues[0], measSys, numerator);
|
||||
if (status == 0) {
|
||||
if (!status) {
|
||||
return 0;
|
||||
}
|
||||
vector<double> denominator = { 1.0, 0.0 };
|
||||
status = ComputeValue(baseValues[1], measSys, denominator);
|
||||
if (status == 0) {
|
||||
if (!status) {
|
||||
return 0;
|
||||
}
|
||||
factors[0] = numerator[0] / denominator[0];
|
||||
@ -557,23 +557,23 @@ int Convert(double &value, const string &fromUnit, const string &fromMeasSys, co
|
||||
UErrorCode icuStatus = U_ZERO_ERROR;
|
||||
icu::MeasureUnit::getAvailable(unitArray, MAX_UNIT_NUM, icuStatus);
|
||||
for (icu::MeasureUnit curUnit : unitArray) {
|
||||
if (strcmp(curUnit.getSubtype(), fromUnit.c_str()) == 0) {
|
||||
if (!strcmp(curUnit.getSubtype(), fromUnit.c_str())) {
|
||||
fromUnitType = curUnit.getType();
|
||||
}
|
||||
if (strcmp(curUnit.getSubtype(), toUnit.c_str()) == 0) {
|
||||
if (!strcmp(curUnit.getSubtype(), toUnit.c_str())) {
|
||||
toUnitType = curUnit.getType();
|
||||
}
|
||||
}
|
||||
if (fromUnitType.empty() || toUnitType.empty() || strcmp(fromUnitType.c_str(), toUnitType.c_str()) != 0) {
|
||||
if (fromUnitType.empty() || toUnitType.empty() || strcmp(fromUnitType.c_str(), toUnitType.c_str())) {
|
||||
return 0;
|
||||
}
|
||||
int status = ComputeValue(fromUnit, fromMeasSys, fromFactors);
|
||||
if (status == 0) {
|
||||
if (!status) {
|
||||
return 0;
|
||||
}
|
||||
vector<double> toFactors = {0.0, 0.0};
|
||||
status = ComputeValue(toUnit, toMeasSys, toFactors);
|
||||
if (status == 0) {
|
||||
if (!status) {
|
||||
return 0;
|
||||
}
|
||||
if (fromFactors.size() == FACTOR_SIZE) {
|
||||
@ -585,6 +585,6 @@ int Convert(double &value, const string &fromUnit, const string &fromMeasSys, co
|
||||
value = result;
|
||||
return 1;
|
||||
}
|
||||
} // I18n
|
||||
} // Global
|
||||
} // OHOS
|
||||
} // namespace I18n
|
||||
} // namespace Global
|
||||
} // namespace OHOS
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -106,7 +106,7 @@ void NumberFormat::InitProperties()
|
||||
}
|
||||
if (!styleString.empty() && styleString == "unit") {
|
||||
for (icu::MeasureUnit curUnit : unitArray) {
|
||||
if (strcmp(curUnit.getSubtype(), unit.c_str()) == 0) {
|
||||
if (!strcmp(curUnit.getSubtype(), unit.c_str())) {
|
||||
numberFormat = numberFormat.unit(curUnit);
|
||||
unitType = curUnit.getType();
|
||||
}
|
||||
@ -255,7 +255,7 @@ std::string NumberFormat::Format(double number)
|
||||
double num = number;
|
||||
for (size_t i = 0; i < preferredUnits.size(); i++) {
|
||||
int status = Convert(num, unit, unitMeasSys, preferredUnits[i], unitMeasSys);
|
||||
if (status == 0) {
|
||||
if (!status) {
|
||||
continue;
|
||||
}
|
||||
if (num >= 1) {
|
||||
@ -274,7 +274,7 @@ std::string NumberFormat::Format(double number)
|
||||
}
|
||||
if (!preferredUnit.empty()) {
|
||||
for (icu::MeasureUnit curUnit : unitArray) {
|
||||
if (strcmp(curUnit.getSubtype(), preferredUnit.c_str()) == 0) {
|
||||
if (!strcmp(curUnit.getSubtype(), preferredUnit.c_str())) {
|
||||
numberFormat = numberFormat.unit(curUnit);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -72,6 +72,6 @@ std::string PhoneNumberFormat::format(const std::string &number) const
|
||||
util->Format(phoneNumber, phoneNumberFormat, &formatted_number);
|
||||
return formatted_number;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace I18n
|
||||
} // namespace Global
|
||||
} // namespace OHOS
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -81,7 +81,7 @@ void PluralRules::InitPluralRules(std::vector<std::string> &localeTags,
|
||||
{
|
||||
UPluralType uPluralType = (type == "cardinal") ? UPLURAL_TYPE_CARDINAL : UPLURAL_TYPE_ORDINAL;
|
||||
UErrorCode status = UErrorCode::U_ZERO_ERROR;
|
||||
if (localeTags.size() == 0) {
|
||||
if (!localeTags.size()) {
|
||||
localeTags.push_back(LocaleConfig::GetSystemLocale());
|
||||
}
|
||||
for (size_t i = 0; i < localeTags.size(); i++) {
|
||||
@ -150,6 +150,6 @@ std::string PluralRules::Select(double number)
|
||||
unicodeString.toUTF8String(result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace I18n
|
||||
} // namespace Global
|
||||
} // namespace OHOS
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -48,7 +48,7 @@ bool PreferredLanguage::AddPreferredLanguageExist(std::vector<std::string> &pref
|
||||
}
|
||||
}
|
||||
preferredLanguageList[index] = language;
|
||||
if (languageIdx == 0 || index == 0) {
|
||||
if (!languageIdx || !index) {
|
||||
bool status = LocaleConfig::SetSystemLanguage(preferredLanguageList[0]);
|
||||
if (!status) {
|
||||
return false;
|
||||
@ -61,7 +61,7 @@ bool PreferredLanguage::AddPreferredLanguageNonExist(std::vector<std::string> &p
|
||||
const std::string& language)
|
||||
{
|
||||
preferredLanguageList.insert(preferredLanguageList.begin() + index, language);
|
||||
if (index == 0) {
|
||||
if (!index) {
|
||||
bool status = LocaleConfig::SetSystemLanguage(preferredLanguageList[0]);
|
||||
if (!status) {
|
||||
return false;
|
||||
@ -131,7 +131,7 @@ bool PreferredLanguage::RemovePreferredLanguage(int index)
|
||||
std::vector<std::string>::iterator it = preferredLanguageList.begin();
|
||||
preferredLanguageList.erase(it + idx);
|
||||
bool status = false;
|
||||
if (idx == 0) {
|
||||
if (!idx) {
|
||||
status = LocaleConfig::SetSystemLanguage(preferredLanguageList[0]);
|
||||
if (!status) {
|
||||
return false;
|
||||
@ -154,7 +154,7 @@ std::vector<std::string> PreferredLanguage::GetPreferredLanguageList()
|
||||
std::string systemLanguage = LocaleConfig::GetSystemLanguage();
|
||||
std::vector<std::string> list;
|
||||
Split(preferredLanguageValue, ";", list);
|
||||
if (list.size() == 0) {
|
||||
if (!list.size()) {
|
||||
if (systemLanguage != "") {
|
||||
list.push_back(systemLanguage);
|
||||
}
|
||||
@ -296,7 +296,7 @@ bool PreferredLanguage::IsValidLanguage(const std::string &language)
|
||||
|
||||
bool PreferredLanguage::IsValidTag(const std::string &tag)
|
||||
{
|
||||
if (tag.size() == 0) {
|
||||
if (!tag.size()) {
|
||||
return false;
|
||||
}
|
||||
std::vector<std::string> splits;
|
||||
@ -320,6 +320,6 @@ void PreferredLanguage::Split(const std::string &src, const std::string &sep, st
|
||||
dest.push_back(src.substr(begin));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace I18n
|
||||
} // namespace Global
|
||||
} // namespace OHOS
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -96,13 +96,13 @@ void RelativeTimeFormat::ParseConfigs(std::map<std::string, std::string> &config
|
||||
|
||||
std::string RelativeTimeFormat::Format(double number, const std::string &unit)
|
||||
{
|
||||
if (relativeUnits.count(unit) == 0) {
|
||||
if (!relativeUnits.count(unit)) {
|
||||
return "";
|
||||
}
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
icu::UnicodeString formattedTime;
|
||||
std::string result;
|
||||
if (strcmp(numeric.c_str(), "always") == 0) {
|
||||
if (!strcmp(numeric.c_str(), "always")) {
|
||||
formattedTime = relativeTimeFormat->formatNumericToValue(number, relativeUnits[unit], status).toString(status);
|
||||
} else {
|
||||
formattedTime = relativeTimeFormat->formatToValue(number, relativeUnits[unit], status).toString(status);
|
||||
@ -142,13 +142,13 @@ void RelativeTimeFormat::ProcessIntegerField(const std::map<size_t, size_t> &ind
|
||||
void RelativeTimeFormat::FormatToParts(double number, const std::string &unit,
|
||||
std::vector<std::vector<std::string>> &timeVector)
|
||||
{
|
||||
if (relativeUnits.count(unit) == 0) {
|
||||
if (!relativeUnits.count(unit)) {
|
||||
return;
|
||||
}
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
std::string result;
|
||||
icu::FormattedRelativeDateTime fmtRelativeTime;
|
||||
if (numeric.empty() || strcmp(numeric.c_str(), "always") == 0) {
|
||||
if (numeric.empty() || !strcmp(numeric.c_str(), "always")) {
|
||||
fmtRelativeTime = relativeTimeFormat->formatNumericToValue(number, relativeUnits[unit], status);
|
||||
} else {
|
||||
fmtRelativeTime = relativeTimeFormat->formatToValue(number, relativeUnits[unit], status);
|
||||
|
2
frameworks/intl/test/BUILD.gn
Executable file → Normal file
2
frameworks/intl/test/BUILD.gn
Executable file → Normal file
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
0
frameworks/intl/test/unittest/intl_test.cpp
Executable file → Normal file
0
frameworks/intl/test/unittest/intl_test.cpp
Executable file → Normal file
0
frameworks/intl/test/unittest/intl_test.h
Executable file → Normal file
0
frameworks/intl/test/unittest/intl_test.h
Executable file → Normal file
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -51,7 +51,7 @@ void LocaleConfigTest::TearDown(void)
|
||||
HWTEST_F(LocaleConfigTest, LocaleConfigFuncTest001, TestSize.Level1)
|
||||
{
|
||||
int ret = SetParameter("hm.sys.language", "");
|
||||
if (ret == 0) {
|
||||
if (!ret) {
|
||||
EXPECT_EQ(LocaleConfig::GetSystemLanguage(), "zh-Hans");
|
||||
}
|
||||
}
|
||||
@ -64,7 +64,7 @@ HWTEST_F(LocaleConfigTest, LocaleConfigFuncTest001, TestSize.Level1)
|
||||
HWTEST_F(LocaleConfigTest, LocaleConfigFuncTest002, TestSize.Level1)
|
||||
{
|
||||
int ret = SetParameter("hm.sys.locale", "");
|
||||
if (ret == 0) {
|
||||
if (!ret) {
|
||||
EXPECT_EQ(LocaleConfig::GetSystemRegion(), "CN");
|
||||
}
|
||||
}
|
||||
@ -77,7 +77,7 @@ HWTEST_F(LocaleConfigTest, LocaleConfigFuncTest002, TestSize.Level1)
|
||||
HWTEST_F(LocaleConfigTest, LocaleConfigFuncTest003, TestSize.Level1)
|
||||
{
|
||||
int ret = SetParameter("hm.sys.locale", "");
|
||||
if (ret == 0) {
|
||||
if (!ret) {
|
||||
EXPECT_EQ(LocaleConfig::GetSystemLocale(), "zh-Hans-CN");
|
||||
}
|
||||
}
|
||||
|
2
frameworks/zone/BUILD.gn
Executable file → Normal file
2
frameworks/zone/BUILD.gn
Executable file → Normal file
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
2
frameworks/zone/src/zone_util.cpp
Executable file → Normal file
2
frameworks/zone/src/zone_util.cpp
Executable file → Normal file
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
0
frameworks/zone/test/BUILD.gn
Executable file → Normal file
0
frameworks/zone/test/BUILD.gn
Executable file → Normal file
0
frameworks/zone/test/unittest/zone_util_performance_test.cpp
Executable file → Normal file
0
frameworks/zone/test/unittest/zone_util_performance_test.cpp
Executable file → Normal file
0
frameworks/zone/test/unittest/zone_util_performance_test.h
Executable file → Normal file
0
frameworks/zone/test/unittest/zone_util_performance_test.h
Executable file → Normal file
2
frameworks/zone/test/unittest/zone_util_test.cpp
Executable file → Normal file
2
frameworks/zone/test/unittest/zone_util_test.cpp
Executable file → Normal file
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
0
frameworks/zone/test/unittest/zone_util_test.h
Executable file → Normal file
0
frameworks/zone/test/unittest/zone_util_test.h
Executable file → Normal file
2
interfaces/js/kits/BUILD.gn
Executable file → Normal file
2
interfaces/js/kits/BUILD.gn
Executable file → Normal file
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -253,7 +253,7 @@ napi_value I18nAddon::UnitConvert(napi_env env, napi_callback_info info)
|
||||
localeTags.push_back(localeBuf.data());
|
||||
std::map<std::string, std::string> map = {};
|
||||
map.insert(std::make_pair("style", "unit"));
|
||||
if (convertStatus == 0) {
|
||||
if (!convertStatus) {
|
||||
HiLog::Error(LABEL, "Do not support the conversion");
|
||||
map.insert(std::make_pair("unit", fromUnit));
|
||||
} else {
|
||||
@ -287,7 +287,7 @@ napi_value I18nAddon::IsDigitAddon(napi_env env, napi_callback_info info)
|
||||
}
|
||||
int32_t code = 0;
|
||||
std::string character = GetString(env, argv[0], code);
|
||||
if (code != 0) {
|
||||
if (code) {
|
||||
return nullptr;
|
||||
}
|
||||
bool isDigit = IsDigit(character);
|
||||
@ -315,7 +315,7 @@ napi_value I18nAddon::IsSpaceCharAddon(napi_env env, napi_callback_info info)
|
||||
}
|
||||
int32_t code = 0;
|
||||
std::string character = GetString(env, argv[0], code);
|
||||
if (code != 0) {
|
||||
if (code) {
|
||||
return nullptr;
|
||||
}
|
||||
bool isSpaceChar = IsSpaceChar(character);
|
||||
@ -343,7 +343,7 @@ napi_value I18nAddon::IsWhiteSpaceAddon(napi_env env, napi_callback_info info)
|
||||
}
|
||||
int32_t code = 0;
|
||||
std::string character = GetString(env, argv[0], code);
|
||||
if (code != 0) {
|
||||
if (code) {
|
||||
return nullptr;
|
||||
}
|
||||
bool isWhiteSpace = IsWhiteSpace(character);
|
||||
@ -371,7 +371,7 @@ napi_value I18nAddon::IsRTLCharacterAddon(napi_env env, napi_callback_info info)
|
||||
}
|
||||
int32_t code = 0;
|
||||
std::string character = GetString(env, argv[0], code);
|
||||
if (code != 0) {
|
||||
if (code) {
|
||||
return nullptr;
|
||||
}
|
||||
bool isRTLCharacter = IsRTLCharacter(character);
|
||||
@ -399,7 +399,7 @@ napi_value I18nAddon::IsIdeoGraphicAddon(napi_env env, napi_callback_info info)
|
||||
}
|
||||
int32_t code = 0;
|
||||
std::string character = GetString(env, argv[0], code);
|
||||
if (code != 0) {
|
||||
if (code) {
|
||||
return nullptr;
|
||||
}
|
||||
bool isIdeoGraphic = IsIdeoGraphic(character);
|
||||
@ -427,7 +427,7 @@ napi_value I18nAddon::IsLetterAddon(napi_env env, napi_callback_info info)
|
||||
}
|
||||
int32_t code = 0;
|
||||
std::string character = GetString(env, argv[0], code);
|
||||
if (code != 0) {
|
||||
if (code) {
|
||||
return nullptr;
|
||||
}
|
||||
bool isLetter = IsLetter(character);
|
||||
@ -455,7 +455,7 @@ napi_value I18nAddon::IsLowerCaseAddon(napi_env env, napi_callback_info info)
|
||||
}
|
||||
int32_t code = 0;
|
||||
std::string character = GetString(env, argv[0], code);
|
||||
if (code != 0) {
|
||||
if (code) {
|
||||
return nullptr;
|
||||
}
|
||||
bool isLowerCase = IsLowerCase(character);
|
||||
@ -483,7 +483,7 @@ napi_value I18nAddon::IsUpperCaseAddon(napi_env env, napi_callback_info info)
|
||||
}
|
||||
int32_t code = 0;
|
||||
std::string character = GetString(env, argv[0], code);
|
||||
if (code != 0) {
|
||||
if (code) {
|
||||
return nullptr;
|
||||
}
|
||||
bool isUpperCase = IsUpperCase(character);
|
||||
@ -511,7 +511,7 @@ napi_value I18nAddon::GetTypeAddon(napi_env env, napi_callback_info info)
|
||||
}
|
||||
int32_t code = 0;
|
||||
std::string character = GetString(env, argv[0], code);
|
||||
if (code != 0) {
|
||||
if (code) {
|
||||
return nullptr;
|
||||
}
|
||||
std::string type = GetType(character);
|
||||
@ -1123,7 +1123,7 @@ napi_value I18nAddon::CalendarConstructor(napi_env env, napi_callback_info info)
|
||||
}
|
||||
int32_t code = 0;
|
||||
std::string localeTag = GetString(env, argv[0], code);
|
||||
if (code != 0) {
|
||||
if (code) {
|
||||
return nullptr;
|
||||
}
|
||||
CalendarType type = GetCalendarType(env, argv[1]);
|
||||
@ -1157,7 +1157,7 @@ CalendarType I18nAddon::GetCalendarType(napi_env env, napi_value value)
|
||||
}
|
||||
int32_t code = 0;
|
||||
std::string calendarType = GetString(env, value, code);
|
||||
if (code != 0) {
|
||||
if (code) {
|
||||
return type;
|
||||
}
|
||||
if (g_typeMap.find(calendarType) != g_typeMap.end()) {
|
||||
@ -1620,7 +1620,7 @@ napi_value I18nAddon::GetDisplayName(napi_env env, napi_callback_info info)
|
||||
}
|
||||
int32_t code = 0;
|
||||
std::string localeTag = GetString(env, argv[0], code);
|
||||
if (code != 0) {
|
||||
if (code) {
|
||||
return nullptr;
|
||||
}
|
||||
I18nAddon *obj = nullptr;
|
||||
@ -1684,7 +1684,7 @@ napi_value I18nAddon::BreakIteratorConstructor(napi_env env, napi_callback_info
|
||||
}
|
||||
int32_t code = 0;
|
||||
std::string localeTag = GetString(env, argv[0], code);
|
||||
if (code != 0) {
|
||||
if (code) {
|
||||
return nullptr;
|
||||
}
|
||||
std::unique_ptr<I18nAddon> obj = std::make_unique<I18nAddon>();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -1700,7 +1700,7 @@ napi_value IntlAddon::CompareString(napi_env env, napi_callback_info info)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int32_t compareResult = obj->collator_->Compare(first.data(), second.data());
|
||||
CompareResult compareResult = obj->collator_->Compare(first.data(), second.data());
|
||||
napi_value result = nullptr;
|
||||
status = napi_create_int32(env, compareResult, &result);
|
||||
if (status != napi_ok) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -25,7 +25,7 @@ class LocaleUtil {
|
||||
public:
|
||||
static bool IsRTL(const std::string &locale);
|
||||
}
|
||||
} // I18n
|
||||
} // Global
|
||||
} // OHOS
|
||||
} // namespace I18n
|
||||
} // namespace Global
|
||||
} // namespace OHOS
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -47,7 +47,7 @@ private:
|
||||
static constexpr int CONFIG_LEN = 128;
|
||||
static constexpr uint32_t LANGUAGE_LEN = 2;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace I18n
|
||||
} // namespace Global
|
||||
} // namespace OHOS
|
||||
#endif
|
8
interfaces/native/innerkits/zone/include/zone_util.h
Executable file → Normal file
8
interfaces/native/innerkits/zone/include/zone_util.h
Executable file → Normal file
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -101,7 +101,7 @@ private:
|
||||
static void GetString(icu::StringEnumeration *strEnum, std::string &ret);
|
||||
static bool Init();
|
||||
};
|
||||
} // I18n
|
||||
} // Global
|
||||
} // OHOS
|
||||
} // namespace I18n
|
||||
} // namespace Global
|
||||
} // namespace OHOS
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user