From bc010992c44c4964aa8a4485edda681012fa28cf Mon Sep 17 00:00:00 2001 From: zhangdd_ewan Date: Thu, 4 Sep 2025 16:48:23 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E5=A2=9Endk=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangdd_ewan --- ohos_icu4c/BUILD.gn | 5 +- ohos_icu4c/libicu.map | 21 +++++ ohos_icu4c/src/icu_native.cpp | 151 ++++++++++++++++++++++++++++++++++ 3 files changed, 176 insertions(+), 1 deletion(-) create mode 100644 ohos_icu4c/src/icu_native.cpp diff --git a/ohos_icu4c/BUILD.gn b/ohos_icu4c/BUILD.gn index 9ce03ad1..7a29688a 100644 --- a/ohos_icu4c/BUILD.gn +++ b/ohos_icu4c/BUILD.gn @@ -26,7 +26,10 @@ ohos_shared_library("icundk") { ] include_dirs = [ "//third_party/icu/icu4c/source/common" ] - sources = [ "src/icu_addon.cpp" ] + sources = [ + "src/icu_addon.cpp", + "src/icu_native.cpp", + ] deps = [ ":ohos_icudat", diff --git a/ohos_icu4c/libicu.map b/ohos_icu4c/libicu.map index 50ca9424..44781763 100644 --- a/ohos_icu4c/libicu.map +++ b/ohos_icu4c/libicu.map @@ -523,6 +523,27 @@ u_strToUTF32WithSub; u_strFromUTF32WithSub; u_errorName; + u_charAge; + u_getUnicodeVersion; + uldn_open; + uldn_close; + uldn_getLocale; + uldn_getDialectHandling; + uldn_localeDisplayName; + uldn_languageDisplayName; + uldn_scriptDisplayName; + uldn_scriptCodeDisplayName; + uldn_regionDisplayName; + uldn_variantDisplayName; + uldn_keyDisplayName; + uldn_keyValueDisplayName; + uldn_openForContext; + uldn_getContext; + ulocdata_getCLDRVersion; + u_versionFromString; + u_versionFromUString; + u_versionToString; + u_getVersion; local: *; diff --git a/ohos_icu4c/src/icu_native.cpp b/ohos_icu4c/src/icu_native.cpp new file mode 100644 index 00000000..d67953c8 --- /dev/null +++ b/ohos_icu4c/src/icu_native.cpp @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2025 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Restore C api definition */ +#undef u_charAge +#undef u_getUnicodeVersion +#undef uldn_open +#undef uldn_close +#undef uldn_getLocale +#undef uldn_getDialectHandling +#undef uldn_localeDisplayName +#undef uldn_languageDisplayName +#undef uldn_scriptDisplayName +#undef uldn_scriptCodeDisplayName +#undef uldn_regionDisplayName +#undef uldn_variantDisplayName +#undef uldn_keyDisplayName +#undef uldn_keyValueDisplayName +#undef uldn_openForContext +#undef uldn_getContext +#undef ulocdata_getCLDRVersion +#undef u_versionFromString +#undef u_versionFromUString +#undef u_versionToString +#undef u_getVersion + +extern "C" +{ +void u_charAge(UChar32 c, UVersionInfo versionArray) +{ + U_ICU_ENTRY_POINT_RENAME(u_charAge)(c, versionArray); +} +void u_getUnicodeVersion(UVersionInfo versionArray) +{ + U_ICU_ENTRY_POINT_RENAME(u_getUnicodeVersion)(versionArray); +} +ULocaleDisplayNames* uldn_open(const char *locale, UDialectHandling dialectHandling, UErrorCode *pErrorCode) +{ + return U_ICU_ENTRY_POINT_RENAME(uldn_open)(locale, dialectHandling, pErrorCode); +} +void uldn_close(ULocaleDisplayNames *ldn) +{ + U_ICU_ENTRY_POINT_RENAME(uldn_close)(ldn); +} +const char* uldn_getLocale(const ULocaleDisplayNames *ldn) +{ + return U_ICU_ENTRY_POINT_RENAME(uldn_getLocale)(ldn); +} +UDialectHandling uldn_getDialectHandling(const ULocaleDisplayNames *ldn) +{ + return U_ICU_ENTRY_POINT_RENAME(uldn_getDialectHandling)(ldn); +} +int32_t uldn_localeDisplayName(const ULocaleDisplayNames *ldn, const char *locale, UChar *result, + int32_t maxResultSize, UErrorCode *pErrorCode) +{ + return U_ICU_ENTRY_POINT_RENAME(uldn_localeDisplayName)(ldn, locale, result, maxResultSize, pErrorCode); +} +int32_t uldn_languageDisplayName(const ULocaleDisplayNames *ldn, const char *lang, UChar *result, + int32_t maxResultSize, UErrorCode *pErrorCode) +{ + return U_ICU_ENTRY_POINT_RENAME(uldn_languageDisplayName)(ldn, lang, result, maxResultSize, pErrorCode); +} +int32_t uldn_scriptDisplayName(const ULocaleDisplayNames *ldn, const char *script, UChar *result, + int32_t maxResultSize, UErrorCode *pErrorCode) +{ + return U_ICU_ENTRY_POINT_RENAME(uldn_scriptDisplayName)(ldn, script, result, maxResultSize, pErrorCode); +} +int32_t uldn_scriptCodeDisplayName(const ULocaleDisplayNames *ldn, UScriptCode scriptCode, UChar *result, + int32_t maxResultSize, UErrorCode *pErrorCode) +{ + return U_ICU_ENTRY_POINT_RENAME(uldn_scriptCodeDisplayName)(ldn, + scriptCode, result, maxResultSize, pErrorCode); +} +int32_t uldn_regionDisplayName(const ULocaleDisplayNames *ldn, const char *region, UChar *result, + int32_t maxResultSize, UErrorCode *pErrorCode) +{ + return U_ICU_ENTRY_POINT_RENAME(uldn_regionDisplayName)(ldn, region, result, maxResultSize, pErrorCode); +} +int32_t uldn_variantDisplayName(const ULocaleDisplayNames *ldn, const char *variant, UChar *result, + int32_t maxResultSize, UErrorCode *pErrorCode) +{ + return U_ICU_ENTRY_POINT_RENAME(uldn_variantDisplayName)(ldn, + variant, result, maxResultSize, pErrorCode); +} +int32_t uldn_keyDisplayName(const ULocaleDisplayNames *ldn, const char *key, UChar *result, + int32_t maxResultSize, UErrorCode *pErrorCode) +{ + return U_ICU_ENTRY_POINT_RENAME(uldn_keyDisplayName)(ldn, key, result, maxResultSize, pErrorCode); +} +int32_t uldn_keyValueDisplayName(const ULocaleDisplayNames *ldn, const char *key, const char *value, + UChar *result, int32_t maxResultSize, UErrorCode *pErrorCode) +{ + return U_ICU_ENTRY_POINT_RENAME(uldn_keyValueDisplayName)(ldn, + key, value, result, maxResultSize, pErrorCode); +} +ULocaleDisplayNames* uldn_openForContext(const char *locale, UDisplayContext *contexts, + int32_t length, UErrorCode *pErrorCode) +{ + return U_ICU_ENTRY_POINT_RENAME(uldn_openForContext)(locale, contexts, length, pErrorCode); +} +UDisplayContext uldn_getContext(const ULocaleDisplayNames *ldn, UDisplayContextType type, + UErrorCode *pErrorCode) +{ + return U_ICU_ENTRY_POINT_RENAME(uldn_getContext)(ldn, type, pErrorCode); +} +void ulocdata_getCLDRVersion(UVersionInfo versionArray, UErrorCode *status) +{ + U_ICU_ENTRY_POINT_RENAME(ulocdata_getCLDRVersion)(versionArray, status); +} +void u_versionFromString(UVersionInfo versionArray, const char *versionString) +{ + U_ICU_ENTRY_POINT_RENAME(u_versionFromString)(versionArray, versionString); +} +void u_versionFromUString(UVersionInfo versionArray, const UChar *versionString) +{ + U_ICU_ENTRY_POINT_RENAME(u_versionFromUString)(versionArray, versionString); +} +void u_versionToString(const UVersionInfo versionArray, char *versionString) +{ + U_ICU_ENTRY_POINT_RENAME(u_versionToString)(versionArray, versionString); +} +void u_getVersion(UVersionInfo versionArray) +{ + U_ICU_ENTRY_POINT_RENAME(u_getVersion)(versionArray); +} +} \ No newline at end of file -- Gitee From ac7a992dde2a4b2fed4801bb4014de60d6398b76 Mon Sep 17 00:00:00 2001 From: zhangdd_ewan Date: Wed, 10 Sep 2025 19:30:38 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=96=B0=E5=A2=9Endk=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangdd_ewan --- ohos_icu4c/BUILD.gn | 5 +- ohos_icu4c/src/icu_addon.cpp | 128 ++++++++++++++++++++++++++++ ohos_icu4c/src/icu_native.cpp | 151 ---------------------------------- 3 files changed, 129 insertions(+), 155 deletions(-) delete mode 100644 ohos_icu4c/src/icu_native.cpp diff --git a/ohos_icu4c/BUILD.gn b/ohos_icu4c/BUILD.gn index 7a29688a..9ce03ad1 100644 --- a/ohos_icu4c/BUILD.gn +++ b/ohos_icu4c/BUILD.gn @@ -26,10 +26,7 @@ ohos_shared_library("icundk") { ] include_dirs = [ "//third_party/icu/icu4c/source/common" ] - sources = [ - "src/icu_addon.cpp", - "src/icu_native.cpp", - ] + sources = [ "src/icu_addon.cpp" ] deps = [ ":ohos_icudat", diff --git a/ohos_icu4c/src/icu_addon.cpp b/ohos_icu4c/src/icu_addon.cpp index efa1e068..7e594a15 100644 --- a/ohos_icu4c/src/icu_addon.cpp +++ b/ohos_icu4c/src/icu_addon.cpp @@ -33,6 +33,16 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef ICU_SUPPORT_LIBBEGETUTIL #include "parameter.h" @@ -565,6 +575,27 @@ bool g_isCustomLocale = false; #undef u_strToUTF32WithSub #undef u_strFromUTF32WithSub #undef u_errorName +#undef u_charAge +#undef u_getUnicodeVersion +#undef uldn_open +#undef uldn_close +#undef uldn_getLocale +#undef uldn_getDialectHandling +#undef uldn_localeDisplayName +#undef uldn_languageDisplayName +#undef uldn_scriptDisplayName +#undef uldn_scriptCodeDisplayName +#undef uldn_regionDisplayName +#undef uldn_variantDisplayName +#undef uldn_keyDisplayName +#undef uldn_keyValueDisplayName +#undef uldn_openForContext +#undef uldn_getContext +#undef ulocdata_getCLDRVersion +#undef u_versionFromString +#undef u_versionFromUString +#undef u_versionToString +#undef u_getVersion extern "C" { @@ -2841,4 +2872,101 @@ const char* u_errorName(UErrorCode code) { return U_ICU_ENTRY_POINT_RENAME(u_errorName)(code); } +void u_charAge(UChar32 c, UVersionInfo versionArray) +{ + U_ICU_ENTRY_POINT_RENAME(u_charAge)(c, versionArray); +} +void u_getUnicodeVersion(UVersionInfo versionArray) +{ + U_ICU_ENTRY_POINT_RENAME(u_getUnicodeVersion)(versionArray); +} +ULocaleDisplayNames* uldn_open(const char *locale, UDialectHandling dialectHandling, UErrorCode *pErrorCode) +{ + return U_ICU_ENTRY_POINT_RENAME(uldn_open)(locale, dialectHandling, pErrorCode); +} +void uldn_close(ULocaleDisplayNames *ldn) +{ + U_ICU_ENTRY_POINT_RENAME(uldn_close)(ldn); +} +const char* uldn_getLocale(const ULocaleDisplayNames *ldn) +{ + return U_ICU_ENTRY_POINT_RENAME(uldn_getLocale)(ldn); +} +UDialectHandling uldn_getDialectHandling(const ULocaleDisplayNames *ldn) +{ + return U_ICU_ENTRY_POINT_RENAME(uldn_getDialectHandling)(ldn); +} +int32_t uldn_localeDisplayName(const ULocaleDisplayNames *ldn, const char *locale, UChar *result, + int32_t maxResultSize, UErrorCode *pErrorCode) +{ + return U_ICU_ENTRY_POINT_RENAME(uldn_localeDisplayName)(ldn, locale, result, maxResultSize, pErrorCode); +} +int32_t uldn_languageDisplayName(const ULocaleDisplayNames *ldn, const char *lang, UChar *result, + int32_t maxResultSize, UErrorCode *pErrorCode) +{ + return U_ICU_ENTRY_POINT_RENAME(uldn_languageDisplayName)(ldn, lang, result, maxResultSize, pErrorCode); +} +int32_t uldn_scriptDisplayName(const ULocaleDisplayNames *ldn, const char *script, UChar *result, + int32_t maxResultSize, UErrorCode *pErrorCode) +{ + return U_ICU_ENTRY_POINT_RENAME(uldn_scriptDisplayName)(ldn, script, result, maxResultSize, pErrorCode); +} +int32_t uldn_scriptCodeDisplayName(const ULocaleDisplayNames *ldn, UScriptCode scriptCode, UChar *result, + int32_t maxResultSize, UErrorCode *pErrorCode) +{ + return U_ICU_ENTRY_POINT_RENAME(uldn_scriptCodeDisplayName)(ldn, + scriptCode, result, maxResultSize, pErrorCode); +} +int32_t uldn_regionDisplayName(const ULocaleDisplayNames *ldn, const char *region, UChar *result, + int32_t maxResultSize, UErrorCode *pErrorCode) +{ + return U_ICU_ENTRY_POINT_RENAME(uldn_regionDisplayName)(ldn, region, result, maxResultSize, pErrorCode); +} +int32_t uldn_variantDisplayName(const ULocaleDisplayNames *ldn, const char *variant, UChar *result, + int32_t maxResultSize, UErrorCode *pErrorCode) +{ + return U_ICU_ENTRY_POINT_RENAME(uldn_variantDisplayName)(ldn, + variant, result, maxResultSize, pErrorCode); +} +int32_t uldn_keyDisplayName(const ULocaleDisplayNames *ldn, const char *key, UChar *result, + int32_t maxResultSize, UErrorCode *pErrorCode) +{ + return U_ICU_ENTRY_POINT_RENAME(uldn_keyDisplayName)(ldn, key, result, maxResultSize, pErrorCode); +} +int32_t uldn_keyValueDisplayName(const ULocaleDisplayNames *ldn, const char *key, const char *value, + UChar *result, int32_t maxResultSize, UErrorCode *pErrorCode) +{ + return U_ICU_ENTRY_POINT_RENAME(uldn_keyValueDisplayName)(ldn, + key, value, result, maxResultSize, pErrorCode); +} +ULocaleDisplayNames* uldn_openForContext(const char *locale, UDisplayContext *contexts, + int32_t length, UErrorCode *pErrorCode) +{ + return U_ICU_ENTRY_POINT_RENAME(uldn_openForContext)(locale, contexts, length, pErrorCode); +} +UDisplayContext uldn_getContext(const ULocaleDisplayNames *ldn, UDisplayContextType type, + UErrorCode *pErrorCode) +{ + return U_ICU_ENTRY_POINT_RENAME(uldn_getContext)(ldn, type, pErrorCode); +} +void ulocdata_getCLDRVersion(UVersionInfo versionArray, UErrorCode *status) +{ + U_ICU_ENTRY_POINT_RENAME(ulocdata_getCLDRVersion)(versionArray, status); +} +void u_versionFromString(UVersionInfo versionArray, const char *versionString) +{ + U_ICU_ENTRY_POINT_RENAME(u_versionFromString)(versionArray, versionString); +} +void u_versionFromUString(UVersionInfo versionArray, const UChar *versionString) +{ + U_ICU_ENTRY_POINT_RENAME(u_versionFromUString)(versionArray, versionString); +} +void u_versionToString(const UVersionInfo versionArray, char *versionString) +{ + U_ICU_ENTRY_POINT_RENAME(u_versionToString)(versionArray, versionString); +} +void u_getVersion(UVersionInfo versionArray) +{ + U_ICU_ENTRY_POINT_RENAME(u_getVersion)(versionArray); +} } \ No newline at end of file diff --git a/ohos_icu4c/src/icu_native.cpp b/ohos_icu4c/src/icu_native.cpp deleted file mode 100644 index d67953c8..00000000 --- a/ohos_icu4c/src/icu_native.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) 2025 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* Restore C api definition */ -#undef u_charAge -#undef u_getUnicodeVersion -#undef uldn_open -#undef uldn_close -#undef uldn_getLocale -#undef uldn_getDialectHandling -#undef uldn_localeDisplayName -#undef uldn_languageDisplayName -#undef uldn_scriptDisplayName -#undef uldn_scriptCodeDisplayName -#undef uldn_regionDisplayName -#undef uldn_variantDisplayName -#undef uldn_keyDisplayName -#undef uldn_keyValueDisplayName -#undef uldn_openForContext -#undef uldn_getContext -#undef ulocdata_getCLDRVersion -#undef u_versionFromString -#undef u_versionFromUString -#undef u_versionToString -#undef u_getVersion - -extern "C" -{ -void u_charAge(UChar32 c, UVersionInfo versionArray) -{ - U_ICU_ENTRY_POINT_RENAME(u_charAge)(c, versionArray); -} -void u_getUnicodeVersion(UVersionInfo versionArray) -{ - U_ICU_ENTRY_POINT_RENAME(u_getUnicodeVersion)(versionArray); -} -ULocaleDisplayNames* uldn_open(const char *locale, UDialectHandling dialectHandling, UErrorCode *pErrorCode) -{ - return U_ICU_ENTRY_POINT_RENAME(uldn_open)(locale, dialectHandling, pErrorCode); -} -void uldn_close(ULocaleDisplayNames *ldn) -{ - U_ICU_ENTRY_POINT_RENAME(uldn_close)(ldn); -} -const char* uldn_getLocale(const ULocaleDisplayNames *ldn) -{ - return U_ICU_ENTRY_POINT_RENAME(uldn_getLocale)(ldn); -} -UDialectHandling uldn_getDialectHandling(const ULocaleDisplayNames *ldn) -{ - return U_ICU_ENTRY_POINT_RENAME(uldn_getDialectHandling)(ldn); -} -int32_t uldn_localeDisplayName(const ULocaleDisplayNames *ldn, const char *locale, UChar *result, - int32_t maxResultSize, UErrorCode *pErrorCode) -{ - return U_ICU_ENTRY_POINT_RENAME(uldn_localeDisplayName)(ldn, locale, result, maxResultSize, pErrorCode); -} -int32_t uldn_languageDisplayName(const ULocaleDisplayNames *ldn, const char *lang, UChar *result, - int32_t maxResultSize, UErrorCode *pErrorCode) -{ - return U_ICU_ENTRY_POINT_RENAME(uldn_languageDisplayName)(ldn, lang, result, maxResultSize, pErrorCode); -} -int32_t uldn_scriptDisplayName(const ULocaleDisplayNames *ldn, const char *script, UChar *result, - int32_t maxResultSize, UErrorCode *pErrorCode) -{ - return U_ICU_ENTRY_POINT_RENAME(uldn_scriptDisplayName)(ldn, script, result, maxResultSize, pErrorCode); -} -int32_t uldn_scriptCodeDisplayName(const ULocaleDisplayNames *ldn, UScriptCode scriptCode, UChar *result, - int32_t maxResultSize, UErrorCode *pErrorCode) -{ - return U_ICU_ENTRY_POINT_RENAME(uldn_scriptCodeDisplayName)(ldn, - scriptCode, result, maxResultSize, pErrorCode); -} -int32_t uldn_regionDisplayName(const ULocaleDisplayNames *ldn, const char *region, UChar *result, - int32_t maxResultSize, UErrorCode *pErrorCode) -{ - return U_ICU_ENTRY_POINT_RENAME(uldn_regionDisplayName)(ldn, region, result, maxResultSize, pErrorCode); -} -int32_t uldn_variantDisplayName(const ULocaleDisplayNames *ldn, const char *variant, UChar *result, - int32_t maxResultSize, UErrorCode *pErrorCode) -{ - return U_ICU_ENTRY_POINT_RENAME(uldn_variantDisplayName)(ldn, - variant, result, maxResultSize, pErrorCode); -} -int32_t uldn_keyDisplayName(const ULocaleDisplayNames *ldn, const char *key, UChar *result, - int32_t maxResultSize, UErrorCode *pErrorCode) -{ - return U_ICU_ENTRY_POINT_RENAME(uldn_keyDisplayName)(ldn, key, result, maxResultSize, pErrorCode); -} -int32_t uldn_keyValueDisplayName(const ULocaleDisplayNames *ldn, const char *key, const char *value, - UChar *result, int32_t maxResultSize, UErrorCode *pErrorCode) -{ - return U_ICU_ENTRY_POINT_RENAME(uldn_keyValueDisplayName)(ldn, - key, value, result, maxResultSize, pErrorCode); -} -ULocaleDisplayNames* uldn_openForContext(const char *locale, UDisplayContext *contexts, - int32_t length, UErrorCode *pErrorCode) -{ - return U_ICU_ENTRY_POINT_RENAME(uldn_openForContext)(locale, contexts, length, pErrorCode); -} -UDisplayContext uldn_getContext(const ULocaleDisplayNames *ldn, UDisplayContextType type, - UErrorCode *pErrorCode) -{ - return U_ICU_ENTRY_POINT_RENAME(uldn_getContext)(ldn, type, pErrorCode); -} -void ulocdata_getCLDRVersion(UVersionInfo versionArray, UErrorCode *status) -{ - U_ICU_ENTRY_POINT_RENAME(ulocdata_getCLDRVersion)(versionArray, status); -} -void u_versionFromString(UVersionInfo versionArray, const char *versionString) -{ - U_ICU_ENTRY_POINT_RENAME(u_versionFromString)(versionArray, versionString); -} -void u_versionFromUString(UVersionInfo versionArray, const UChar *versionString) -{ - U_ICU_ENTRY_POINT_RENAME(u_versionFromUString)(versionArray, versionString); -} -void u_versionToString(const UVersionInfo versionArray, char *versionString) -{ - U_ICU_ENTRY_POINT_RENAME(u_versionToString)(versionArray, versionString); -} -void u_getVersion(UVersionInfo versionArray) -{ - U_ICU_ENTRY_POINT_RENAME(u_getVersion)(versionArray); -} -} \ No newline at end of file -- Gitee