From d17be071161e9740a4a9f174acfd3069bbdb91d2 Mon Sep 17 00:00:00 2001 From: "jk7744.park" Date: Tue, 8 Sep 2015 22:08:19 +0900 Subject: [PATCH] tizen 2.3.1 release --- CMakeLists.txt | 24 + LICENSE | 202 +++ LICENSE.ICU | 14 + capi-base-utils.manifest | 5 + doc/utils_doc.h | 44 + packaging/capi-base-utils.spec | 78 + src/CMakeLists.txt | 71 + src/capi-base-utils-i18n.pc.in | 13 + src/include/mobile/utils_i18n.h | 1779 +++++++++++++++++++ src/include/mobile/utils_i18n_private.h | 88 + src/include/mobile/utils_i18n_timezone.h | 467 +++++ src/include/mobile/utils_i18n_types.h | 1989 ++++++++++++++++++++++ src/include/mobile/utils_i18n_ubrk.h | 346 ++++ src/include/mobile/utils_i18n_ucalendar.h | 910 ++++++++++ src/include/mobile/utils_i18n_uchar.h | 175 ++ src/include/mobile/utils_i18n_ucollator.h | 230 +++ src/include/mobile/utils_i18n_udate.h | 632 +++++++ src/include/mobile/utils_i18n_udatepg.h | 642 +++++++ src/include/mobile/utils_i18n_uenumeration.h | 194 +++ src/include/mobile/utils_i18n_ulocale.h | 841 +++++++++ src/include/mobile/utils_i18n_unormalization.h | 114 ++ src/include/mobile/utils_i18n_unumber.h | 645 +++++++ src/include/mobile/utils_i18n_usearch.h | 207 +++ src/include/mobile/utils_i18n_uset.h | 1175 +++++++++++++ src/include/mobile/utils_i18n_ustring.h | 1380 +++++++++++++++ src/include/wearable/utils_i18n.h | 1779 +++++++++++++++++++ src/include/wearable/utils_i18n_private.h | 88 + src/include/wearable/utils_i18n_timezone.h | 452 +++++ src/include/wearable/utils_i18n_types.h | 1989 ++++++++++++++++++++++ src/include/wearable/utils_i18n_ubrk.h | 346 ++++ src/include/wearable/utils_i18n_ucalendar.h | 910 ++++++++++ src/include/wearable/utils_i18n_uchar.h | 175 ++ src/include/wearable/utils_i18n_ucollator.h | 230 +++ src/include/wearable/utils_i18n_udate.h | 632 +++++++ src/include/wearable/utils_i18n_udatepg.h | 642 +++++++ src/include/wearable/utils_i18n_uenumeration.h | 194 +++ src/include/wearable/utils_i18n_ulocale.h | 841 +++++++++ src/include/wearable/utils_i18n_unormalization.h | 114 ++ src/include/wearable/utils_i18n_unumber.h | 645 +++++++ src/include/wearable/utils_i18n_usearch.h | 182 ++ src/include/wearable/utils_i18n_uset.h | 1175 +++++++++++++ src/include/wearable/utils_i18n_ustring.h | 1339 +++++++++++++++ src/utils_i18n_private.c | 104 ++ src/utils_i18n_timezone.cpp | 426 +++++ src/utils_i18n_ubrk.c | 240 +++ src/utils_i18n_ucalendar.c | 550 ++++++ src/utils_i18n_uchar.c | 35 + src/utils_i18n_ucollator.c | 77 + src/utils_i18n_udate.c | 343 ++++ src/utils_i18n_udatepg.c | 345 ++++ src/utils_i18n_uenumeration.c | 132 ++ src/utils_i18n_ulocale.c | 443 +++++ src/utils_i18n_unormalization.c | 40 + src/utils_i18n_unumber.c | 392 +++++ src/utils_i18n_usearch.c | 79 + src/utils_i18n_uset.c | 699 ++++++++ src/utils_i18n_ustring.c | 733 ++++++++ 57 files changed, 28636 insertions(+) create mode 100755 CMakeLists.txt create mode 100644 LICENSE create mode 100644 LICENSE.ICU create mode 100644 capi-base-utils.manifest create mode 100755 doc/utils_doc.h create mode 100755 packaging/capi-base-utils.spec create mode 100755 src/CMakeLists.txt create mode 100644 src/capi-base-utils-i18n.pc.in create mode 100755 src/include/mobile/utils_i18n.h create mode 100755 src/include/mobile/utils_i18n_private.h create mode 100755 src/include/mobile/utils_i18n_timezone.h create mode 100644 src/include/mobile/utils_i18n_types.h create mode 100755 src/include/mobile/utils_i18n_ubrk.h create mode 100644 src/include/mobile/utils_i18n_ucalendar.h create mode 100644 src/include/mobile/utils_i18n_uchar.h create mode 100755 src/include/mobile/utils_i18n_ucollator.h create mode 100644 src/include/mobile/utils_i18n_udate.h create mode 100755 src/include/mobile/utils_i18n_udatepg.h create mode 100755 src/include/mobile/utils_i18n_uenumeration.h create mode 100644 src/include/mobile/utils_i18n_ulocale.h create mode 100755 src/include/mobile/utils_i18n_unormalization.h create mode 100644 src/include/mobile/utils_i18n_unumber.h create mode 100755 src/include/mobile/utils_i18n_usearch.h create mode 100755 src/include/mobile/utils_i18n_uset.h create mode 100644 src/include/mobile/utils_i18n_ustring.h create mode 100755 src/include/wearable/utils_i18n.h create mode 100755 src/include/wearable/utils_i18n_private.h create mode 100755 src/include/wearable/utils_i18n_timezone.h create mode 100644 src/include/wearable/utils_i18n_types.h create mode 100755 src/include/wearable/utils_i18n_ubrk.h create mode 100644 src/include/wearable/utils_i18n_ucalendar.h create mode 100644 src/include/wearable/utils_i18n_uchar.h create mode 100755 src/include/wearable/utils_i18n_ucollator.h create mode 100644 src/include/wearable/utils_i18n_udate.h create mode 100755 src/include/wearable/utils_i18n_udatepg.h create mode 100755 src/include/wearable/utils_i18n_uenumeration.h create mode 100644 src/include/wearable/utils_i18n_ulocale.h create mode 100755 src/include/wearable/utils_i18n_unormalization.h create mode 100644 src/include/wearable/utils_i18n_unumber.h create mode 100755 src/include/wearable/utils_i18n_usearch.h create mode 100755 src/include/wearable/utils_i18n_uset.h create mode 100755 src/include/wearable/utils_i18n_ustring.h create mode 100755 src/utils_i18n_private.c create mode 100755 src/utils_i18n_timezone.cpp create mode 100644 src/utils_i18n_ubrk.c create mode 100644 src/utils_i18n_ucalendar.c create mode 100755 src/utils_i18n_uchar.c create mode 100755 src/utils_i18n_ucollator.c create mode 100644 src/utils_i18n_udate.c create mode 100755 src/utils_i18n_udatepg.c create mode 100755 src/utils_i18n_uenumeration.c create mode 100755 src/utils_i18n_ulocale.c create mode 100755 src/utils_i18n_unormalization.c create mode 100755 src/utils_i18n_unumber.c create mode 100755 src/utils_i18n_usearch.c create mode 100644 src/utils_i18n_uset.c create mode 100644 src/utils_i18n_ustring.c diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100755 index 0000000..0822a80 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,24 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +PROJECT(${PKG_NAME} C CXX) +SET(VERSION "${PKG_VERSION}") + +MESSAGE("PROJECT : ${PROJECT_NAME}") +MESSAGE("VERSION : ${VERSION}") + +INCLUDE(FindPkgConfig) + +PKG_CHECK_MODULES(common_pkgs REQUIRED capi-base-common dlog) +INCLUDE_DIRECTORIES( + ${common_pkgs_INCLUDE_DIRS} +) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror") +SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}") + +SET(common_pc_requires "capi-base-common") +SET(common_libs + ${common_pkgs_LDFLAGS} +) + +ADD_SUBDIRECTORY(src/) diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/LICENSE.ICU b/LICENSE.ICU new file mode 100644 index 0000000..7883949 --- /dev/null +++ b/LICENSE.ICU @@ -0,0 +1,14 @@ + +ICU License - ICU 1.8.1 and later + +COPYRIGHT AND PERMISSION NOTICE + +Copyright (c) 1995-2015 International Business Machines Corporation and others + +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, provided that the above copyright notice(s) and this permission notice appear in all copies of the Software and that both the above copyright notice(s) and this permission notice appear in supporting documentation. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization of the copyright holder. \ No newline at end of file diff --git a/capi-base-utils.manifest b/capi-base-utils.manifest new file mode 100644 index 0000000..97e8c31 --- /dev/null +++ b/capi-base-utils.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/doc/utils_doc.h b/doc/utils_doc.h new file mode 100755 index 0000000..1cff578 --- /dev/null +++ b/doc/utils_doc.h @@ -0,0 +1,44 @@ +#ifndef __UTILS_DOC_H__ +#define __UTILS_DOC_H__ + +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + + +/** + * @file utils_doc.h + * @brief This file contains high level documentation of the utils service. + */ + +/** + * @ingroup CAPI_BASE_FRAMEWORK + * @defgroup CAPI_BASE_UTILS_MODULE Utils + * @brief utils Service + * @section CAPI_BASE_UTILS_MODULE_OVERVIEW Overview + * + * + * + * + * + * + * + * + * + *
ModuleDescription
@ref CAPI_BASE_UTILS_I18N_MODULEi18n module contains uchar, ucollator, unormalization, usearch, ustring, ucalendar, udate, udatepg, ulocale and unumber. + * This module provides flexible generation of number or date format patterns and helps you to format and parse dates/number for any locale.
+ */ + +#endif /* __UTILS_DOC_H__*/ diff --git a/packaging/capi-base-utils.spec b/packaging/capi-base-utils.spec new file mode 100755 index 0000000..cced079 --- /dev/null +++ b/packaging/capi-base-utils.spec @@ -0,0 +1,78 @@ +Name: capi-base-utils +Summary: Base Utils +Version: 1.0.2 +Release: 1 +Group: Base +License: Apache-2.0 and ICU +Source0: %{name}-%{version}.tar.gz +BuildRequires: cmake +BuildRequires: pkgconfig(icu-i18n) +BuildRequires: pkgconfig(capi-base-common) +BuildRequires: pkgconfig(dlog) + +Requires(post): /sbin/ldconfig +Requires(postun): /sbin/ldconfig + +%description +The base utils library for internationalization and localization + +%package devel +License: Apache-2.0 and ICU +Summary: The Base Utils Library (Development) +Group: Base +Requires: %{name} = %{version}-%{release} + +%description devel +The base utils library for internationalization and localization (Development) + +%prep +%setup -q + +%build +#export CFLAGS="$CFLAGS -Wall -Werror -Wno-unused-function" +cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DLIB_INSTALL_DIR:PATH=%{_libdir} -DINCLUDE_INSTALL_DIR:PATH=%{_includedir} \ + -DPKG_NAME=%{name} -DPKG_VERSION=%{version} \ +%if "%{?tizen_profile_name}" == "wearable" + -DTIZEN_WEARABLE=YES \ +%endif +%if "%{?tizen_profile_name}" == "mobile" + -DTIZEN_MOBILE=YES \ +%endif + +make %{?jobs:-j%jobs} + +%install +rm -rf %{buildroot} +%make_install +mkdir -p %{buildroot}/usr/share/license +cp LICENSE %{buildroot}/usr/share/license/%{name} +cat LICENSE.ICU >> %{buildroot}/usr/share/license/%{name} + +%post -p /sbin/ldconfig + +%postun -p /sbin/ldconfig + +%files +%manifest capi-base-utils.manifest +%{_libdir}/libbase-utils-i18n.so* +/usr/share/license/%{name} + +%files devel +%defattr(-,root,root,-) +%{_includedir}/base/utils_i18n_ucalendar.h +%{_includedir}/base/utils_i18n_udate.h +%{_includedir}/base/utils_i18n_udatepg.h +%{_includedir}/base/utils_i18n_ulocale.h +%{_includedir}/base/utils_i18n_unumber.h +%{_includedir}/base/utils_i18n_uchar.h +%{_includedir}/base/utils_i18n_ucollator.h +%{_includedir}/base/utils_i18n_unormalization.h +%{_includedir}/base/utils_i18n_usearch.h +%{_includedir}/base/utils_i18n_ustring.h +%{_includedir}/base/utils_i18n_timezone.h +%{_includedir}/base/utils_i18n_types.h +%{_includedir}/base/utils_i18n_uenumeration.h +%{_includedir}/base/utils_i18n_uset.h +%{_includedir}/base/utils_i18n_ubrk.h +%{_includedir}/base/utils_i18n.h +%{_libdir}/pkgconfig/*.pc diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100755 index 0000000..b858ab8 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,71 @@ +SET(target_name "base-utils-i18n") +SET(pc_name "capi-base-utils-i18n") + +SET(dependents "icu-i18n") +PKG_CHECK_MODULES(baseutils REQUIRED ${dependents}) + +IF (TIZEN_WEARABLE) +SET(INC_DIR "include/wearable") +ELSEIF (TIZEN_MOBILE) +SET(INC_DIR "include/mobile") +ELSE (TIZEN_WEARABLE) +SET(INC_DIR "include/wearable") +ENDIF (TIZEN_WEARABLE) + +INCLUDE_DIRECTORIES( + ${baseutils_INCLUDE_DIRS} + ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR} +) + +SET(BASEUTILS_SRCS + utils_i18n_private.c + utils_i18n_uchar.c + utils_i18n_ucollator.c + utils_i18n_unormalization.c + utils_i18n_usearch.c + utils_i18n_ustring.c + utils_i18n_ucalendar.c + utils_i18n_udate.c + utils_i18n_udatepg.c + utils_i18n_ulocale.c + utils_i18n_unumber.c + utils_i18n_uenumeration.c + utils_i18n_uset.c + utils_i18n_ubrk.c + utils_i18n_timezone.cpp +) + +ADD_LIBRARY(${target_name} SHARED ${BASEUTILS_SRCS} + # ${CMAKE_CURRENT_SOURCE_DIR}/*.c +) + +TARGET_LINK_LIBRARIES(${target_name} + ${common_libs} + ${baseutils_LDFLAGS} +) + +SET_TARGET_PROPERTIES(${target_name} PROPERTIES VERSION ${PKG_VERSION}) +SET_TARGET_PROPERTIES(${target_name} PROPERTIES SOVERSION 0) + +SET(PC_REQUIRED "${common_pc_requires} icu-i18n") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}") +CONFIGURE_FILE(${pc_name}.pc.in ${pc_name}.pc @ONLY) + +INSTALL(TARGETS ${target_name} DESTINATION ${LIB_INSTALL_DIR}) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n_types.h DESTINATION ${INCLUDE_INSTALL_DIR}/base) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n_uchar.h DESTINATION ${INCLUDE_INSTALL_DIR}/base) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n_ucollator.h DESTINATION ${INCLUDE_INSTALL_DIR}/base) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n_unormalization.h DESTINATION ${INCLUDE_INSTALL_DIR}/base) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n_usearch.h DESTINATION ${INCLUDE_INSTALL_DIR}/base) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n_ustring.h DESTINATION ${INCLUDE_INSTALL_DIR}/base) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n_ucalendar.h DESTINATION ${INCLUDE_INSTALL_DIR}/base) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n_udate.h DESTINATION ${INCLUDE_INSTALL_DIR}/base) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n_udatepg.h DESTINATION ${INCLUDE_INSTALL_DIR}/base) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n_ulocale.h DESTINATION ${INCLUDE_INSTALL_DIR}/base) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n_unumber.h DESTINATION ${INCLUDE_INSTALL_DIR}/base) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n_timezone.h DESTINATION ${INCLUDE_INSTALL_DIR}/base) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n_uenumeration.h DESTINATION ${INCLUDE_INSTALL_DIR}/base) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n_uset.h DESTINATION ${INCLUDE_INSTALL_DIR}/base) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n_ubrk.h DESTINATION ${INCLUDE_INSTALL_DIR}/base) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n.h DESTINATION ${INCLUDE_INSTALL_DIR}/base) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${pc_name}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) diff --git a/src/capi-base-utils-i18n.pc.in b/src/capi-base-utils-i18n.pc.in new file mode 100644 index 0000000..70dadc8 --- /dev/null +++ b/src/capi-base-utils-i18n.pc.in @@ -0,0 +1,13 @@ +# Package Information for pkg-config + +prefix=/usr +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include/base + +Name: base-utils +Description: base-utils +Version: @VERSION@ +Requires: @PC_REQUIRED@ +Libs: -L${libdir} -lbase-utils-i18n +Cflags: -I${includedir} diff --git a/src/include/mobile/utils_i18n.h b/src/include/mobile/utils_i18n.h new file mode 100755 index 0000000..94a07bd --- /dev/null +++ b/src/include/mobile/utils_i18n.h @@ -0,0 +1,1779 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +#ifndef __UTILS_I18N_H__ +#define __UTILS_I18N_H__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** + * @file utils_i18n.h + * @version 0.1 + * @brief utils_i18n + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @ingroup CAPI_BASE_UTILS_MODULE + * @defgroup CAPI_BASE_UTILS_I18N_MODULE i18n + * @brief The i18n module contains uchar, ucollator, unormalization, usearch, ustring, ucalendar, udate, udatepg, ulocale and unumber. + * This module provides flexible generation of number or date format patterns and helps you format and parse dates/number for any locale. + * @section CAPI_BASE_UTILS_I18N_MODULE_HEADER Required Header + * \#include + * @section CAPI_BASE_UTILS_I18N_MODULE_OVERVIEW Overview + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
APIDescription
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULEThe Timezone module represents a time zone offset, and also figures out daylight savings.
@ref CAPI_BASE_UTILS_I18N_UENUMERATION_MODULEUEnumeration defines functions for handling String Enumeration.
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULEUbrk module defines methods for finding the location of boundaries in text.
@ref CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULEUcollator module performs locale-sensitive string comparison. It builds searching and sorting routines for natural language text and provides correct sorting orders for most locales.
@ref CAPI_BASE_UTILS_I18N_UCHAR_MODULEUchar module provides low-level access to the Unicode Character Database.
@ref CAPI_BASE_UTILS_I18N_UNORMALIZATION_MODULEUnormalization module provides Unicode normalization functionality for standard unicode normalization.
@ref CAPI_BASE_UTILS_I18N_USEARCH_MODULEUsearch module provides language-sensitive text searching based on the comparison rules defined in a ucollator data struct.
@ref CAPI_BASE_UTILS_I18N_USET_MODULEUset module allows to specify a subset of character used in strings.
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULEUstring module provides general unicode string handling.
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULEUcalendar is used for converting between a i18n_udate type and a set of integer fields + such as #I18N_UCALENDAR_YEAR, #I18N_UCALENDAR_MONTH, #I18N_UCALENDAR_DATE, #I18N_UCALENDAR_HOUR, and so on.
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULEUdate module consists of functions that convert dates and times from their + internal representations to textual form and back again in a language-independent manner.
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE Udatepg module provides flexible generation of date format patterns, like "yy-MM-dd".
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULEA ulocale represents a specific geographical, political, or cultural region.
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULEUnumber helps you format and parse numbers for any locale.
+ * + * @section CAPI_BASE_UTILS_I18N_MODULE_MAPPING_TABLE Mapping Table + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
ModuleNative APIICU API
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_create_unknowngetUnknown
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_create_gmtgetGMT
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_createcreateTimeZone
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_destroy
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_foreach_timezone_id_by_regioncreateTimeZoneIDEnumeration
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_foreach_timezone_idcreateEnumeration
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_foreach_timezone_id_with_offsetcreateEnumeration
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_foreach_timezone_id_by_countrycreateEnumeration
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_count_equivalent_idscountEquivalentIDs
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_get_equivalent_idgetEquivalentID
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_create_defaultcreateDefault
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_set_defaultsetDefault
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_get_tzdata_versiongetTZDataVersion
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_get_regiongetRegion
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_get_offset_with_dategetOffset
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_set_raw_offsetsetRawOffset
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_get_raw_offsetgetRawOffset
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_get_idgetID
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_set_idsetID
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_get_display_namegetDisplayName
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_get_display_name_with_localegetDisplayName
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_get_display_name_with_typegetDisplayName
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_get_display_name_with_type_localegetDisplayName
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_use_daylight_timeuseDaylightTime
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_has_same_rulehasSameRules
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_cloneclone
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_get_dst_savingsgetDSTSavings
@ref CAPI_BASE_UTILS_I18N_UENUMERATION_MODULE#i18n_uenumeration_destroyuenum_close
@ref CAPI_BASE_UTILS_I18N_UENUMERATION_MODULE#i18n_uenumeration_countuenum_count
@ref CAPI_BASE_UTILS_I18N_UENUMERATION_MODULE#i18n_uenumeration_unextuenum_unext
@ref CAPI_BASE_UTILS_I18N_UENUMERATION_MODULE#i18n_uenumeration_nextuenum_next
@ref CAPI_BASE_UTILS_I18N_UENUMERATION_MODULE#i18n_uenumeration_resetuenum_reset
@ref CAPI_BASE_UTILS_I18N_UENUMERATION_MODULE#i18n_uenumeration_uchar_strings_enumeration_createuenum_openUCharStringsEnumeration
@ref CAPI_BASE_UTILS_I18N_UENUMERATION_MODULE#i18n_uenumeration_char_strings_enumeration_createuenum_openCharStringsEnumeration
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULE#i18n_ubrk_createubrk_open
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULE#i18n_ubrk_create_rulesubrk_openRules
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULE#i18n_ubrk_safe_cloneubrk_safeClone
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULE#i18n_ubrk_destroyubrk_close
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULE#i18n_ubrk_set_textubrk_setText
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULE#i18n_ubrk_currentubrk_current
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULE#i18n_ubrk_nextubrk_next
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULE#i18n_ubrk_precedingubrk_preceding
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULE#i18n_ubrk_previousubrk_previous
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULE#i18n_ubrk_firstubrk_first
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULE#i18n_ubrk_lastubrk_last
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULE#i18n_ubrk_followingubrk_following
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULE#i18n_ubrk_get_availableubrk_getAvailable
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULE#i18n_ubrk_count_availableubrk_countAvailable
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULE#i18n_ubrk_is_boundaryubrk_isBoundary
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULE#i18n_ubrk_get_rule_statusubrk_getRuleStatus
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULE#i18n_ubrk_get_rule_status_vecubrk_getRuleStatusVec
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULE#i18n_ubrk_get_locale_by_typeubrk_getLocaleByType
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_set_default_timezoneucal_setDefaultTimeZone
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_get_nowucal_getNow
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_createucal_open
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_destroyucal_close
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_cloneucal_clone
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_get_timezone_displaynameucal_getTimeZoneDisplayName
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_is_in_daylight_timeucal_inDaylightTime
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_setucal_set
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_set_attributeucal_setAttribute
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_get_attributeucal_getAttribute
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_get_millisecondsucal_getMillis
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_set_millisecondsucal_setMillis
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_set_date_timeucal_setDateTime
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_is_equivalent_toucal_equivalentTo
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_adducal_add
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_getucal_get
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_clearucal_clear
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_clear_fielducal_clearField
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_count_availableucal_countAvailable
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_country_timezones_createucal_openCountryTimeZones
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_get_availableucal_getAvailable
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_get_canonical_timezone_iducal_getCanonicalTimeZoneID
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_get_day_of_week_typeucal_getDayOfWeekType
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_get_default_timezoneucal_getDefaultTimeZone
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_get_field_differenceucal_getFieldDifference
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_get_gregorian_changeucal_getGregorianChange
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_get_keyword_values_for_localeucal_getKeywordValuesForLocale
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_get_limitucal_getLimit
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_get_locale_by_typeucal_getLocaleByType
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_get_timezone_iducal_getTimeZoneID
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_get_timezone_transition_dateucal_getTimeZoneTransitionDate
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_get_typeucal_getType
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_get_tz_data_versionucal_getTZDataVersion
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_get_weekend_transitionucal_getWeekendTransition
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_is_setucal_isSet
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_is_weekenducal_isWeekend
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_rollucal_roll
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_set_dateucal_setDate
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_set_gregorian_changeucal_setGregorianChange
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_set_timezoneucal_setTimeZone
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_timezones_createucal_openTimeZones
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_timezone_id_enumeration_createucal_openTimeZoneIDEnumeration
@ref CAPI_BASE_UTILS_I18N_UCHAR_MODULE#i18n_uchar_get_int_property_valueu_getIntpropertyValue
@ref CAPI_BASE_UTILS_I18N_UCHAR_MODULE#i18n_uchar_get_ublock_codeublock_getCode
@ref CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULE#i18n_ucollator_createucol_open
@ref CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULE#i18n_ucollator_destroyucol_close
@ref CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULE#i18n_ucollator_str_collatorucol_strcoll
@ref CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULE#i18n_ucollator_equalucol_equal
@ref CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULE#i18n_ucollator_set_strengthucol_setStrength
@ref CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULE#i18n_ucollator_set_attributeucol_setAttribute
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_createudat_open
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_destroyudat_close
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_format_dateudat_format
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_apply_patternudat_applyPattern
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_cloneudat_clone
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_count_availableudat_countAvailable
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_count_symbolsudat_countSymbols
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_get_2digit_year_startudat_get2DigitYearStart
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_get_availableudat_getAvailable
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_get_calendarudat_getCalendar
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_get_locale_by_typeudat_getLocaleByType
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_get_number_formatudat_getNumberFormat
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_get_symbolsudat_getSymbols
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_is_lenientudat_isLenient
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_parseudat_parse
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_parse_calendarudat_parseCalendar
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_set_2digit_year_startudat_set2DigitYearStart
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_set_calendarudat_setCalendar
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_set_contextudat_setContext
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_set_lenientudat_setLenient
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_set_number_formatudat_setNumberFormat
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_set_symbolsudat_setSymbols
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_to_calendar_date_fieldudat_toCalendarDateField
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_to_patternudat_toPattern
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_createudatpg_open
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_destroyudatpg_close
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_get_best_patternudatpg_getBestPattern
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_add_patternudatpg_addPattern
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_base_skeletons_createudatpg_openBaseSkeletons
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_cloneudatpg_clone
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_create_emptyudatpg_openEmpty
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_get_append_item_formatudatpg_getAppendItemFormat
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_get_append_item_nameudatpg_getAppendItemName
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_get_base_skeletonudatpg_getBaseSkeleton
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_get_best_pattern_with_optionsudatpg_getBestPatternWithOptions
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_get_date_time_formatudatpg_getDateTimeFormat
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_get_decimaludatpg_getDecimal
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_get_pattern_for_skeletonudatpg_getPatternForSkeleton
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_get_skeletonudatpg_getSkeleton
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_replace_field_typesudatpg_replaceFieldTypes
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_replace_field_types_with_optionsudatpg_replaceFieldTypesWithOptions
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_set_append_item_formatudatpg_setAppendItemFormat
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_set_append_item_nameudatpg_setAppendItemName
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_set_date_time_formatudatpg_setDateTimeFormat
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_set_decimaludatpg_setDecimal
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_skeletons_createudatpg_openSkeletons
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_defaultuloc_getDefault
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_set_defaultuloc_setDefault
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_languageuloc_getLanguage
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_countryuloc_getCountry
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_display_nameuloc_getDisplayName
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_add_likely_subtagsuloc_addLikelySubtags
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_canonicalizeuloc_canonicalize
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_for_language_taguloc_forLanguageTag
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_base_nameuloc_getBaseName
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_character_orientationuloc_getCharacterOrientation
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_display_countryuloc_getDisplayCountry
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_display_keyworduloc_getDisplayKeyword
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_display_keyword_valueuloc_getDisplayKeywordValue
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_display_languageuloc_getDisplayLanguage
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_display_scriptuloc_getDisplayScript
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_display_variantuloc_getDisplayVariant
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_iso3_countryuloc_getISO3Country
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_iso3_languageuloc_getISO3Language
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_iso_countriesuloc_getISOCountries
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_iso_languagesuloc_getISOLanguages
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_keyword_valueuloc_getKeywordValue
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_lciduloc_getLCID
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_line_orientationuloc_getLineOrientation
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_locale_for_lciduloc_getLocaleForLCID
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_nameuloc_getName
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_parentuloc_getParent
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_scriptuloc_getScript
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_variantuloc_getVariant
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_keywords_createuloc_openKeywords
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_minimize_subtagsuloc_minimizeSubtags
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_set_keyword_valueuloc_setKeywordValue
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_to_language_taguloc_toLanguageTag
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_availableuloc_getAvailable
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_count_availableuloc_countAvailable
@ref CAPI_BASE_UTILS_I18N_UNORMALIZATION_MODULE#i18n_unormalization_get_instanceunorm2_getInstance
@ref CAPI_BASE_UTILS_I18N_UNORMALIZATION_MODULE#i18n_unormalization_normalizeunorm2_normalize
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_createunum_open
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_destroyunum_close
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_get_symbolunum_getSymbol
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_apply_patternunum_applyPattern
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_cloneunum_clone
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_count_availableunum_countAvailable
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_formatunum_format
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_format_decimalunum_formatDecimal
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_format_doubleunum_formatDouble
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_format_double_currencyunum_formatDoubleCurrency
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_format_int64unum_formatInt64
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_get_attributeunum_getAttribute
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_get_availableunum_getAvailable
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_get_double_attributeunum_getDoubleAttribute
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_get_locale_by_typeunum_getLocaleByType
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_get_text_attributeunum_getTextAttribute
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_parseunum_parse
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_parse_decimalunum_parseDecimal
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_parse_doubleunum_parseDouble
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_parse_double_currencyunum_parseDoubleCurrency
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_parse_int64unum_parseInt64
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_set_attributeunum_setAttribute
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_set_double_attributeunum_setDoubleAttribute
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_set_symbolunum_setSymbol
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_set_text_attributeunum_setTextAttribute
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_to_patternunum_toPattern
@ref CAPI_BASE_UTILS_I18N_USEARCH_MODULE#i18n_usearch_create_newusearch_open
@ref CAPI_BASE_UTILS_I18N_USEARCH_MODULE#i18n_usearch_destroyusearch_close
@ref CAPI_BASE_UTILS_I18N_USEARCH_MODULE#i18n_usearch_get_matched_textusearch_getMatchedText
@ref CAPI_BASE_UTILS_I18N_USEARCH_MODULE#i18n_usearch_get_collatorusearch_getCollator
@ref CAPI_BASE_UTILS_I18N_USEARCH_MODULE#i18n_usearch_firstusearch_first
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_create_emptyuset_openEmpty
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_createuset_open
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_create_patternuset_openPattern
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_create_pattern_optionsuset_openPatternOptions
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_destroyuset_close
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_cloneuset_clone
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_is_frozenuset_isFrozen
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_freezeuset_freeze
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_clone_as_thaweduset_cloneAsThawed
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_setuset_set
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_apply_patternuset_applyPattern
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_apply_int_property_valueuset_applyIntPropertyValue
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_apply_property_aliasuset_applyPropertyAlias
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_resembles_patternuset_resemblesPattern
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_to_patternuset_toPattern
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_adduset_add
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_add_alluset_addAll
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_add_rangeuset_addRange
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_add_stringuset_addString
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_add_all_code_pointsuset_addAllCodePoints
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_removeuset_remove
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_remove_rangeuset_removeRange
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_remove_stringuset_removeString
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_remove_alluset_removeAll
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_retainuset_retain
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_retain_alluset_retainAll
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_compactuset_compact
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_complementuset_complement
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_complement_alluset_complementAll
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_clearuset_clear
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_destroy_overuset_closeOver
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_remove_all_stringsuset_removeAllStrings
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_is_emptyuset_isEmpty
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_containsuset_contains
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_contains_rangeuset_containsRange
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_contains_stringuset_containsString
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_index_ofuset_indexOf
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_char_atuset_charAt
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_sizeuset_size
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_get_item_countuset_getItemCount
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_get_itemuset_getItem
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_contains_alluset_containsAll
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_contains_all_code_pointsuset_containsAllCodePoints
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_contains_noneuset_containsNone
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_contains_someuset_containsSome
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_spanuset_span
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_span_backuset_spanBack
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_span_utf8uset_spanUTF8
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_span_back_utf8uset_spanBackUTF8
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_equalsuset_equals
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_serializeuset_serialize
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_get_serialized_setuset_getSerializedSet
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_set_serialized_to_oneuset_setSerializedToOne
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_serialized_containsuset_serializedContains
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_get_serialized_range_countuset_getSerializedRangeCount
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_get_serialized_rangeuset_getSerializedRange
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_get_lengthu_strlen
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_count_char32u_countChar32
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_has_more_char32_thanu_strHasMoreChar32Than
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_catu_strcat
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_cat_nu_strncat
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_stringu_strstr
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_find_firstu_strFindFirst
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_charu_strchr
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_char32u_strchr32
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_r_stringu_strrstr
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_find_lastu_strFindLast
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_r_charu_strrchr
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_r_char32u_strrchr32
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_pbrku_strpbrk
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_cspnu_strcspn
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_spnu_strspn
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_tokenizer_ru_strtok_r
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_compareu_strcmp
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_compare_code_point_orderu_strcmpCodePointOrder
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_compare_binary_orderu_strCompare
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_case_compare_with_lengthu_strCaseCompare
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_compare_nu_strncmp
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_compare_n_code_point_orderu_strncmpCodePointOrder
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_case_compareu_strcasecmp
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_case_compare_nu_strncasecmp
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_mem_case_compareu_memcasecmp
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_copyu_strcpy
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_copy_nu_strncpy
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_copy_uau_uastrcpy
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_copy_ua_nu_uastrncpy
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_copy_auu_austrcpy
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_copy_au_nu_austrncpy
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_mem_copyu_memcpy
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_mem_moveu_memmove
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_mem_setu_memset
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_mem_compareu_memcmp
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_mem_compare_code_point_orderu_memcmpCodePointOrder
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_mem_charu_memchr
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_mem_char32u_memchr32
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_mem_r_charu_memrchr
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_mem_r_char32u_memrchr32
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_unescapeu_unescape
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_unescape_atu_unescapeAt
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_to_upperu_strToUpper
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_to_loweru_strToLower
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_to_title_newu_strToTitle
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_fold_caseu_strFoldCase
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_to_WCSu_strToWCS
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_from_WCSu_strFromWCS
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_to_UTF8u_strToUTF8
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_from_UTF8u_strFromUTF8
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_to_UTF8_with_subu_strToUTF8WithSub
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_from_UTF8_with_subu_strFromUTF8WithSub
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_from_UTF8_lenientu_strFromUTF8Lenient
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_to_UTF32u_strToUTF32
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_from_UTF32u_strFromUTF32
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_to_UTF32_with_subu_strToUTF32WithSub
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_from_UTF32_with_subu_strFromUTF32WithSub
+ */ + +#ifdef __cplusplus +} +#endif + +#endif /* __UTILS_I18N_H__*/ diff --git a/src/include/mobile/utils_i18n_private.h b/src/include/mobile/utils_i18n_private.h new file mode 100755 index 0000000..d0eb671 --- /dev/null +++ b/src/include/mobile/utils_i18n_private.h @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +#ifndef __UTILS_I18N_PRIVATE_H__ +#define __UTILS_I18N_PRIVATE_H__ + +#include +#include +#include +#include + +/** + * @file utils_i18n_private.h + * @version 0.1 + * @brief utils_i18n_private + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "BASE_UTILS" + +#define ERR(fmt, arg...) SLOGE("%s:%d " fmt, __FUNCTION__, __LINE__, ##arg) + +#define ret_if(expr) do { \ + if (expr) { \ + ERR("(%s)", #expr); \ + return; \ + } \ +} while (0) +#define retv_if(expr, val) do { \ + if (expr) { \ + ERR("(%s)", #expr); \ + return (val); \ + } \ +} while (0) +#define retm_if(expr, fmt, arg...) do { \ + if (expr) { \ + ERR(fmt, ##arg); \ + return; \ + } \ +} while (0) +#define retvm_if(expr, val, fmt, arg...) do { \ + if (expr) { \ + ERR(fmt, ##arg); \ + return (val); \ + } \ +} while (0) + +#define retex_if(expr, val, fmt, arg...) do { \ + if(expr) { \ + ERR(fmt, ##arg); \ + val; \ + goto CATCH; \ + } \ + } while (0); + +#define ERR_MAPPING_REVERSE(BASE_UTILS_ERROR, ICU_ERROR) ICU_ERROR = \ + (UErrorCode)_i18n_error_mapping_reverse((int)BASE_UTILS_ERROR) + +#define ERR_MAPPING(ICU_ERROR, BASE_UTILS_ERROR) BASE_UTILS_ERROR = \ + (i18n_error_code_e)_i18n_error_mapping((int)ICU_ERROR) + +int _i18n_error_mapping ( int err ); +int _i18n_error_mapping_reverse ( int err ); + +#ifdef __cplusplus +} +#endif + +#endif /* __UTILS_I18N_PRIVATE_H__*/ diff --git a/src/include/mobile/utils_i18n_timezone.h b/src/include/mobile/utils_i18n_timezone.h new file mode 100755 index 0000000..a33865b --- /dev/null +++ b/src/include/mobile/utils_i18n_timezone.h @@ -0,0 +1,467 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +#ifndef __UTILS_I18N_TIMEZONE_H__ +#define __UTILS_I18N_TIMEZONE_H__ + +#include + +/** + * @file utils_i18n_timezone.h + * @version 0.1 + * @brief utils_i18n_timezone + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @ingroup CAPI_BASE_UTILS_I18N_MODULE + * @defgroup CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE Timezone + * @brief The Timezone module represents a time zone offset, and also figures out daylight savings. + * @section CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE_OVERVIEW Overview + * @details The Timezone module represents a time zone offset, and also figures out daylight savings.\n + * Typically, you get an i18n_timezone_h using #i18n_timezone_create_default which creates a TimeZone based on the time zone + * where the program is running. For example, for a program running in Japan, + * #i18n_timezone_create_default creates an i18n_timezone_h based on Japanese Standard Time.\n + * You can also get an i18n_timezone_h using #i18n_timezone_create along with a time zone ID. + * For instance, the time zone ID for the US Pacific Time zone is "America/Los_Angeles". + * So, you can get a Pacific Time i18n_timezone_h with:\n + * + * i18n_timezone_h timezone;\n + * i18n_timezone_create(&timezone, "America/Los_Angeles");\n + * + * To create a new i18n_timezone_h, you call the factory function #i18n_timezone_create() and pass it a time zone ID. + * You can use the int #i18n_timezone_foreach_timezone_id() function to obtain a list of all the time zone IDs recognized by #i18n_timezone_create().\n + * You can also use #i18n_timezone_create_default() to create an i18n_timezone_h. This function uses platform-specific APIs to produce + * an i18n_timezone_h for the time zone corresponding to the client's computer's physical location. + * For example, if you're in Japan (assuming your machine is set up correctly), #i18n_timezone_create_default() + * will return an i18n_timezone_h for Japanese Standard Time ("Asia/Tokyo"). + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE + * @{ + */ + +/** + * @brief Returns the "unknown" time zone. + * @details #i18n_timezone_create() returns a mutable clone of this time zone if the input ID is not recognized. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] timezone the "unknown" time zone. + * + * @retval #I18N_ERROR_NONE Successful + * @see i18n_timezone_create() + * @see i18n_timezone_create_gmt() + */ +int i18n_timezone_create_unknown ( i18n_timezone_h *timezone ); + +/** + * @brief The GMT (=UTC) time zone has a raw offset of zero and does not use daylight savings time. + * @details This is a commonly used time zone.\n + * Note: For backward compatibility reason, the ID used by the time zone returned by this method is "GMT", although the I18N's canonical ID for the GMT time zone is "Etc/GMT". + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] timezone the GMT/UTC time zone. + * + * @retval #I18N_ERROR_NONE Successful + * @see i18n_timezone_create_unknown() + */ +int i18n_timezone_create_gmt ( i18n_timezone_h *timezone ); + +/** + * @brief Creates an i18n_timezone_h for the given timezone_id. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] timezone the GMT/UTC time zone. + * @param[in] timezone_id the ID for an i18n_timezone_h, such as "America/Los_Angeles", or a custom ID such as "GMT-8:00". + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_create ( i18n_timezone_h *timezone, const char *timezone_id ); + +/** + * @brief Destroys an i18n_timezone_h. + * @details Once destroyed, an i18n_timezone_h may no longer be used. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] timezone The i18n_timezone_h to destroy. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_destroy(i18n_timezone_h timezone); + +/** + * @brief Returns an enumeration over system time zone IDs with the given filter conditions. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] timezone_type The system time zone type. + * @param[in] region The ISO 3166 two-letter country code or UN M.49 three-digit area code. When NULL, no filtering done by region. + * @param[in] raw_offset An offset from GMT in milliseconds, ignoring the effect of daylight savings time, if any. When NULL, no filtering done by zone offset. + * @param[in] cb The callback function to get an enumeration object, owned by the caller. + * @param[in] user_data The user data to be passed to the callback function. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_foreach_timezone_id_by_region(i18n_system_timezone_type_e timezone_type, const char *region, const int32_t *raw_offset, i18n_timezone_id_cb cb, void* user_data); + +/** + * @brief Returns an enumeration over all recognized time zone IDs. + * (i.e., all strings that #i18n_timezone_create() accepts) + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] cb The callback function to get an enumeration object, owned by the caller. + * @param[in] user_data The user data to be passed to the callback function. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_foreach_timezone_id(i18n_timezone_id_cb cb, void* user_data); + +/** + * @brief Returns an enumeration over time zone IDs with a given raw offset from GMT. + * @details There may be several times zones with the same GMT offset that differ in the way they + * handle daylight savings time. For example, the state of Arizona doesn't observe daylight + * savings time. If you ask for the time zone IDs corresponding to GMT-7:00, + * you'll get back an enumeration over two time zone IDs: "America/Denver," + * which corresponds to Mountain Standard Time in the winter and Mountain Daylight Time in the summer, + * and "America/Phoenix", which corresponds to Mountain Standard Time year-round, even in the summer. + * + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] raw_offset an offset from GMT in milliseconds, ignoring the effect of daylight savings time, if any + * @param[in] cb The callback function to get an enumeration object, owned by the caller. + * @param[in] user_data The user data to be passed to the callback function. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_foreach_timezone_id_with_offset(int32_t raw_offset, i18n_timezone_id_cb cb, void* user_data); + +/** + * @brief Returns an enumeration over time zone IDs associated with the given country. + * @details Some zones are affiliated with no country (e.g., "UTC"); these may also be retrieved, as a group. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] country The ISO 3166 two-letter country code, or NULL to retrieve zones not affiliated with any country. + * @param[in] cb The callback function to get an enumeration object, owned by the caller. + * @param[in] user_data The user data to be passed to the callback function. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_foreach_timezone_id_by_country(const char *country, i18n_timezone_id_cb cb, void* user_data); + +/** + * @brief Returns the number of IDs in the equivalency group that includes the given ID. + * @details An equivalency group contains zones that have the same GMT offset and rules.\n + * The returned count includes the given ID; it is always >= 1. The given ID must be a system time zone. If it is not, returns zero. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] timezone_id a system time zone ID + * @param[out] count the number of zones in the equivalency group containing 'timezone_id', or zero if 'timezone_id' is not a valid system ID + * + * @retval #I18N_ERROR_NONE Successful + * @see i18n_timezone_get_equivalent_id() + */ +int i18n_timezone_count_equivalent_ids(const char *timezone_id, int32_t *count); + +/** + * @brief Returns an ID in the equivalency group that includes the given ID. + * @details An equivalency group contains zones that have the same GMT offset and rules.\n + * The given index must be in the range 0..n-1, where n is the out parameter value + * from i18n_timezone_count_equivalent_ids(timezone_id, &n). + * For some value of 'index', the returned value will be equal to the given id. + * If the given id is not a valid system time zone, + * or if 'index' is out of range, then returns an empty string. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] timezone_id a system time zone ID + * @param[in] index a value from 0 to n-1, where n is the out parameter value from i18n_timezone_count_equivalent_ids(timezone_id, &n) + * @param[out] equivalent_timezone_id the ID of the index-th zone in the equivalency group containing 'timezone_id', + * or an empty string if 'timezone_id' is not a valid system ID or 'index' is out of range + * + * @retval #I18N_ERROR_NONE Successful + * @see i18n_timezone_count_equivalent_ids() + */ +int i18n_timezone_get_equivalent_id(const char *timezone_id, int32_t index, char **equivalent_timezone_id); + +/** + * @brief Creates a new copy of the default i18n_timezone_h for this host. + * @details Unless the default time zone has already been set using #i18n_timezone_set_default(), + * the default is determined by querying the system using methods in TPlatformUtilities. + * If the system routines fail, or if they specify an i18n_timezone_h or i18n_timezone_h offset + * which is not recognized, the i18n_timezone_h indicated by the ID kLastResortID + * is instantiated and made the default. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] timezone A default i18n_timezone_h. Clients are responsible for deleting the time zone object returned. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_create_default ( i18n_timezone_h *timezone ); + +/** + * @brief Sets the default time zone (i.e., what's returned by #i18n_timezone_create_default()) to be the specified time zone. + * @details If NULL is specified for the time zone, the default time zone is set to the default host time zone. + * The caller remains responsible for deleting it. \n + * This function is not thread safe. It is an error for multiple threads to concurrently attempt to set + * the default time zone, or for any thread to attempt to reference the default zone while another thread is setting it. + * + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @remarks Do not use unless you know what you are doing. + * + * @param[in] timezone The given timezone. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_set_default( i18n_timezone_h timezone ); + +/** + * @brief Returns the timezone data version currently used by I18N. + * @remarks The specific error code can be obtained using the get_last_result() + * method. Error codes are described in #i18n_error_code_e description. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @return the version string, such as "2007f" + * @exception #I18N_ERROR_NONE Successful + */ +const char* i18n_timezone_get_tzdata_version(void); + +/** + * @brief Gets the region code associated with the given system time zone ID. + * @details The region code is either ISO 3166 2-letter country code or UN M.49 3-digit area code. + * When the time zone is not associated with a specific location, for example - "Etc/UTC", + * "EST5EDT", then this method returns "001" (UN M.49 area code for World). + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] timezone_id The system time zone ID. + * @param[out] region Output buffer for receiving the region code. + * @param[out] region_len The length of the region code. + * @param[in] region_capacity The size of the output buffer. If it is lower than required @a region buffer size, + * then I18N_ERROR_BUFFER_OVERFLOW error is returned. + * + * @return the version string, such as "2007f" + */ +int i18n_timezone_get_region(const char *timezone_id, char *region, int32_t *region_len, int32_t region_capacity); + +/** + * @brief Returns the time zone raw and GMT offset for the given moment in time. + * @details Upon return, local-millis = GMT-millis + rawOffset + dstOffset. All computations are performed + * in the proleptic Gregorian calendar. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] timezone The i18n_timezone_h to get an offset. + * @param[in] date moment in time for which to return offsets, in units of milliseconds from January 1, 1970 0:00 GMT, either GMT time or local wall time, depending on `local'. + * @param[in] local output if true, `date' is local wall time; otherwise it is in GMT time. + * @param[out] raw_offset parameter to receive the raw offset, that is, the offset not including DST adjustments + * @param[out] dst_offset output parameter to receive the DST offset, that is, the offset to be added to `raw_offset' to obtain the total offset between local and GMT time. If DST is not in effect, this value is zero; otherwise it is a positive value, typically one hour. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_get_offset_with_date(i18n_timezone_h timezone, i18n_udate date, i18n_ubool local, int32_t *raw_offset, int32_t *dst_offset); + +/** + * @brief Sets the i18n_timezone_h's raw GMT offset + * (i.e., the number of milliseconds to add to GMT to get local time, before taking daylight savings time into account). + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] timezone The i18n_timezone_h to set a raw offset. + * @param[in] offset_milliseconds The new raw GMT offset for this time zone. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_set_raw_offset(i18n_timezone_h timezone, int32_t offset_milliseconds); + +/** + * @brief Gets the region code associated with the given system time zone ID. + * @details The region code is either ISO 3166 2-letter country code or UN M.49 3-digit area code. When the time zone is not associated with a specific location, for example - "Etc/UTC", "EST5EDT", then this method returns "001" (UN M.49 area code for World). + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] timezone The i18n_timezone_h to get a raw offset. + * @param[out] offset_milliseconds The i18n_timezone_h's raw GMT offset. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_get_raw_offset(i18n_timezone_h timezone, int32_t *offset_milliseconds); + +/** + * @brief Fills in "timezone_id" with the i18n_timezone_h's ID. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] timezone The i18n_timezone_h to get a timezone ID. + * @param[out] timezone_id Receives this i18n_timezone_h's ID. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_get_id(i18n_timezone_h timezone, char **timezone_id); + +/** + * @brief Sets the i18n_timezone_h's ID to the specified value. + * @details This doesn't affect any other fields. for example,\n + * \n + * i18n_timezone_h timezone = NULL;\n + * i18n_timezone_create ( &timezone, "America/New_York" );\n + * i18n_timezone_set_id ( "America/Los_Angeles" );\n + * \n + * the timezone's GMT offset and daylight-savings rules don't change to those for Los Angeles. + * They're still those for New York. Only the ID has changed. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] timezone The i18n_timezone_h to set a timezone ID. + * @param[in] timezone_id The new time zone ID. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_set_id(i18n_timezone_h timezone, const char *timezone_id); + +/** + * @brief Returns a name of this time zone suitable for presentation to the user in the default locale. + * @details This method returns the long name, not including daylight savings. + * If the display name is not available for the locale, then this method returns a string in the localized GMT offset format such as GMT[+-]HH:mm. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] timezone The i18n_timezone_h to get a display name. + * @param[out] display_name The human-readable name of this time zone in the default locale. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_get_display_name(i18n_timezone_h timezone, char **display_name); + +/** + * @brief Returns a name of this time zone suitable for presentation to the user in the default locale. + * @details This method returns the long name, not including daylight savings. + * If the display name is not available for the locale, then this method returns a string in the localized GMT offset format such as GMT[+-]HH:mm. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] timezone The i18n_timezone_h to get a display name. + * @param[in] language The language in which to supply the display name. This parameter can be NULL; if so, the locale is initialized to match the current default locale. + * @param[in] country The country in which to supply the display name. This parameter can be NULL. + * @param[out] display_name The human-readable name of this time zone in the default locale. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_get_display_name_with_locale(i18n_timezone_h timezone, const char *language, const char *country , char **display_name); + +/** + * @brief Returns a name of this time zone suitable for presentation to the user in the default locale. + * @details If the display name is not available for the locale, + * then this method returns a string in the localized GMT offset format such as GMT[+-]HH:mm. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] timezone The i18n_timezone_h to get a display name. + * @param[in] daylight If true, display_name is filled with the daylight savings name. + * @param[in] style The style displayed on. + * @param[out] display_name The human-readable name of this time zone in the default locale. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_get_display_name_with_type(i18n_timezone_h timezone, i18n_ubool daylight, i18n_timezone_display_type_e style, char **display_name); + +/** + * @brief Returns a name of this time zone suitable for presentation to the user in the default locale. + * @details If the display name is not available for the locale, + * then this method returns a string in the localized GMT offset format such as GMT[+-]HH:mm. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] timezone The i18n_timezone_h to get a display name. + * @param[in] daylight If true, display_name is filled with the daylight savings name. + * @param[in] style The style displayed on. + * @param[in] language The language in which to supply the display name. This parameter can be NULL; if so, the locale is initialized to match the current default locale. + * @param[in] country The country in which to supply the display name. This parameter can be NULL. + * @param[out] display_name The human-readable name of this time zone in the default locale. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_get_display_name_with_type_locale(i18n_timezone_h timezone, i18n_ubool daylight, i18n_timezone_display_type_e style, const char *language, const char *country, char **display_name); + +/** + * @brief Queries if this time zone uses daylight savings time. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] timezone The i18n_timezone_h to know whether uses daylight savings time or not. + * @param[out] daylight_time True if this time zone uses daylight savings time, False, otherwise. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_use_daylight_time(i18n_timezone_h timezone, i18n_ubool *daylight_time); + +/** + * @brief Queries if the given date is in daylight savings time in this time zone. + * @details This method is wasteful since it creates a new GregorianCalendar and deletes it each time it is called. + * @since_tizen 2.3 + * + * @deprecated Deprecated since 2.3.1. Use i18n_ucalendar_is_in_daylight_time() instead. + * + * @param[in] timezone The i18n_timezone_h to know whether in daylight savings time or not. + * @param[in] date the given i18n_udate. + * @param[out] daylight_time True if the given date is in daylight savings time, False, otherwise. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_in_daylight_time(i18n_timezone_h timezone, i18n_udate date, i18n_ubool *daylight_time); + +/** + * @brief Returns true if this zone has the same rule and offset as another zone. + * @details That is, if this zone differs only in ID, if at all. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] timezone The i18n_timezone_h to know whether has the same rule or not. + * @param[in] other The i18n_timezone_h to be compared with. + * @param[out] same_rule True if the given zone is the same as this one, with the possible exception of the ID. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_has_same_rule(i18n_timezone_h timezone, i18n_timezone_h other, i18n_ubool *same_rule); + +/** + * @brief Clones i18n_timezone_h polymorphically. + * @details Clients are responsible for deleting the i18n_timezone_h cloned. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] timezone The i18n_timezone_h to clone. + * @param[out] clone A new copy of this i18n_timezone_h. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_clone(i18n_timezone_h timezone, i18n_timezone_h *clone); + +/** + * @brief Returns the amount of time to be added to local standard time to get local wall clock time. + * @details The default implementation always returns 3600000 milliseconds (i.e., one hour) if this time zone observes Daylight Saving Time. + * Otherwise, 0 (zero) is returned.\n + * If an underlying TimeZone implementation subclass supports historical Daylight Saving Time changes, + * this method returns the known latest daylight saving value. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] timezone The i18n_timezone_h to get DST savings. + * @param[out] dst_savings The amount of saving time in milliseconds. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_get_dst_savings(i18n_timezone_h timezone, int32_t *dst_savings); + +#ifdef __cplusplus +} +#endif + +/** + * @} + * @} + */ +#endif /* __UTILS_I18N_TIMEZONE_H__*/ diff --git a/src/include/mobile/utils_i18n_types.h b/src/include/mobile/utils_i18n_types.h new file mode 100644 index 0000000..a833e08 --- /dev/null +++ b/src/include/mobile/utils_i18n_types.h @@ -0,0 +1,1989 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + * + * Copyright (C) 1999-2012, International Business Machines + * Corporation and others. All Rights Reserved. + */ + + + +#ifndef __UTILS_I18N_TYPES_H__ +#define __UTILS_I18N_TYPES_H__ + +#include +#include +#include + +/** + * @file utils_i18n_types.h + * @version 0.1 + * @brief utils_i18n_types + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_MODULE + * @{ + */ + +/** + * @brief Enumeration for error codes to replace exception handlings. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { + I18N_ERROR_NONE = TIZEN_ERROR_NONE, /**< No error, no warning */ + I18N_ERROR_MISSING_RESOURCE = TIZEN_ERROR_UTILITY_ICU | 0x01, /**< The requested resource cannot be found */ + I18N_ERROR_INVALID_FORMAT = TIZEN_ERROR_UTILITY_ICU | 0x02, /**< Data format is not what is expected */ + I18N_ERROR_FILE_ACCESS = TIZEN_ERROR_UTILITY_ICU | 0x03, /**< The requested file cannot be found */ + I18N_ERROR_INTERNAL_PROGRAM = TIZEN_ERROR_UTILITY_ICU | 0x04, /**< Indicates a bug in the library code */ + I18N_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ + I18N_ERROR_INDEX_OUTOFBOUNDS = TIZEN_ERROR_UTILITY_ICU | 0x05, /**< Trying to access the index that is out of bounds */ + I18N_ERROR_INVALID_CHAR_FOUND = TIZEN_ERROR_UTILITY_ICU | 0x06, /**< Character conversion: Unmappable input sequence. In other APIs: Invalid character */ + I18N_ERROR_BUFFER_OVERFLOW = TIZEN_ERROR_UTILITY_ICU | 0x07, /**< A result would not fit in the supplied buffer */ + I18N_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Requested operation is not supported in the current context */ + I18N_ERROR_COLLATOR_VERSION_MISMATCH = TIZEN_ERROR_UTILITY_ICU | 0x08, /**< Collator version is not compatible with the base version */ + I18N_ERROR_USELESS_COLLATOR = TIZEN_ERROR_UTILITY_ICU | 0x09, /**< Collator is options only and no base is specified */ + I18N_ERROR_NO_WRITE_PERMISSION = TIZEN_ERROR_UTILITY_ICU | 0x0A, /**< Attempt to modify read-only or constant data */ + I18N_ERROR_RESOURCE_TYPE_MISMATCH = TIZEN_ERROR_UTILITY_ICU | 0x0B, /**< An operation is requested over a resource that does not support it */ + I18N_ERROR_TOO_MANY_ALIASES = TIZEN_ERROR_UTILITY_ICU | 0x0C, /**< Too many aliases in the path to the requested resource */ + I18N_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid function parameter */ + I18N_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ + + I18N_ERROR_MESSAGE_PARSE = TIZEN_ERROR_UTILITY_ICU | 0x0D, /**< Unable to parse a message (message format). @if MOBILE (Since 2.3.1) @endif*/ + I18N_ERROR_PARSE = TIZEN_ERROR_UTILITY_ICU | 0x0E, /**< Equivalent to Java ParseException. @if MOBILE (Since 2.3.1) @endif*/ + I18N_ERROR_TRUNCATED_CHAR_FOUND = TIZEN_ERROR_UTILITY_ICU | 0x0F, /**< Character conversion: Incomplete input sequence. @if MOBILE (Since 2.3.1) @endif*/ + I18N_ERROR_ILLEGAL_CHAR_FOUND = TIZEN_ERROR_UTILITY_ICU | 0x10, /**< Character conversion: Illegal input sequence/combination of input units. @if MOBILE (Since 2.3.1) @endif*/ + I18N_ERROR_INVALID_TABLE_FORMAT = TIZEN_ERROR_UTILITY_ICU | 0x11, /**< Conversion table file found, but corrupted. @if MOBILE (Since 2.3.1) @endif*/ + I18N_ERROR_INVALID_TABLE_FILE = TIZEN_ERROR_UTILITY_ICU | 0x12, /**< Conversion table file not found. @if MOBILE (Since 2.3.1) @endif*/ + I18N_ERROR_ILLECAL_ESCAPE_SEQUENCE = TIZEN_ERROR_UTILITY_ICU | 0x13, /**< ISO-2022 illlegal escape sequence. @if MOBILE (Since 2.3.1) @endif*/ + I18N_ERROR_UNSUPPORTED_ESCAPE_SEQUENCE = TIZEN_ERROR_UTILITY_ICU | 0x14, /**< ISO-2022 unsupported escape sequence. @if MOBILE (Since 2.3.1) @endif*/ + I18N_ERROR_NO_SPACE_AVAILABLE = TIZEN_ERROR_UTILITY_ICU | 0x15, /**< No space available for in-buffer expansion for Arabic shaping. @if MOBILE (Since 2.3.1) @endif*/ + I18N_ERROR_CE_NOT_FOUND = TIZEN_ERROR_UTILITY_ICU | 0x16, /**< Currently used only while setting variable top, but can be used generally. @if MOBILE (Since 2.3.1) @endif*/ + I18N_ERROR_PRIMARY_TOO_LONG = TIZEN_ERROR_UTILITY_ICU | 0x17, /**< User tried to set variable top to a primary that is longer than two bytes. @if MOBILE (Since 2.3.1) @endif*/ + I18N_ERROR_STATE_TOO_OLD = TIZEN_ERROR_UTILITY_ICU | 0x18, /**< ICU cannot construct a service from this state, as it is no longer supported. @if MOBILE (Since 2.3.1) @endif*/ + I18N_ERROR_ENUM_OUT_OF_SYNC = TIZEN_ERROR_UTILITY_ICU | 0x19, /**< UEnumeration out of sync with underlying collection. @if MOBILE (Since 2.3.1) @endif*/ + I18N_ERROR_INVARIANT_CONVERSION = TIZEN_ERROR_UTILITY_ICU | 0x1A, /**< Unable to convert a UChar* string to char* with the invariant converter. @if MOBILE (Since 2.3.1) @endif*/ + I18N_ERROR_INVALID_STATE = TIZEN_ERROR_UTILITY_ICU | 0x1B, /**< Requested operation can not be completed with ICU in its current state. @if MOBILE (Since 2.3.1) @endif*/ + I18N_ERROR_MALFORMED_SET = TIZEN_ERROR_UTILITY_ICU | 0x1C, /**< A UnicodeSet pattern is invalid. @if MOBILE (Since 2.3.1) @endif*/ + I18N_WARNING_STRING_NOT_TERMINATED = TIZEN_ERROR_UTILITY_ICU | 0x1D, /**< String not terminated with NULL. @if MOBILE (Since 2.3.1) @endif*/ + I18N_ERROR_STD3_ASCII_RULES = TIZEN_ERROR_UTILITY_ICU | 0x1E, /**< Argument does not satisfy STD3 rules. @if MOBILE (Since 2.3.1) @endif*/ + I18N_ERROR_UNASSIGNED = TIZEN_ERROR_UTILITY_ICU | 0x1F, /**< Unassigned code points are found. @if MOBILE (Since 2.3.1) @endif*/ + I18N_WARNING_SORT_KEY_TOO_SHORT = TIZEN_ERROR_UTILITY_ICU | 0x20, /**< Number of levels requested in getBound is higher than the number of levels in the sort key. @if MOBILE (Since 2.3.1) @endif*/ + I18N_ERROR_UNKNOWN = TIZEN_ERROR_UNKNOWN, /**< Unknown error. @if MOBILE (Since 2.3.1) @endif*/ +} i18n_error_code_e; + +/** + * @} + * @} + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_UCHAR_MODULE + * @{ + */ + +#define I18N_U_MASK(x) ((uint32_t)1<<(x)) /**< Get a single-bit bit set (a flag) from a bit number 0..31. @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif*/ + +#define I18N_U_GC_CN_MASK I18N_U_MASK(I18N_UCHAR_U_GENERAL_OTHER_TYPES) /** comment... * / + * U_<[A-Z_]+> = , + */ + I18N_UCHAR_U_LEFT_TO_RIGHT, /**< L */ + I18N_UCHAR_U_RIGHT_TO_LEFT, /**< R */ + I18N_UCHAR_U_EUROPEAN_NUMBER, /**< EN */ + I18N_UCHAR_U_EUROPEAN_NUMBER_SEPARATOR, /**< ES */ + I18N_UCHAR_U_EUROPEAN_NUMBER_TERMINATOR, /**< ET */ + I18N_UCHAR_U_ARABIC_NUMBER, /**< AN */ + I18N_UCHAR_U_COMMON_NUMBER_SEPARATOR, /**< CS */ + I18N_UCHAR_U_BLOCK_SEPARATOR, /**< B */ + I18N_UCHAR_U_SEGMENT_SEPARATOR, /**< S */ + I18N_UCHAR_U_WHITE_SPACE_NEUTRAL, /**< WS */ + I18N_UCHAR_U_OTHER_NEUTRAL, /**< ON */ + I18N_UCHAR_U_LEFT_TO_RIGHT_EMBEDDING, /**< LRE */ + I18N_UCHAR_U_LEFT_TO_RIGHT_OVERRIDE, /**< LRO */ + I18N_UCHAR_U_RIGHT_TO_LEFT_ARABIC, /**< AL */ + I18N_UCHAR_U_RIGHT_TO_LEFT_EMBEDDING, /**< RLE */ + I18N_UCHAR_U_RIGHT_TO_LEFT_OVERRIDE, /**< RLO */ + I18N_UCHAR_U_POP_DIRECTIONAL_FORMAT, /**< PDF */ + I18N_UCHAR_U_DIR_NON_SPACING_MARK, /**< NSM */ + I18N_UCHAR_U_BOUNDARY_NEUTRAL, /**< BN */ + I18N_UCHAR_U_CHAR_DIRECTION_COUNT /**< */ +} i18n_uchar_direction_e; + +/** + * @brief Enumeration for Decomposition Type constants. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { +/* + * Note: UDecompositionType constants are parsed by preparseucd.py. + * It matches lines like + * U_DT_ + */ + I18N_UCHAR_U_DT_NONE, /**< [none] */ + I18N_UCHAR_U_DT_CANONICAL, /**< [can] */ + I18N_UCHAR_U_DT_COMPAT, /**< [com] */ + I18N_UCHAR_U_DT_CIRCLE, /**< [enc] */ + I18N_UCHAR_U_DT_FINAL, /**< [fin] */ + I18N_UCHAR_U_DT_FONT, /**< [font] */ + I18N_UCHAR_U_DT_FRACTION, /**< [fra] */ + I18N_UCHAR_U_DT_INITIAL, /**< [init] */ + I18N_UCHAR_U_DT_ISOLATED, /**< [iso] */ + I18N_UCHAR_U_DT_MEDIAL, /**< [med] */ + I18N_UCHAR_U_DT_NARROW, /**< [nar] */ + I18N_UCHAR_U_DT_NOBREAK, /**< [nb] */ + I18N_UCHAR_U_DT_SMALL, /**< [sml] */ + I18N_UCHAR_U_DT_SQUARE, /**< [sqr] */ + I18N_UCHAR_U_DT_SUB, /**< [sub] */ + I18N_UCHAR_U_DT_SUPER, /**< [sup] */ + I18N_UCHAR_U_DT_VERTICAL, /**< [vert] */ + I18N_UCHAR_U_DT_WIDE, /**< [wide] */ + I18N_UCHAR_U_DT_COUNT /**< 18 */ +} i18n_uchar_u_decomposition_type_e; + +/** + * @brief Enumeration for East Asian Width constants. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { + I18N_UCHAR_U_EA_NEUTRAL, /**< [N] */ + I18N_UCHAR_U_EA_AMBIGUOUS, /**< [A] */ + I18N_UCHAR_U_EA_HALFWIDTH, /**< [H] */ + I18N_UCHAR_U_EA_FULLWIDTH, /**< [F] */ + I18N_UCHAR_U_EA_NARROW, /**< [Na] */ + I18N_UCHAR_U_EA_WIDE, /**< [W] */ + I18N_UCHAR_U_EA_COUNT +} i18n_uchar_u_east_asian_width_e; + +/** + * @brief Enumeration for Unicode general category types. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { + I18N_UCHAR_U_UNASSIGNED, /**< Non-category for unassigned and non-character code points */ + I18N_UCHAR_U_GENERAL_OTHER_TYPES = 0, /**< Cn "Other, Not Assigned (no characters in [UnicodeData.txt] have this property)" (same as #I18N_UCHAR_U_UNASSIGNED!) */ + I18N_UCHAR_U_UPPERCASE_LETTER, /**< Lu */ + I18N_UCHAR_U_LOWERCASE_LETTER, /**< Ll */ + I18N_UCHAR_U_TITLECASE_LETTER, /**< Lt */ + I18N_UCHAR_U_MODIFIER_LETTER, /**< Lm */ + I18N_UCHAR_U_OTHER_LETTER, /**< Lo */ + I18N_UCHAR_U_NON_SPACING_MARK, /**< Mn */ + I18N_UCHAR_U_ENCLOSING_MARK, /**< Me */ + I18N_UCHAR_U_COMBINING_SPACING_MARK, /**< Mc */ + I18N_UCHAR_U_DECIMAL_DIGIT_NUMBER, /**< Nd */ + I18N_UCHAR_U_LETTER_NUMBER, /**< Nl */ + I18N_UCHAR_U_OTHER_NUMBER, /**< No */ + I18N_UCHAR_U_SPACE_SEPARATOR, /**< Zs */ + I18N_UCHAR_U_LINE_SEPARATOR, /**< Zl */ + I18N_UCHAR_U_PARAGRAPH_SEPARATOR, /**< Zp */ + I18N_UCHAR_U_CONTROL_CHAR, /**< Cc */ + I18N_UCHAR_U_FORMAT_CHAR, /**< Cf */ + I18N_UCHAR_U_PRIVATE_USE_CHAR, /**< Co */ + I18N_UCHAR_U_SURROGATE, /**< Cs */ + I18N_UCHAR_U_DASH_PUNCTUATION, /**< Pd */ + I18N_UCHAR_U_START_PUNCTUATION, /**< Ps */ + I18N_UCHAR_U_END_PUNCTUATION, /**< Pe */ + I18N_UCHAR_U_CONNECTOR_PUNCTUATION, /**< Pc */ + I18N_UCHAR_U_OTHER_PUNCTUATION, /**< Po */ + I18N_UCHAR_U_MATH_SYMBOL, /**< Sm */ + I18N_UCHAR_U_CURRENCY_SYMBOL, /**< Sc */ + I18N_UCHAR_U_MODIFIER_SYMBOL, /**< Sk */ + I18N_UCHAR_U_OTHER_SYMBOL, /**< So */ + I18N_UCHAR_U_INITIAL_PUNCTUATION, /**< Pi */ + I18N_UCHAR_U_FINAL_PUNCTUATION, /**< Pf */ + I18N_UCHAR_U_CHAR_CATEGORY_COUNT /**< One higher than the last enum #i18n_uchar_category_e constant */ +} i18n_uchar_category_e; + +/** + * @brief Enumeration for Joining Group constants. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { +/* + * Note: UJoiningGroup constants are parsed by preparseucd.py. + * It matches lines like + * U_JG_ + */ + I18N_UCHAR_U_JG_NO_JOINING_GROUP, /**< */ + I18N_UCHAR_U_JG_AIN, /**< */ + I18N_UCHAR_U_JG_ALAPH, /**< */ + I18N_UCHAR_U_JG_ALEF, /**< */ + I18N_UCHAR_U_JG_BEH, /**< */ + I18N_UCHAR_U_JG_BETH, /**< */ + I18N_UCHAR_U_JG_DAL, /**< */ + I18N_UCHAR_U_JG_DALATH_RISH, /**< */ + I18N_UCHAR_U_JG_E, /**< */ + I18N_UCHAR_U_JG_FEH, /**< */ + I18N_UCHAR_U_JG_FINAL_SEMKATH, /**< */ + I18N_UCHAR_U_JG_GAF, /**< */ + I18N_UCHAR_U_JG_GAMAL, /**< */ + I18N_UCHAR_U_JG_HAH, /**< */ + I18N_UCHAR_U_JG_TEH_MARBUTA_GOAL, /**< */ + I18N_UCHAR_U_JG_HAMZA_ON_HEH_GOAL = I18N_UCHAR_U_JG_TEH_MARBUTA_GOAL, /**< */ + I18N_UCHAR_U_JG_HE, /**< */ + I18N_UCHAR_U_JG_HEH, /**< */ + I18N_UCHAR_U_JG_HEH_GOAL, /**< */ + I18N_UCHAR_U_JG_HETH, /**< */ + I18N_UCHAR_U_JG_KAF, /**< */ + I18N_UCHAR_U_JG_KAPH, /**< */ + I18N_UCHAR_U_JG_KNOTTED_HEH, /**< */ + I18N_UCHAR_U_JG_LAM, /**< */ + I18N_UCHAR_U_JG_LAMADH, /**< */ + I18N_UCHAR_U_JG_MEEM, /**< */ + I18N_UCHAR_U_JG_MIM, /**< */ + I18N_UCHAR_U_JG_NOON, /**< */ + I18N_UCHAR_U_JG_NUN, /**< */ + I18N_UCHAR_U_JG_PE, /**< */ + I18N_UCHAR_U_JG_QAF, /**< */ + I18N_UCHAR_U_JG_QAPH, /**< */ + I18N_UCHAR_U_JG_REH, /**< */ + I18N_UCHAR_U_JG_REVERSED_PE, /**< */ + I18N_UCHAR_U_JG_SAD, /**< */ + I18N_UCHAR_U_JG_SADHE, /**< */ + I18N_UCHAR_U_JG_SEEN, /**< */ + I18N_UCHAR_U_JG_SEMKATH, /**< */ + I18N_UCHAR_U_JG_SHIN, /**< */ + I18N_UCHAR_U_JG_SWASH_KAF, /**< */ + I18N_UCHAR_U_JG_SYRIAC_WAW, /**< */ + I18N_UCHAR_U_JG_TAH, /**< */ + I18N_UCHAR_U_JG_TAW, /**< */ + I18N_UCHAR_U_JG_TEH_MARBUTA, /**< */ + I18N_UCHAR_U_JG_TETH, /**< */ + I18N_UCHAR_U_JG_WAW, /**< */ + I18N_UCHAR_U_JG_YEH, /**< */ + I18N_UCHAR_U_JG_YEH_BARREE, /**< */ + I18N_UCHAR_U_JG_YEH_WITH_TAIL, /**< */ + I18N_UCHAR_U_JG_YUDH, /**< */ + I18N_UCHAR_U_JG_YUDH_HE, /**< */ + I18N_UCHAR_U_JG_ZAIN, /**< */ + I18N_UCHAR_U_JG_FE, /**< */ + I18N_UCHAR_U_JG_KHAPH, /**< */ + I18N_UCHAR_U_JG_ZHAIN, /**< */ + I18N_UCHAR_U_JG_BURUSHASKI_YEH_BARREE, /**< */ + I18N_UCHAR_U_JG_FARSI_YEH, /**< */ + I18N_UCHAR_U_JG_NYA, /**< */ + I18N_UCHAR_U_JG_ROHINGYA_YEH, + I18N_UCHAR_U_JG_COUNT /**< */ + } i18n_uchar_u_joining_group_e; + +/** + * @brief Enumeration for Joining Type constants. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { +/* + * Note: i18n_uchar_u_joining_type_e constants are parsed by preparseucd.py. + * It matches lines like + * U_JT_ + */ + I18N_UCHAR_U_JT_NON_JOINING, /**< [U] */ + I18N_UCHAR_U_JT_JOIN_CAUSING, /**< [C] */ + I18N_UCHAR_U_JT_DUAL_JOINING, /**< [D] */ + I18N_UCHAR_U_JT_LEFT_JOINING, /**< [L] */ + I18N_UCHAR_U_JT_RIGHT_JOINING, /**< [R] */ + I18N_UCHAR_U_JT_TRANSPARENT, /**< [T] */ + I18N_UCHAR_U_JT_COUNT /**< 6 */ +} i18n_uchar_u_joining_type_e; + +/** + * @brief Enumeration for Line Break constants. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { +/* + * Note: i18n_uchar_u_line_break_e constants are parsed by preparseucd.py. + * It matches lines like + * U_LB_ + */ + I18N_UCHAR_U_LB_UNKNOWN, /**< [XX] */ + I18N_UCHAR_U_LB_AMBIGUOUS, /**< [AI] */ + I18N_UCHAR_U_LB_ALPHABETIC, /**< [AL] */ + I18N_UCHAR_U_LB_BREAK_BOTH, /**< [B2] */ + I18N_UCHAR_U_LB_BREAK_AFTER, /**< [BA] */ + I18N_UCHAR_U_LB_BREAK_BEFORE, /**< [BB] */ + I18N_UCHAR_U_LB_MANDATORY_BREAK, /**< [BK] */ + I18N_UCHAR_U_LB_CONTINGENT_BREAK, /**< [CB] */ + I18N_UCHAR_U_LB_CLOSE_PUNCTUATION, /**< [CL] */ + I18N_UCHAR_U_LB_COMBINING_MARK, /**< [CM] */ + I18N_UCHAR_U_LB_CARRIAGE_RETURN, /**< [CR] */ + I18N_UCHAR_U_LB_EXCLAMATION, /**< [EX] */ + I18N_UCHAR_U_LB_GLUE, /**< [GL] */ + I18N_UCHAR_U_LB_HYPHEN, /**< [HY] */ + I18N_UCHAR_U_LB_IDEOGRAPHIC, /**< [ID] */ + I18N_UCHAR_U_LB_INSEPARABLE, /**< [IN] */ + I18N_UCHAR_U_LB_INSEPERABLE = I18N_UCHAR_U_LB_INSEPARABLE, + I18N_UCHAR_U_LB_INFIX_NUMERIC, /**< [IS] */ + I18N_UCHAR_U_LB_LINE_FEED, /**< [LF] */ + I18N_UCHAR_U_LB_NONSTARTER, /**< [NS] */ + I18N_UCHAR_U_LB_NUMERIC, /**< [NU] */ + I18N_UCHAR_U_LB_OPEN_PUNCTUATION, /**< [OP] */ + I18N_UCHAR_U_LB_POSTFIX_NUMERIC, /**< [PO] */ + I18N_UCHAR_U_LB_PREFIX_NUMERIC, /**< [PR] */ + I18N_UCHAR_U_LB_QUOTATION, /**< [QU] */ + I18N_UCHAR_U_LB_COMPLEX_CONTEXT, /**< [SA] */ + I18N_UCHAR_U_LB_SURROGATE, /**< [SG] */ + I18N_UCHAR_U_LB_SPACE, /**< [SP] */ + I18N_UCHAR_U_LB_BREAK_SYMBOLS, /**< [SY] */ + I18N_UCHAR_U_LB_ZWSPACE, /**< [ZW] */ + I18N_UCHAR_U_LB_NEXT_LINE, /**< [NL] */ + I18N_UCHAR_U_LB_WORD_JOINER, /**< [WJ] */ + I18N_UCHAR_U_LB_H2, /**< [H2] */ + I18N_UCHAR_U_LB_H3, /**< [H3] */ + I18N_UCHAR_U_LB_JL, /**< [JL] */ + I18N_UCHAR_U_LB_JT, /**< [JT] */ + I18N_UCHAR_U_LB_JV, /**< [JV] */ + I18N_UCHAR_U_LB_CLOSE_PARENTHESIS, /**< [CP] */ + I18N_UCHAR_U_LB_COUNT + } i18n_uchar_u_line_break_e; + +/** + * @brief Enumeration for Numeric Type constants. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { +/* + * Note: i18n_uchar_u_numeric_type_e constants are parsed by preparseucd.py. + * It matches lines like + * U_NT_ + */ + I18N_UCHAR_U_NT_NONE, /**< [None] */ + I18N_UCHAR_U_NT_DECIMAL, /**< [de] */ + I18N_UCHAR_U_NT_DIGIT, /**< [di] */ + I18N_UCHAR_U_NT_NUMERIC, /**< [nu] */ + I18N_UCHAR_U_NT_COUNT /**< */ +} i18n_uchar_u_numeric_type_e; + +/** + * @brief Enumeration for Hangul Syllable Type constants. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { +/* + * Note: i18n_uchar_u_hangul_syllable_type_e constants are parsed by preparseucd.py. + * It matches lines like + * U_HST_ + */ + I18N_UCHAR_U_HST_NOT_APPLICABLE, /**< [NA] */ + I18N_UCHAR_U_HST_LEADING_JAMO, /**< [L] */ + I18N_UCHAR_U_HST_VOWEL_JAMO, /**< [V] */ + I18N_UCHAR_U_HST_TRAILING_JAMO, /**< [T] */ + I18N_UCHAR_U_HST_LV_SYLLABLE, /**< [LV] */ + I18N_UCHAR_U_HST_LVT_SYLLABLE, /**< [LVT] */ + I18N_UCHAR_U_HST_COUNT /**< */ +} i18n_uchar_u_hangul_syllable_type_e; + +/** + * @brief Enumeration for Sentence Break constants. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { +/* + * Note: i18n_uchar_u_sentence_break_e constants are parsed by preparseucd.py. + * It matches lines like + * U_SB_ + */ + I18N_UCHAR_U_SB_OTHER, /**< [XX] */ + I18N_UCHAR_U_SB_ATERM, /**< [AT] */ + I18N_UCHAR_U_SB_CLOSE, /**< [CL] */ + I18N_UCHAR_U_SB_FORMAT, /**< [FO] */ + I18N_UCHAR_U_SB_LOWER, /**< [LO] */ + I18N_UCHAR_U_SB_NUMERIC, /**< [NU] */ + I18N_UCHAR_U_SB_OLETTER, /**< [LE] */ + I18N_UCHAR_U_SB_SEP, /**< [SE] */ + I18N_UCHAR_U_SB_SP, /**< [SP] */ + I18N_UCHAR_U_SB_STERM, /**< [ST] */ + I18N_UCHAR_U_SB_UPPER, /**< [UP] */ + I18N_UCHAR_U_SB_CR, /**< [CR] */ + I18N_UCHAR_U_SB_EXTEND, /**< [EX] */ + I18N_UCHAR_U_SB_LF, /**< [LF] */ + I18N_UCHAR_U_SB_SCONTINUE, /**< [SC] */ + I18N_UCHAR_U_SB_COUNT /**< */ +} i18n_uchar_u_sentence_break_e; + +/** + * @brief Enumeration for Word Break constants. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { +/* + * Note: i18n_uchar_u_word_break_values_e constants are parsed by preparseucd.py. + * It matches lines like + * U_WB_ + */ + I18N_UCHAR_U_WB_OTHER, /**< [XX] */ + I18N_UCHAR_U_WB_ALETTER, /**< [LE] */ + I18N_UCHAR_U_WB_FORMAT, /**< [FO] */ + I18N_UCHAR_U_WB_KATAKANA, /**< [KA] */ + I18N_UCHAR_U_WB_MIDLETTER, /**< [ML] */ + I18N_UCHAR_U_WB_MIDNUM, /**< [MN] */ + I18N_UCHAR_U_WB_NUMERIC, /**< [NU] */ + I18N_UCHAR_U_WB_EXTENDNUMLET, /**< [EX] */ + I18N_UCHAR_U_WB_CR, /**< [CR] */ + I18N_UCHAR_U_WB_EXTEND, /**< [Extend] */ + I18N_UCHAR_U_WB_LF, /**< [LF] */ + I18N_UCHAR_U_WB_MIDNUMLET, /**< [MB] */ + I18N_UCHAR_U_WB_NEWLINE, /**< [NL] */ + I18N_UCHAR_U_WB_COUNT /**< */ +} i18n_uchar_u_word_break_values_e; + +/** + * @brief Enumeration for Grapheme Cluster Break constants. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { +/* + * Note: i18n_uchar_u_grapheme_cluster_break_e constants are parsed by preparseucd.py. + * It matches lines like + * U_GCB_ + */ + I18N_UCHAR_U_GCB_OTHER, /**< [XX] */ + I18N_UCHAR_U_GCB_CONTROL, /**< [CN] */ + I18N_UCHAR_U_GCB_CR, /**< [CR] */ + I18N_UCHAR_U_GCB_EXTEND, /**< [EX] */ + I18N_UCHAR_U_GCB_L, /**< [L] */ + I18N_UCHAR_U_GCB_LF, /**< [LF] */ + I18N_UCHAR_U_GCB_LV, /**< [LV] */ + I18N_UCHAR_U_GCB_LVT, /**< [LVT] */ + I18N_UCHAR_U_GCB_T, /**< [T] */ + I18N_UCHAR_U_GCB_V, /**< [V] */ + I18N_UCHAR_U_GCB_SPACING_MARK, /**< [SM] */ + I18N_UCHAR_U_GCB_PREPEND, /**< [PP] */ + I18N_UCHAR_UCHAR_U_GCB_COUNT /**< */ +} i18n_uchar_u_grapheme_cluster_break_e; + +/** + * @} + * @} + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULE + * @{ + */ + +/** + * @brief Structure representing a collator object instance. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef void *i18n_ucollator_h; + +/** + * @brief Enumeration for attributes that collation service understands. + * All the attributes can take #I18N_UCOLLATOR_DEFAULT value, as well as the values specific to each one. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { + I18N_UCOLLATOR_FRENCH_COLLATION, /**< Attribute for direction of secondary weights - used in Canadian French. Acceptable values are #I18N_UCOLLATOR_ON, which results in secondary weights being considered backwards, and #I18N_UCOLLATOR_OFF which treats secondary weights in the order they appear */ + I18N_UCOLLATOR_ALTERNATE_HANDLING, /**< Attribute for handling variable elements. Acceptable values are #I18N_UCOLLATOR_NON_IGNORABLE (default) which treats all the codepoints with non-ignorable primary weights in the same way, and #I18N_UCOLLATOR_SHIFTED which causes codepoints with primary weights that are equal or below the variable top value to be ignored at the primary level and moved to the quaternary level */ + I18N_UCOLLATOR_CASE_FIRST, /**< Controls the ordering of upper and lower case letters. Acceptable values are #I18N_UCOLLATOR_OFF (default), which orders upper and lower case letters in accordance to their tertiary weights, #I18N_UCOLLATOR_UPPER_FIRST which forces upper case letters to sort before lower case letters, and #I18N_UCOLLATOR_LOWER_FIRST which does the opposite */ + I18N_UCOLLATOR_CASE_LEVEL, /**< Controls whether an extra case level (positioned before the third level) is generated or not. Acceptable values are #I18N_UCOLLATOR_OFF (default), when case level is not generated, and #I18N_UCOLLATOR_ON which causes the case level to be generated. Contents of the case level are affected by the value of the #I18N_UCOLLATOR_CASE_FIRST attribute. A simple way to ignore accent differences in a string is to set the strength to #I18N_UCOLLATOR_PRIMARY and enable case level */ + I18N_UCOLLATOR_NORMALIZATION_MODE, /**< Controls whether the normalization check and necessary normalizations are performed. When set to #I18N_UCOLLATOR_OFF (default) no normalization check is performed. The correctness of the result is guaranteed only if the input data is in so-called FCD form (see users manual for more info). When set to #I18N_UCOLLATOR_ON, an incremental check is performed to see whether the input data is in the FCD form. If the data is not in the FCD form, incremental NFD normalization is performed */ + I18N_UCOLLATOR_DECOMPOSITION_MODE = I18N_UCOLLATOR_NORMALIZATION_MODE, /**< An alias for the #I18N_UCOLLATOR_NORMALIZATION_MODE attribute */ + I18N_UCOLLATOR_STRENGTH, /**< The strength attribute. Can be either #I18N_UCOLLATOR_PRIMARY, #I18N_UCOLLATOR_SECONDARY, #I18N_UCOLLATOR_TERTIARY, #I18N_UCOLLATOR_QUATERNARY, or #I18N_UCOLLATOR_IDENTICAL. The usual strength for most locales (except Japanese) is tertiary. Quaternary strength is useful when combined with shifted setting for the alternate handling attribute and for JIS X 4061 collation, when it is used to distinguish between Katakana and Hiragana. Otherwise, quaternary level is affected only by the number of non-ignorable code points in the string. Identical strength is rarely useful, as it amounts to codepoints of the NFD form of the string */ + I18N_UCOLLATOR_NUMERIC_COLLATION = I18N_UCOLLATOR_STRENGTH + 2, /**< When turned on, this attribute makes substrings of digits that are sort according to their numeric values. This is a way to get '100' to sort AFTER '2'. Note that the longest digit substring that can be treated as a single unit is 254 digits (not counting leading zeros). If a digit substring is longer than that, the digits beyond the limit will be treated as a separate digit substring. A "digit" in this sense is a code point with General_Category=Nd, which does not include circled numbers, roman numerals, and so on. Only a contiguous digit substring is considered, that is, non-negative integers without separators. There is no support for plus/minus signs, decimals, exponents, and so on */ + I18N_UCOLLATOR_ATTRIBUTE_COUNT /**< The number of i18n_ucollator_attribute_e constants */ +} i18n_ucollator_attribute_e; + +/** + * @brief Enumeration containing attribute values for controlling collation behavior. + * Here are all the allowable values. Not every attribute can take every value. + * The only universal value is #I18N_UCOLLATOR_DEFAULT, which resets the attribute value to the predefined value for that locale. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { + I18N_UCOLLATOR_DEFAULT = -1, /**< Accepted by most attributes */ + I18N_UCOLLATOR_PRIMARY = 0, /**< Primary collation strength */ + I18N_UCOLLATOR_SECONDARY = 1, /**< Secondary collation strength */ + I18N_UCOLLATOR_TERTIARY = 2, /**< Tertiary collation strength */ + I18N_UCOLLATOR_DEFAULT_STRENGTH = I18N_UCOLLATOR_TERTIARY, /**< Default collation strength */ + I18N_UCOLLATOR_CE_STRENGTH_LIMIT, + I18N_UCOLLATOR_QUATERNARY = 3, /**< Quaternary collation strength */ + I18N_UCOLLATOR_IDENTICAL = 15, /**< Identical collation strength */ + I18N_UCOLLATOR_STRENGTH_LIMIT, + + I18N_UCOLLATOR_OFF = 16, /**< Turn the feature off - works for #I18N_UCOLLATOR_FRENCH_COLLATION, #I18N_UCOLLATOR_CASE_LEVEL & #I18N_UCOLLATOR_DECOMPOSITION_MODE */ + I18N_UCOLLATOR_ON = 17, /**< Turn the feature on - works for #I18N_UCOLLATOR_FRENCH_COLLATION, #I18N_UCOLLATOR_CASE_LEVEL & #I18N_UCOLLATOR_DECOMPOSITION_MODE */ + + I18N_UCOLLATOR_SHIFTED = 20, /**< Valid for #I18N_UCOLLATOR_ALTERNATE_HANDLING. Alternate handling will be shifted. */ + I18N_UCOLLATOR_NON_IGNORABLE = 21, /**< Valid for #I18N_UCOLLATOR_ALTERNATE_HANDLING. Alternate handling will be non ignorable. */ + I18N_UCOLLATOR_LOWER_FIRST = 24, /**< Valid for #I18N_UCOLLATOR_CASE_FIRST - lower case sorts before upper case. */ + I18N_UCOLLATOR_UPPER_FIRST = 25, /**< Upper case sorts before lower case. */ + I18N_UCOLLATOR_ATTRIBUTE_VALUE_COUNT +} i18n_ucollator_attribute_value_e; + +/** + * @brief Enumeration in which the base letter represents a primary difference. Set comparison level to #I18N_UCOLLATOR_PRIMARY to ignore secondary and tertiary differences. Use this to set the strength of an #i18n_ucollator_h. Example of primary difference, "abc" < "abd" + * Diacritical differences on the same base letter represent a secondary difference. Set comparison level to #I18N_UCOLLATOR_SECONDARY to ignore tertiary differences. Use this to set the strength of an #i18n_ucollator_h. Example of secondary difference, "ä" >> "a". + * Uppercase and lowercase versions of the same character represent a tertiary difference. Set comparison level to #I18N_UCOLLATOR_TERTIARY to include all comparison differences. Use this to set the strength of an #i18n_ucollator_h. Example of tertiary difference, "abc" <<< "ABC". + * Two characters are considered "identical" when they have the same unicode spellings. #I18N_UCOLLATOR_IDENTICAL. For example, "ä" == "ä". + * #i18n_ucollator_strength_e is also used to determine the strength of sort keys generated from #i18n_ucollator_h. These values can now be found in the #i18n_ucollator_attribute_value_e enum. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef i18n_ucollator_attribute_value_e i18n_ucollator_strength_e; + +/** + * @brief Enumeration for source and target string comparison result. + * #I18N_UCOLLATOR_LESS is returned if the source string is compared to be less than the target string in the {@link i18n_ucollator_str_collator() } method. + * #I18N_UCOLLATOR_EQUAL is returned if the source string is compared to be equal to the target string in the {@link i18n_ucollator_str_collator() } method. + * #I18N_UCOLLATOR_GREATER is returned if the source string is compared to be greater than the target string in the {@link #i18n_ucollator_str_collator() } method. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { + I18N_UCOLLATOR_EQUAL = 0, /**< string a == string b */ + I18N_UCOLLATOR_GREATER = 1, /**< string a > string b */ + I18N_UCOLLATOR_LESS = -1 /**< string a < string b */ +} i18n_ucollator_result_e; + +/** + * @} + * @} + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_UNORMALIZATION_MODULE + * @{ + */ + + +/** + * @brief i18n_unormalizer_h. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + */ + +typedef const void* i18n_unormalizer_h; + +/** + * @brief Enumeration of constants for normalization modes. + * For details about standard Unicode normalization forms and about the algorithms which are also used with custom mapping tables see http://www.unicode.org/unicode/reports/tr15/ + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { + I18N_UNORMALIZATION_COMPOSE, /**< Decomposition followed by composition. Same as standard NFC when using an "nfc" instance. Same as standard NFKC when using an "nfkc" instance. + For details about standard Unicode normalization forms see http://www.unicode.org/unicode/reports/tr15/ */ + I18N_UNORMALIZATION_DECOMPOSE, /**< Map and reorder canonically. Same as standard NFD when using an "nfc" instance. Same as standard NFKD when using an "nfkc" instance. + For details about standard Unicode normalization forms see http://www.unicode.org/unicode/reports/tr15/ */ + I18N_UNORMALIZATION_FCD, /**< "Fast C or D" form. If a string is in this form, then further decomposition without reordering would yield the same form as DECOMPOSE. + Text in "Fast C or D" form can be processed efficiently with data tables that are "canonically closed", + that is, that provide equivalent data for equivalent text, without having to be fully normalized. + Not a standard Unicode normalization form. Not a unique form: Different FCD strings can be canonically equivalent. + For details see http://www.unicode.org/notes/tn5/#FCD */ + I18N_UNORMALIZATION_COMPOSE_CONTIGUOUS /**< Compose only contiguously. Also known as "FCC" or "Fast C Contiguous". The result will often but not always be in NFC. + The result will conform to FCD which is useful for processing. Not a standard Unicode normalization form. + For details see http://www.unicode.org/notes/tn5/#FCC */ +} i18n_unormalization_mode_e; + +/** + * @} + * @} + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_USEARCH_MODULE + * @{ + */ + +/** + * @brief i18n_usearch_h. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef void* i18n_usearch_h; + +/** + * @} + * @} + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE + * @{ + */ + +/** + * @brief i18n_ucalendar_h. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef void* i18n_ucalendar_h; + +/** + * @brief The time zone ID reserved for unknown time zone. + * @since_tizen 2.3.1 + */ +#define I18N_UCALENDAR_UNKNOWN_ZONE_ID "Etc/Unknown" + +/** + * @brief Enumeration for possible fields in an #i18n_ucalendar_h. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { + I18N_UCALENDAR_ERA, /**< Field number indicating the era, e.g., AD or BC in the Gregorian (Julian) calendar */ + I18N_UCALENDAR_YEAR, /**< Field number indicating the year */ + I18N_UCALENDAR_MONTH, /**< Field number indicating the month. This is a calendar-specific value. \n The first month of the year is JANUARY; + the last depends on the number of months in a year */ + I18N_UCALENDAR_WEEK_OF_YEAR, /**< Field number indicating the week number within the current year. \n + The first week of the year, as defined by the #I18N_UCALENDAR_FIRST_DAY_OF_WEEK and #I18N_UCALENDAR_MINIMAL_DAYS_IN_FIRST_WEEK attributes, has value 1. + Subclasses define the value of #I18N_UCALENDAR_WEEK_OF_YEAR for days before the first week of the year */ + I18N_UCALENDAR_WEEK_OF_MONTH, /**< Field number indicating the week number within the current month. \n + The first week of the month, as defined by the #I18N_UCALENDAR_FIRST_DAY_OF_WEEK and #I18N_UCALENDAR_MINIMAL_DAYS_IN_FIRST_WEEK attributes, has value 1. + Subclasses define the value of WEEK_OF_MONTH for days before the first week of the month */ + I18N_UCALENDAR_DATE, /**< Field number indicating the day of the month. \n This is a synonym for DAY_OF_MONTH. The first day of the month has value 1 */ + I18N_UCALENDAR_DAY_OF_YEAR, /**< Field number indicating the day number within the current year. \n The first day of the year has value 1. */ + I18N_UCALENDAR_DAY_OF_WEEK, /**< Field number indicating the day of the week. \n + This field takes values "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", and "Saturday" */ + I18N_UCALENDAR_DAY_OF_WEEK_IN_MONTH, /**< Field number indicating the ordinal number of the day of the week within the current month. \n + Together with the "day of week" field, this uniquely specifies a day within a month. + "day of month" 1 through 7 always correspond to "day of week in month" 1; 8 through 15 correspond to "day of week in month" 2, and so on. + "day of week in month" 0 indicates the week before "day of week in month" 1. + Negative values count back from the end of the month, so the last Sunday of a month is specified as "day of week" = "Sunday", + "day of week in month" = -1. Because negative values count backward they will usually be aligned differently within the month than positive values. + For example, if a month has 31 days, "day of week in month" -1 will overlap "day of week in month" 5 and the end of 4 */ + I18N_UCALENDAR_AM_PM, /**< Field number indicating whether the "hour" is before or after noon. \n E.g., at 10:04:15.250 PM the AM_PM is PM */ + I18N_UCALENDAR_HOUR, /**< Field number indicating the hour of the morning or afternoon. \n "hour" is used for the 12-hour clock. E.g., at 10:04:15.250 PM the "Hour" is 10 */ + I18N_UCALENDAR_HOUR_OF_DAY, /**< Field number indicating the hour of the day. \n "Hour of day" is used for the 24-hour clock. E.g., at 10:04:15.250 PM the "Hour of day" is 22 */ + I18N_UCALENDAR_MINUTE, /**< Field number indicating the minute within the hour. \n E.g., at 10:04:15.250 PM the #I18N_UCALENDAR_MINUTE is 4 */ + I18N_UCALENDAR_SECOND, /**< Field number indicating the second within the minute. \n E.g., at 10:04:15.250 PM the #I18N_UCALENDAR_SECOND is 15 */ + I18N_UCALENDAR_MILLISECOND, /**< Field number indicating the millisecond within the second. \n E.g., at 10:04:15.250 PM the #I18N_UCALENDAR_MILLISECOND is 250 */ + I18N_UCALENDAR_ZONE_OFFSET, /**< Field number indicating the raw offset from GMT in milliseconds */ + I18N_UCALENDAR_DST_OFFSET, /**< Field number indicating the daylight savings offset in milliseconds */ + I18N_UCALENDAR_YEAR_WOY, /**< Field number indicating the extended year corresponding to the #I18N_UCALENDAR_WEEK_OF_YEAR field. \n + This may be one greater or less than the value of #I18N_UCALENDAR_EXTENDED_YEAR */ + I18N_UCALENDAR_DOW_LOCAL, /**< Field number indicating the localized day of the week. \n + This will be a value from 1 to 7 inclusive, with 1 being the localized first day of the week */ + I18N_UCALENDAR_EXTENDED_YEAR, /**< Year of this calendar system, encompassing all supra-year fields. \n + For example, in Gregorian/Julian calendars, positive Extended Year values indicate years AD, 1 BC = 0 extended, 2 BC = -1 extended, and so on */ + I18N_UCALENDAR_JULIAN_DAY, /**< Field number indicating the modified Julian day number. \n + This is different from the conventional Julian day number in two regards. + First, it demarcates days at local zone midnight, rather than noon GMT. Second, it is a local number; that is, it depends on the local time zone. + It can be thought of as a single number that encompasses all the date-related fields */ + I18N_UCALENDAR_MILLISECONDS_IN_DAY, /**< Ranges from 0 to 23:59:59.999 (regardless of DST). \n + This field behaves exactly like a composite of all time-related fields, not including the zone fields. + As such, it also reflects discontinuities in those fields on DST transition days. On a day of DST onset, it will jump forward. + On a day of DST cessation, it will jump backward. + This reflects the fact that it must be combined with the DST offset field to obtain a unique local time value */ + I18N_UCALENDAR_IS_LEAP_MONTH, /**< Whether or not the current month is a leap month (0 or 1) */ + I18N_UCALENDAR_FIELD_COUNT, /**< Number of enumerators */ + I18N_UCALENDAR_DAY_OF_MONTH = I18N_UCALENDAR_DATE /**< Field number indicating the day of the month. \n This is a synonym for #I18N_UCALENDAR_DATE. The first day of the month has value 1 */ +} i18n_ucalendar_date_fields_e; + +/** + * @brief Enumeration for possible months in an #i18n_ucalendar_h. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { + I18N_UCALENDAR_TRADITIONAL, /**< Despite the name, #I18N_UCALENDAR_TRADITIONAL designates the locale's default calendar, which may be the Gregorian calendar or some other calendar */ + I18N_UCALENDAR_DEFAULT = I18N_UCALENDAR_TRADITIONAL, /**< A better name for #I18N_UCALENDAR_TRADITIONAL */ + I18N_UCALENDAR_GREGORIAN /**< Unambiguously designates the Gregorian calendar for the locale */ +} i18n_ucalendar_type_e; + +/** + * @brief Enumeration for possible months in an #i18n_ucalendar_h. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { + I18N_UCALENDAR_JANUARY, /**< January */ + I18N_UCALENDAR_FEBRUARY, /**< February */ + I18N_UCALENDAR_MARCH, /**< March */ + I18N_UCALENDAR_APRIL, /**< April */ + I18N_UCALENDAR_MAY, /**< May */ + I18N_UCALENDAR_JUNE, /**< June */ + I18N_UCALENDAR_JULY, /**< July */ + I18N_UCALENDAR_AUGUST, /**< August */ + I18N_UCALENDAR_SEPTEMBER, /**< September */ + I18N_UCALENDAR_OCTOBER, /**< October */ + I18N_UCALENDAR_NOVEMBER, /**< November */ + I18N_UCALENDAR_DECEMBER /**< December */ +} i18n_ucalendar_months_e; + +/** + * @brief Enumeration for possible formats of an #i18n_ucalendar_h's display name. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { + I18N_UCALENDAR_STANDARD, /**< Standard display name */ + I18N_UCALENDAR_SHORT_STANDARD, /**< Short standard display name */ + I18N_UCALENDAR_DST, /**< Daylight savings display name */ + I18N_UCALENDAR_SHORT_DST /**< Short daylight savings display name */ +} i18n_ucalendar_displayname_type_e; + +/** + * @brief Enumeration for types of #i18n_ucalendar_h attributes. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { + I18N_UCALENDAR_LENIENT, /**< Lenient parsing */ + I18N_UCALENDAR_FIRST_DAY_OF_WEEK, /**< First day of the week */ + I18N_UCALENDAR_MINIMAL_DAYS_IN_FIRST_WEEK /**< Minimum number of days in the first week */ +} i18n_ucalendar_attribute_e; + +/** + * @brief System time zone type constants. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { + I18N_UCALENDAR_ZONE_TYPE_ANY, /**< Any system zones. */ + I18N_UCALENDAR_ZONE_TYPE_CANONICAL, /**< Canonical system zones. */ + I18N_UCALENDAR_ZONE_TYPE_CANONICAL_LOCATION /**< Canonical system zones associated with actual locations. */ +} i18n_system_timezone_type_e; + +/** + * @brief Possible limit values for an #i18n_ucalendar_h. + * @since_tizen 2.3.1 + */ +typedef enum { + I18N_UCALENDAR_MINIMUM, /**< Minimum value */ + I18N_UCALENDAR_MAXIMUM, /**< Maximum value */ + I18N_UCALENDAR_GREATEST_MINIMUM, /**< Greatest minimum value */ + I18N_UCALENDAR_LEAST_MAXIMUM, /**< Least maximum value */ + I18N_UCALENDAR_ACTUAL_MINIMUM, /**< Actual minimum value */ + I18N_UCALENDAR_ACTUAL_MAXIMUM /**< Actual maximum value */ +} i18n_ucalendar_limit_type_e; + +/** + * @brief Weekday types, as returned by i18n_ucalendar_get_day_of_week_type(). + * @since_tizen 2.3.1 + */ +typedef enum { + I18N_UCALENDAR_WEEKDAY, /**< Designates a full weekday (no part of the day is included in the weekend). */ + I18N_UCALENDAR_WEEKEND, /**< Designates a full weekend day (the entire day is included in the weekend). */ + I18N_UCALENDAR_WEEKEND_ONSET, /**< Designates a day that starts as a weekday and transitions to the weekend. + Call i18n_ucalendar_get_weekend_transition() to get the time of transition. */ + I18N_UCALENDAR_WEEKEND_CEASE, /**< Designates a day that starts as the weekend and transitions to a weekday. + Call i18n_ucalendar_get_weekend_transition() to get the time of transition. */ +} i18n_ucalendar_weekday_type_e; + +/** + * @brief Useful constants for days of week. + * @details Note: Calendar day-of-week is 1-based. Clients who create locale resources for the field of first-day-of-week should be aware of this. + * For instance, in US locale, first-day-of-week is set to 1, i.e., #I18N_UCALENDAR_SUNDAY. Possible days of the week in an #i18n_ucalendar_h. + * @since_tizen 2.3.1 + */ +typedef enum { + I18N_UCALENDAR_SUNDAY = 1, /**< Sunday */ + I18N_UCALENDAR_MONDAY, /**< Monday */ + I18N_UCALENDAR_TUESDAY, /**< Tuesday */ + I18N_UCALENDAR_WEDNESDAY, /**< Wednesday */ + I18N_UCALENDAR_THURSDAY, /**< Thursday */ + I18N_UCALENDAR_FRIDAY, /**< Friday */ + I18N_UCALENDAR_SATURDAY /**< Saturday */ +} i18n_ucalendar_days_of_week_e; + +/** + * @brief Time zone transition types for i18n_ucalendar_get_timezone_transition_date(). + * @since_tizen 2.3.1 + * + * @see i18n_ucalendar_get_timezone_transition_date() + */ +typedef enum { + I18N_UCALENDAR_TZ_TRANSITION_NEXT, /**< Get the next transition after the current date, i.e. excludes the current date */ + I18N_UCALENDAR_TZ_TRANSITION_NEXT_INCLUSIVE, /**< Get the next transition on or after the current date, i.e. may include the current date */ + I18N_UCALENDAR_TZ_TRANSITION_PREVIOUS, /**< Get the previous transition before the current date, i.e. excludes the current date */ + I18N_UCALENDAR_TZ_TRANSITION_PREVIOUS_INCLUSIVE, /**< Get the previous transition on or before the current date, i.e. may include the current date */ +} i18n_utimezone_transition_type_e; + +/** + * @} + * @} + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_UDATE_MODULE + * @{ + */ + +/** + * @brief Date and Time data type. \n This is a primitive data type that holds the date and time as the number of milliseconds since 1970-jan-01, 00:00 UTC. UTC leap seconds are ignored. + */ + +/** + * @brief Date and Time data type. + * @details This is a primitive data type that holds the date and time as the number of milliseconds since 1970-jan-01, 00:00 UTC. UTC leap seconds are ignored. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef double i18n_udate; + +/** + * @brief A date formatter. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef void *i18n_udate_format_h; + +/** + * @brief A struct representing a range of text containing a specific field. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef struct { + int32_t field; /**< The field. */ + int32_t beginIndex; /**< The start of the text range containing field.*/ + int32_t endIndex; /**< The limit of the text range containing field.*/ +} i18n_ufield_position_s; + +/** + * @brief Handle to struct representing a range of text containing a specific field. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef i18n_ufield_position_s* i18n_ufield_position_h; + +/** + * @brief Enumeration for the possible date/time format styles. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { + I18N_UDATE_FULL, /**< Full style */ + I18N_UDATE_LONG, /**< Long style */ + I18N_UDATE_MEDIUM, /**< Medium style */ + I18N_UDATE_SHORT, /**< Short style */ + I18N_UDATE_DEFAULT = I18N_UDATE_MEDIUM, /**< Default style */ + I18N_UDATE_RELATIVE = (1 << 7), /**< Bitfield for relative date */ + I18N_UDATE_FULL_RELATIVE = I18N_UDATE_FULL | I18N_UDATE_RELATIVE, /**< #I18N_UDATE_FULL | #I18N_UDATE_RELATIVE */ + I18N_UDATE_LONG_RELATIVE = I18N_UDATE_LONG | I18N_UDATE_RELATIVE, /**< #I18N_UDATE_LONG | #I18N_UDATE_RELATIVE */ + I18N_UDATE_MEDIUM_RELATIVE = I18N_UDATE_MEDIUM | I18N_UDATE_RELATIVE, /**< #I18N_UDATE_MEDIUM | #I18N_UDATE_RELATIVE */ + I18N_UDATE_SHORT_RELATIVE = I18N_UDATE_SHORT | I18N_UDATE_RELATIVE, /**< #I18N_UDATE_SHORT | #I18N_UDATE_RELATIVE */ + I18N_UDATE_NONE = -1, /**< No style */ + I18N_UDATE_PATTERN = -2 /**< Use the pattern given in the parameter to i18n_udate_create(). */ +} i18n_udate_format_style_e; + +/** + * @brief Enumeration for format fields. + * @since_tizen 2.3.1 + */ +typedef enum { + I18N_UDATE_FORMAT_ERA_FIELD, /**< Era field */ + I18N_UDATE_FORMAT_YEAR_FIELD, /**< Year field */ + I18N_UDATE_FORMAT_MONTH_FIELD, /**< Month field */ + I18N_UDATE_FORMAT_DATE_FIELD, /**< Date field */ + I18N_UDATE_FORMAT_HOUR_OF_DAY1_FIELD, /**< Hour of day1 field */ + I18N_UDATE_FORMAT_HOUR_OF_DAY0_FIELD, /**< Hour of day0 field */ + I18N_UDATE_FORMAT_MINUTE_FIELD, /**< Minute field */ + I18N_UDATE_FORMAT_SECOND_FIELD, /**< Second field */ + I18N_UDATE_FORMAT_FRACTIONAL_SECOND_FIELD, /**< Fractional second field */ + I18N_UDATE_FORMAT_DAY_OF_WEEK_FIELD, /**< Day of week field */ + I18N_UDATE_FORMAT_DAY_OF_YEAR_FIELD, /**< Day of year field */ + I18N_UDATE_FORMAT_DAY_OF_WEEK_IN_MONTH_FIELD, /**< Day of week in month field */ + I18N_UDATE_FORMAT_WEEK_OF_YEAR_FIELD, /**< Week of year field */ + I18N_UDATE_FORMAT_WEEK_OF_MONTH_FIELD, /**< Week of month field */ + I18N_UDATE_FORMAT_AM_PM_FIELD, /**< a.m. / p.m. field */ + I18N_UDATE_FORMAT_HOUR1_FIELD, /**< Hour1 field */ + I18N_UDATE_FORMAT_HOUR0_FIELD, /**< Hour0 field */ + I18N_UDATE_FORMAT_TIMEZONE_FIELD, /**< Timezone field */ + I18N_UDATE_FORMAT_YEAR_WOY_FIELD, /**< Year woy field */ + I18N_UDATE_FORMAT_DOW_LOCAL_FIELD, /**< Dow local field */ + I18N_UDATE_FORMAT_EXTENDED_YEAR_FIELD, /**< Extended year field */ + I18N_UDATE_FORMAT_JULIAN_DAY_FIELD, /**< Julian day field */ + I18N_UDATE_FORMAT_MILLISECONDS_IN_DAY_FIELD, /**< Milliseconds in day field */ + I18N_UDATE_FORMAT_TIMEZONE_RFC_FIELD, /**< Timezone RFC field */ + I18N_UDATE_FORMAT_TIMEZONE_GENERIC_FIELD, /**< Timezone generic field */ + I18N_UDATE_FORMAT_STANDALONE_DAY_FIELD, /**< Standalone day field */ + I18N_UDATE_FORMAT_STANDALONE_MONTH_FIELD, /**< Standalone month field */ + I18N_UDATE_FORMAT_QUARTER_FIELD, /**< Quarter field */ + I18N_UDATE_FORMAT_STANDALONE_QUARTER_FIELD, /**< Standalone quarter field */ + I18N_UDATE_FORMAT_TIMEZONE_SPECIAL_FIELD, /**< Timezone special field */ + I18N_UDATE_FORMAT_YEAR_NAME_FIELD, /**< Year name field */ + I18N_UDATE_FORMAT_TIMEZONE_LOCALIZED_GMT_OFFSET_FIELD, /**< Timezone localized gmt offset field */ + I18N_UDATE_FORMAT_TIMEZONE_ISO_FIELD, /**< Timezone ISO field */ + I18N_UDATE_FORMAT_TIMEZONE_ISO_LOCAL_FIELD, /**< Timezone ISO local field */ + I18N_UDATE_FORMAT_FIELD_COUNT /**< Field count */ +} i18n_udate_format_field_e; + +/** + * @brief Enumeration for symbol types. + * @since_tizen 2.3.1 + */ +typedef enum { + I18N_UDATE_FORMAT_SYMBOL_TYPE_ERAS, /**< Eras */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_MONTHS, /**< Months */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_SHORT_MONTHS, /**< Short months */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_WEEKDAYS, /**< Weekdays */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_SHORT_WEEKDAYS, /**< Short weekdays */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_AM_PMS, /**< AM PMs */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_LOCALIZED_CHARS, /**< Localized chars */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_ERA_NAMES, /**< Era names */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_NARROW_MONTHS, /**< Narrow months */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_NARROW_WEEKDAYS, /**< Narrow weekdays */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_STANDALONE_MONTHS, /**< Standalone months */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_STANDALONE_SHORT_MONTHS, /**< Standalone short months */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_STANDALONE_NARROW_MONTHS, /**< Standalone narrow months */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_STANDALONE_WEEKDAYS, /**< Standalone weekdays */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_STANDALONE_SHORT_WEEKDAYS, /**< Standalone short weekdays */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_STANDALONE_NARROW_WEEKDAYS, /**< Standalone narrow weekdays */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_QUARTERS, /**< Quarters */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_SHORT_QUARTERS, /**< Short quarters */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_STANDALONE_QUARTERS, /**< Standalone quarters */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_STANDALONE_SHORT_QUARTERS, /**< Standalone short quarters */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_SHORTER_WEEKDAYS, /**< Shorter weekdays */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_STANDALONE_SHORTER_WEEKDAYS, /**< Standalone shorter weekdays */ +} i18n_udate_format_symbol_type_e; + +/** + * @brief Display context types, for getting values of a particular setting. + * @details Note, the specific numeric values are internal and may change. + * @since_tizen 2.3.1 + + */ +typedef enum{ + I18N_UDISPCTX_TYPE_DIALECT_HANDLING, /** + +/** + * @file utils_i18n_ubrk.h + * @version 0.1 + * @brief utils_i18n_ubrk + */ + +/** + * @ingroup CAPI_BASE_UTILS_I18N_MODULE + * @defgroup CAPI_BASE_UTILS_I18N_UBRK_MODULE Ubrk + * @brief Ubrk defines methods for finding the location of boundaries in text. + * + * @section CAPI_BASE_UTILS_I18N_UBRK_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_BASE_UTILS_I18N_UBRK_MODULE_OVERVIEW Overview + * @details Pointer to a #i18n_ubreak_iterator_h maintains a current position and scans over text returning the index of characters where boundaries occur. + * + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_UBRK_MODULE + * @{ + */ + +/** + * @brief Opens a new #i18n_ubreak_iterator_h for locating text boundaries for a specified locale. + * @details A #i18n_ubreak_iterator_h may be used for detecting character, line, word, + * and sentence breaks in text. + * @remarks Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * @param[in] type The type of #i18n_ubreak_iterator_h to open: one of #I18N_UBRK_CHARACTER, #I18N_UBRK_WORD, + * #I18N_UBRK_LINE, #I18N_UBRK_SENTENCE + * @param[in] locale The locale specifying the text-breaking conventions. + * If @c NULL, the default locale will be used. + * @param[in] text The text to be iterated over. May be @c NULL, then the iterator will be created without any text. + * The text can be set later with i18n_ubrk_set_text() function. + * @param[in] text_length The number of characters in text, or -1 if NULL-terminated. + * @param[out] break_iter A pointer to the #i18n_ubreak_iterator_h for the specified locale. + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ubrk_create_rules() + */ +int i18n_ubrk_create (i18n_ubreak_iterator_type_e type, const char *locale, const i18n_uchar *text, int32_t text_length, i18n_ubreak_iterator_h *break_iter); + +/** + * @brief Opens a new #i18n_ubreak_iterator_h for locating text boundaries using specified breaking rules. + * @remarks Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * @param[in] rules A set of rules specifying the text breaking conventions. + * @param[in] rules_length The number of characters in rules, or -1 if NULL-terminated. + * @param[in] text The text to be iterated over. May be @c NULL, in which case i18n_ubrk_set_text() is + * used to specify the text to be iterated. + * @param[in] text_length The number of characters in text, or -1 if NULL-terminated. + * @param[out] break_iter A pointer to the #i18n_ubreak_iterator_h for the specified rules. + * @param[out] parse_err Receives position and context information for any syntax errors + * detected while parsing the rules. + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ubrk_create() + */ +int i18n_ubrk_create_rules (const i18n_uchar *rules, int32_t rules_length, const i18n_uchar *text, int32_t text_length, i18n_ubreak_iterator_h *break_iter, i18n_uparse_error_s *parse_err); + +/** + * @brief Thread safe cloning operation. + * @remarks Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * @param[in] break_iter iterator to be cloned. Must not be @c NULL. + * @param[in] stack_buffer User allocated space for the new clone. If @c NULL new memory will be allocated. + * If buffer is not large enough, new memory will be allocated. + * Clients can use the #I18N_U_BRK_SAFECLONE_BUFFERSIZE. This will probably be enough to avoid memory allocations. + * @param[in] p_buffer_size A pointer to size of allocated space. + * If *p_buffer_size == 0, a sufficient size for use in cloning will + * be returned ('pre-flighting') + * If *p_buffer_size is not enough for a stack-based safe clone, + * new memory will be allocated. + * @param[out] break_iter_clone A pointer to the cloned #i18n_ubreak_iterator_h. + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ubrk_safe_clone (const i18n_ubreak_iterator_h break_iter, void *stack_buffer, int32_t *p_buffer_size, i18n_ubreak_iterator_h *break_iter_clone); + +/** + * @brief Closes a #i18n_ubreak_iterator_h. + * @details Once closed, a #i18n_ubreak_iterator_h may no longer be used. + * @remarks Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * @param[in] break_iter The break iterator to close. Must not be @c NULL. + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter +*/ +int i18n_ubrk_destroy (i18n_ubreak_iterator_h break_iter); + +/** + * @brief Sets an existing iterator to point to a new piece of text. + * @remarks Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * @param[in] break_iter The iterator to use. Must not be @c NULL. + * @param[in] text The text to be set. Must not be @c NULL. + * @param[in] text_length The length of the text. + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ubrk_set_text (i18n_ubreak_iterator_h break_iter, const i18n_uchar *text, int32_t text_length); + +/** + * @brief Determines the most recently-returned text boundary. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * @param[in] break_iter The break iterator to use. Must not be @c NULL. + * @return The character index most recently returned by, i18n_ubrk_next(), i18n_ubrk_previous(), + * i18n_ubrk_first(), or i18n_ubrk_last(). + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ubrk_current (const i18n_ubreak_iterator_h break_iter); + +/** + * @brief Advances the iterator to the boundary following the current boundary. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * @param[in] break_iter The break iterator to use. Must not be @c NULL. + * @return The character index of the next text boundary, or #I18N_UBRK_DONE + * if all text boundaries have been returned. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ubrk_previous() + */ +int32_t i18n_ubrk_next (i18n_ubreak_iterator_h break_iter); + +/** + * @brief Sets the iterator position to the boundary preceding the current boundary. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * @param[in] break_iter The break iterator to use. Must not be @c NULL. + * @return The character index of the preceding text boundary, or #I18N_UBRK_DONE + * if all text boundaries have been returned. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ubrk_next() + */ +int32_t i18n_ubrk_previous (i18n_ubreak_iterator_h break_iter); + +/** + * @brief Sets the iterator position to the index of the first character in the text being scanned. + * @details This is not always the same as index @c 0 of the text. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * @param[in] break_iter The break iterator to use. Must not be @c NULL. + * @return The character index of the first character in the text being scanned. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ubrk_last() + */ +int32_t i18n_ubrk_first (i18n_ubreak_iterator_h break_iter); + +/** + * @brief Sets the iterator position to the index immediately beyond the last character in the text being scanned. + * @details This is not the same as the last character. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * @param[in] break_iter The break iterator to use. Must not be @c NULL. + * @return The character offset immediately beyond the last character in the + * text being scanned. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ubrk_first() + */ +int32_t i18n_ubrk_last (i18n_ubreak_iterator_h break_iter); + +/** + * @brief Sets the iterator position to the first boundary preceding the specified @c offset. + * @details The new position is always smaller than @c offset, or #I18N_UBRK_DONE. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * @param[in] break_iter The break iterator to use. Must not be @c NULL. + * @param[in] offset The offset to begin scanning. + * @return The text boundary preceding offset, or #I18N_UBRK_DONE. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ubrk_following() + */ +int32_t i18n_ubrk_preceding (i18n_ubreak_iterator_h break_iter, int32_t offset); + +/** + * @brief Advances the iterator to the first boundary following the specified @c offset. + * @details The value returned is always greater than @c offset, or #I18N_UBRK_DONE. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * @param[in] break_iter The break iterator to use. Must not be @c NULL. + * @param[in] offset The offset to begin scanning. + * @return The text boundary following offset, or #I18N_UBRK_DONE. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ubrk_preceding() + */ +int32_t i18n_ubrk_following (i18n_ubreak_iterator_h break_iter, int32_t offset); + +/** + * @brief Gets a locale for which text breaking information is available. + * @details A #i18n_ubreak_iterator_h in a locale returned by this function will perform the correct + * text breaking for the locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * @param[in] index The index of the desired locale. + * @return A locale for which number text breaking information is available, or @c 0 if none. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ubrk_count_available() + */ +const char *i18n_ubrk_get_available (int32_t index); + +/** + * @brief Determines how many locales have text breaking information available. + * @details This function is most useful as determining the loop ending condition for + * calls to i18n_ubrk_get_available(). + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * @return The number of locales for which text breaking information is available. + * @exception #I18N_ERROR_NONE Successful + * @see i18n_ubrk_get_available() + */ +int32_t i18n_ubrk_count_available (void); + +/** + * @brief Returns true if the specfied position is a boundary position. + * @details As a side effect, leaves the iterator pointing to the first boundary position at + * or after @c offset. + * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are + * described in Exceptions section. + * @since_tizen 2.3.1 + * @param[in] break_iter The break iterator to use. Must not be @c NULL. + * @param[in] offset The offset to check. + * @return True if "offset" is a boundary position. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_ubool i18n_ubrk_is_boundary (i18n_ubreak_iterator_h break_iter, int32_t offset); + +/** + * @brief Returns the status from the break rule that determined the most recently + * returned break position. + * @details The values appear in the rule source + * within brackets, {123}, for example. For rules that do not specify a + * status, a default value of 0 is returned. + *

+ * For word break iterators, the possible values are defined in enum #i18n_uchar_u_word_break_values_e. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * @param[in] break_iter The break iterator to use. Must not be @c NULL. + * @return The status from the break rule that determined the most recently returned break position. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ubrk_get_rule_status (i18n_ubreak_iterator_h break_iter); + +/** + * @brief Gets the statuses from the break rules that determined the most recently + * returned break position. + * @details The values appear in the rule source within brackets, {123}, for example. The default status value for rules + * that do not explicitly provide one is zero. + *

+ * For word break iterators, the possible values are defined in enum #i18n_uchar_u_word_break_values_e. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and in #i18n_error_code_e description. + * + * @since_tizen 2.3.1 + * @param[in] break_iter The break iterator to use. Must not be @c NULL. + * @param[out] fill_in_vec An array to be filled in with the status values. + * @param[in] capacity The length of the supplied vector. A length of zero causes + * the function to return the number of status values, in the + * normal way, without attempting to store any values. + * @return The number of rule status values from rules that determined + * the most recent boundary returned by the break iterator. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ubrk_get_rule_status_vec (i18n_ubreak_iterator_h break_iter, int32_t *fill_in_vec, int32_t capacity); + +/** + * @brief Returns the locale of the break iterator. You can choose between the valid and + * the actual locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and in #i18n_error_code_e description. + * + * @since_tizen 2.3.1 + * @param[in] break_iter Break iterator. Must not be @c NULL. + * @param[in] type Locale type (valid or actual). + * @return locale string + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +const char *i18n_ubrk_get_locale_by_type (const i18n_ubreak_iterator_h break_iter, i18n_ulocale_data_locale_type_e type); + +#ifdef __cplusplus +} +#endif + +/** + * @} + * @} + */ + +#endif diff --git a/src/include/mobile/utils_i18n_ucalendar.h b/src/include/mobile/utils_i18n_ucalendar.h new file mode 100644 index 0000000..8dae458 --- /dev/null +++ b/src/include/mobile/utils_i18n_ucalendar.h @@ -0,0 +1,910 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +#ifndef __UTILS_I18N_UCALENDAR_H__ +#define __UTILS_I18N_UCALENDAR_H__ + +#include + +/** + * @file utils_i18n_ucalendar.h + * @version 0.1 + * @brief utils_i18n_ucalendar + */ + +/** + * @ingroup CAPI_BASE_UTILS_I18N_MODULE + * @defgroup CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE Ucalendar + * @brief The Ucalendar is used for converting between an udate module and a set of integer fields + * such as #I18N_UCALENDAR_YEAR, #I18N_UCALENDAR_MONTH, #I18N_UCALENDAR_DATE, #I18N_UCALENDAR_HOUR, and so on. + * @section CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE_HEADER Required Header + * \#include + * @section CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE_OVERVIEW Overview + * @details The Ucalendar is used for converting between an udate module and a set of integer fields + * such as #I18N_UCALENDAR_YEAR, #I18N_UCALENDAR_MONTH, #I18N_UCALENDAR_DATE, #I18N_UCALENDAR_HOUR, and so on. + * (An udate module represents a specific instant in time with millisecond precision. See udate for + * information about the udate.) + * + * @section CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE_SAMPLE_CODE_1 Sample Code 1 + * @brief Converts the given date and time to the corresponding UTC time(number of seconds that have elapsed since January 1, 1970), considering the given time zone + * @code + + #define ms2sec(ms) (long long int)(ms)/1000.0 + + // get time in sec from input date and time + long long int _time_convert_itol(char *tzid, int y, int mon, int d, int h, int min, int s) + { + long long int lli; + i18n_ucalendar_h ucal; + i18n_udate date; + int ret = I18N_ERROR_NONE; + int year, month, day, hour, minute, second; + int len; + + i18n_uchar *_tzid = NULL; + + if (tzid == NULL) { + tzid = "Etc/GMT"; + } + _tzid = (i18n_uchar*)calloc(strlen(tzid) + 1, sizeof(i18n_uchar)); + if (_tzid == NULL) { + return -1; + } + // converts 'tzid' to unicode string + i18n_ustring_copy_ua(_tzid, tzid); + + // gets length of '_tzid' + i18n_ustring_get_length(_tzid, &len); + // creates i18n_ucalendar_h + ret = i18n_ucalendar_create(_tzid, len, "en_US", I18N_UCALENDAR_TRADITIONAL, &ucal); + if (ret) { + dlog_print(DLOG_INFO, LOG_TAG, "i18n_ucalendar_create failed.\n"); + return -1; + } + + // sets i18n_ucalendar_h's date + i18n_ucalendar_set_date_time(ucal, y, mon-1, d, h, min, s); + + // gets the current value of a field from i18n_ucalendar_h + i18n_ucalendar_get(ucal, I18N_UCALENDAR_YEAR, &year); + i18n_ucalendar_get(ucal, I18N_UCALENDAR_MONTH, &month); + i18n_ucalendar_get(ucal, I18N_UCALENDAR_DATE, &day); + i18n_ucalendar_get(ucal, I18N_UCALENDAR_HOUR, &hour); + i18n_ucalendar_get(ucal, I18N_UCALENDAR_MINUTE, &minute); + i18n_ucalendar_get(ucal, I18N_UCALENDAR_SECOND, &second); + dlog_print(DLOG_INFO, LOG_TAG, "Date from ucal, year:%d month:%d day:%d hour:%d minute:%d second:%d.\n",year, month, day, hour, minute, second); + + // gets i18n_ucalendar's current time and converts it from milliseconds to seconds + i18n_ucalendar_get_milliseconds(ucal, &date); + lli = ms2sec(date); + // destroys i18n_ucalendar_h + i18n_ucalendar_destroy(ucal); + if (_tzid) { + free(_tzid); + } + + return lli; + } + * @endcode + * + * @section CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE_SAMPLE_CODE_2 Sample Code 2 + * @brief Describes an example that uses _time_convert_itol from 'Sample Code 2' + * @code + // converts the given time to UTC time(number of seconds that have elapsed since January 1, 1970) + long long int time = _time_convert_itol("Etc/GMT", 2014, 5, 28, 15, 14, 0); + dlog_print(DLOG_INFO, LOG_TAG, "Time Zone: %s\t, %d/%d/%d/%d/%d/%d\n", "Etc/GMT", 2014, 5, 28, 15, 14, 0); + dlog_print(DLOG_INFO, LOG_TAG, "_time_convert_itol test : %lld\n", time); + * @endcode + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE + * @{ + */ + +/** + * @brief Sets the default time zone. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] zone_id null-terminated time zone ID + * + * @return An #i18n_error_code_e error code + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucalendar_set_default_timezone ( const i18n_uchar *zone_id ); + +/** + * @brief Gets the current date and time. + * @details The value returned is represented as milliseconds from the epoch. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] date The current date and time + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucalendar_get_now ( i18n_udate *date ); + +/** + * @brief Creates an #i18n_ucalendar_h. + * An #i18n_ucalendar_h may be used to convert a millisecond value to a year, + * month, and day. + * @details Note: When an unknown TimeZone ID is specified, the #i18n_ucalendar_h returned + * by the function is initialized with GMT ("Etc/GMT") without any + * errors/warnings. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @remarks Must release @a calendar using i18n_ucalendar_destroy(). + * + * @param[in] zone_id The desired TimeZone ID \n + * If @c 0, use the default time zone. + * @param[in] len The length of the zone ID, + * otherwise @c -1 if null-terminated + * @param[in] locale The desired locale + * If @c NULL, the default locale will be used. + * @param[in] type The type of #I18N_UCALENDAR_DEFAULT to create \n + * This can be #I18N_UCALENDAR_GREGORIAN to create the Gregorian + * calendar for the locale, or #I18N_UCALENDAR_DEFAULT to create the default calendar for the locale (the + * default calendar may also be Gregorian). + * @param[out] calendar A pointer to an #i18n_ucalendar_h, + * otherwise @c 0 if an error occurs + * + * @return An #i18n_error_code_e error code + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @retval #I18N_ERROR_OUT_OF_MEMORY Out of memory + */ +int i18n_ucalendar_create ( const i18n_uchar *zone_id, int32_t len, const char *locale, i18n_ucalendar_type_e type, i18n_ucalendar_h *calendar ); + +/** + * @brief Destroys an #i18n_ucalendar_h. + * @details Once destroyed, an #i18n_ucalendar_h may no longer be used. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] calendar The #i18n_ucalendar_h to destroy + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucalendar_destroy ( i18n_ucalendar_h calendar ); + +/** + * @brief Creates a copy of a #i18n_ucalendar_h. + * This function performs a deep copy. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] cal The #i18n_ucalendar_h to copy + * @param[out] identical_to_cal A pointer to a #i18n_ucalendar_h identical to @a cal. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucalendar_clone ( const i18n_ucalendar_h cal, i18n_ucalendar_h *identical_to_cal ); + +/** + * @brief Gets the display name for a calendar's TimeZone. + * @details A display name is suitable for presentation to a user. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] calendar The #i18n_ucalendar_h to query + * @param[in] type The desired display name format \n + * One of #I18N_UCALENDAR_STANDARD, #I18N_UCALENDAR_SHORT_STANDARD, #I18N_UCALENDAR_DST, or #I18N_UCALENDAR_SHORT_DST + * @param[in] locale The desired locale for the display name + * @param[out] result A pointer to a buffer to receive the formatted number + * @param[in] result_len The maximum size of the result + * @param[out] buf_size_needed The total buffer size needed \n + * If greater than @a result_len, the output is truncated + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucalendar_get_timezone_displayname ( const i18n_ucalendar_h calendar, i18n_ucalendar_displayname_type_e type, const char *locale, i18n_uchar *result, int32_t result_len, int32_t *buf_size_needed ); + +/** + * @brief Determines if an #i18n_ucalendar_h is currently in daylight savings time. + * @details Daylight savings time is not used in all parts of the world. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] calendar The #i18n_ucalendar_h to query + * @param[out] is_in If @c true @a calendar is currently in daylight savings time, + * otherwise @c false + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucalendar_is_in_daylight_time ( const i18n_ucalendar_h calendar, i18n_ubool *is_in ); + +/** + * @brief Sets the value of a field in a #i18n_ucalendar_h. + * @details All fields are represented as 32-bit integers. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] cal The #i18n_ucalendar_h to modify + * @param[in] field The field to set \n + * One of #I18N_UCALENDAR_ERA, #I18N_UCALENDAR_YEAR, + * #I18N_UCALENDAR_MONTH, #I18N_UCALENDAR_WEEK_OF_YEAR, #I18N_UCALENDAR_WEEK_OF_MONTH, + * #I18N_UCALENDAR_DATE, #I18N_UCALENDAR_DAY_OF_YEAR, #I18N_UCALENDAR_DAY_OF_WEEK, + * #I18N_UCALENDAR_DAY_OF_WEEK_IN_MONTH, #I18N_UCALENDAR_AM_PM, #I18N_UCALENDAR_HOUR, + * #I18N_UCALENDAR_HOUR_OF_DAY, #I18N_UCALENDAR_MINUTE, #I18N_UCALENDAR_SECOND, + * #I18N_UCALENDAR_MILLISECOND, #I18N_UCALENDAR_ZONE_OFFSET, #I18N_UCALENDAR_DST_OFFSET. + * @param[in] val The desired value of @a field. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucalendar_set ( i18n_ucalendar_h cal, i18n_ucalendar_date_fields_e field, int32_t val ); + +/** + * @brief Sets a numeric attribute associated with an #i18n_ucalendar_h. + * @details Numeric attributes include the first day of the week, or the minimal number + * of days in the first week of the month. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] calendar The #i18n_ucalendar_h to modify + * @param[in] attr The desired attribute \n + * One of #I18N_UCALENDAR_LENIENT, #I18N_UCALENDAR_FIRST_DAY_OF_WEEK, + * or #I18N_UCALENDAR_MINIMAL_DAYS_IN_FIRST_WEEK. + * + * @param[in] val The new value of @a attr + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucalendar_set_attribute ( i18n_ucalendar_h calendar, i18n_ucalendar_attribute_e attr, int32_t val ); + +/** + * @brief Gets a numeric attribute associated with an i18n_ucalendar. + * @details Numeric attributes include the first day of the week, or the minimal numbers of days + * in the first week of the month. + * + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] calendar The i18n_ucalendar to query + * @param[in] attr The desired attribute \n + * One of #I18N_UCALENDAR_LENIENT, #I18N_UCALENDAR_FIRST_DAY_OF_WEEK, + * or #I18N_UCALENDAR_MINIMAL_DAYS_IN_FIRST_WEEK. + * + * @param[out] val The value of @a attr + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucalendar_get_attribute ( i18n_ucalendar_h calendar, i18n_ucalendar_attribute_e attr, int32_t *val); + +/** + * @brief Gets a calendar's current time in milliseconds. + * @details The time is represented as milliseconds from the epoch. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] calendar The #i18n_ucalendar_h to query + * @param[out] date The calendar's current time in milliseconds + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ucalendar_set_milliseconds() + * @see i18n_ucalendar_set_date_time() + */ +int i18n_ucalendar_get_milliseconds( const i18n_ucalendar_h calendar, i18n_udate *date ); + +/** + * @brief Sets a calendar's current time in milliseconds. + * @details The time is represented as milliseconds from the epoch. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] calendar The #i18n_ucalendar_h to set + * @param[in] milliseconds The desired date and time + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ucalendar_get_milliseconds() + * @see i18n_ucalendar_set_date_time() + */ +int i18n_ucalendar_set_milliseconds ( i18n_ucalendar_h calendar, i18n_udate milliseconds ); + +/** + * @brief Sets a calendar's current date. + * @details The date is represented as a series of 32-bit integers. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] calendar The #i18n_ucalendar_h to set + * @param[in] year The desired year + * @param[in] month The desired month\n + * One of #I18N_UCALENDAR_JANUARY, #I18N_UCALENDAR_FEBRUARY, #I18N_UCALENDAR_MARCH, #I18N_UCALENDAR_APRIL, #I18N_UCALENDAR_MAY, + * #I18N_UCALENDAR_JUNE, #I18N_UCALENDAR_JULY, #I18N_UCALENDAR_AUGUST, #I18N_UCALENDAR_SEPTEMBER, #I18N_UCALENDAR_OCTOBER, #I18N_UCALENDAR_NOVEMBER, or #I18N_UCALENDAR_DECEMBER + * @param[in] date The desired day of the month + * @param[in] hour The desired hour of the day + * @param[in] min The desired minute + * @param[in] sec The desired second + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ucalendar_get_milliseconds() + * @see i18n_ucalendar_set_milliseconds() + */ +int i18n_ucalendar_set_date_time ( i18n_ucalendar_h calendar, int32_t year, int32_t month, int32_t date, int32_t hour, int32_t min, int32_t sec ); + +/** + * @brief Returns @c true if two #i18n_ucalendar_h calendars are equivalent. + * @details Equivalent #i18n_ucalendar_h calendars will behave identically, but they may be set to + * different times. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] calendar1 The first of the calendars to compare + * @param[in] calendar2 The second of the calendars to compare + * @param[out] equiv If @c true @a cal1 and @a cal2 are equivalent, otherwise @c false + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucalendar_is_equivalent_to ( const i18n_ucalendar_h calendar1, const i18n_ucalendar_h calendar2, i18n_ubool *equiv ); + +/** + * @brief Adds a specified signed amount to a particular field in a #i18n_ucalendar_h. + * @details This can modify more significant fields in the calendar. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] calendar The #i18n_ucalendar_h to which to add + * @param[in] field The field to which to add the signed value\n One of #I18N_UCALENDAR_ERA, #I18N_UCALENDAR_YEAR, #I18N_UCALENDAR_MONTH, + * #I18N_UCALENDAR_WEEK_OF_YEAR, #I18N_UCALENDAR_WEEK_OF_MONTH, #I18N_UCALENDAR_DATE, #I18N_UCALENDAR_DAY_OF_YEAR, #I18N_UCALENDAR_DAY_OF_WEEK, + * #I18N_UCALENDAR_DAY_OF_WEEK_IN_MONTH, #I18N_UCALENDAR_AM_PM, #I18N_UCALENDAR_HOUR, #I18N_UCALENDAR_HOUR_OF_DAY, #I18N_UCALENDAR_MINUTE, #I18N_UCALENDAR_SECOND, + * #I18N_UCALENDAR_MILLISECOND. + * @param[in] amount The signed amount to add to the field \n + * If the amount causes the value to exceed to maximum or minimum values for that field, + * other fields are modified to preserve the magnitude of the change. + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + + */ +int i18n_ucalendar_add ( i18n_ucalendar_h calendar, i18n_ucalendar_date_fields_e field, int32_t amount ); + +/** + * @brief Gets the current value of a field from an #i18n_ucalendar_h. + * @details All fields are represented as 32-bit integers. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] calendar The #i18n_ucalendar_h to query + * @param[in] field The desired field\n One of I18N_UCALENDAR_ERA, I18N_UCALENDAR_YEAR, I18N_UCALENDAR_MONTH, + * #I18N_UCALENDAR_WEEK_OF_YEAR, #I18N_UCALENDAR_WEEK_OF_MONTH, #I18N_UCALENDAR_DATE, #I18N_UCALENDAR_DAY_OF_YEAR, #I18N_UCALENDAR_DAY_OF_WEEK, + * #I18N_UCALENDAR_DAY_OF_WEEK_IN_MONTH, #I18N_UCALENDAR_AM_PM, #I18N_UCALENDAR_HOUR, #I18N_UCALENDAR_HOUR_OF_DAY, #I18N_UCALENDAR_MINUTE, #I18N_UCALENDAR_SECOND, + * #I18N_UCALENDAR_MILLISECOND, #I18N_UCALENDAR_ZONE_OFFSET, or #I18N_UCALENDAR_DST_OFFSET. + * @param[out] val The value of the desired field. + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucalendar_get ( const i18n_ucalendar_h calendar, i18n_ucalendar_date_fields_e field, int32_t *val ); + + +// Newly Added APIs + + + +/** + * @brief Returns the difference between the target time and the time this calendar object is currently set to. + * @details If the target time is after the current calendar setting, the the returned value will be positive. + * The field parameter specifies the units of the return value. + * For example, if field is I18N_UCALENDAR_MONTH and i18n_ucalendar_get_field_difference returns 3, + * then the target time is 3 to less than 4 months after the current calendar setting.
+ * As a side effect of this call, this calendar is advanced toward target by the given amount. + * That is, calling this function has the side effect of calling i18n_ucalendar_add on this calendar with the + * specified field and an amount equal to the return value from this function.
+ * A typical way of using this function is to call it first with the largest field of interest, then with progressively smaller fields. + * @since_tizen 2.3.1 + * + * @param[in] calendar The i18n_ucalendar_h to compare and update. + * @param[in] target The target date to compare to the current calendar setting. + * @param[in] field One of #I18N_UCALENDAR_ERA, #I18N_UCALENDAR_YEAR, #I18N_UCALENDAR_MONTH, + * #I18N_UCALENDAR_WEEK_OF_YEAR, #I18N_UCALENDAR_WEEK_OF_MONTH, #I18N_UCALENDAR_DATE, + * #I18N_UCALENDAR_DAY_OF_YEAR, #I18N_UCALENDAR_DAY_OF_WEEK, #I18N_UCALENDAR_DAY_OF_WEEK_IN_MONTH, + * #I18N_UCALENDAR_AM_PM, #I18N_UCALENDAR_HOUR, #I18N_UCALENDAR_HOUR_OF_DAY, #I18N_UCALENDAR_MINUTE, + * #I18N_UCALENDAR_SECOND, #I18N_UCALENDAR_MILLISECOND. + * Please note that the returned value type is int32_t. In case of #I18N_UCALENDAR_MILLISECOND, maximal + * difference between dates may be equal to the maximal value of the int32_t, which is 2147483647 (about one month difference). + * If the difference is bigger, then the #I18N_ERROR_INVALID_PARAMETER error will be returned. + * @param[out] status A pointer to an i18n_error_code_e to receive any errors + * + * @return The date difference for the specified field. + */ +int32_t i18n_ucalendar_get_field_difference ( i18n_ucalendar_h calendar, i18n_udate target, i18n_ucalendar_date_fields_e field, i18n_error_code_e *status ); + +/** + * @brief Creates an enumeration over system time zone IDs with the given filter conditions. + * @since_tizen 2.3.1 + * + * @param[in] zone_type The system time zone type. + * @param[in] region The ISO 3166 two-letter country code or UN M.49 three-digit + * area code. When @c NULL, no filtering done by region. + * @param[in] raw_offset An offset from GMT in milliseconds, ignoring the effect + * of daylight savings time, if any. When @c NULL, no filtering done by zone offset. + * + * @param[out] enumeration A Pointer to the enumeration object that the caller must dispose of using + * i18n_uenumeration_destroy(), or@c NULL upon failure. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucalendar_timezone_id_enumeration_create ( i18n_system_timezone_type_e zone_type, const char *region, const int32_t *raw_offset, i18n_uenumeration_h *enumeration); + +/** + * @brief Creates an enumeration over all time zones. + * @since_tizen 2.3.1 + * + * @param[out] enumeration A pointer to the enumeration object that the caller must dispose of using + * i18n_uenumeration_destroy(), or @c NULL upon failure. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucalendar_timezones_create (i18n_uenumeration_h * enumeration); + +/** + * @brief Creates an enumeration over all time zones associated with the given country. + * @details Some zones are affiliated with no country (e.g., "UTC"); these may also be retrieved, as a group. + * @since_tizen 2.3.1 + * + * @param[in] country The ISO 3166 two-letter country code, or @c NULL to retrieve zones not affiliated with any country + * + * @param[out] enumeration A pointer to the enumeration object that the caller must dispose of using + * i18n_uenumeration_destroy(), or @c NULL upon failure. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucalendar_country_timezones_create (const char *country, i18n_uenumeration_h * enumeration); + +/** + * @brief Returns the default time zone. + * @details The default is determined initially by querying the host operating system. + * It may be changed with i18n_ucalendar_set_default_timezone() + * or with the C++ TimeZone API. + * @remarks The specific error code can be obtained using the get_last_result() + * method. Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[out] result A buffer to receive the result, or @c NULL + * @param[in] result_capacity The capacity of the @c result buffer + * + * @return The @c result string length, not including the terminating @c NULL. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid parameter + */ +int32_t i18n_ucalendar_get_default_timezone (i18n_uchar *result, int32_t result_capacity); + +/** + * @brief Sets the TimeZone used by a #i18n_ucalendar_h. + * @details A #i18n_ucalendar_h uses a timezone for converting from Greenwich time to local time. + * @since_tizen 2.3.1 + * + * @param[in] calendar The #i18n_ucalendar_h to set. + * @param[in] zone_id The desired TimeZone ID. If NULL, use the default time zone. + * @param[in] length The length of @c zone_id, or -1 if NULL-terminated. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucalendar_set_timezone ( i18n_ucalendar_h calendar, const i18n_uchar *zone_id, int32_t length ); + +/** + * @brief Gets the ID of the calendar's time zone. + * @remarks The specific error code can be obtained using the get_last_result() + * method. Error codes are described in Exceptions section and + * #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] calendar The #i18n_ucalendar_h to query. + * @param[out] result Receives the calendar's time zone ID. + * @param[in] result_length The maximum size of the @c result. + * + * @return The total buffer size needed; if greater than @c result_length, the output was truncated. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ucalendar_get_timezone_id (const i18n_ucalendar_h calendar, i18n_uchar *result, int32_t result_length); + +/** + * @brief Sets the Gregorian Calendar change date. + * @details This is the point when the switch from Julian dates to Gregorian dates + * occurred. Default is 00:00:00 local time, October 15, 1582. + * Previous to this time and date will be Julian dates. + * This function works only for Gregorian calendars. If the #i18n_ucalendar_h + * is not an instance of a Gregorian calendar, then a + * #I18N_ERROR_NOT_SUPPORTED error code is set. + * @since_tizen 2.3.1 + * + * @param[in] calendar The calendar object. + * @param[in] date The given Gregorian cutover date. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_ucalendar_get_gregorian_change() + */ +int i18n_ucalendar_set_gregorian_change ( i18n_ucalendar_h calendar, i18n_udate date); + +/** + * @brief Gets the Gregorian Calendar change date. + * @details This is the point when the switch from Julian dates to Gregorian dates + * occurred. Default is 00:00:00 local time, October 15, 1582. + * Previous to this time and date will be Julian dates. + * This function works only for Gregorian calendars. If the #i18n_ucalendar_h + * is not an instance of a Gregorian calendar, then a + * #I18N_ERROR_NOT_SUPPORTED error code is set. + * @since_tizen 2.3.1 + * + * @param[in] calendar The calendar object. + * @param[out] date A pointer to the Gregorian cutover time for this calendar. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_ucalendar_set_gregorian_change() + */ +int i18n_ucalendar_get_gregorian_change (const i18n_ucalendar_h calendar, i18n_udate *date); + +/** + * @brief Gets a locale for which calendars are available. + * @details A #i18n_ucalendar_h in a locale returned by this function will contain + * the correct day and month names for the locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] locale_index The index of the desired locale. + * + * @return A locale for which calendars are available, or 0 if none. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid parameter + * @see i18n_ucalendar_count_available() + */ +const char * i18n_ucalendar_get_available (int32_t locale_index); + +/** + * @brief Determines how many locales have calendars available. + * @details This function is most useful as determining the loop ending condition for calls to i18n_ucalendar_get_available(). + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @return The number of locales for which calendars are available. + * @exception #I18N_ERROR_NONE Successful + * @see i18n_ucalendar_get_available() + */ +int32_t i18n_ucalendar_count_available (void); + +/** + * @brief Sets a calendar's current date. + * @details The date is represented as a series of 32-bit integers. + * @since_tizen 2.3.1 + * + * @param[in] calendar The #i18n_ucalendar_h to set. + * @param[in] year The desired year. + * @param[in] month The desired month; one of #I18N_UCALENDAR_JANUARY, #I18N_UCALENDAR_FEBRUARY, #I18N_UCALENDAR_MARCH, + * #I18N_UCALENDAR_APRIL, #I18N_UCALENDAR_MAY, #I18N_UCALENDAR_JUNE, #I18N_UCALENDAR_JULY, #I18N_UCALENDAR_AUGUST, + * #I18N_UCALENDAR_SEPTEMBER, #I18N_UCALENDAR_OCTOBER, #I18N_UCALENDAR_NOVEMBER, #I18N_UCALENDAR_DECEMBER + * @param[in] date The desired day of the month. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_ucalendar_add() + * @see i18n_ucalendar_set_milliseconds() + * @see i18n_ucalendar_set_milliseconds() + * @see i18n_ucalendar_set_date_time() + */ +int i18n_ucalendar_set_date (i18n_ucalendar_h calendar, int32_t year, int32_t month, int32_t date); + +/** + * @brief Adds a specified signed amount to a particular field in a #i18n_ucalendar_h. + * @details This will not modify more significant fields in the calendar. + * Rolling by a positive value always means moving forward in time + * (unless the limit of the field is reached, in which case it may pin or wrap), + * so for Gregorian calendar, starting with 100 BC and + * rolling the year by +1 results in 99 BC. + * When eras have a definite beginning and end (as in the Chinese calendar, + * or as in most eras in the Japanese calendar) then rolling the year past either + * limit of the era will cause the year to wrap around. When eras only have a limit at one end, + * then attempting to roll the year past that limit will result in pinning the year at that limit. + * Note that for most calendars in which era 0 years move forward in time (such as Buddhist, Hebrew, or Islamic), + * it is possible for add or roll to result in negative years for era 0 (that is the + * only way to represent years before the calendar epoch). + * @since_tizen 2.3.1 + * + * @param[in] calendar The #i18n_ucalendar_h to which to add. + * @param[in] field The field to which to add the signed value; one of #I18N_UCALENDAR_ERA, + * #I18N_UCALENDAR_YEAR, #I18N_UCALENDAR_MONTH, #I18N_UCALENDAR_WEEK_OF_YEAR, + * #I18N_UCALENDAR_WEEK_OF_MONTH, #I18N_UCALENDAR_DATE, #I18N_UCALENDAR_DAY_OF_YEAR, + * #I18N_UCALENDAR_DAY_OF_WEEK, #I18N_UCALENDAR_DAY_OF_WEEK_IN_MONTH, #I18N_UCALENDAR_AM_PM, + * #I18N_UCALENDAR_HOUR, #I18N_UCALENDAR_HOUR_OF_DAY, #I18N_UCALENDAR_MINUTE, + * #I18N_UCALENDAR_SECOND, #I18N_UCALENDAR_MILLISECOND. + * @param[in] amount The signed amount to add to the @c field. If the amount causes the + * value to exceed to maximum or minimum values for that field, the field is pinned + * to a permissible value. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @remarks #I18N_UCALENDAR_ZONE_OFFSET and #I18N_UCALENDAR_DST_OFFSET are not supported by this function. + * @see i18n_ucalendar_add() + */ +int i18n_ucalendar_roll (i18n_ucalendar_h calendar, i18n_ucalendar_date_fields_e field, int32_t amount); + +/** + * @brief Determines if a field in a #i18n_ucalendar_h is set. + * @details All fields are represented as 32-bit integers. + * @remarks The specific error code can be obtained using the get_last_result() + * method. Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] calendar The #i18n_ucalendar_h to query. + * @param[in] field The desired field. + * + * @return @c true if field is set, @c false otherwise. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ucalendar_get() + * @see i18n_ucalendar_set() + * @see i18n_ucalendar_clear_field() + * @see i18n_ucalendar_clear() + * + */ +i18n_ubool i18n_ucalendar_is_set (const i18n_ucalendar_h calendar, i18n_ucalendar_date_fields_e field); + +/** + * @brief Clears a field in a #i18n_ucalendar_h. + * @details All fields are represented as 32-bit integers. + * @since_tizen 2.3.1 + * + * @param[in] calendar The #i18n_ucalendar_h containing the field to clear. + * @param[in] field The field to clear. + * + * @return Error code + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_ucalendar_get() + * @see i18n_ucalendar_set() + * @see i18n_ucalendar_is_set() + * @see i18n_ucalendar_clear() + * + */ +int i18n_ucalendar_clear_field (i18n_ucalendar_h calendar, i18n_ucalendar_date_fields_e field); + +/** + * @brief Clears all fields in a #i18n_ucalendar_h. + * @details All fields are represented as 32-bit integers. + * @since_tizen 2.3.1 + * + * @param[in] calendar #i18n_ucalendar_h to clear. + * + * @return Error code + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_ucalendar_is_set() + * @see i18n_ucalendar_clear_field() + * + */ +int i18n_ucalendar_clear (i18n_ucalendar_h calendar); + +/** + * @brief Determines a limit for a field in an #i18n_ucalendar_h. + * @details A limit is a maximum or minimum value for a field. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] calendar The #i18n_ucalendar_h to query. + * @param[in] field The desired field; one of #I18N_UCALENDAR_ERA, #I18N_UCALENDAR_YEAR, #I18N_UCALENDAR_MONTH, + * #I18N_UCALENDAR_WEEK_OF_YEAR, #I18N_UCALENDAR_WEEK_OF_MONTH, #I18N_UCALENDAR_DATE, + * #I18N_UCALENDAR_DAY_OF_YEAR, #I18N_UCALENDAR_DAY_OF_WEEK, #I18N_UCALENDAR_DAY_OF_WEEK_IN_MONTH, + * #I18N_UCALENDAR_AM_PM, #I18N_UCALENDAR_HOUR, #I18N_UCALENDAR_HOUR_OF_DAY, + * #I18N_UCALENDAR_MINUTE, #I18N_UCALENDAR_SECOND, #I18N_UCALENDAR_MILLISECOND, + * #I18N_UCALENDAR_ZONE_OFFSET, #I18N_UCALENDAR_DST_OFFSET, #I18N_UCALENDAR_YEAR_WOY, + * #I18N_UCALENDAR_DOW_LOCAL, #I18N_UCALENDAR_EXTENDED_YEAR, #I18N_UCALENDAR_JULIAN_DAY, + * #I18N_UCALENDAR_MILLISECONDS_IN_DAY, #I18N_UCALENDAR_IS_LEAP_MONTH. + * @param[in] type The desired critical point; one of #I18N_UCALENDAR_MINIMUM, #I18N_UCALENDAR_MAXIMUM, + * #I18N_UCALENDAR_GREATEST_MINIMUM, #I18N_UCALENDAR_LEAST_MAXIMUM, + * #I18N_UCALENDAR_ACTUAL_MINIMUM, #I18N_UCALENDAR_ACTUAL_MAXIMUM. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @return The requested value. + */ +int32_t i18n_ucalendar_get_limit (const i18n_ucalendar_h calendar, i18n_ucalendar_date_fields_e field, i18n_ucalendar_limit_type_e type); + +/** + * @brief Gets the locale for this @c calendar object. + * @details You can choose between valid and actual locale. + * @remarks The specific error code can be obtained using the get_last_result() + * method. Error codes are described in Exceptions section and + * #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] calendar The calendar object + * @param[in] type Type of the locale we're looking for (valid or actual) + * + * @return The requested value. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +const char *i18n_ucalendar_get_locale_by_type (const i18n_ucalendar_h calendar, i18n_ulocale_data_locale_type_e type); + +/** + * @brief Returns the timezone data version currently used by ICU. + * @remarks The specific error code can be obtained using the get_last_result() + * method. Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @return The version string, such as "2007f". + * @exception #I18N_ERROR_NONE Successful + */ +const char *i18n_ucalendar_get_tz_data_version (void); + +/** + * @brief Returns the canonical system timezone ID or the normalized custom time zone ID for the given time zone ID. + * @remarks The specific error code can be obtained using the get_last_result() + * method. Error codes are described in Exceptions section and + * #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] id The input timezone ID to be canonicalized. + * @param[in] length The length of the @c id, or @c -1 if NULL-terminated. + * @param[out] result The buffer receives the canonical system timezone ID or the custom timezone ID in normalized format. + * @param[in] result_capacity The capacity of the @c result buffer. + * @param[out] is_system_id Receives if the given @c id is a known system timezone ID. + * + * @return The result string length, not including the terminating NULL. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ucalendar_get_canonical_timezone_id (const i18n_uchar *id, int32_t length, i18n_uchar *result, int32_t result_capacity, i18n_ubool *is_system_id); + +/** + * @brief Gets the resource keyword value string designating the calendar type for the #i18n_ucalendar_h. + * @remarks The specific error code can be obtained using the get_last_result() + * method. Error codes are described in Exceptions section and + * #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] calendar The #i18n_ucalendar_h to query. + * + * @return The resource keyword value string. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +const char *i18n_ucalendar_get_type (const i18n_ucalendar_h calendar); + +/** + * @brief Given a key and a locale, returns an array of string values in a preferred order that would make a difference. + * @details These are all and only those values where the open (creation) of the service with the + * locale formed from the input locale plus input keyword and that value + * has different behavior than creation with the input locale alone. + * @since_tizen 2.3.1 + * + * @param[in] key One of the keys supported by this service. For now, only "calendar" is supported. + * @param[in] locale The locale + * @param[in] commonly_used If set to @c true it will return only commonly used values with + * the given locale in preferred order. Otherwise, it will return all the available + * values for the locale. + * + * @param[out] enumeration A pointer to the string enumeration over keyword values for the given key and the locale. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucalendar_get_keyword_values_for_locale (const char *key, const char *locale, i18n_ubool commonly_used, i18n_uenumeration_h *enumeration); + +/** + * @brief Returns whether the given day of the week is a weekday, a weekend day, + * or a day that transitions from one to the other, for the locale and calendar system + * associated with this @c #i18n_ucalendar_h (the locale's region is often the most determinant factor). + * @details If a transition occurs at midnight, then the days before and after the + * transition will have the type #I18N_UCALENDAR_WEEKDAY or #I18N_UCALENDAR_WEEKEND. + * If a transition occurs at a time other than midnight, then the day of the + * transition will have the type #I18N_UCALENDAR_WEEKEND_ONSET or #I18N_UCALENDAR_WEEKEND_CEASE. + * In this case, the function i18n_ucalendar_get_weekend_transition() will + * return the point of transition. + * @since_tizen 2.3.1 + * + * @param[in] calendar The #i18n_ucalendar_h to query. + * @param[in] day_of_week The day of the week whose type is desired (#I18N_UCALENDAR_SUNDAY..#I18N_UCALENDAR_SATURDAY). + * + * @param [out] weekday A pointer to the #i18n_ucalendar_weekday_type_e for the day of the week. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucalendar_get_day_of_week_type (const i18n_ucalendar_h calendar, i18n_ucalendar_days_of_week_e day_of_week, i18n_ucalendar_weekday_type_e *weekday); + +/** + * @brief Returns the time during the day at which the weekend begins or ends in this calendar system. + * @details If i18n_ucalendar_get_day_of_week_type() returns #I18N_UCALENDAR_WEEKEND_ONSET + * for the specified @c day_of_week, return the time at which the weekend begins. If + * i18n_ucalendar_get_day_of_week_type() returns #I18N_UCALENDAR_WEEKEND_CEASE for + * the specified @c day_of_week, return the time at which the weekend ends. If + * i18n_ucalendar_get_day_of_week_type() returns some other #i18n_ucalendar_weekday_type_e + * for the specified @c day_of_week, it is an error condition (#I18N_ERROR_INVALID_PARAMETER). + * @remarks The specific error code can be obtained using the get_last_result() + * method. Error codes are described in Exceptions section and + * #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] calendar The #i18n_ucalendar_h to query. + * @param[in] day_of_week The day of the week whose type is desired (#I18N_UCALENDAR_SUNDAY..#I18N_UCALENDAR_SATURDAY). + * + * @return The milliseconds after midnight at which the weekend begins or ends. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ucalendar_get_weekend_transition (const i18n_ucalendar_h calendar, i18n_ucalendar_days_of_week_e day_of_week); + +/** + * @brief Returns @c true if the given #i18n_udate is in the weekend in this calendar system. + * @remarks The specific error code can be obtained using the get_last_result() + * method. Error codes are described in Exceptions section and + * #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] calendar The #i18n_ucalendar_h to query. + * @param[in] date The #i18n_udate in question. + * + * @return @c true if the given #i18n_udate is in the weekend in this calendar system, @c false otherwise. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_ubool i18n_ucalendar_is_weekend (i18n_ucalendar_h calendar, i18n_udate date); + +/** + * @brief Get the #i18n_udate for the next/previous time zone transition relative + * to the calendar's current date, in the time zone to which the calendar is currently set. + * @details If there is no known time zone transition of the requested type relative + * to the calendar's date, the function returns @c false. + * @remarks The specific error code can be obtained using the get_last_result() + * method. Error codes are described in Exceptions section and + * #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] calendar The #i18n_ucalendar_h to query. + * @param[in] type The type of transition desired. + * @param[out] transition A pointer to a #i18n_udate to be set to the transition time. + * If the function returns @c false, the value set is unspecified. + * + * @return @c true if the given #i18n_udate is in the weekend in this calendar system, @c false otherwise. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_ubool i18n_ucalendar_get_timezone_transition_date (const i18n_ucalendar_h calendar, i18n_utimezone_transition_type_e type, i18n_udate *transition); + +/** + * @} + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __I18N_UCALENDAR_H__*/ diff --git a/src/include/mobile/utils_i18n_uchar.h b/src/include/mobile/utils_i18n_uchar.h new file mode 100644 index 0000000..4194c05 --- /dev/null +++ b/src/include/mobile/utils_i18n_uchar.h @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +#ifndef __UTILS_I18N_UCHAR_H__ +#define __UTILS_I18N_UCHAR_H__ + +#include + +/** + * @file utils_i18n_uchar.h + * @version 0.1 + * @brief utils_i18n + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @ingroup CAPI_BASE_UTILS_I18N_MODULE + * @defgroup CAPI_BASE_UTILS_I18N_UCHAR_MODULE Uchar + * @brief The Uchar module provides low-level access to the Unicode Character Database. + * + * @section CAPI_BASE_UTILS_I18N_UCHAR_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_BASE_UTILS_I18N_UCHAR_MODULE_OVERVIEW Overview + * @details The Uchar module provides low-level access to the Unicode Character Database. + * + * @section CAPI_BASE_UTILS_I18N_UCHAR_MODULE_SAMPLE_CODE_1 Sample Code 1 + * @brief Gets the property value of 'east asian width' among an enumerated property, + * and the unicode allocation block that contains the character. + * @code + int ret = I18N_ERROR_NONE; + i18n_uchar32 code_point = 0; + int property_value = 0; + i18n_uchar_u_east_asian_width_e east_asian_width = I18N_UCHAR_U_EA_NEUTRAL; + i18n_uchar_ublock_code_e block_code = I18N_UCHAR_UBLOCK_NO_BLOCK; + + // How to get the east asian width type for 's' + code_point = 0x73; // 's' + ret = i18n_uchar_get_int_property_value(code_point, I18N_UCHAR_EAST_ASIAN_WIDTH, &property_value); + if (ret != I18N_ERROR_NONE) { + dlog_print(DLOG_INFO, LOG_TAG, "Error occured!!\n"); + } else { + east_asian_width = (i18n_uchar_u_east_asian_width_e)property_value; + dlog_print(DLOG_INFO, LOG_TAG, "East Asian Width Type for ( %.4x ) is ( %d )\n", code_point, east_asian_width); + // East Asian Width Type for ( 0073 ) is ( 4 ) which is I18N_UCHAR_U_EA_NARROW + } + + // How to get the block code for 's' + ret = i18n_uchar_get_ublock_code(code_point, &block_code); + if (ret != I18N_ERROR_NONE) { + dlog_print(DLOG_INFO, LOG_TAG, "Error occured!!\n"); + } else { + dlog_print(DLOG_INFO, LOG_TAG, "block name for ( %.4x ) is ( %d )\n", code_point, block_code); + // block code for ( 0073 ) is ( 1 ) which is I18N_UCHAR_UBLOCK_BASIC_LATIN + } + + // How to get the east asian width type for 'sung' as ideographs + code_point = 0x661F; // 'sung' as ideographs + ret = i18n_uchar_get_int_property_value(code_point, I18N_UCHAR_EAST_ASIAN_WIDTH, &property_value); + if (ret != I18N_ERROR_NONE) { + dlog_print(DLOG_INFO, LOG_TAG, "Error occured!!\n"); + } else { + east_asian_width = (i18n_uchar_u_east_asian_width_e)property_value; + dlog_print(DLOG_INFO, LOG_TAG, "East Asian Width Type for ( %.4x ) is ( %d )\n", code_point, east_asian_width); + // East Asian Width Type for ( 661f ) is ( 5 ) which is I18N_UCHAR_U_EA_WIDE + } + + // How to get the block code for 'sung' as ideographs + ret = i18n_uchar_get_ublock_code(code_point, &block_code); + if (ret != I18N_ERROR_NONE) { + dlog_print(DLOG_INFO, LOG_TAG, "Error occured!!\n"); + } else { + dlog_print(DLOG_INFO, LOG_TAG, "block name for ( %.4x ) is ( %d )\n", code_point, block_code); + // block code for ( 661f ) is ( 71 ) which is I18N_UCHAR_UBLOCK_CJK_UNIFIED_IDEOGRAPHS + } + + // How to get the east asian width type for 'sung' as hangul + code_point = 0xC131; // 'sung' as hangul + ret = i18n_uchar_get_int_property_value(code_point, I18N_UCHAR_EAST_ASIAN_WIDTH, &property_value); + if (ret != I18N_ERROR_NONE) { + dlog_print(DLOG_INFO, LOG_TAG, "Error occured!!\n"); + } else { + east_asian_width = (i18n_uchar_u_east_asian_width_e)property_value; + dlog_print(DLOG_INFO, LOG_TAG, "East Asian Width Type for ( %.4x ) is ( %d )\n", code_point, east_asian_width); + // East Asian Width Type for ( c131 ) is ( 5 ) which is I18N_UCHAR_U_EA_WIDE + } + + // How to get the block code for 'sung' as hangul + ret = i18n_uchar_get_ublock_code(code_point, &block_code); + if (ret != I18N_ERROR_NONE) { + dlog_print(DLOG_INFO, LOG_TAG, "Error occured!!\n"); + } else { + dlog_print(DLOG_INFO, LOG_TAG, "block name for ( %.4x ) is ( %d )\n", code_point, block_code); + // block code for ( c131 ) is ( 74 ) which is I18N_UCHAR_UBLOCK_HANGUL_SYLLABLES + } + + * @endcode + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_UCHAR_MODULE + * @{ + */ + +/** + * @brief Gets the property value for an enumerated property for a code point. + * @details + * + * int property_value;\n + * #i18n_uchar_u_east_asian_width_e east_asian_width;\n + * #i18n_uchar_get_int_property_value (c, #I18N_UCHAR_EAST_ASIAN_WIDTH, &property_value);\n + * east_asian_width = (#i18n_uchar_u_east_asian_width_e)property_value;\n + * + * int property_value;\n + * bool is_ideographic;\n + * #i18n_uchar_get_int_property_value(c, #I18N_UCHAR_IDEOGRAPHIC, &property_value);\n + * is_ideographic = (bool)property_value;\n + * + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] c The code point to test. + * @param[in] which The #i18n_uchar_uproperty_e selector constant, identifies which property to check \n + * Must be #I18N_UCHAR_BINARY_START<=which<#I18N_UCHAR_BINARY_LIMIT + * or #I18N_UCHAR_INT_START<=which<#I18N_UCHAR_INT_LIMIT + * or #I18N_UCHAR_MASK_START<=which<#I18N_UCHAR_MASK_LIMIT. + * @param[out] property_val The numeric value that is directly the property value or, + * for enumerated properties, corresponds to the numeric value of the enumerated + * constant of the respective property value enumeration type (cast to enum type if necessary)\n + * Returns @c 0 or @c 1 (for false/true) for binary Unicode properties\n + * Returns a bit-mask for mask properties \n + * Returns @c 0 if 'which' is out of bounds or if the Unicode version does not have data for the property at all, or not for this code point. + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_uchar_get_int_property_value ( i18n_uchar32 c, i18n_uchar_uproperty_e which, int32_t *property_val ); + +/** + * @brief Gets the Unicode allocation block that contains the character. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] c The code point to test + * @param[out] block_val The block value for the code point + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_uchar_get_ublock_code ( i18n_uchar32 c, i18n_uchar_ublock_code_e *block_val ); + +#ifdef __cplusplus +} +#endif + +/** + * @} + * @} + */ + +#endif /* __UTILS_I18N_UCHAR_H__*/ diff --git a/src/include/mobile/utils_i18n_ucollator.h b/src/include/mobile/utils_i18n_ucollator.h new file mode 100755 index 0000000..cd129da --- /dev/null +++ b/src/include/mobile/utils_i18n_ucollator.h @@ -0,0 +1,230 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +#ifndef __UTILS_I18N_UCOLLATOR_H__ +#define __UTILS_I18N_UCOLLATOR_H__ + +#include + +/** + * @file utils_i18n_ucollator.h + * @version 0.1 + * @brief utils_i18n_ucollator + */ + +#ifdef __cplusplus +extern "C" { +# endif + +/** + * @ingroup CAPI_BASE_UTILS_I18N_MODULE + * @defgroup CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULE Ucollator + * @brief The Ucollator module performs locale-sensitive string comparison. + * + * @section CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULE_OVERVIEW Overview + * @details The Ucollator module performs locale-sensitive string comparison. It builds searching and sorting routines for natural language text and provides correct sorting orders for most locales supported. + * + * @section CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULE_SAMPLE_CODE_1 Sample Code 1 + * @brief Converts two different byte strings to two different unicode strings and compares the unicode strings to check if the strings are equal to each other. + * @code + i18n_uchar uchar_src[64] = {0,}; + i18n_uchar uchar_target[64] = {0,}; + char *src = "tizen"; + char *target = "bada"; + int uchar_src_len = 0; + int uchar_target_len = 0; + i18n_ucollator_h coll = NULL; + i18n_ubool result = NULL; + + i18n_ustring_from_UTF8( uchar_src, 64, NULL, src, -1 ); + i18n_ustring_from_UTF8( uchar_target, 64, NULL, target, -1 ); + + // creates a collator + i18n_ucollator_create( "en_US", &coll ); + + // sets strength for coll + i18n_ucollator_set_strength( coll, I18N_UCOLLATOR_PRIMARY ); + + // compares uchar_src with uchar_target + i18n_ustring_get_length( uchar_src, &uchar_src_len ); + i18n_ustring_get_length( uchar_target, &uchar_target_len ); + i18n_ucollator_equal( coll, uchar_src, uchar_src_len, uchar_target, uchar_target_len, &result ); + dlog_print(DLOG_INFO, LOG_TAG, "%s %s %s\n", src, result == 1 ? "is equal to" : "is not equal to", target ); // tizen is not equal to bada + + // destroys the collator + i18n_ucollator_destroy( coll ); + * @endcode + * @section CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULE_SAMPLE_CODE_2 Sample Code 2 + * @brief Sorts in ascending order on the given data using string_ucollator + * @code + i18n_ucollator_h coll = NULL; + char *src[3] = { "cat", "banana", "airplane" }; + char *tmp = NULL; + i18n_uchar buf_01[16] = {0,}; + i18n_uchar buf_02[16] = {0,}; + i18n_ucollator_result_e result = I18N_UCOLLATOR_EQUAL; + int i = 0, j = 0; + int ret = I18N_ERROR_NONE; + int buf_01_len = 0, buf_02_len = 0; + + for ( i = 0; i < sizeof( src ) / sizeof( src[0] ); i++ ) { + dlog_print(DLOG_INFO, LOG_TAG, "%s\n", src[i] ); + } // cat banana airplane + + // creates a collator + ret = i18n_ucollator_create( "en_US", &coll ); + + // compares and sorts in ascending order + if ( ret == I18N_ERROR_NONE ) { + i18n_ucollator_set_strength( coll, I18N_UCOLLATOR_TERTIARY ); + for ( i = 0; i < 2; i++ ) { + for ( j = 0; j < 2 - i; j++ ) { + i18n_ustring_copy_ua( buf_01, src[j] ); + i18n_ustring_copy_ua( buf_02, src[j+1] ); + i18n_ustring_get_length( buf_01, &buf_01_len ); + i18n_ustring_get_length( buf_02, &buf_02_len ); + // compares buf_01 with buf_02 + i18n_ucollator_str_collator( coll, buf_01, buf_01_len, buf_02, buf_02_len, &result ); + if ( result == I18N_UCOLLATOR_GREATER ) { + tmp = src[j]; + src[j] = src[j+1]; + src[j+1] = tmp; + } + } + } + } + // destroys the collator + i18n_ucollator_destroy( coll ); // deallocate memory for collator + + for ( i = 0; i < sizeof( src ) / sizeof( src[0] ); i++ ) { + dlog_print(DLOG_INFO, LOG_TAG, "%s\n", src[i] ); + } // ariplane banana cat + * @endcode + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULE + * @{ + */ + +/** + * @brief Creates a i18n_ucollator_h for comparing strings. + * @details The i18n_ucollator_h is used in all the calls to the Collation service.\n + * After finished, collator must be disposed off by calling {@link #i18n_ucollator_destroy()}. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @remarks Must release @a collator using i18n_ucollator_destroy(). + * + * @param[in] locale The locale containing the required collation rules\n + * Special values for locales can be passed in - if @c NULL is passed for the locale, the default locale collation rules will be used \n + * If empty string ("") or "root" is passed, UCA rules will be used. + * @param[out] collator i18n_ucollator_h, otherwise @c 0 if an error occurs + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ucollator_destroy() + */ +int i18n_ucollator_create ( const char *locale, i18n_ucollator_h *collator ); + +/** + * @brief Closes a i18n_ucollator_h. + * @details Once closed, a string_ucollator_h should not be used. Every an open collator should be closed. Otherwise, a memory leak will result. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] collator The i18n_ucollator_h to close + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ucollator_create() + */ +int i18n_ucollator_destroy ( i18n_ucollator_h collator ); + +/** + * @brief Compares two strings. + * @details The strings will be compared using the options already specified. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] collator The i18n_ucollator_h containing the comparison rules + * @param[in] src The source string + * @param[in] src_len The length of the source, otherwise @c -1 if null-terminated + * @param[in] target The target string. + * @param[in] target_len The length of the target, otherwise @c -1 if null-terminated + * @param[out] result The result of comparing the strings \n + * One of #I18N_UCOLLATOR_EQUAL, #I18N_UCOLLATOR_GREATER, or #I18N_UCOLLATOR_LESS + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ucollator_equal() + */ +int i18n_ucollator_str_collator ( const i18n_ucollator_h collator, const i18n_uchar *src, int32_t src_len, const i18n_uchar *target, int32_t target_len, i18n_ucollator_result_e *result ); + +/** + * @brief Compares two strings for equality. + * @details This function is equivalent to {@link #i18n_ucollator_str_collator()}. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] collator The i18n_ucollator_h containing the comparison rules + * @param[in] src The source string + * @param[in] src_len The length of the source, otherwise @c -1 if null-terminated + * @param[in] target The target string + * @param[in] target_len The length of the target, otherwise @c -1 if null-terminated + * @param[out] equal If @c true source is equal to target, otherwise @c false + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ucollator_str_collator() + */ +int i18n_ucollator_equal ( const i18n_ucollator_h collator, const i18n_uchar *src, int32_t src_len, const i18n_uchar *target, int32_t target_len, i18n_ubool *equal ); + +/** + * @brief Sets the collation strength used in a collator. + * @details The strength influences how strings are compared. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] collator The i18n_collator_h to set. + * @param[in] strength The desired collation strength.\n + * One of #i18n_ucollator_strength_e + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucollator_set_strength ( i18n_ucollator_h collator, i18n_ucollator_strength_e strength ); + +/** + * @brief Sets a universal attribute setter. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] collator The i18n_collator_h containing attributes to be changed + * @param[in] attr The attribute type + * @param[in] val The attribute value + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucollator_set_attribute ( i18n_ucollator_h collator, i18n_ucollator_attribute_e attr, i18n_ucollator_attribute_value_e val ); + +#ifdef __cplusplus +} +#endif + +/** + * @} + * @} + */ + +#endif /* __UTILS_I18N_UCOLLATOR_H__*/ diff --git a/src/include/mobile/utils_i18n_udate.h b/src/include/mobile/utils_i18n_udate.h new file mode 100644 index 0000000..f5eb738 --- /dev/null +++ b/src/include/mobile/utils_i18n_udate.h @@ -0,0 +1,632 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +#ifndef __UTILS_I18N_UDATE_H__ +#define __UTILS_I18N_UDATE_H__ + +#include + +/** + * @file utils_i18n_udate.h + * @version 0.1 + * @brief utils_i18n_udate + */ + +/** + * @ingroup CAPI_BASE_UTILS_I18N_MODULE + * @defgroup CAPI_BASE_UTILS_I18N_UDATE_MODULE Udate + * @brief The Udate module consists of functions that convert dates and time from their + * internal representations to textual form and back again in a language-independent + * manner. + * + * @section CAPI_BASE_UTILS_I18N_UDATE_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_BASE_UTILS_I18N_UDATE_MODULE_OVERVIEW Overview + * @details The Udate module consists of functions that convert dates and time from their + * internal representations to textual form and back again in a language-independent + * manner. Converting from the internal representation (milliseconds since midnight, + * January 1, 1970) to text is known as "formatting," and converting from text to + * milliseconds is known as "parsing". We currently define only one concrete handle + * #i18n_udate_format_h, which can handle pretty much all normal date formatting and parsing + * actions.\n + * The Udate module helps you format and parse dates for any locale. Your code can be + * completely independent of the locale conventions for months, days of the week, + * or even the calendar format: lunar vs. solar. + * + * @section CAPI_BASE_UTILS_I18N_UDATE_MODULE_SAMPLE_CODE_1 Sample Code 1 + * @brief Gets the best pattern according to a given locale and formats a current date and time using a locale_udate_format_h + * @code + i18n_udatepg_h pattern_generator = NULL; + char *locale = I18N_ULOCALE_US; + + dlog_print(DLOG_INFO, LOG_TAG, "pattern_generator\n"); + + if(!pattern_generator) { + // create a pattern generator according to a given locale + i18n_udatepg_create(locale, &pattern_generator); + } + + if(!pattern_generator) { + dlog_print(DLOG_INFO, LOG_TAG, "i18n_udatepg_create fail"); + return ; + } + + i18n_uchar bestPattern[64] = {0,}; + char bestPatternString[64] = {0,}; + int bestPatternLength, len; + const char *custom_format = "yyyy.MM.dd G 'at' HH:mm:ss zzz"; + i18n_uchar uch_custom_format[64]; + int ret = I18N_ERROR_NONE; + + dlog_print(DLOG_INFO, LOG_TAG, "getBestPattern\n"); + + i18n_ustring_copy_ua(uch_custom_format, custom_format); + len = i18n_ustring_get_length(uch_custom_format); + + // gets the best pattern that matches the given custom_format + i18n_udatepg_get_best_pattern(pattern_generator, uch_custom_format, len, bestPattern, 64, &bestPatternLength); + + i18n_ustring_copy_au_n(bestPatternString, bestPattern, 64); + // gets "MM/dd/yyyy G h:mm:ss a zzz" as the best pattern + dlog_print(DLOG_INFO, LOG_TAG, "getBestPattern(char[]) : %s \n", bestPatternString); + + // closes a generator + i18n_udatepg_destroy(pattern_generator); + + i18n_udate_format_h formatter_KR = NULL; + i18n_udate_format_h formatter_LA = NULL; + i18n_udate_format_h formatter_SaoPaulo = NULL; + i18n_uchar formatted[64] = {0,}; + char result[64] = {0,}; + int formattedLength; + i18n_udate date; + const char *timezone_KR = "GMT+9:00"; // TimeZone for Korea/Seoul + const char *timezone_LA = "America/Los_Angeles"; + const char *timezone_SaoPaulo = "America/Sao_Paulo"; // Brazil/East + i18n_uchar utf16_timezone_KR[64] = {0,}; + i18n_uchar utf16_timezone_LA[64] = {0,}; + i18n_uchar utf16_timezone_SaoPaulo[64] = {0,}; + + i18n_ustring_copy_ua_n(utf16_timezone_KR, timezone_KR, strlen(timezone_KR)); + i18n_ustring_copy_ua_n(utf16_timezone_LA, timezone_LA, strlen(timezone_LA)); + i18n_ustring_copy_ua_n(utf16_timezone_SaoPaulo, timezone_SaoPaulo, strlen(timezone_SaoPaulo)); + + // creates new i18n_udate_format_h to format dates and times + ret = i18n_udate_create(I18N_UDATE_FULL , I18N_UDATE_FULL , locale, utf16_timezone_KR, -1, bestPattern, -1, &formatter_KR); + if ( ret != I18N_ERROR_NONE ) { + dlog_print(DLOG_INFO, LOG_TAG, "i18n_udate_create failed !!! \n"); + } + if (!formatter_KR) { + dlog_print(DLOG_INFO, LOG_TAG, "formatter is NULL\n"); + } + ret = i18n_udate_create(I18N_UDATE_FULL , I18N_UDATE_FULL , locale, utf16_timezone_LA, -1, bestPattern, -1, &formatter_LA); + if ( ret != I18N_ERROR_NONE ) { + dlog_print(DLOG_INFO, LOG_TAG, "i18n_udate_create failed !!! \n"); + } + if (!formatter_LA) { + dlog_print(DLOG_INFO, LOG_TAG, "formatter is NULL\n"); + } + ret = i18n_udate_create(I18N_UDATE_PATTERN , I18N_UDATE_PATTERN , locale, utf16_timezone_SaoPaulo, -1, bestPattern, -1, &formatter_SaoPaulo); + if ( ret != I18N_ERROR_NONE ) { + dlog_print(DLOG_INFO, LOG_TAG, "i18n_udate_create failed !!! \n"); + } + if (!formatter_LA) { + dlog_print(DLOG_INFO, LOG_TAG, "formatter is NULL\n"); + } + + dlog_print(DLOG_INFO, LOG_TAG, "i18n_udate_format_date\n"); + + // gets the current date and time + i18n_ucalendar_get_now(&date); + + // formats a date using i18n_udate_format_h + i18n_udate_format_date(formatter_KR, date, formatted, 64, NULL, &formattedLength); + i18n_ustring_copy_au_n(result, formatted, 64); + //ex) KOREA/Seoul - Current date : Wednesday, June 18, 2014 1:34:54 PM GMT+09:00 + dlog_print(DLOG_INFO, LOG_TAG, "KOREA/Seoul - Current date : %s\n",result); + + // formats a date using i18n_udate_format + i18n_udate_format_date(formatter_LA, date, formatted, 64, NULL, &formattedLength); + i18n_ustring_copy_au_n(result, formatted, 64); + //ex) America/LOS Angeles - Current date : Tuesday, June 17, 2014 9:34:54 PM Pacific Daylight Time + dlog_print(DLOG_INFO, LOG_TAG, "America/LOS Angeles - Current date : %s\n",result); + + // formats a date using i18n_udate_format_h + i18n_udate_format_date(formatter_SaoPaulo, date, formatted, 64, NULL, &formattedLength); + i18n_ustring_copy_au_n(result, formatted, 64); + //ex) Brazil/Sao Paulo - Current date : 6 18, 2014 AD, 1:34:54 PM GMT-2 + dlog_print(DLOG_INFO, LOG_TAG, "Brazil/Sao Paulo - Current date : %s\n",result); + + dlog_print(DLOG_INFO, LOG_TAG, "i18n_udate_destroy\n"); + // destroy an i18n_udate_format_h + i18n_udate_destroy(formatter_KR); + i18n_udate_destroy(formatter_LA); + i18n_udate_destroy(formatter_SaoPaulo); + * @endcode + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_UDATE_MODULE + * @{ + */ + +/** + * @brief Creates a new #i18n_udate_format_h for formatting and parsing dates and times. + * @details A #i18n_udate_format_h may be used to format dates in calls to {@link i18n_udate_create()}. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @remarks Must release @a format using i18n_udate_destroy(). + * + * @param[in] time_style The style used to format times\n One of #I18N_UDATE_FULL, #I18N_UDATE_LONG, + * #I18N_UDATE_MEDIUM, #I18N_UDATE_SHORT, #I18N_UDATE_DEFAULT, or #I18N_UDATE_NONE (relative time styles + * are not currently supported). + * @param[in] date_style The style used to format dates\n One of #I18N_UDATE_FULL, #I18N_UDATE_LONG, + * #I18N_UDATE_MEDIUM, #I18N_UDATE_SHORT, #I18N_UDATE_DEFAULT, #I18N_UDATE_RELATIVE, #I18N_UDATE_LONG_RELATIVE, + * #I18N_UDATE_MEDIUM_RELATIVE, #I18N_UDATE_SHORT_RELATIVE, #I18N_UDATE_PATTERN, or #I18N_UDATE_NONE + * @param[in] locale The locale specifying the formatting conventions. + * @param[in] tz_id A timezone ID specifying the timezone to use\n If @c 0, use the default timezone. + * @param[in] tz_id_len The length of @a tz_id, otherwise @c -1 if NULL-terminated. + * @param[in] pattern A pattern specifying the format to use. The pattern is generated by Udatepg module. + * When the pattern parameter is used, pass in #I18N_UDATE_PATTERN for both time_style and date_style. + * @param[in] pattern_len The number of characters in the pattern, or otherwise @c -1 if NULL-terminated. + * @param[out] format A pointer to an #i18n_udate_format_h to use for formatting dates and times, otherwise @c 0 if an error occurs. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_udate_create ( i18n_udate_format_style_e time_style, i18n_udate_format_style_e date_style, const char *locale, const i18n_uchar *tz_id, int32_t tz_id_len, const i18n_uchar *pattern, int pattern_len, i18n_udate_format_h *format ); + +/** + * @brief Destroys an #i18n_udate_format_h. + * @details Once destroyed, an #i18n_udate_format_h may no longer be used. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] format The formatter to destroy. + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_udate_destroy ( i18n_udate_format_h format ); + +/** + * @brief Formats a date using an #i18n_udate_format_h. + * @details The date will be formatted using the conventions specified in {@link i18n_udate_create()} + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] format The formatter to use. + * @param[in] date_to_format The date to format. + * @param[out] result A pointer to a buffer to receive the formatted number. + * @param[in] result_len The maximum size of the result. + * @param[in] pos A pointer to an i18n_ufield_position\n + * On input, position->field is read\n + * On output, position->beginIndex and position->endIndex indicate + * the beginning and ending indices of field number position->field, if such a field exists\n + * This parameter may be @c NULL, in which case no field + * position data is returned. + * @param[out] buf_size_needed The total buffer size needed\n + * If greater than @a result_len, the output was truncated. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_udate_format_date ( const i18n_udate_format_h format, i18n_udate date_to_format, i18n_uchar *result, int32_t result_len, i18n_ufield_position_h pos, int32_t *buf_size_needed ); + + +// Newly Added APIs + +/** + * @brief Maps from an #i18n_udate_format_h to the corresponding #i18n_ucalendar_date_fields_e. + * @details Note: since the mapping is many-to-one, there is no inverse mapping. + * @since_tizen 2.3.1 + * + * @param[in] field The #i18n_udate_format_h to map. + * #I18N_UDATE_FORMAT_TIMEZONE_LOCALIZED_GMT_OFFSET_FIELD, #I18N_UDATE_FORMAT_TIMEZONE_ISO_FIELD, + * #I18N_UDATE_FORMAT_TIMEZONE_ISO_LOCAL_FIELD and #I18N_UDATE_FORMAT_FIELD_COUNT are not supported. + * @param[out] date_field_type A pointer to the #i18n_ucalendar_date_fields_e. + * + * @return Error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_udate_to_calendar_date_field ( i18n_udate_format_field_e field, i18n_ucalendar_date_fields_e *date_field_type ); + +/** + * @brief Creates a copy of an #i18n_udate_format_h. + * @details This function performs a deep copy. + * @since_tizen 2.3.1 + * + * @param[in] format The format to copy. + * @param[out] format_clone A pointer to clone of @c format. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_udate_clone ( const i18n_udate_format_h format, i18n_udate_format_h *format_clone ); + +/** + * @brief Parses a string into an date/time using an #i18n_udate_format_h. + * @details The date will be parsed using the conventions specified in {@link i18n_udate_create()}.
+ * Note that the normal date formats associated with some calendars - such as the Chinese lunar calendar - do not specify enough fields to enable dates to be parsed unambiguously. + * In the case of the Chinese lunar calendar, while the year within the current 60-year cycle is specified, + * the number of such cycles since the start date of the calendar (in the #I18N_UCALENDAR_ERA field of the i18n_ucalendar_h) is not normally part of the format, + * and parsing may assume the wrong era. + * For such cases it is recommended that clients parse using i18n_udate_parse_calendar() with the calendar passed in set to the current date, + * or to a date within the era/cycle that should be assumed if absent in the format. + * @since_tizen 2.3.1 + * + * @param[in] format The formatter to use. + * @param[in] text The text to parse. + * @param[in] text_length The length of text, or -1 if NULL-terminated. + * @param[in] parse_pos If not 0, on input a pointer to an integer specifying the offset at which to begin parsing. + * If not 0, on output the offset at which parsing ended. + * @param[out] parsed_date A pointer to the value of the parsed date/time. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udate_format_date() + */ +int i18n_udate_parse ( const i18n_udate_format_h format, const i18n_uchar *text, int32_t text_length, int32_t *parse_pos, i18n_udate *parsed_date ); + +/** + * @brief Parses a string into an date/time using an #i18n_udate_format_h. + * @details The date will be parsed using the conventions specified in {@link i18n_udate_create()}. + * @since_tizen 2.3.1 + * + * @param[in] format The formatter to use. + * @param[in,out] calendar A pointer to calendar set on input to the date and time to be used for missing values in the date/time string being parsed, + * and set on output to the parsed date/time. + * When the calendar type is different from the internal calendar held by the #i18n_udate_format_h instance, + * the internal calendar will be cloned to a work calendar set to the same milliseconds and time zone as this calendar parameter, + * field values will be parsed based on the work calendar, then the result (milliseconds and time zone) will be set in this calendar. + * @param[in] text The text to parse. + * @param[in] text_length The length of text, or -1 if NULL-terminated. + * @param[in] parse_pos If not 0, on input a pointer to an integer specifying the offset at which to begin parsing. + * If not 0, on output the offset at which parsing ended. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udate_format_date() + */ +int i18n_udate_parse_calendar (const i18n_udate_format_h format, i18n_ucalendar_h *calendar, const i18n_uchar *text, + int32_t text_length, int32_t *parse_pos ); + +/** + * @brief Determines if an #i18n_udate_format_h will perform lenient parsing. + * @details With lenient parsing, the parser may use heuristics to interpret inputs that do not precisely match the pattern. + * With strict parsing, inputs must match the pattern. + * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] format The #i18n_udate_format_h to query. + * + * @return true if format is set to perform lenient parsing, false otherwise. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udate_set_lenient() + */ +i18n_ubool i18n_udate_is_lenient ( const i18n_udate_format_h format ); + +/** + * @brief Specifies whether an #i18n_udate_format_h will perform lenient parsing. + * @details With lenient parsing, the parser may use heuristics to interpret inputs that do not precisely match the pattern. + * With strict parsing, inputs must match the pattern. + * @since_tizen 2.3.1 + * + * @param[in] format The #i18n_udate_format_h to set. + * @param[in] is_lenient true if fmt should perform lenient parsing, false otherwise. + * + * @return Error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udate_is_lenient() + */ +int i18n_udate_set_lenient ( i18n_udate_format_h format, i18n_ubool is_lenient ); + +/** + * @brief Gets the #i18n_ucalendar_h associated with an #i18n_udate_format_h. + * @details An #i18n_udate_format_h uses an #i18n_ucalendar_h to convert a raw value to, for example, the day of the week. + * @since_tizen 2.3.1 + * + * @param[in] format The #i18n_udate_format_h to query. + * @param[out] calendar A pointer to the #i18n_ucalendar_h used by format. + * + * @return Error code. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udate_set_calendar() + */ +int i18n_udate_get_calendar ( const i18n_udate_format_h format, i18n_ucalendar_h *calendar); + +/** + * @brief Sets the #i18n_ucalendar_h associated with an #i18n_udate_format_h. + * @details An #i18n_udate_format_h uses an #i18n_ucalendar_h to convert a raw value to, for example, the day of the week. + * @since_tizen 2.3.1 + * + * @param[in] format The #i18n_udate_format_h. + * @param[in] calendar_to_set An #i18n_ucalendar_h to be used by the format. + * + * @return Error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udate_get_calendar() + */ +int i18n_udate_set_calendar ( i18n_udate_format_h format, const i18n_ucalendar_h calendar_to_set ); + +/** + * @brief Gets the #i18n_unumber_format_h associated with an #i18n_udate_format_h. + * @details An #i18n_udate_format_h uses an #i18n_unumber_format_h to format numbers within a date, for example the day number. + * @since_tizen 2.3.1 + * + * @param[in] format The formatter to query. + * @param[out] number_format A pointer to the #i18n_unumber_format_h used by @a format to format numbers. + * + * @return Error code. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udate_set_number_format() + */ +int i18n_udate_get_number_format ( const i18n_udate_format_h format, i18n_unumber_format_h *number_format ); + +/** + * @brief Sets the #i18n_unumber_format_h associated with an #i18n_udate_format_h. + * @details An #i18n_udate_format_h uses an #i18n_unumber_format_h to format numbers within a date, for example the day number. + * @since_tizen 2.3.1 + * + * @param[in] format The #i18n_udate_format_h to set. + * @param[in] number_format_to_set An #i18n_unumber_format_h to be used by @a format to format numbers. + * + * @return Error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udate_get_number_format() + */ +int i18n_udate_set_number_format ( i18n_udate_format_h format, const i18n_unumber_format_h number_format_to_set ); + +/** + * @brief Gets a locale for which date/time formatting patterns are available. + * @details An #i18n_udate_format_h in a locale returned by this function will perform the correct formatting and parsing for the locale. + * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] locale_index The index of the desired locale. + * + * @return A locale for which date/time formatting patterns are available, or 0 if none. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + + * @see i18n_udate_count_available() + */ +const char *i18n_udate_get_available ( int32_t locale_index ); + +/** + * @brief Determines how many locales have date/time formatting patterns available. + * @details This function is the most useful for determining the loop ending condition for calls to {@link #i18n_udate_get_available()}. + * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @return The number of locales for which date/time formatting patterns are available. + * + * @exception #I18N_ERROR_NONE Successful + * + * @see i18n_udate_get_available() + */ +int32_t i18n_udate_count_available ( void ); + +/** + * @brief Gets the year relative to which all 2-digit years are interpreted. + * @details For example, if the 2-digit start year is 2100, the year 99 will be interpreted as 2199. + * + * @since_tizen 2.3.1 + * + * @param[in] format The #i18n_udate_format_h to get. + * @param[out] year A pointer to the year relative to which all 2-digit years are interpreted. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udate_set_2digit_year_start() + */ +int i18n_udate_get_2digit_year_start ( const i18n_udate_format_h format, i18n_udate *year ); + +/** + * @brief Sets the year relative to which all 2-digit years will be interpreted. + * @details For example, if the 2-digit start year is 2100, the year 99 will be interpreted as 2199. + * + * @since_tizen 2.3.1 + * + * @param[in] format The #i18n_udate_format_h to map. + * @param[in] date The year relative to which all 2-digit years will be interpreted. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udate_get_2digit_year_start() + */ +int i18n_udate_set_2digit_year_start ( i18n_udate_format_h format, i18n_udate date ); + +/** + * @brief Extracts the pattern from an #i18n_udate_format_h. + * @details The pattern will follow the pattern syntax rules. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] format The #i18n_udate_format_h to query. + * @param[in] localized true if the pattern should be localized, false otherwise. + * @param[out] result A pointer to a buffer to receive the pattern. + * @param[in] result_length The maximum size of result. + * + * @return The total buffer size needed; if greater than result_length, the output was truncated. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udate_apply_pattern() + */ +int32_t i18n_udate_to_pattern ( const i18n_udate_format_h format, i18n_ubool localized, i18n_uchar *result, + int32_t result_length ); + +/** + * @brief Sets the pattern used by an #i18n_udate_format_h. + * @details The pattern should follow the pattern syntax rules. + * @since_tizen 2.3.1 + * + * @param[in] format The #i18n_udate_format_h to set. + * @param[in] localized true if the pattern is localized, false otherwise. + * @param[in] pattern The new pattern. + * @param[in] pattern_length The length of pattern, or -1 if NULL-terminated. + * + * @return Error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udate_to_pattern() + */ +int i18n_udate_apply_pattern ( i18n_udate_format_h format, i18n_ubool localized, const i18n_uchar *pattern, + int32_t pattern_length ); + +/** + * @brief Gets the symbols associated with an #i18n_udate_format_h. + * @details The symbols are what an #i18n_udate_format_h uses to represent locale-specific data, for example month or day names. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] format The #i18n_udate_format_h to query. + * @param[in] type The type of symbols to get. + * All the types defined in the #i18n_udate_format_symbol_type_e enumeration are supported. + * @param[in] symbol_index The desired symbol of type type. + * @param[out] result A pointer to a buffer to receive the pattern. + * @param[in] result_length The maximum size of the result buffer. + * + * @return The total buffer size needed; if greater than result_length, the output was truncated. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udate_count_symbols() + * @see #i18n_udate_set_symbols() + */ +int32_t i18n_udate_get_symbols ( const i18n_udate_format_h format, i18n_udate_format_symbol_type_e type, int32_t symbol_index, + i18n_uchar *result, int32_t result_length ); + +/** + * @brief Counts the number of particular symbols for an #i18n_udate_format_h. + * @details This function is most useful for determining the loop termination condition for calls to {@link #i18n_udate_get_symbols()}. + * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] format The #i18n_udate_format_h to query. + * @param[in] type The type of symbols to count. + * If wrong type is passed, 0 will be returned. + * + * @return The number of symbols of type @a type. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udate_get_symbols() + * @see #i18n_udate_set_symbols() + */ +int32_t i18n_udate_count_symbols ( const i18n_udate_format_h format, i18n_udate_format_symbol_type_e type ); + +/** + * @brief Sets the symbols associated with an #i18n_udate_format_h. + * @details The symbols are what an #i18n_udate_format_h uses to represent locale-specific data, for example month or day names. + * + * @since_tizen 2.3.1 + * + * @param[in] format The #i18n_udate_format_h to set. + * @param[in] type The type of symbols to set. + * All the types defined in the #i18n_udate_format_symbol_type_e enumeration are supported. + * If a type not defined in the enumeration is passed, then the #I18N_ERROR_NOT_SUPPORTED error is returned. + * @param[in] symbol_index The index of the symbol to set of type type. + * @param[in] value The new value. + * @param[in] value_length The length of @a value, or @c -1 if NULL-terminated. + * + * @return Error code. Error codes not listed below are described in the #i18n_error_code_e enumeration. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udate_count_symbols() + * @see #i18n_udate_get_symbols() + */ +int i18n_udate_set_symbols ( i18n_udate_format_h format, i18n_udate_format_symbol_type_e type, int32_t symbol_index, + i18n_uchar *value, int32_t value_length ); + +/** + * @brief Gets the locale for this date format object. + * @details You can choose between valid and actual locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] format The #i18n_udate_format_h to get the locale from. + * @param[in] type The type of the locale we're looking for (valid or actual). + * + * @return The locale name. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +const char * i18n_udate_get_locale_by_type ( const i18n_udate_format_h format, i18n_ulocale_data_locale_type_e type ); + +/** + * @brief Sets a particular #i18n_udisplay_context_e value in the formatter, such as #I18N_UDISPLAY_CONTEXT_CAPITALIZATION_FOR_STANDALONE. + * @remarks I18N_UDISPLAY_CONTEXT_STANDARD_NAMES and I18N_UDISPLAY_CONTEXT_DIALECT_NAMES are not supported. + * + * @since_tizen 2.3.1 + * + * @param[in] format The #i18n_udate_format_h to set a #i18n_udisplay_context_e value. + * @param[in] value The #i18n_udisplay_context_e value to set. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_udate_set_context ( i18n_udate_format_h format, i18n_udisplay_context_e value ); + + +/** + * @} + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __UTILS_I18N_UDATE_H__*/ diff --git a/src/include/mobile/utils_i18n_udatepg.h b/src/include/mobile/utils_i18n_udatepg.h new file mode 100755 index 0000000..174690b --- /dev/null +++ b/src/include/mobile/utils_i18n_udatepg.h @@ -0,0 +1,642 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +#ifndef __UTILS_I18N_UDATEPG_H__ +#define __UTILS_I18N_UDATEPG_H__ + +#include + +/** + * @file utils_i18n_udatepg.h + * @version 0.1 + * @brief utils_i18n_udatepg + */ + +/** + * @ingroup CAPI_BASE_UTILS_I18N_MODULE + * @defgroup CAPI_BASE_UTILS_I18N_UDATEPG_MODULE Udatepg + * @brief The Udatepg module provides flexible generation of date format patterns, like "yy-MM-dd". The user can build up the generator by adding successive patterns. + * + * @section CAPI_BASE_UTILS_I18N_UDATEPG_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_BASE_UTILS_I18N_UDATEPG_MODULE_OVERVIEW Overview + * @details The Udatepg module provides flexible generation of date format patterns, + * like "yy-MM-dd". The user can build up the generator by adding successive patterns. + * Once that is done, a query can be made using a "skeleton", which is a pattern that + * just includes the desired fields and lengths. The generator will return the + * "best fit" pattern corresponding to that skeleton.\n + * The main method people will use is i18n_udatepg_get_best_pattern(), since normally + * #i18n_udatepg_h is pre-built with data from a particular locale. + * However, generators can be built directly from other data as well. + * + * All input handlers must not be @c NULL. + * + * @section CAPI_BASE_UTILS_I18N_UDATEPG_MODULE_SAMPLE_CODE_1 Sample Code 1 + * @brief Gets the best pattern according to a given locale and formats a current date and time using an i18n_udate_format_h + * @code + i18n_udatepg_h pattern_generator = NULL; + char *locale = I18N_ULOCALE_US; + + dlog_print(DLOG_INFO, LOG_TAG, "pattern_generator\n"); + + if(!pattern_generator) { + // create a pattern generator according to a given locale + i18n_udatepg_create(locale, &pattern_generator); + } + + if(!pattern_generator) { + dlog_print(DLOG_INFO, LOG_TAG, "i18n_udatepg_create fail"); + return ; + } + + i18n_uchar bestPattern[64] = {0,}; + char bestPatternString[64] = {0,}; + int bestPatternLength, len; + const char *custom_format = "yyyy.MM.dd G 'at' HH:mm:ss zzz"; + i18n_uchar uch_custom_format[64]; + int ret = I18N_ERROR_NONE; + + dlog_print(DLOG_INFO, LOG_TAG, "getBestPattern\n"); + + i18n_ustring_copy_ua(uch_custom_format, custom_format); + len = i18n_ustring_get_length(uch_custom_format); + + // gets the best pattern that matches the given custom_format + i18n_udatepg_get_best_pattern(pattern_generator, uch_custom_format, len, bestPattern, 64, &bestPatternLength); + + i18n_ustring_copy_au_n(bestPatternString, bestPattern, 64); + // gets "MM/dd/yyyy G h:mm:ss a zzz" as the best pattern + dlog_print(DLOG_INFO, LOG_TAG, "getBestPattern(char[]) : %s \n", bestPatternString); + + // closes a generator + i18n_udatepg_destroy(pattern_generator); + + i18n_udate_format_h formatter_KR = NULL; + i18n_udate_format_h formatter_LA = NULL; + i18n_udate_format_h formatter_SaoPaulo = NULL; + i18n_uchar formatted[64] = {0,}; + char result[64] = {0,}; + int formattedLength; + i18n_udate date; + const char *timezone_KR = "GMT+9:00"; // TimeZone for Korea/Seoul + const char *timezone_LA = "America/Los_Angeles"; + const char *timezone_SaoPaulo = "America/Sao_Paulo"; // Brazil/East + i18n_uchar utf16_timezone_KR[64] = {0,}; + i18n_uchar utf16_timezone_LA[64] = {0,}; + i18n_uchar utf16_timezone_SaoPaulo[64] = {0,}; + + i18n_ustring_copy_ua_n(utf16_timezone_KR, timezone_KR, strlen(timezone_KR)); + i18n_ustring_copy_ua_n(utf16_timezone_LA, timezone_LA, strlen(timezone_LA)); + i18n_ustring_copy_ua_n(utf16_timezone_SaoPaulo, timezone_SaoPaulo, strlen(timezone_SaoPaulo)); + + // creates new i18n_udate_format to format dates and times + ret = i18n_udate_create(I18N_UDATE_FULL , I18N_UDATE_FULL , locale, utf16_timezone_KR, -1, bestPattern, -1, &formatter_KR); + if ( ret != I18N_ERROR_NONE ) { + dlog_print(DLOG_INFO, LOG_TAG, "i18n_udate_create failed !!! \n"); + } + if (!formatter_KR) { + dlog_print(DLOG_INFO, LOG_TAG, "formatter is NULL\n"); + } + ret = i18n_udate_create(I18N_UDATE_FULL , I18N_UDATE_FULL , locale, utf16_timezone_LA, -1, bestPattern, -1, &formatter_LA); + if ( ret != I18N_ERROR_NONE ) { + dlog_print(DLOG_INFO, LOG_TAG, "i18n_udate_create failed !!! \n"); + } + if (!formatter_LA) { + dlog_print(DLOG_INFO, LOG_TAG, "formatter is NULL\n"); + } + ret = i18n_udate_create(I18N_UDATE_PATTERN , I18N_UDATE_PATTERN , locale, utf16_timezone_SaoPaulo, -1, bestPattern, -1, &formatter_SaoPaulo); + if ( ret != I18N_ERROR_NONE ) { + dlog_print(DLOG_INFO, LOG_TAG, "i18n_udate_create failed !!! \n"); + } + if (!formatter_LA) { + dlog_print(DLOG_INFO, LOG_TAG, "formatter is NULL\n"); + } + + dlog_print(DLOG_INFO, LOG_TAG, "i18n_udate_format_date\n"); + + // gets the current date and time + i18n_ucalendar_get_now(&date); + + // formats a date using i18n_udate_format + i18n_udate_format_date(formatter_KR, date, formatted, 64, NULL, &formattedLength); + i18n_ustring_copy_au_n(result, formatted, 64); + //ex) KOREA/Seoul - Current date : Wednesday, June 18, 2014 1:34:54 PM GMT+09:00 + dlog_print(DLOG_INFO, LOG_TAG, "KOREA/Seoul - Current date : %s\n",result); + + // formats a date using i18n_udate_format + i18n_udate_format_date(formatter_LA, date, formatted, 64, NULL, &formattedLength); + i18n_ustring_copy_au_n(result, formatted, 64); + //ex) America/LOS Angeles - Current date : Tuesday, June 17, 2014 9:34:54 PM Pacific Daylight Time + dlog_print(DLOG_INFO, LOG_TAG, "America/LOS Angeles - Current date : %s\n",result); + + // formats a date using i18n_udate_format + i18n_udate_format_date(formatter_SaoPaulo, date, formatted, 64, NULL, &formattedLength); + i18n_ustring_copy_au_n(result, formatted, 64); + //ex) Brazil/Sao Paulo - Current date : 6 18, 2014 AD, 1:34:54 PM GMT-2 + dlog_print(DLOG_INFO, LOG_TAG, "Brazil/Sao Paulo - Current date : %s\n",result); + + dlog_print(DLOG_INFO, LOG_TAG, "i18n_udate_destroy\n"); + // destroy an #i18n_udate_format_h + i18n_udate_destroy(formatter_KR); + i18n_udate_destroy(formatter_LA); + i18n_udate_destroy(formatter_SaoPaulo); + * @endcode + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_UDATEPG_MODULE + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Opens a generator according to a given locale. + * @remarks Must release @a dtpg using i18n_udatepg_destroy(). + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] locale If @c NULL - default locale will be used. + * @param[out] dtpg A pointer to #i18n_udatepg_h. Must not be @c NULL. + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_udatepg_create ( const char *locale, i18n_udatepg_h *dtpg ); + +/** + * @brief Destroys a generator. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] dtpg A pointer to #i18n_udatepg_h. Must not be @c NULL. + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_udatepg_destroy ( i18n_udatepg_h dtpg ); + +/** + * @brief Gets the best pattern matching the input skeleton. + * @details It is guaranteed to have all of the fields in the skeleton. + * @remarks This function uses a non-const #i18n_udatepg_h: + * It uses a stateful pattern parser which is set up for each generator object, + * rather than creating one for each function call. + * Consecutive calls to this function do not affect each other, + * but this function cannot be used concurrently on a single generator object. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] dtpg A pointer to #i18n_udatepg_h. Must not be @c NULL. + * @param[in] skeleton The skeleton is a pattern containing only the variable fields.\n + * For example, "MMMdd" and "mmhh" are skeletons. Must not be @c NULL. + * @param[in] len The length of the @a skeleton, >= 0. + * @param[out] best_pattern The best pattern found from the given @a skeleton. + * @param[in] capacity The capacity of @a best_pattern, >= 0 + * @param[out] best_pattern_len The length of @a best_pattern. + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @retval #I18N_ERROR_BUFFER_OVERFLOW A result would not fit in the supplied buffer + */ +int i18n_udatepg_get_best_pattern ( i18n_udatepg_h dtpg, const i18n_uchar *skeleton, int32_t len, i18n_uchar *best_pattern, int32_t capacity, int32_t *best_pattern_len ); + + +// Newly Added APIs + + +/** + * @brief Creates an empty generator, to be constructed with i18n_udatepg_add_pattern() etc. + * @since_tizen 2.3.1 + * + * @param[out] dtpg A pointer to the #i18n_udatepg_h handle. + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_udatepg_create_empty (i18n_udatepg_h *dtpg); + +/** + * @brief Creates a copy of a generator. + * @since_tizen 2.3.1 + * + * @param[in] dtpg An #i18n_udatepg_h handle to be copied. Must not be @c NULL. + * @param[out] dtpg_clone A pointer to clone of @c dtpg handle. + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_udatepg_clone ( const i18n_udatepg_h dtpg, i18n_udatepg_h * dtpg_clone); + +/** + * @brief Gets the best pattern matching the input @a skeleton. + * @details It is guaranteed to have all of the fields in the @a skeleton. + * + * Note that this function uses a non-const #i18n_udatepg_h: + * It uses a stateful pattern parser which is set up for each generator object, + * rather than creating one for each function call. + * Consecutive calls to this function do not affect each other, + * but this function cannot be used concurrently on a single generator object. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] dtpg An #i18n_udatepg_h handle. Must not be @c NULL. + * @param[in] skeleton The @c skeleton is a pattern containing only the variable fields; + * for example, "MMMdd" and "mmhh" are skeletons. Must not be @c NULL. + * @param[in] length The length of @c skeleton, >= 0. + * @param[in] options Options for forcing the length of specified fields in the + * returned pattern to match those in the @c skeleton (when this + * would not happen otherwise). For default behavior, use + * #I18N_UDATEPG_MATCH_NO_OPTIONS. + * @param[out] best_pattern The best pattern found from the given @c skeleton. + * @param[in] capacity The capacity of @c best_pattern, >= 0. + * + * @return The length of @c best_pattern. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_udatepg_get_best_pattern_with_options ( i18n_udatepg_h dtpg, const i18n_uchar *skeleton, int32_t length, + i18n_udatepg_date_time_pattern_match_options_e options, i18n_uchar *best_pattern, int32_t capacity ); + +/** + * @brief Gets a unique skeleton from a given pattern. For example, both "MMM-dd" and "dd/MMM" produce the skeleton "MMMdd". + * @details Note that this function uses a non-const #i18n_udatepg_h: + * It uses a stateful pattern parser which is set up for each generator object, + * rather than creating one for each function call. + * Consecutive calls to this function do not affect each other, + * but this function cannot be used concurrently on a single generator object. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] dtpg An #i18n_udatepg_h handle. Must not be @c NULL. + * @param[in] pattern Input pattern, such as "dd/MMM". Must not be @c NULL. + * @param[in] length The length of @c pattern, >= 0. + * @param[out] skeleton Such as "MMMdd". + * @param[in] capacity The capacity of @c skeleton, >= 0. + * + * @return The length of @c skeleton. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_udatepg_get_skeleton ( i18n_udatepg_h dtpg, const i18n_uchar *pattern, int32_t length, i18n_uchar *skeleton, int32_t capacity ); + +/** + * @brief Gets a unique base skeleton from a given pattern. + * @details This is the same as the skeleton, except that differences in length are minimized so + * as to only preserve the difference between string and numeric form. So + * for example, both "MMM-dd" and "d/MMM" produce the skeleton "MMMd"(notice the single d).
+ * Note that this function uses a non-const #i18n_udatepg_h : + * It uses a stateful pattern parser which is set up for each generator object, + * rather than creating one for each function call. + * Consecutive calls to this function do not affect each other, + * but this function cannot be used concurrently on a single generator object. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] dtpg An #i18n_udatepg_h handle. Must not be @c NULL. + * @param[in] pattern Input pattern, such as "dd/MMM". Must not be @c NULL. + * @param[in] length The length of @c pattern, >= 0. + * @param[out] base_skeleton Such as "Md". + * @param[in] capacity The capacity of base @c skeleton, >= 0. + * + * @return The length of @c base_skeleton. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_udatepg_get_base_skeleton ( i18n_udatepg_h dtpg, const i18n_uchar *pattern, int32_t length, i18n_uchar *base_skeleton, int32_t capacity ); + +/** + * @brief Adds a pattern to the generator. + * @details If the pattern has the same skeleton as an existing pattern, + * and the override parameter is set, then the previous + * value is overridden. Otherwise, the previous value is retained. + * In either case, the conflicting status is set and previous value is stored in conflicting pattern.
+ * Note that single-field patterns (like "MMM") are automatically added, and don't need to be added explicitly! + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] dtpg An #i18n_udatepg_h handle. Must not be @c NULL. + * @param[in] pattern Input pattern, such as "dd/MMM". Must not be @c NULL. + * @param[in] pattern_length The length of @c pattern, >= 0. + * @param[in] override when existing values are to be overridden use true, + * otherwise use false. + * @param[out] conflicting_pattern Previous pattern with the same skeleton. + * @param[in] capacity The capacity of @c conflicting_pattern. + * @param[out] conflict_status A pointer to the conflicting status + * The value could be #I18N_UDATEPG_NO_CONFLICT, #I18N_UDATEPG_BASE_CONFLICT or #I18N_UDATEPG_CONFLICT. + * + * @return Length of @c conflicting_pattern. -1 if @c conflict_status is #I18N_UDATEPG_NO_CONFLICT + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_udatepg_add_pattern ( i18n_udatepg_h dtpg, const i18n_uchar *pattern, int32_t pattern_length, i18n_ubool override, i18n_uchar *conflicting_pattern, int32_t capacity, i18n_udatepg_date_time_pattern_conflict_e * conflict_status ); + +/** + * @brief An append_item_format is a pattern used to append a field if there is no good match. + * @details For example, suppose that the input skeleton is "GyyyyMMMd", + * and there is no matching pattern internally, but there is a pattern + * matching "yyyyMMMd", say "d-MM-yyyy". Then that pattern is used, plus the G. + * The way these two are conjoined is by using the append_item_format for G (era). + * So if that value is, say "{0}, {1}" then the final resulting + * pattern is "d-MM-yyyy, G".
+ * There are actually three available variables : {0} is the pattern so far, + * {1} is the element we are adding, and {2} is the name of the element.
+ * This reflects the way that the CLDR data is organized. + * @since_tizen 2.3.1 + * + * @param[in] dtpg An #i18n_udatepg_h handle. Must not be @c NULL. + * @param[in] field One of #i18n_udatepg_date_time_pattern_field_e, such as #I18N_UDATEPG_ERA_FIELD. + * @param[in] value Pattern, such as "{0}, {1}". Must not be @c NULL. + * @param[in] length The length of @c value, >= 0. + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udatepg_get_append_item_format() + */ +int i18n_udatepg_set_append_item_format ( i18n_udatepg_h dtpg, i18n_udatepg_date_time_pattern_field_e field, const i18n_uchar *value, int32_t length ); + +/** + * @brief Getter corresponding to i18n_udatepg_set_append_item_format(). + * @details Values below 0 or at or above #I18N_UDATEPG_FIELD_COUNT are illegal arguments. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] dtpg An #i18n_udatepg_h handle. Must not be @c NULL. + * @param[in] field One of #i18n_udatepg_date_time_pattern_field_e, such as #I18N_UDATEPG_ERA_FIELD. + * @param[out] pattern_length A pointer that will receive the length of append item format @a value. + * + * @return The append_item_format for @a field + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udatepg_set_append_item_format() + */ +const i18n_uchar *i18n_udatepg_get_append_item_format ( const i18n_udatepg_h dtpg, i18n_udatepg_date_time_pattern_field_e field, int32_t *pattern_length ); + +/** + * @brief Sets the name of field, e.g. "era" in English for ERA. + * @details These are only used if the corresponding append_item_format is used, and if it contains a {2} variable. + * This reflects the way that the CLDR data is organized. + * @since_tizen 2.3.1 + * + * @param[in] dtpg An #i18n_udatepg_h handle. Must not be @c NULL. + * @param[in] field #i18n_udatepg_date_time_pattern_field_e, such as #I18N_UDATEPG_ERA_FIELD. + * @param[in] value Name for the @c field. Must not be @c NULL. + * @param[in] length The length of @c value, >= 0. + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udatepg_get_append_item_name() + */ +int i18n_udatepg_set_append_item_name ( i18n_udatepg_h dtpg, i18n_udatepg_date_time_pattern_field_e field, const i18n_uchar *value, + int32_t length ); + +/** + * @brief Getter corresponding to i18n_udatepg_set_append_item_name(). + * @details Values below 0 or at or above #I18N_UDATEPG_FIELD_COUNT are illegal arguments. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] dtpg The #i18n_udate_format_h handle. Must not be @c NULL. + * @param[in] field #i18n_udatepg_date_time_pattern_field_e, such as #I18N_UDATEPG_ERA_FIELD. + * @param[out] pattern_length A pointer that will receive the length of the name for @c field. + * + * @return The name for @c field + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udatepg_set_append_item_name() + */ +const i18n_uchar *i18n_udatepg_get_append_item_name ( const i18n_udatepg_h dtpg, i18n_udatepg_date_time_pattern_field_e field, + int32_t *pattern_length ); + +/** + * @brief The date time format is a message format pattern used to compose date and time patterns. + * @brief The default value is "{0} {1}", where {0} will be replaced by the date pattern and {1} will be replaced by the time pattern. + * This is used when the input skeleton contains both date and time fields, + * but there is not a close match among the added patterns. + * For example, suppose that this object was created by adding "dd-MMM" and "hh:mm", + * and its date time format is the default "{0} {1}". Then if the input skeleton is "MMMdhmm", + * there is not an exact match, so the input skeleton is broken up into two components "MMMd" and "hmm". + * There are close matches for those two skeletons, so the result is put together with this pattern, resulting in "d-MMM h:mm". + * @since_tizen 2.3.1 + * + * @param[in] dtpg An #i18n_udate_format_h handle. Must not be @c NULL. + * @param[in] date_time_format A message format pattern, here {0} will be replaced by the date pattern + * and {1} will be replaced by the time pattern. Must not be @c NULL. + * @param[in] length The length of @c date_time_format, >= 0. + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udatepg_get_date_time_format() + */ +int i18n_udatepg_set_date_time_format ( const i18n_udatepg_h dtpg, const i18n_uchar *date_time_format, int32_t length ); + +/** + * @brief Getter corresponding to i18n_udatepg_set_date_time_format(). + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] dtpg An #i18n_udate_format_h handle. Must not be @c NULL. + * @param[out] pattern_length A pointer that will receive the length of the @a date_time_format. + * + * @return A date_time_format + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udatepg_set_date_time_format() + */ +const i18n_uchar *i18n_udatepg_get_date_time_format ( const i18n_udatepg_h dtpg, int32_t *pattern_length ); + +/** + * @brief The decimal value is used in formatting fractions of seconds. + * @details If the skeleton contains fractional seconds, then this is used with the fractional seconds. + * For example, suppose that the input pattern is "hhmmssSSSS", + * and the best matching pattern internally is "H:mm:ss", and the decimal string is ",". + * Then the resulting pattern is modified to be "H:mm:ss,SSSS" + * @since_tizen 2.3.1 + * + * @param[in] dtpg The #i18n_udate_format_h handle. Must not be @c NULL. + * @param[in] decimal Decimal. Must not be @c NULL. + * @param[in] length The length of @c decimal, >= 0. + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udatepg_get_decimal() + */ +int i18n_udatepg_set_decimal ( i18n_udatepg_h dtpg, const i18n_uchar *decimal, int32_t length ); + +/** + * @brief Getter corresponding to i18n_udatepg_set_decimal(). + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] dtpg The #i18n_udate_format_h handle. Must not be @c NULL. + * @param[out] pattern_length A pointer that will receive the length of the @a decimal string. + * + * @return Corresponding to the decimal point. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udatepg_set_decimal() + */ +const i18n_uchar *i18n_udatepg_get_decimal ( const i18n_udatepg_h dtpg, int32_t *pattern_length ); + +/** + * @brief Adjusts the field types (width and subtype) of a @a pattern to match what is in a @a skeleton. + * @details That is, if you supply a @a pattern like "d-M H:m", and a @a skeleton of "MMMMddhhmm", + * then the input pattern is adjusted to be "dd-MMMM hh:mm". + * This is used internally to get the best match for the input @a skeleton, but can also be used externally.
+ * Note that this function uses a non-const #i18n_udatepg_h: + * It uses a stateful pattern parser which is set up for each generator object, + * rather than creating one for each function call. Consecutive calls to this function do not affect each other, + * but this function cannot be used concurrently on a single generator object. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] dtpg The #i18n_udate_format_h handle. Must not be @c NULL. + * @param[in] pattern Input pattern. Must not be @c NULL. + * @param[in] pattern_length The length of input @a pattern, >= 0. + * @param[in] skeleton The skeleton. Must not be @c NULL. + * @param[in] skeleton_length The length of input @a skeleton, >= 0. + * @param[out] dest Pattern adjusted to match the @a skeleton fields widths and subtypes. + * @param[in] dest_capacity The capacity of @a dest, >= 0. + * + * @return The length of @a dest. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_udatepg_replace_field_types ( i18n_udatepg_h dtpg, const i18n_uchar *pattern, int32_t pattern_length, + const i18n_uchar *skeleton, int32_t skeleton_length, i18n_uchar *dest, int32_t dest_capacity ); + +/** + * @brief Adjusts the field types (width and subtype) of a pattern to match what is in a @a skeleton. + * @details That is, if you supply a @a pattern like "d-M H:m", and a @a skeleton of "MMMMddhhmm", + * then the input @a pattern is adjusted to be "dd-MMMM hh:mm". + * This is used internally to get the best match for the input @a skeleton, but can also be used externally.
+ * Note that this function uses a non-const #i18n_udatepg_h: + * It uses a stateful pattern parser which is set up for each generator object, + * rather than creating one for each function call. Consecutive calls to this function do not affect each other, + * but this function cannot be used concurrently on a single generator object. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] dtpg The #i18n_udate_format_h handle. Must not be @c NULL. + * @param[in] pattern Input pattern. Must not be @c NULL. + * @param[in] pattern_length The length of input @a pattern, >= 0. + * @param[in] skeleton The skeleton. Must not be @c NULL. + * @param[in] skeleton_length The length of input @a skeleton, >= 0. + * @param[in] options Options controlling whether the length of specified + * fields in the @a pattern are adjusted to match those in the @a skeleton + * (when this would not happen otherwise). + * For default behavior, use #I18N_UDATEPG_MATCH_NO_OPTIONS. + * @param[out] dest Pattern adjusted to match the @a skeleton fields widths and subtypes. + * @param[in] dest_capacity The capacity of @a dest, >= 0. + * + * @return The length of @a dest. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_udatepg_replace_field_types_with_options ( i18n_udatepg_h dtpg, const i18n_uchar *pattern, int32_t pattern_length, + const i18n_uchar *skeleton, int32_t skeleton_length, i18n_udatepg_date_time_pattern_match_options_e options, + i18n_uchar *dest, int32_t dest_capacity ); + +/** + * @brief Creates an #i18n_uenumeration_h for list of all the skeletons in canonical form. + * @details Call i18n_udatepg_get_pattern_for_skeleton() to get the corresponding pattern. + * @since_tizen 2.3.1 + * + * @param[in] dtpg An #i18n_udate_format_h handle. Must not be @c NULL. + * @param[out] enumeration A pointer to the #i18n_uenumeration_h for list of all the skeletons. The caller must destroy the object. + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_udatepg_skeletons_create ( const i18n_udatepg_h dtpg, i18n_uenumeration_h *enumeration ); + +/** + * @brief Creates an #i18n_uenumeration_h for list of all the base skeletons in canonical form. + * @since_tizen 2.3.1 + * + * @param[in] dtpg An #i18n_udate_format_h handle. Must not be @c NULL. + * @param[out] enumeration A pointer to the #i18n_uenumeration_h for list of all the base skeletons. The caller must destroy the object. + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_udatepg_base_skeletons_create ( const i18n_udatepg_h dtpg, i18n_uenumeration_h *enumeration ); + +/** + * @brief Gets the pattern corresponding to a given skeleton. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] dtpg The #i18n_udate_format_h handle. Must not be @c NULL. + * @param[in] skeleton The skeleton. Must not be @c NULL. + * @param[in] skeleton_length The length of @a skeleton, >= 0. + * @param[out] pattern_length The pointer to the length of return pattern + * + * @return Pattern corresponding to a given skeleton + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +const i18n_uchar *i18n_udatepg_get_pattern_for_skeleton ( const i18n_udatepg_h dtpg, const i18n_uchar *skeleton, int32_t skeleton_length, int32_t *pattern_length ); + + +#ifdef __cplusplus +} +#endif + +/** + * @} + * @} + */ + +#endif /* __UTILS_I18N_UDATEPG_H__*/ diff --git a/src/include/mobile/utils_i18n_uenumeration.h b/src/include/mobile/utils_i18n_uenumeration.h new file mode 100755 index 0000000..bbfe620 --- /dev/null +++ b/src/include/mobile/utils_i18n_uenumeration.h @@ -0,0 +1,194 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +#ifndef __UTILS_I18N_UENUMERATION_PRODUCT_H__ +#define __UTILS_I18N_UENUMERATION_PRODUCT_H__ + +#include + +/** + * @file utils_i18n_uenumeration.h + * @version 0.1 + * @brief utils_i18n_uenumeration + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @ingroup CAPI_BASE_UTILS_I18N_MODULE + * @defgroup CAPI_BASE_UTILS_I18N_UENUMERATION_MODULE UEnumeration + * @brief UEnumeration defines functions for handling String Enumeration. + * + * @section CAPI_BASE_UTILS_I18N_UENUMERATION_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_BASE_UTILS_I18N_UENUMERATION_MODULE_OVERVIEW Overview + * @details The UEnumeration module allows to create String Enumeration + * from chars and uchars. + * +*/ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_UENUMERATION_MODULE + * @{ + */ + +/** + * @brief Disposes of resources in use by the iterator. + * @details If @c enumeration is NULL, does nothing. After this call, any char* or i18n_uchar* returned + * by i18n_uenumeration_unext() or i18n_uenumeration_next() is invalid. + * @remarks Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] enumeration An #i18n_uenumeration_h to destroy + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_uenumeration_destroy ( i18n_uenumeration_h enumeration ); + +/** + * @brief Returns the number of elements that the iterator traverses. + * @details If the iterator is out-of-sync with its service, error code is set to #I18N_ERROR_ENUM_OUT_OF_SYNC. + * This is a convenience function. It can end up being very expensive as all the items might have to be pre-fetched + * (depending on the type of data being traversed). + * Use with caution and only when necessary. + * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] enumeration An #i18n_uenumeration_h to count + * + * @return The number of elements in the iterator + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @exception #I18N_ERROR_ENUM_OUT_OF_SYNC The iterator is out of sync + */ +int32_t i18n_uenumeration_count ( i18n_uenumeration_h enumeration ); + +/** + * @brief Returns the next element in the iterator's list. + * @details If there are no more elements, returns NULL. + * If the iterator is out-of-sync with its service, error code is set to #I18N_ERROR_ENUM_OUT_OF_SYNC and NULL is returned. + * If the native service string is a char* string, it is converted to i18n_uchar* with the invariant converter. + * The result is terminated by (i18n_uchar)0. + * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] enumeration An #i18n_uenumeration_h + * @param[out] result_length A pointer to receive the length of the result (not including the terminating \\0). + * If the pointer is NULL it is ignored. + * + * @return A pointer to the string. The string will be zero-terminated. + * The return pointer is owned by this iterator and must not be deleted by the caller. + * The pointer is valid until the next call to any i18n_uenumeration_... method, including i18n_uenumeration_next() or i18n_uenumeration_unext(). + * When all strings have been traversed, returns NULL. + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @exception #I18N_ERROR_ENUM_OUT_OF_SYNC The iterator is out of sync + */ +const i18n_uchar *i18n_uenumeration_unext ( i18n_uenumeration_h enumeration, int32_t *result_length ); + +/** + * @brief Returns the next element in the iterator's list. + * @details If there are no more elements, returns NULL. If the iterator is out-of-sync with its service, + * the #I18N_ERROR_ENUM_OUT_OF_SYNC error code is set and NULL is returned. + * If the native service string is a i18n_uchar* string, it is converted to char* with the invariant converter. + * The result is terminated by (char)0. If the conversion fails (because a character cannot be converted) + * then the error code is set to #I18N_ERROR_INVARIANT_CONVERSION and the return value is undefined (but non-NULL). + * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] enumeration An #i18n_uenumeration_h + * @param[out] result_length A pointer to receive the length of the result (not including the terminating \\0). + * If the pointer is NULL it is ignored. + * + * @return A pointer to the string. The string will be zero-terminated. + * The return pointer is owned by this iterator and must not be deleted by the caller. + * The pointer is valid until the next call to any i18n_uenumeration_... method, including i18n_uenumeration_next() or i18n_uenumeration_unext(). + * When all strings have been traversed, returns NULL. + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @exception #I18N_ERROR_ENUM_OUT_OF_SYNC The iterator is out of sync + * @exception #I18N_ERROR_INVARIANT_CONVERSION The underlying native string is i18n_uchar* and conversion to char* with the invariant converter fails. + * This error pertains only to current string, so iteration might be able to continue successfully. + */ +const char *i18n_uenumeration_next ( i18n_uenumeration_h enumeration, int32_t *result_length ); + +/** + * @brief Resets the iterator to the current list of service IDs. + * @details This re-establishes sync with the service and rewinds the iterator to start at the first element. + * @remarks Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] enumeration An #i18n_uenumeration_h + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_uenumeration_reset ( i18n_uenumeration_h enumeration ); + +/** + * @brief Given an array of const i18n_uchar* strings, return an #i18n_uenumeration_h. + * @details String pointers from 0..count-1 must not be NULL. + * Do not free or modify either the string array or the characters it points to until this object has been destroyed with i18n_uenumeration_destroy(). + * @remarks Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] strings An array of const i18n_uchar* strings (each null terminated). All storage is owned by the caller. + * @param[in] count The length of the array + * @param[out] enumeration A pointer to the new #i18n_uenumeration_h. Caller is responsible for calling i18n_uenumeration_destroy() to free memory. + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_uenumeration_destroy() + */ +int i18n_uenumeration_uchar_strings_enumeration_create(const i18n_uchar *const strings[], int32_t count, i18n_uenumeration_h *enumeration ); + +/** + * @brief Given an array of const char* strings (invariant chars only), return an #i18n_uenumeration_h. + * @details String pointers from 0..count-1 must not be NULL. + * Do not free or modify either the string array or the characters it points to until this object has been destroyed with i18n_uenumeration_destroy(). + * @remarks Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] strings A array of char* strings (each null terminated). All storage is owned by the caller. + * @param[in] count The length of the array + * @param[out] enumeration A pointer to the new #i18n_uenumeration_h. Caller is responsible for calling i18n_uenumeration_destroy() to free memory + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_uenumeration_destroy() + */ +int i18n_uenumeration_char_strings_enumeration_create(const char* const strings[], int32_t count, i18n_uenumeration_h *enumeration ); + +/** + * @} + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __UTILS_I18N_UENUMERATION_PRODUCT_H__*/ diff --git a/src/include/mobile/utils_i18n_ulocale.h b/src/include/mobile/utils_i18n_ulocale.h new file mode 100644 index 0000000..51d6e89 --- /dev/null +++ b/src/include/mobile/utils_i18n_ulocale.h @@ -0,0 +1,841 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + * + * Copyright (C) 1997-2013, International Business Machines + * Corporation and others. All Rights Reserved. + */ + +#ifndef __UTILS_I18N_ULOCALE_H__ +#define __UTILS_I18N_ULOCALE_H__ + +#include + +/** + * @file utils_i18n_ulocale.h + * @version 0.1 + * @brief utils_i18n_ulocale + */ + +/** + * @ingroup CAPI_BASE_UTILS_I18N_MODULE + * @defgroup CAPI_BASE_UTILS_I18N_ULOCALE_MODULE Ulocale + * @brief A Locale represents a specific geographical, political, or cultural region. + * @section CAPI_BASE_UTILS_I18N_ULOCALE_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_BASE_UTILS_I18N_ULOCALE_MODULE_OVERVIEW Overview + * @details A Locale represents a specific geographical, political, or cultural region. + * An operation that requires a Locale to perform its task is called locale-sensitive + * and uses the Locale to tailor information for the user. For example, displaying + * a number is a locale-sensitive operation. The number should be formatted according + * to the customs/conventions of the user's native country, region, or culture. + * In the C APIs, a locale is simply a const char string. + * + * @section CAPI_BASE_UTILS_I18N_ULOCALE_MODULE_SAMPLE_CODE_1 Sample Code 1 + * @brief Gets a default locale and a full name for the locale + * @code + const char *locale; + const char *in_locale_id = "en_US"; + char language[64] = {0,}; + i18n_uchar result_w[64] = {0,}; + char result[64] = {0,}; + int language_capacity = 64; + int buf_size_language; + int buf_size_display_name; + int ret = I18N_ERROR_NONE; + + // Sets default locale + ret = i18n_ulocale_set_default(getenv("LC_TIME")); + + // Gets default locale + ret = i18n_ulocale_get_default(&locale); + if ( ret != I18N_ERROR_NONE ) { + dlog_print(DLOG_ERROR, LOG_TAG, "i18n_ulocale_get_default() failed!!! \n"); + } + dlog_print(DLOG_INFO, LOG_TAG, "default locale : %s\n", locale); // default locale : en_GB.UTF-8 + + // Gets the language code for the specified locale + ret = i18n_ulocale_get_language(locale, language, language_capacity, &buf_size_language); + if ( ret != I18N_ERROR_NONE ) { + dlog_print(DLOG_ERROR, LOG_TAG, "i18n_ulocale_get_language() failed!!! \n"); + } + dlog_print(DLOG_INFO, LOG_TAG, "language code for the locale : %s\n", language); // language code for the locale : en + + // Gets the full name suitable for display for the specified locale + ret = i18n_ulocale_get_display_name(locale, in_locale_id, result_w, 64, &buf_size_display_name); + if ( ret != I18N_ERROR_NONE ) { + dlog_print(DLOG_ERROR, LOG_TAG, "i18n_ulocale_get_display_name() failed!!! \n"); + } + i18n_ustring_copy_au(result, result_w); + dlog_print(DLOG_INFO, LOG_TAG, "full name suitable for the locale : %s\n", result); // full name suitable for the locale : English (United Kingdom) + * @endcode + * + * @section CAPI_BASE_UTILS_I18N_ULOCALE_MODULE_SAMPLE_CODE_2 Sample Code 2 + * @brief See all available locales + * @code + int i = 0; + int32_t count = i18n_ulocale_count_available(); + for(i = 0; i < count; i++) + { + dlog_print(DLOG_INFO, LOG_TAG, "Available locale %d : %s " ,i, i18n_ulocale_get_available(i)); + // ... + //Available locale 5 : en_GB + //Available locale 6 : en_US + //Available locale 7 : en_US_POSIX + // ... + } + * @endcode + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_ULOCALE_MODULE + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Gets I18N's default locale. + * @details The returned string is a snapshot in time, and will remain valid + * and unchanged even when i18n_ulocale_set_default() is called. + * The returned storage is owned by I18N, and must not be altered or deleted by the caller. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] locale The I18N default locale + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ulocale_get_default ( const char **locale ); + +/** + * @brief Sets I18N's default locale. + * @details By default (without calling this function), + * I18N's default locale will be based on information obtained from the underlying system environment. + * + * Changes to I18N's default locale do not propagate back to the system environment. + * + * Changes to I18N's default locale to not affect any services that may already be open based on the previous default locale value. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] locale_id The new I18N default locale.\n + * A value of @c NULL will try to get the system's default locale. + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ulocale_set_default ( const char *locale_id ); + +/** + * @brief Gets the language code for the specified locale. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] locale_id The locale to get the ISO language code with.\n + * @c NULL may be used to specify the default. + * @param[out] language The language code for @a locale_id + * @param[in] language_capacity The size of the @a language buffer to store the language code with + * @param[out] buf_size_language The actual buffer size needed for the language code.\n + * If it's greater than @a language_capacity, the returned language code will be truncated. + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ulocale_get_language ( const char *locale_id, char *language, int32_t language_capacity, int32_t *buf_size_language ); + +/** + * @brief Gets the country code for the specified locale. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] locale_id The locale to get the country code with + * @param[out] country The country code for @a locale_id + * @param[in] country_capacity The size of the @a country buffer to store the country code with + * @param[out] error Error information if retrieving the country code failed + * + * @return The actual buffer size needed for the country code.\n + * If it's greater than @a country_capacity, the returned country code will be truncated. + */ +int32_t i18n_ulocale_get_country ( const char *locale_id, char *country, int32_t country_capacity, int *error ); + +/** + * @brief Gets the full name suitable for display for the specified locale. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] locale_id The locale to get the displayable name with.\n + * @c NULL may be used to specify the default. + * @param[in] in_locale_id The locale to be used to display the name.\n + * @c NULL may be used to specify the default. + * @param[out] result The displayable name for @a locale_id + * @param[in] max_result_size The size of the name buffer to store the displayable full name with + * @param[out] buf_size_display_name The actual buffer size needed for the displayable name.\n + * If it's greater than @a max_result_size, the returned displayable name will be truncated. + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ulocale_get_display_name ( const char *locale_id, const char *in_locale_id, i18n_uchar *result, int32_t max_result_size, int32_t *buf_size_display_name ); + +/** + * @brief Gets the specified locale from a list of all available locales. + * @details The return value is a pointer to an item of a locale name array. + * Both this array and the pointers it contains are owned by I18N + * and should not be deleted or written through by the caller. + * The locale name is terminated by a null pointer. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] n The specific locale name index of the available locale list + * + * @return A specified locale name of all available locales + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +const char* i18n_ulocale_get_available ( int32_t n ); + +/** + * @brief Gets the size of the all available locale list. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @return The size of the locale list + * @exception #I18N_ERROR_NONE Success + */ +int32_t i18n_ulocale_count_available ( void ); + +// Newly Added APIs + +/** + * @brief Gets the script code for the specified locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] locale_id The locale to get the ISO script code with + * @param[out] script The script code for @a locale_id. Must not be @c NULL. + * @param[in] script_capacity The size of the @a script buffer to store the script code with + * + * @return The actual buffer size needed for the script code. If it's greater than @a script_capacity, + * the returned script code will be truncated. If the @a script buffer is @c NULL + * or the @a script_capacity is lower than @c 0 , then the #I18N_ERROR_INVALID_PARAMETER error will be set + * and @c -1 will be returned. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ulocale_get_script ( const char *locale_id, char *script, int32_t script_capacity ); + +/** + * @brief Gets the variant code for the specified locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] locale_id The locale to get the variant code with + * @param[out] variant The variant code for @a locale_id + * @param[in] variant_capacity The size of the @a variant buffer to store the variant code with + * + * @return The actual buffer size needed for the variant code. If it's greater than @a variant_capacity, + * the returned variant code will be truncated. If the @a variant buffer is @c NULL + * or the @a variant_capacity is lower than @c 0 , then the #I18N_ERROR_INVALID_PARAMETER error will be set + * and @c -1 will be returned. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ulocale_get_variant ( const char *locale_id, char *variant, int32_t variant_capacity ); + +/** + * @brief Gets the full name for the specified locale. + * @details Note : This has the effect of 'canonicalizing' the I18N locale ID to + * a certain extent. Upper and lower case are set as needed. + * It does NOT map aliased names in any way. + * See the top of this header file. + * This API supports preflighting. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] locale_id The locale to get the full name with + * @param[out] name Fill in buffer for the name without keywords. + * @param[in] name_capacity Capacity of the fill in buffer. + * + * @return The actual buffer size needed for the full name. If it's greater than @a name_capacity, + * the returned full name will be truncated. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_BUFFER_OVERFLOW A result would not fit in the supplied buffer + */ +int32_t i18n_ulocale_get_name ( const char *locale_id, char *name, int32_t name_capacity ); + +/** + * @brief Gets the full name for the specified locale. + * @details Note : This has the effect of 'canonicalizing' the string to + * a certain extent. Upper and lower case are set as needed, + * and if the components were in 'POSIX' format they are changed to + * I18N format. It does NOT map aliased names in any way. + * See the top of this header file. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] locale_id The locale to get the full name with + * @param[out] name The full name for @a locale_id + * @param[in] name_capacity The size of the @a name buffer to store the full name with + * + * @return The actual buffer size needed for the full name. If it's greater than @a name_capacity, + * the returned full name will be truncated. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_BUFFER_OVERFLOW A result would not fit in the supplied buffer + */ +int32_t i18n_ulocale_canonicalize ( const char *locale_id, char *name, int32_t name_capacity ); + +/** + * @brief Gets the ISO language code for the specified locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] locale_id The locale to get the ISO language code with + * + * @return A language the ISO language code for @a locale_id + * + * @exception #I18N_ERROR_NONE Successful + */ +const char * i18n_ulocale_get_iso3_language ( const char *locale_id ); + +/** + * @brief Gets the ISO country code for the specified locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] locale_id The locale to get the ISO country code with + * + * @return A country the ISO country code for @a locale_id + * + * @exception #I18N_ERROR_NONE Successful + */ +const char * i18n_ulocale_get_iso3_country ( const char *locale_id ); + +/** + * @brief Gets the Win32 LCID value for the specified locale. + * @details If the I18N locale is not recognized by Windows, 0 will be returned. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] locale_id The locale to get the Win32 LCID value with + * + * @return A country the Win32 LCID for @a locale_id + * + * @exception #I18N_ERROR_NONE Successful + */ +uint32_t i18n_ulocale_get_lcid ( const char *locale_id ); + +/** + * @brief Gets the language name suitable for display for the specified locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] locale The locale to get the ISO language code with + * @param[in] display_locale The locale to be used to display the name.\n + * @c NULL may be used to specify the default. + * @param[out] language The displayable language code for @a locale. + * @param[in] language_capacity The size of the @a language buffer to store the displayable language code with + * + * @return The actual buffer size needed for the displayable language code. If it's greater than + * @a language_capacity, the returned language code will be truncated. If the @a language buffer is @c NULL + * or the @a language_capacity is lower than @c 0 , then the #I18N_ERROR_INVALID_PARAMETER error will be set + * and @c 0 will be returned. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ulocale_get_display_language ( const char *locale, const char *display_locale, i18n_uchar *language, int32_t language_capacity ); + +/** + * @brief Gets the script name suitable for display for the specified locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] locale The locale to get the displayable script code with. @c NULL may be used to specify the default. + * @param[in] display_locale The locale to be used to display the name. @c NULL may be used to specify the default. + * @param[out] script The displayable country code for @a locale + * @param[in] script_capacity The size of the script buffer to store the displayable script code with + * + * @return The actual buffer size needed for the displayable script code. If it's greater than @a script_capacity, + * the returned displayable script code will be truncated. If the @a script buffer is @c NULL + * or the @a script_capacity is lower than @c 0 , then the #I18N_ERROR_INVALID_PARAMETER error will be set + * and @c 0 will be returned. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ulocale_get_display_script ( const char *locale, const char *display_locale, i18n_uchar *script, int32_t script_capacity ); + +/** + * @brief Gets the country name suitable for display for the specified locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] locale The locale to get the displayable country code with. @c NULL may be used to specify the default. + * @param[in] display_locale The locale to be used to display the name. @c NULL may be used to specify the default. + * @param[out] country The displayable country code for @a locale + * @param[in] country_capacity The size of the @a country buffer to store the displayable country code with + * + * @return The actual buffer size needed for the displayable country code. If it's greater than @a country_capacity, + * the returned displayable country code will be truncated. If the @a country buffer is @c NULL + * or the @a country_capacity is lower than @c 0 , then the #I18N_ERROR_INVALID_PARAMETER error will be set + * and @c 0 will be returned. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ulocale_get_display_country ( const char *locale, const char *display_locale, i18n_uchar *country, int32_t country_capacity ); + +/** + * @brief Gets the variant name suitable for display for the specified locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] locale The locale to get the displayable variant code with. @c NULL may be used to specify the default. + * @param[in] display_locale The locale to be used to display the name. @c NULL may be used to specify the default. + * @param[out] variant The displayable variant code for @a locale + * @param[in] variant_capacity The size of the @a variant buffer to store the displayable variant code with + * + * @return The actual buffer size needed for the displayable variant code. If it's greater than @a variant_capacity, + * the returned displayable variant code will be truncated. If the @a variant buffer is @c NULL + * or the @a variant_capacity is lower than @c 0 , then the #I18N_ERROR_INVALID_PARAMETER error will be set + * and @c 0 will be returned. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ulocale_get_display_variant ( const char *locale, const char *display_locale, i18n_uchar *variant, int32_t variant_capacity ); + +/** + * @brief Gets the keyword name suitable for display for the specified locale. + * @details E.g : for the locale string de_DE\@collation=PHONEBOOK, this API gets the display string for the keyword collation. + * Usage : + * @code + * i18n_error_code_e status = I18N_ERROR_NONE; + * const char* keyword = NULL; + * int32_t keyword_len = 0; + * int32_t keyword_count = 0; + * i18n_uchar display_keyword[256]; + * int32_t display_keyword_len = 0; + * i18n_uenumeration_h keyword_enum = i18n_ulocale_keywords_create("de_DE@collation=PHONEBOOK;calendar=TRADITIONAL"); + * + * for(keyword_count = i18n_uenumeration_count(keyword_enum); keyword_count > 0; keyword_count--){ + * status = get_last_result(); + * if(status > 0){ + * // something went wrong so handle the error + * break; + * } + * // the uenum_next returns NULL-terminated string + * keyword = i18n_uenumeration_next(keyword_enum, &keyword_len); + * display_keyword_len = i18n_ulocale_get_display_keyword(keyword, "en_US", display_keyword, 256); + * // do something interesting + * } + * i18n_uenumeration_destroy(keyword_enum); + * @endcode + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] keyword The keyword whose display string needs to be returned. + * @param[in] display_locale The locale to be used to display the name. @c NULL may be used to specify the default. + * @param[out] dest The buffer to which the displayable keyword should be written. + * @param[in] dest_capacity The size of the buffer (number of #i18n_uchar characters). If it is 0, then + * @a dest may be @c NULL and the function will only return the length of the result without + * writing any of the result string (pre-flighting). + * + * @return The actual buffer size needed for the displayable variant code. If the @a dest buffer is @c NULL + * or the @a dest_capacity is lower than @c 0 , then the #I18N_ERROR_INVALID_PARAMETER error will be set + * and @c 0 will be returned. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_ulocale_keywords_create() + * @see i18n_uenumeration_count() + * @see i18n_uenumeration_next() + * @see i18n_uenumeration_destroy() + */ +int32_t i18n_ulocale_get_display_keyword ( const char *keyword, const char *display_locale, i18n_uchar *dest, int32_t dest_capacity ); + +/** + * @brief Gets the value of the keyword suitable for display for the specified locale. + * @details E.g : for the locale string de_DE\@collation=PHONEBOOK, this API gets the display string for PHONEBOOK, in the display locale, when "collation" is specified as the keyword. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] locale The locale to get the displayable variant code with. @c NULL may be used to specify the default. + * @param[in] keyword The keyword for whose value should be used. + * @param[in] display_locale The locale to be used to display the name. @c NULL may be used to specify the default. + * @param[out] dest The buffer to which the displayable keyword should be written. + * @param[in] dest_capacity The size of the buffer (number of #i18n_uchar characters). If it is 0, then + * @a dest may be @c NULL and the function will only return the length of the result + * without writing any of the result string (pre-flighting). + * + * @return The actual buffer size needed for the displayable variant code. If the @a dest buffer is @c NULL + * or the @a dest_capacity is lower than @c 0 , then the #I18N_ERROR_INVALID_PARAMETER error will be set + * and @c 0 will be returned. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ulocale_get_display_keyword_value ( const char *locale, const char *keyword, const char *display_locale, i18n_uchar *dest, int32_t dest_capacity ); + +/** + * @brief Gets a list of all available 2-letter language codes defined in ISO 639, + * plus additional 3-letter codes determined to be useful for locale generation as + * defined by Unicode CLDR. + * @details This is a pointer to an array of pointers to arrays of char. All of these pointers are owned + * by I18N - do not delete them, and do not write through them. + * The array is terminated with a @c NULL pointer. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @return A list of all available language codes + * + * @exception #I18N_ERROR_NONE Successful + */ +const char * const *i18n_ulocale_get_iso_languages ( void ); + +/** + * + * @brief Gets a list of all available 2-letter country codes defined in ISO 639. + * @details This is a pointer to an array of pointers to arrays of char. All of these pointers are + * owned by I18N - do not delete them, and do not write through them. + * The array is terminated with a @c NULL pointer. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @return A list of all available country codes + * + * @exception #I18N_ERROR_NONE Successful + */ +const char * const *i18n_ulocale_get_iso_countries ( void ); + +/** + * @brief Truncates the locale ID string to get the parent locale ID. + * @details Copies the part of the string before the last underscore. + * The parent locale ID will be an empty string if there is no + * underscore, or if there is only one underscore at @a locale_id[0]. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] locale_id Input locale ID string. + * @param[out] parent Output string buffer for the parent locale ID. Must not be @c NULL. + * @param[in] parent_capacity Size of the output buffer. If it's lower than the number of characters + * stored in the @a locale_id between the first character and the last occurrence + * of the underscore ("_") character, than the error code will be set to + * #I18N_ERROR_BUFFER_OVERFLOW. + * + * @return The length of the parent locale ID. If the @a parent buffer is @c NULL or the @a parent_capacity is lower than @c 0, + * then the #I18N_ERROR_INVALID_PARAMETER error will be set and @c -1 will be returned. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @exception #I18N_ERROR_BUFFER_OVERFLOW If the capacity of the @a parent is lower than the number of characters + * in the @a locale_id from index 0 to the index of the last occurrence of + * the underscore ("_") symbol. + */ +int32_t i18n_ulocale_get_parent ( const char *locale_id, char *parent, int32_t parent_capacity ); + +/** + * @brief Gets the full name for the specified locale. + * @details Note : This has the effect of 'canonicalizing' the string to a certain extent. + * Upper and lower case are set as needed, + * and if the components were in 'POSIX' format they are changed to I18N format. + * It does NOT map aliased names in any way. + * See the top of this header file. + * + * This API strips off the keyword part, so "de_DE\@collation=phonebook" will become "de_DE". + * This API supports preflighting. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] locale_id The locale to get the full name with + * @param[out] name Fill in buffer for the name without keywords. + * @param[in] name_capacity Capacity of the fill in buffer. + * + * @return The actual buffer size needed for the full name. If it's greater than @a name_capacity, + * the returned full name will be truncated. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_BUFFER_OVERFLOW A result would not fit in the supplied buffer + */ +int32_t i18n_ulocale_get_base_name ( const char *locale_id, char *name, int32_t name_capacity ); + +/** + * @brief Gets an enumeration of keywords for the specified locale. + * @details Enumeration must get disposed of by the client using i18n_uenumeration_destroy() function. + * @remarks Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] locale_id The locale to get the variant code with + * + * @param enumeration A pointer to the enumeration of keywords or @c NULL if there are no keywords. + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ulocale_keywords_create ( const char *locale_id, i18n_uenumeration_h *enumeration ); + +/** + * @brief Gets the value for a keyword. + * @details Locale name does not need to be normalized. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] locale_id A locale name containing the keyword ("de_DE@currency=EURO;collation=PHONEBOOK") + * @param[in] keyword_name The name of the keyword for which we want the value. Case insensitive. + * @param[out] buffer Receiving buffer + * @param[in] buffer_capacity Capacity of receiving @a buffer + * + * @return The length of keyword value. If the @a keyword_name or @a buffer is @c NULL or the @a buffer_capacity is lower than @c 0, + * then the #I18N_ERROR_INVALID_PARAMETER error will be set and @c -1 will be returned. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ulocale_get_keyword_value ( const char *locale_id, const char *keyword_name, char *buffer, int32_t buffer_capacity ); + +/** + * @brief Sets or removes the value of the specified keyword. + * @details For removing all keywords, use i18n_ulocale_get_base_name(). + * + * NOTE : Unlike almost every other I18N function which takes a + * buffer, this function will NOT truncate the output text. If a + * #I18N_ERROR_BUFFER_OVERFLOW is received, it means that the original + * buffer is untouched. This is done to prevent incorrect or possibly + * even malformed locales from being generated and used. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] keyword_name A name of the keyword to be set. Case insensitive. + * @param[in] keyword_value A value of the keyword to be set. If 0-length or + * @c NULL, will result in the keyword being removed. + * No error is given if that keyword does not exist. + * @param[out] buffer Input buffer containing locale to be modified. + * @param[in] buffer_capacity Capacity of receiving @a buffer + * + * @return The length needed for the @a buffer. If the @a keyword_name or @a buffer is @c NULL or the @a buffer_capacity is lower than @c 0, + * then the #I18N_ERROR_INVALID_PARAMETER error will be set and @c -1 will be returned. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_ulocale_get_keyword_value() + */ +int32_t i18n_ulocale_set_keyword_value ( const char *keyword_name, const char *keyword_value, char *buffer, int32_t buffer_capacity ); + +/** + * @brief Gets the layout character orientation for the specified locale. + * @remarks Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] locale_id locale name + * @param[out] layout_type A pointer to the enum indicating the layout orientation for characters. + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ulocale_get_character_orientation ( const char *locale_id, i18n_ulocale_layout_type_e *layout_type ); + +/** + * @brief Gets the layout line orientation for the specified locale. + * @remarks Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] locale_id locale name + * @param[out] layout_type A pointer to the enum indicating the layout orientation for lines. + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ulocale_get_line_orientation ( const char *locale_id, i18n_ulocale_layout_type_e *layout_type ); + +/** + * @brief Gets the I18N locale ID for the specified Win32 LCID value. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] host_id The Win32 LCID to translate + * @param[out] locale The output buffer for the I18N locale ID, which will be NULL-terminated if there is room. + * @param[in] locale_capacity The size of the output buffer + * + * @return The actual size of the locale ID, not including NULL-termination. + * If the @a locale buffer is @c NULL or the @a locale_capacity is lower than @c 0, + * then the #I18N_ERROR_INVALID_PARAMETER error will be set and @c -1 will be returned. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ulocale_get_locale_for_lcid ( uint32_t host_id, char *locale, int32_t locale_capacity ); + +/** + * @brief Adds the likely subtags for a provided locale ID, per the algorithm described + * in the following CLDR technical report : http://www.unicode.org/reports/tr35/#Likely_Subtags + * @details If @a locale_id is already in the maximal form, or there is no data available + * for maximization, it will be copied to the output buffer. For example, + * "und-Zzzz" cannot be maximized, since there is no reasonable maximization. + * + * Examples : + * + * "en" maximizes to "en_Latn_US" + * + * "de" maximizes to "de_Latn_US" + * + * "sr" maximizes to "sr_Cyrl_RS" + * + * "sh" maximizes to "sr_Latn_RS" (Note this will not reverse.) + * + * "zh_Hani" maximizes to "zh_Hans_CN" (Note this will not reverse.) + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] locale_id The locale to maximize + * @param[out] maximized_locale_id The maximized locale + * @param[in] maximized_locale_id_capacity The capacity of the @a maximized_locale_id buffer + * + * @return The actual buffer size needed for the maximized locale. If it's + * greater than @a maximized_lacale_id_capacity, the returned ID will be truncated. + * On error, the return value is -1. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ulocale_add_likely_subtags ( const char *locale_id, char *maximized_locale_id, int32_t maximized_locale_id_capacity ); + +/** + * @brief Minimizes the subtags for a provided locale ID, per the algorithm described + * in the following CLDR technical report: http://www.unicode.org/reports/tr35/#Likely_Subtags + * @details If @a locale_id is already in the minimal form, or there is no data available + * for minimization, it will be copied to the output buffer. Since the + * minimization algorithm relies on proper maximization, see the comments + * for i18n_ulocale_add_likely_subtags() for reasons why there might not be any data. + * + * Examples : + * + * "en_Latn_US" minimizes to "en" + * + * "de_Latn_US" minimizes to "de" + * + * "sr_Cyrl_RS" minimizes to "sr" + * + * "zh_Hant_TW" minimizes to "zh_TW" (The region is preferred to the script, and minimizing to "zh" would imply "zh_Hans_CN".) + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] locale_id The locale to minimize + * @param[out] minimized_locale_id The minimized locale + * @param[in] minimized_locale_id_capacity The capacity of the @a minimized_locale_id buffer + * + * @return The actual buffer size needed for the minimized locale. If it's + * greater than @a minimized_locale_id_capacity, the returned ID will be truncated. + * On error, the return value is -1. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ulocale_minimize_subtags ( const char *locale_id, char *minimized_locale_id, int32_t minimized_locale_id_capacity ); + +/** + * @brief Returns a locale ID for the specified BCP47 language tag string. + * @details If the specified language tag contains any ill-formed subtags, + * the first such subtag and all following subtags are ignored.
+ * + * This implements the 'Language-Tag' production of BCP47, and so + * supports grandfathered (regular and irregular) as well as private + * use language tags. Private use tags are represented as 'x-whatever', + * and grandfathered tags are converted to their canonical replacements + * where they exist. Note that a few grandfathered tags have no modern + * replacement, these will be converted using the fallback described in + * the first paragraph, so some information might be lost. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] langtag The input BCP47 language tag. + * @param[out] locale_id The output buffer receiving a locale ID for the + * specified BCP47 language tag. + * @param[in] locale_id_capacity The size of the @a locale_id output buffer. + * @param[in] parsed_length If not @c NULL, successfully parsed length + * for the input language tag is set. + * + * @return The length of the locale ID. If the @a langtag or @a locale_id buffer is @c NULL or the @a locale_id_capacity is lower than @c 0, + * then the #I18N_ERROR_INVALID_PARAMETER error will be set and @c -1 will be returned. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ulocale_for_language_tag ( const char *langtag, char *locale_id, int32_t locale_id_capacity, int32_t *parsed_length ); + +/** + * @brief Returns a well-formed language tag for this locale ID. + * @details Note : When @a strict is @c false, any locale + * fields which do not satisfy the BCP47 syntax requirement will + * be omitted from the result. When @a strict is + * @c true, this function sets #I18N_ERROR_INVALID_PARAMETER to the + * result if any locale fields do not satisfy the + * BCP47 syntax requirement. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] locale_id The input locale ID + * @param[out] langtag The output buffer receiving BCP47 language + * tag for the locale ID. + * @param[in] langtag_capacity The size of the BCP47 language tag + * output buffer. + * @param[in] strict Boolean value indicating if the function returns + * an error for an ill-formed input locale ID. + * + * @return The length of the BCP47 language tag. If the @a locale_id or @a langtag buffer is @c NULL or the @a langtag_capacity is lower than @c 0, + * then the #I18N_ERROR_INVALID_PARAMETER error will be set and @c -1 will be returned. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ulocale_to_language_tag ( const char *locale_id, char *langtag, int32_t langtag_capacity, i18n_ubool strict ); + +#ifdef __cplusplus +} +#endif + +/** + * @} + * @} + */ + +#endif /* __UTILS_I18N_ULOCALE_H__*/ diff --git a/src/include/mobile/utils_i18n_unormalization.h b/src/include/mobile/utils_i18n_unormalization.h new file mode 100755 index 0000000..76ecbc0 --- /dev/null +++ b/src/include/mobile/utils_i18n_unormalization.h @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +#ifndef __UTILS_I18N_UNORMALIZATION_H__ +#define __UTILS_I18N_UNORMALIZATION_H__ + +#include + +/** + * @file utils_i18n_unormalization.h + * @version 0.1 + * @brief utils_i18n_unormaliztion + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @ingroup CAPI_BASE_UTILS_I18N_MODULE + * @defgroup CAPI_BASE_UTILS_I18N_UNORMALIZATION_MODULE Unormalization + * @brief The Unormalization module provides Unicode normalization functionality for standard unicode normalization. + * + * @section CAPI_BASE_UTILS_I18N_UNORMALIZATION_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_BASE_UTILS_I18N_UNORMALIZATION_MODULE_OVERVIEW Overview + * @details The Unormalization module provides Unicode normalization functionality for standard unicode normalization. + * All instances of i18n_unormalizer_h are unmodifiable/immutable. + * Instances returned by i18n_unormalization_get_instance() are singletons that must not be deleted by the caller. + * + * @section CAPI_BASE_UTILS_I18N_UNORMALIZATION_MODULE_SAMPLE_CODE_1 Sample Code 1 + * @brief Creates a normalizer and normalizes a unicode string + * @code + i18n_unormalizer_h normalizer = NULL; + i18n_uchar src = 0xAC00; + i18n_uchar dest[4] = {0,}; + int dest_str_len = 0; + int i = 0; + + // gets instance for normalizer + i18n_unormalization_get_instance( NULL, "nfc", I18N_UNORMALIZATION_DECOMPOSE, &normalizer ); + + // normalizes a unicode string + i18n_unormalization_normalize( normalizer, &src, 1, dest, 4, &dest_str_len ); + dlog_print(DLOG_INFO, LOG_TAG, "src is 0x%x\n", src ); // src is 0xAC00 (0xAC00: A Korean character combined with consonant and vowel) + + for ( i = 0; i < dest_str_len; i++ ) { + dlog_print(DLOG_INFO, LOG_TAG, "dest[%d] is 0x%x\t", i + 1, dest[i] ); // dest[1] is 0x1100 dest[2] is 0x1161 (0x1100: consonant, 0x1161: vowel) + } + * @endcode + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_UNORMALIZATION_MODULE + * @{ + */ + +/** + * @brief Gets a i18n_unormalizer_h which uses the specified data file and composes or decomposes text according to the specified mode. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] package_name @c NULL for ICU built-in data, otherwise application data package name. + * @param[in] name "nfc" or "nfkc" or "nfkc_cf" or the name of the custom data file. + * @param[in] mode The normalization mode (compose or decompose). + * @param[out] normalizer The requested normalizer on success. + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_unormalization_get_instance (const char *package_name, const char *name, i18n_unormalization_mode_e mode, + i18n_unormalizer_h *normalizer); + +/** + * @brief Writes the normalized form of the source string to the destination string(replacing its contents). + * @details The source and destination strings must be different buffers. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] normalizer i18n normalizer handle. + * @param[in] src The source string. + * @param[in] len The length of the source string, otherwise @c -1 if NULL-terminated. + * @param[out] dest The destination string\n + * Its contents are replaced with normalized @a src. + * @param[in] capacity The number of string_uchar that can be written to @a dest + * @param[out] len_deststr The length of the destination string + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_unormalization_normalize (i18n_unormalizer_h normalizer, const i18n_uchar *src, int32_t len, i18n_uchar *dest, int32_t capacity, int32_t *len_deststr); + +#ifdef __cplusplus +} +#endif + +/** + * @} + * @} + */ + +#endif /* __UTILS_I18N_UNORMALIZATION_H__*/ diff --git a/src/include/mobile/utils_i18n_unumber.h b/src/include/mobile/utils_i18n_unumber.h new file mode 100644 index 0000000..c25d665 --- /dev/null +++ b/src/include/mobile/utils_i18n_unumber.h @@ -0,0 +1,645 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +#ifndef __UTILS_I18N_UNUMBER_H__ +#define __UTILS_I18N_UNUMBER_H__ + +#include + +/** + * @file utils_i18n_unumber.h + * @version 0.1 + * @brief utils_i18n_unumber + */ + +/** + * @ingroup CAPI_BASE_UTILS_I18N_MODULE + * @defgroup CAPI_BASE_UTILS_I18N_UNUMBER_MODULE Unumber + * @brief The Unumber module helps you format and parse numbers for any locale. + * + * @section CAPI_BASE_UTILS_I18N_UNUMBER_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_BASE_UTILS_I18N_UNUMBER_MODULE_OVERVIEW Overview + * @details The Unumber module helps you format and parse numbers for any locale. + * Your code can be completely independent of the locale conventions for decimal + * points, thousands-separators, or even the particular decimal digits used, + * or whether the number format is even decimal. There are different number format + * styles like decimal, currency, percent and spellout. + * + * @section CAPI_BASE_UTILS_I18N_UNUMBER_MODULE_SAMPLE_CODE_1 Sample Code 1 + * @brief Gets a currency symbol according to a given locale. + * @code + int buf_len; + i18n_uchar u_buffer[64]; + char a_buffer[64]; + i18n_unumber_format_h num_format; + + // creates and returns a new unumber_format + i18n_unumber_create(I18N_UNUMBER_CURRENCY, NULL, -1, "en_US", NULL, &num_format); + + // gets a symbol associated with i18n_unumber_format + i18n_unumber_get_symbol(num_format, I18N_UNUMBER_CURRENCY_SYMBOL, u_buffer, 64, &buf_len); + + i18n_ustring_copy_au(a_buffer, u_buffer); + // en_US currency symbol: $ + dlog_print(DLOG_INFO, LOG_TAG, "en_US currency symbol: %s \n", a_buffer); + + // destroys i18n_unumber_format + i18n_unumber_destroy(num_format); + * @endcode + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_UNUMBER_MODULE + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Creates and returns a new unumber_format_h for formatting and parsing numbers. + * @details A unumber_format_style_e may be used to format numbers by calling {@link i18n_unumber_create()}. + * The caller must call {@link #i18n_unumber_destroy() } when done to release resources used by this object. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @remarks Must release @a num_format using i18n_unumber_destroy(). + * + * @param[in] style The type of number format to create: one of + * #I18N_UNUMBER_DECIMAL, + * #I18N_UNUMBER_CURRENCY, + * #I18N_UNUMBER_PERCENT, + * #I18N_UNUMBER_SCIENTIFIC, + * #I18N_UNUMBER_SPELLOUT, + * #I18N_UNUMBER_ORDINAL, + * #I18N_UNUMBER_DURATION, + * #I18N_UNUMBER_NUMBERING_SYSTEM, + * #I18N_UNUMBER_PATTERN_RULEBASED, + * or #I18N_UNUMBER_DEFAULT \n + * If #I18N_UNUMBER_PATTERN_DECIMAL or #I18N_UNUMBER_PATTERN_RULEBASED is passed then the number format is created using the given pattern, which must conform + * to the syntax described in DecimalFormat or RuleBasedNumberFormat, respectively. + * @param[in] pattern A pattern specifying the format to use \n This parameter is ignored unless the style is #I18N_UNUMBER_PATTERN_DECIMAL or #I18N_UNUMBER_PATTERN_RULEBASED. + * @param[in] pattern_len The number of characters in the pattern, otherwise @c -1 if NULL-terminated\n + * This parameter is ignored unless the style is I18N_UNUMBER_PATTERN_*. + * @param[in] locale A locale identifier to use to determine formatting + * and parsing conventions, otherwise @c NULL to use the default locale. + * @param[in] parse_err A pointer to a #i18n_uparse_error_s structure to receive the + * details of any parsing errors, otherwise @c NULL if no parsing error details are desired. + * @param[out] num_format A pointer to a newly created #i18n_unumber_format_h, otherwise @c NULL if an error occurs. + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_unumber_create ( i18n_unumber_format_style_e style, const i18n_uchar *pattern, int32_t pattern_len, const char *locale, + i18n_uparse_error_s *parse_err, i18n_unumber_format_h *num_format ); + +/** + * @brief Destroys an #i18n_unumber_format_h. + * @details Once destroyed, an #i18n_unumber_format may no longer be used. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] fmt The formatter to destroy + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_unumber_destroy ( i18n_unumber_format_h fmt ); + +/** + * @brief Gets a symbol associated with an #i18n_unumber_format_h. + * @details An #i18n_unumber_format_h uses symbols to represent the special locale-dependent characters in a number, + * for example the percent sign. This API is not supported for rule-based formatters. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] fmt The formatter to query. + * @param[in] symbol The unumber_format_symbol_e constant for the symbol to get + * @param[out] buffer The string buffer that will receive the symbol string\n + * If it is @c NULL, then only the length of the symbol is returned. + * @param[in] size The size of the string buffer + * @param[out] len_symbol The length of the symbol\n + * The buffer is not modified if length >= size + * + * @retval #I18N_ERROR_NONE Successful. + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_unumber_get_symbol ( const i18n_unumber_format_h fmt, i18n_unumber_format_symbol_e symbol, i18n_uchar *buffer, int32_t size, int32_t *len_symbol ); + + +// Newly Added APIs + + +/** + * @brief Creates a copy of an #i18n_unumber_format_h. + * @details This function performs a deep copy. + * @remarks Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] fmt The format to copy. + * @param[out] fmt_clone A pointer to clone of @a fmt. + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful. + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_unumber_clone (const i18n_unumber_format_h fmt, i18n_unumber_format_h *fmt_clone); + +/** +* @brief Formats an integer using a i18n_unumber_format_h. +* @details The integer will be formatted according to the i18n_unumber_format_h's locale. +* @since_tizen 2.3.1 +* +* @param[in] fmt The formatter to use. +* @param[in] number The number to format. +* @param[out] result A pointer to a buffer to receive the NULL-terminated formatted number. +* If the formatted number fits into dest but cannot be NULL-terminated (length == resultLength) +* then the error code is set to #I18N_WARNING_STRING_NOT_TERMINATED. +* If the formatted number doesn't fit into result then the error code is set to #I18N_ERROR_BUFFER_OVERFLOW. +* @param[in] result_length The maximum size of result. +* @param[in] pos A pointer to a i18n_ufield_position. On input, position->field is read. +* On output, position->beginIndex and position->endIndex indicate the beginning and ending indices of field number position->field, if such a field exists. +* This parameter may be NULL, in which case no field +* @param[out] status A pointer to an i18n_error_code_e to receive any errors +* +* @return The total buffer size needed; if greater than result_length, the output was truncated. +*/ +int32_t i18n_unumber_format (const i18n_unumber_format_h fmt, int32_t number, i18n_uchar *result, int32_t result_length, i18n_ufield_position_s *pos, i18n_error_code_e *status); + +/** + * @brief Formats an int64 using an #i18n_unumber_format_h. + * @details The int64 will be formatted according to the #i18n_unumber_format_h's locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] fmt The formatter to use. + * @param[in] number The number to format. + * @param[out] result A pointer to a buffer to receive the NULL-terminated formatted number. + * If the formatted number fits into @a result but cannot be NULL-terminated (length == result_length) + * then the error code is set to #I18N_WARNING_STRING_NOT_TERMINATED. + * If the formatted number doesn't fit into result then the error code is set to #I18N_ERROR_BUFFER_OVERFLOW. + * @param[in] result_length The maximum size of @a result. + * @param[in,out] pos An #i18n_ufield_position_h handle. On input, position->field is read. + * On output, position->beginIndex and position->endIndex indicate the beginning and ending indices of field number position->field, if such a field exists. + * This parameter may be NULL, in which case no field + * + * @return The total buffer size needed; if greater than @a result_length, the output was truncated. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @exception #I18N_WARNING_STRING_NOT_TERMINATED If the formatted number fits into @a result but cannot be NULL-terminated (length == result_length) + * @exception #I18N_ERROR_BUFFER_OVERFLOW If the formatted number doesn't fit into the @a result buffer + */ +int32_t i18n_unumber_format_int64 (const i18n_unumber_format_h fmt, int64_t number, i18n_uchar *result, int32_t result_length, i18n_ufield_position_h pos); + +/** + * @brief Formats a double using an #i18n_unumber_format_h. + * @details The double will be formatted according to the #i18n_unumber_format_h's locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] fmt The formatter to use. + * @param[in] number The number to format. + * @param[out] result A pointer to a buffer to receive the NULL-terminated formatted number. + * If the formatted number fits into @a result but cannot be NULL-terminated (length == result_length) + * then the error code is set to #I18N_WARNING_STRING_NOT_TERMINATED. + * If the formatted number doesn't fit into result then the error code is set to #I18N_ERROR_BUFFER_OVERFLOW. + * @param[in] result_length The maximum size of @a result. + * @param[in,out] pos An #i18n_ufield_position_h handle. On input, position->field is read. + * On output, position->beginIndex and position->endIndex indicate the beginning + * and ending indices of field number position->field, if such a field exists. + * This parameter may be NULL, in which case no field + * + * @return The total buffer size needed; if greater than @a result_length, the output was truncated. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @exception #I18N_WARNING_STRING_NOT_TERMINATED If the formatted number fits into @a result but cannot be NULL-terminated (length == result_length) + * @exception #I18N_ERROR_BUFFER_OVERFLOW If the formatted number doesn't fit into the @a result buffer + */ +int32_t i18n_unumber_format_double (const i18n_unumber_format_h fmt, double number, i18n_uchar *result, int32_t result_length, i18n_ufield_position_h pos); + +/** + * @brief Formats a decimal number using an #i18n_unumber_format_h. + * @details The number will be formatted according to the #i18n_unumber_format_h's locale. The syntax of the input number + * is a "numeric string" as defined in the Decimal Arithmetic Specification, available at http://speleotrove.com/decimal + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] fmt The formatter to use. + * @param[in] number The number to format. + * @param[in] length The length of the input @a number, or -1 if the input is NULL-terminated. + * @param[out] result A pointer to a buffer to receive the NULL-terminated formatted number. + * If the formatted number fits into @a result but cannot be NULL-terminated (length == result_length) then + * the error code is set to #I18N_WARNING_STRING_NOT_TERMINATED. + * If the formatted number doesn't fit into result then the error code is set to + * #I18N_ERROR_BUFFER_OVERFLOW. + * @param[in] result_length The maximum size of @a result. + * @param[in,out] pos An #i18n_ufield_position_h handle. On input, position->field is read. + * On output, position->beginIndex and position->endIndex indicate the beginning and ending + * indices of field number position->field, if such a field exists. + * This parameter may be NULL, in which case it is ignored. + * + * @return The total buffer size needed; if greater than @a result_length, the output was truncated. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @exception #I18N_WARNING_STRING_NOT_TERMINATED If the formatted number fits into @a result but cannot be NULL-terminated (length == result_length) + * @exception #I18N_ERROR_BUFFER_OVERFLOW If the formatted number doesn't fit into the @a result buffer + */ +int32_t i18n_unumber_format_decimal (const i18n_unumber_format_h fmt, const char *number, int32_t length, i18n_uchar *result, int32_t result_length, i18n_ufield_position_h pos); + +/** + * @brief Formats a double currency amount using an #i18n_unumber_format_h. + * @details The double will be formatted according to the #i18n_unumber_format_h's locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] fmt The formatter to use. + * @param[in] number The number to format. + * @param[in] currency The 3-letter NULL-terminated ISO 4217 currency code. + * @param[out] result A pointer to a buffer to receive the NULL-terminated formatted number. + * If the formatted number fits into @a result but cannot be NULL-terminated (length == result_length) + * then the error code is set to #I18N_WARNING_STRING_NOT_TERMINATED. + * If the formatted number doesn't fit into result then the error code is set to + * #I18N_ERROR_BUFFER_OVERFLOW. + * @param[in] result_length The maximum size of @a result. + * @param[in,out] pos An #i18n_ufield_position_h handle. On input, position->field is read. + * On output, position->beginIndex and position->endIndex indicate the beginning and ending indices + * of field number position->field, if such a field exists. + * This parameter may be NULL, in which case it is ignored. + * + * @return The total buffer size needed; if greater than @a result_length, the output was truncated. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @exception #I18N_WARNING_STRING_NOT_TERMINATED If the formatted number fits into @a result but cannot be NULL-terminated (length == result_length) + * @exception #I18N_ERROR_BUFFER_OVERFLOW If the formatted number doesn't fit into the @a result buffer + */ +int32_t i18n_unumber_format_double_currency (const i18n_unumber_format_h fmt, double number, i18n_uchar *currency, i18n_uchar *result, int32_t result_length, i18n_ufield_position_h pos); + +/** + * @brief Parses a string into an integer using an #i18n_unumber_format_h. + * @details The string will be parsed according to the #i18n_unumber_format_h's locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] fmt The formatter to use. + * @param[in] text The text to parse. + * @param[in] text_length The length of @a text, or -1 if NULL-terminated. + * @param[in,out] parse_pos If not NULL, on input a pointer to an integer specifying the offset at which to begin parsing. + * If not NULL, on output the offset at which parsing ended. + * + * @return The value of the parsed integer + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_unumber_parse (const i18n_unumber_format_h fmt, const i18n_uchar *text, int32_t text_length, int32_t *parse_pos); + +/** + * @brief Parses a string into an int64 using an #i18n_unumber_format_h. + * @details The string will be parsed according to the #i18n_unumber_format_h's locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] fmt The formatter to use. + * @param[in] text The text to parse. + * @param[in] text_length The length of @a text, or -1 if NULL-terminated. + * @param[in,out] parse_pos If not NULL, on input a pointer to an integer specifying the offset at which to begin parsing. + * If not NULL, on output the offset at which parsing ended. + * + * @return The value of the parsed integer + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int64_t i18n_unumber_parse_int64 (const i18n_unumber_format_h fmt, const i18n_uchar *text, int32_t text_length, int32_t *parse_pos); + +/** + * @brief Parses a string into a double using an #i18n_unumber_format_h. + * @details The string will be parsed according to the #i18n_unumber_format_h's locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] fmt The formatter to use. + * @param[in] text The text to parse. + * @param[out] text_length The length of @a text, or -1 if NULL-terminated. + * @param[in,out] parse_pos If not NULL, on input a pointer to an integer specifying the offset at which to begin parsing. + * If not NULL, on output the offset at which parsing ended. + * + * @return The value of the parsed double + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +double i18n_unumber_parse_double (const i18n_unumber_format_h fmt, const i18n_uchar *text, int32_t text_length, int32_t *parse_pos); + +/** + * @brief Parses a number from a string into an unformatted numeric string using an #i18n_unumber_format_h. + * @details The input string will be parsed according to the #i18n_unumber_format_h's locale. + * The syntax of the output is a "numeric string" as defined in the Decimal Arithmetic Specification, available at + * http://speleotrove.com/decimal + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] fmt The formatter to use. + * @param[in] text The text to parse. + * @param[in] text_length The length of @a text, or -1 if NULL-terminated. + * @param[in,out] parse_pos If not NULL, on input a pointer to an integer specifying the offset at which to begin parsing. + * If not NULL, on output the offset at which parsing ended. + * @param[out] out_buf A (char *) buffer to receive the parsed number as a string. + * The output string will be NULL-terminated if there is sufficient space. + * @param[out] out_buf_length The size of the output buffer. May be zero, in which case the @a out_buf pointer may be NULL, + * and the function will return the size of the output string. + * + * @return The length of the output string, not including any terminating NULL. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_unumber_parse_decimal (const i18n_unumber_format_h fmt, const i18n_uchar *text, int32_t text_length, int32_t *parse_pos, char *out_buf, int32_t out_buf_length); + +/** + * @brief Parses a string into a double and a currency using an #i18n_unumber_format_h. + * @details The string will be parsed according to the #i18n_unumber_format_h's locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] fmt The formatter to use. + * @param[in] text The text to parse. + * @param[in] text_length The length of @a text, or -1 if NULL-terminated. + * @param[in,out] parse_pos A pointer to an offset index into text at which to begin parsing. On output, @a parse_pos will + * point after the last parsed character. This parameter may be NULL, in which case parsing begins + * at offset 0. + * If not NULL, on output the offset at which parsing ended. + * @param[out] currency A pointer to the buffer to receive the parsed NULL- terminated currency. + * This buffer must have a capacity of at least 4 #i18n_uchar characters. + * + * @return The parsed double + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +double i18n_unumber_parse_double_currency (const i18n_unumber_format_h fmt, const i18n_uchar *text, int32_t text_length, int32_t *parse_pos, i18n_uchar *currency); + +/** + * @brief Sets the pattern used by an #i18n_unumber_format_h. + * @details This can only be used on a DecimalFormat, other formats return #I18N_ERROR_NOT_SUPPORTED in the status. + * @remarks Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] format The formatter to set. + * @param[in] localized true if the pattern is localized, false otherwise. + * @param[in] pattern The new pattern + * @param[in] pattern_length The length of @a pattern, or -1 if NULL-terminated. + * @param[out] parse_error A pointer to #i18n_uparse_error_s to receive information about errors occurred during parsing, + * or NULL if no parse error information is desired. + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful. + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_unumber_apply_pattern (i18n_unumber_format_h format, i18n_ubool localized, const i18n_uchar *pattern, int32_t pattern_length, i18n_uparse_error_s* parse_error); + +/** + * @brief Gets a locale for which decimal formatting patterns are available. + * @details An #i18n_unumber_format_h in a locale returned by this function will perform the correct formatting and parsing for the locale. + * The results of this call are not valid for rule-based number formats. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] locale_index The index of the desired locale. + * + * @return A locale for which number formatting patterns are available, or 0 if none. + * + * @exception #I18N_ERROR_NONE Successful + */ +const char *i18n_unumber_get_available (int32_t locale_index); + +/** + * @brief Determines how many locales have decimal formatting patterns available. + * @details The results of this call are not valid for rule-based number formats. + * This function is useful for determining the loop ending condition for calls to i18n_unumber_get_available(). + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @return The number of locales for which decimal formatting patterns are available. + * + * @exception #I18N_ERROR_NONE Successful + */ +int32_t i18n_unumber_count_available (void); + +/** + * @brief Gets a numeric attribute associated with an #i18n_unumber_format_h. + * @details An example of a numeric attribute is the number of integer digits a formatter will produce. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] fmt The formatter to query. + * @param[in] attr The attribute to query; one of #I18N_UNUMBER_PARSE_INT_ONLY, #I18N_UNUMBER_GROUPING_USED, + * #I18N_UNUMBER_DECIMAL_ALWAYS_SHOWN, #I18N_UNUMBER_MAX_INTEGER_DIGITS, #I18N_UNUMBER_MIN_INTEGER_DIGITS, + * #I18N_UNUMBER_INTEGER_DIGITS, #I18N_UNUMBER_MAX_FRACTION_DIGITS, #I18N_UNUMBER_MIN_FRACTION_DIGITS, + * #I18N_UNUMBER_FRACTION_DIGITS, #I18N_UNUMBER_MULTIPLIER, #I18N_UNUMBER_GROUPING_SIZE, + * #I18N_UNUMBER_ROUNDING_MODE, #I18N_UNUMBER_FORMAT_WIDTH, #I18N_UNUMBER_PADDING_POSITION, + * #I18N_UNUMBER_SECONDARY_GROUPING_SIZE, #I18N_UNUM_SCALE. + * + * @return The value of @a attr or @c -1 if the given attribute is not supported. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_unumber_get_attribute (const i18n_unumber_format_h fmt, i18n_unumber_format_attribute_e attr); + +/** + * @brief Sets a numeric attribute associated with an #i18n_unumber_format_h. + * @details An example of a numeric attribute is the number of integer digits a formatter will produce. + * If the formatter does not understand the attribute, the call is ignored. Rule-based formatters only understand + * the lenient-parse attribute. The #I18N_UNUMBER_ROUNDING_INCREMENT attribute is not supported. + * @remarks Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] fmt The formatter to set. + * @param[in] attr The attribute to query; one of #I18N_UNUMBER_PARSE_INT_ONLY, #I18N_UNUMBER_GROUPING_USED, + * #I18N_UNUMBER_DECIMAL_ALWAYS_SHOWN, #I18N_UNUMBER_MAX_INTEGER_DIGITS, #I18N_UNUMBER_MIN_INTEGER_DIGITS, + * #I18N_UNUMBER_INTEGER_DIGITS, #I18N_UNUMBER_MAX_FRACTION_DIGITS, #I18N_UNUMBER_MIN_FRACTION_DIGITS, + * #I18N_UNUMBER_FRACTION_DIGITS, #I18N_UNUMBER_MULTIPLIER, #I18N_UNUMBER_GROUPING_SIZE, + * #I18N_UNUMBER_ROUNDING_MODE, #I18N_UNUMBER_FORMAT_WIDTH, #I18N_UNUMBER_PADDING_POSITION, + * #I18N_UNUMBER_SECONDARY_GROUPING_SIZE, #I18N_UNUMBER_SIGNIFICANT_DIGITS_USED, #I18N_UNUMBER_MIN_SIGNIFICANT_DIGITS, + * #I18N_UNUMBER_MAX_SIGNIFICANT_DIGITS, #I18N_UNUMBER_LENIENT_PARSE, #I18N_UNUM_SCALE, + * #I18N_UNUM_FORMAT_FAIL_IF_MORE_THAN_MAX_DIGITS, #I18N_UNUM_PARSE_NO_EXPONENT. + * @param[in] new_value The new value of @a attr. + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful. + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_unumber_set_attribute (i18n_unumber_format_h fmt, i18n_unumber_format_attribute_e attr, int32_t new_value); + +/** + * @brief Gets a numeric attribute associated with an #i18n_unumber_format_h. + * @details An example of a numeric attribute is the number of integer digits a formatter will produce. + * If the formatter does not understand the attribute, -1 is returned. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] fmt The formatter to query. + * @param[in] attr The attribute to query; only #I18N_UNUMBER_ROUNDING_INCREMENT is supported. + * + * @return The value of @a attr. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +double i18n_unumber_get_double_attribute (const i18n_unumber_format_h fmt, i18n_unumber_format_attribute_e attr); + +/** + * @brief Sets a numeric attribute associated with an #i18n_unumber_format_h. + * @details An example of a numeric attribute is the number of integer digits a formatter will produce. + * If the formatter does not understand the attribute, this call is ignored. + * @remarks Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] fmt The formatter to set. + * @param[in] attr The attribute to query; Only #I18N_UNUMBER_ROUNDING_INCREMENT is supported. + * @param[in] new_value The new value of @a attr. + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful. + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_unumber_set_double_attribute (i18n_unumber_format_h fmt, i18n_unumber_format_attribute_e attr, double new_value); + +/** + * @brief Gets a text attribute associated with an #i18n_unumber_format_h. + * @details An example of a text attribute is the suffix for positive numbers. If the formatter does not understand the attribute, + * #I18N_ERROR_NOT_SUPPORTED error code is set. + * Rule-based formatters only understand #I18N_UNUMBER_DEFAULT_RULESET and #I18N_UNUMBER_PUBLIC_RULESETS. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] fmt The formatter to query. + * @param[in] tag The attribute to query; one of #I18N_UNUMBER_POSITIVE_PREFIX, #I18N_UNUMBER_POSITIVE_SUFFIX, + * #I18N_UNUMBER_NEGATIVE_PREFIX, #I18N_UNUMBER_NEGATIVE_SUFFIX, #I18N_UNUMBER_PADDING_CHARACTER, + * #I18N_UNUMBER_CURRENCY_CODE, #I18N_UNUMBER_DEFAULT_RULESET, or #I18N_UNUMBER_PUBLIC_RULESETS. + * @param[out] result A pointer to a buffer to receive the attribute. + * @param[in] result_length The maximum size of @a result. + * + * @return The total buffer size needed; if greater than @a result_length, the output was truncated. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_unumber_get_text_attribute (const i18n_unumber_format_h fmt, i18n_unumber_format_text_attribute_e tag, i18n_uchar *result, int32_t result_length); + +/** + * @brief Sets a text attribute associated with an #i18n_unumber_format_h. + * @details An example of a text attribute is the suffix for positive numbers. Rule-based formatters only understand + * #I18N_UNUMBER_DEFAULT_RULESET. The #I18N_UNUMBER_PUBLIC_RULESETS tag is not supported. + * @remarks Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] fmt The formatter to set. + * @param[in] tag The attribute to set; one of #I18N_UNUMBER_POSITIVE_PREFIX, #I18N_UNUMBER_POSITIVE_SUFFIX, + * #I18N_UNUMBER_NEGATIVE_PREFIX, #I18N_UNUMBER_NEGATIVE_SUFFIX, #I18N_UNUMBER_PADDING_CHARACTER, + * #I18N_UNUMBER_CURRENCY_CODE, #I18N_UNUMBER_DEFAULT_RULESET. + * @param[in] new_value The new value of @a tag. + * @param[in] new_value_length The length of new_value, or -1 if NULL-terminated. + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful. + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_unumber_set_text_attribute (const i18n_unumber_format_h fmt, i18n_unumber_format_text_attribute_e tag, const i18n_uchar *new_value, int32_t new_value_length); + +/** + * @brief Extracts the pattern from an #i18n_unumber_format_h. + * @details The pattern will follow the DecimalFormat pattern syntax. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] fmt The formatter to query. + * @param[in] is_pattern_localized true if the pattern should be localized, false otherwise. + * This is ignored if the formatter is a rule-based formatter. + * @param[out] result A pointer to a buffer to receive the pattern. + * @param[in] result_length The maximum size of @a result. + * + * @return The total buffer size needed; if greater than @a result_length, the output was truncated. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_unumber_to_pattern (const i18n_unumber_format_h fmt, i18n_ubool is_pattern_localized, i18n_uchar *result, int32_t result_length); + +/** + * @brief Sets a symbol associated with an #i18n_unumber_format_h. + * @details An #i18n_unumber_format_h uses symbols to represent the special locale-dependent characters in a number, for example the percent sign. + * This API is not supported for rule-based formatters. + * @remarks Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] fmt The formatter to set. + * @param[in] symbol The #i18n_unumber_format_symbol_e constant for the symbol to set + * @param[in] value The string to set the symbol to + * @param[in] length The length of the input string, or -1 for a zero-terminated string + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful. + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_unumber_set_symbol (i18n_unumber_format_h fmt, i18n_unumber_format_symbol_e symbol, const i18n_uchar *value, int32_t length); + +/** + * @brief Gets the locale for this number format object. + * @details You can choose between valid and actual locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] fmt The formatter to get the locale from. + * @param[in] type Type of the locale we're looking for (valid or actual) + * + * @return The locale name + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +const char *i18n_unumber_get_locale_by_type (const i18n_unumber_format_h fmt, i18n_ulocale_data_locale_type_e type); + + +#ifdef __cplusplus +} +#endif + +/** + * @} + * @} + */ + +#endif /* __UTILS_I18N_UNUMBER_H__*/ diff --git a/src/include/mobile/utils_i18n_usearch.h b/src/include/mobile/utils_i18n_usearch.h new file mode 100755 index 0000000..a770cf6 --- /dev/null +++ b/src/include/mobile/utils_i18n_usearch.h @@ -0,0 +1,207 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +#ifndef __UTILS_I18N_USEARCH_H__ +#define __UTILS_I18N_USEARCH_H__ + +#include + +/** + * @file utils_i18n_usearch.h + * @version 0.1 + * @brief utils_i18n_usearch + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @ingroup CAPI_BASE_UTILS_I18N_MODULE + * @defgroup CAPI_BASE_UTILS_I18N_USEARCH_MODULE Usearch + * @brief The Usearch module provides language-sensitive text searching based on the comparison rules defined in a ucollator data struct. + * + * @section CAPI_BASE_UTILS_I18N_USEARCH_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_BASE_UTILS_I18N_USEARCH_MODULE_OVERVIEW Overview + * @details The Usearch module provides language-sensitive text searching based on the comparison rules defined in a ucollator data struct. + * + * @section CAPI_BASE_UTILS_I18N_USEARCH_MODULE_SAMPLE_CODE_1 Sample Code 1 + * @brief Searches the pattern and gets the matched text. + * @code + char *string = "TIZEN"; + char *keyword = "ZE"; + i18n_uchar target[16] = {0,}; + i18n_uchar pattern[16] = {0,}; + i18n_uchar u_matched[16] = {0,}; + char tmp[1] = {0}; + i18n_usearch_h search = NULL; + int pos = 0; + int matched_text_len = 0; + int i = 0; + i18n_error_code_e error_code; + + i18n_ustring_from_UTF8( target, 16, NULL, string, -1, &error_code ); + i18n_ustring_from_UTF8( pattern, 16, NULL, keyword, -1, &error_code ); + + // creates a search + i18n_usearch_create_new( pattern, -1, target, -1, "en_US", NULL, &search ); + + // gets the first index of the target that matches with the pattern + i18n_usearch_first( search, &pos ); + dlog_print(DLOG_INFO, LOG_TAG, "the first index = %d", pos ); // The first index = 2 + + // gets the matched text + i18n_usearch_get_matched_text( search, u_matched, 16, &matched_text_len ); + for ( i = 0; i < matched_text_len; i++) { + i18n_ustring_copy_au_n( tmp, &u_matched[i], 1 ); + dlog_print(DLOG_INFO, LOG_TAG, "u_matched[%d] = %c", i, tmp[0] ); // u_matched[0] = Z, u_matched[1] = E + } + i18n_usearch_destroy( search ); + * @endcode + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_USEARCH_MODULE + * @{ + */ + +/** + * @brief Creates an i18n_usearch_h using the argument locale language rule set. + * @details A collator will be created in the process, which will be owned by + * this search and will be deleted in i18n_usearch_destroy(). + * @remarks Must release @a search_iter using i18n_usearch_destroy(). + * @since_tizen 2.3 + * + * @deprecated Deprecated since 2.3.1. Use i18n_usearch_create_new() instead. + * + * @param[in] pattern The pattern for matching + * @param[in] pattern_len The length of the pattern, otherwise @c -1 for NULL-termination + * @param[in] text The text string + * @param[in] text_len The length of the text string, otherwise @c -1 for NULL-termination + * @param[in] locale The name of the locale for the rules to be used + * @param[in] break_iter An #i18n_ubreak_iterator_s that will be used to restrict the points at which matches are detected. If a match is found,\n + * but the match's start or end index is not a boundary as determined by the #i18n_ubreak_iterator_s, + * the match will be rejected and another will be searched for. If this parameter is @c NULL,\n + * no break detection is attempted. + * @param[out] search_iter The #i18n_usearch_h, otherwise @c NULL if there is an error + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_usearch_create ( const i18n_uchar *pattern, int32_t pattern_len, const i18n_uchar *text, int32_t text_len, const char *locale, i18n_ubreak_iterator_s *break_iter, i18n_usearch_h *search_iter ); + +/** + * @brief Creates an #i18n_usearch_h using the argument locale language rule set. + * @details A collator will be created in the process, which will be owned by + * this search and will be deleted in i18n_usearch_destroy(). + * @remarks Must release @a search_iter using i18n_usearch_destroy(). + * @since_tizen 2.3.1 + * + * @param[in] pattern The pattern for matching + * @param[in] pattern_len The length of the pattern, otherwise @c -1 for NULL-termination + * @param[in] text The text string + * @param[in] text_len The length of the text string, otherwise @c -1 for NULL-termination + * @param[in] locale The name of the locale for the rules to be used + * @param[in] break_iter An #i18n_ubreak_iterator_h that will be used to restrict the points at which matches are detected. If a match is found,\n + * but the match's start or end index is not a boundary as determined by the #i18n_ubreak_iterator_h, + * the match will be rejected and another will be searched for. If this parameter is @c NULL,\n + * no break detection is attempted. + * @param[out] search_iter The #i18n_usearch_h, otherwise @c NULL if there is an error + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_usearch_create_new ( const i18n_uchar *pattern, int32_t pattern_len, const i18n_uchar *text, + int32_t text_len, const char *locale, i18n_ubreak_iterator_h break_iter, i18n_usearch_h *search_iter); + +/** + * @brief Destroys and cleans up the i18n_usearch_h. + * @details If a collator is created in i18n_usearch_create(), it will be destroyed here. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] search_iter The i18n_usearch_h to clean up + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_usearch_destroy ( i18n_usearch_h search_iter ); + +/** + * @brief Returns the text that matches by the most recent call to i18n_usearch_first(), or so on. + * @details If the iterator is not pointing at a valid match (e.g. just after + * construction or after #I18N_USEARCH_DONE has been returned, it returns + * an empty string. If the result is not large enough to store the matched text, + * the result will be filled with the partial text and an #I18N_ERROR_BUFFER_OVERFLOW + * will be returned in status. The result will be NULL-terminated whenever + * possible. If the buffer fits the matched text exactly, a NULL-termination + * is not possible. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] search_iter The search iterator handle + * @param[out] result i18n_uchar The buffer to store the matched string + * @param[in] result_capacity The length of the result buffer + * @param[out] len_matched_text The exact length of the matched text, not counting the NULL-termination + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @retval #I18N_ERROR_BUFFER_OVERFLOW A result would not fit in the supplied buffer + */ +int i18n_usearch_get_matched_text ( const i18n_usearch_h search_iter, i18n_uchar *result, int32_t result_capacity, int32_t *len_matched_text ); + +/** + * @brief Gets the collator used for the language rules. + * @details Deleting the returned i18n_ucollator_h before calling + * i18n_usearch_destroy() would cause the string search to fail. + * i18n_usearch_destroy() will delete the collator if this search owns it. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] search_iter The search iterator handle + * @param[out] collator The collator + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_usearch_get_collator ( const i18n_usearch_h search_iter, i18n_ucollator_h *collator ); + +/** + * @brief Returns the first index at which the string text matches the search pattern. + * @details The iterator is adjusted so that its current index + * is the match position if one is found. + * If a match is not found, #I18N_USEARCH_DONE will be returned and + * the iterator will be adjusted to the index #I18N_USEARCH_DONE. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] search_iter The search iterator handle + * @param[out] index_first The character index of the first match, + * otherwise #I18N_USEARCH_DONE if there are no matches. + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_usearch_first ( i18n_usearch_h search_iter, int32_t *index_first ); + +#ifdef __cplusplus +} +#endif + +/** + * @} + * @} + */ + +#endif /* __UTILS_I18N_USEARCH_H__*/ diff --git a/src/include/mobile/utils_i18n_uset.h b/src/include/mobile/utils_i18n_uset.h new file mode 100755 index 0000000..6cf528e --- /dev/null +++ b/src/include/mobile/utils_i18n_uset.h @@ -0,0 +1,1175 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + * + * Copyright (C) 1999-2013, International Business Machines Corporation + * and others. All Rights Reserved. + */ + +#ifndef __UTILS_I18N_USET_PRODUCT_H__ +#define __UTILS_I18N_USET_PRODUCT_H__ + +#include + +/** + * @file utils_i18n_uset.h + * @version 0.1 + * @brief utils_i18n_uset + */ + + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @ingroup CAPI_BASE_UTILS_I18N_MODULE + * @defgroup CAPI_BASE_UTILS_I18N_USET_MODULE Uset + * @brief Uset module allows to specify a subset of character used in strings. + * + * @section CAPI_BASE_UTILS_I18N_USET_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_BASE_UTILS_I18N_USET_MODULE_OVERVIEW Overview + * @details Uset module allows to specify a subset of character used in strings. + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_USET_MODULE + * @{ + */ + +/** + * @brief Creates an empty #i18n_uset_h object. + * @details Equivalent to i18n_uset_create(1, 0). + * + * @since_tizen 2.3.1 + * @param[out] set A pointer to the newly created #i18n_uset_h. The caller must call i18n_uset_destroy() on + * it when done. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_uset_destroy() + */ +int i18n_uset_create_empty (i18n_uset_h *set); + +/** + * @brief Creates an #i18n_uset_h object that contains the range of characters + * start..end, inclusive. + * @details If start > end + * then an empty set is created (same as using i18n_uset_empty_create()). + * + * @since_tizen 2.3.1 + * @param[in] start First character of the range, inclusive + * @param[in] end Last character of the range, inclusive + * @param[out] set A pointer to the newly created #i18n_uset_h object. The caller must call i18n_uset_destroy() on + * it when done. + * * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_uset_destroy() + */ +int i18n_uset_create (i18n_uchar32 start, i18n_uchar32 end, i18n_uset_h *set); + +/** + * @brief Creates a set based on a given pattern. + * @details See the UnicodeSet class description for the syntax + * of the pattern language. + * + * @since_tizen 2.3.1 + * @param[in] pattern A string specifying what characters are in the set + * @param[in] pattern_length The length of the pattern, >= 0, or -1 if NULL-terminated. + * @param[out] set A pointer to the newly created #i18n_uset_h object. The caller must call i18n_uset_destroy() on + * it when done. + * * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_uset_destroy() + */ +int i18n_uset_create_pattern (const i18n_uchar *pattern, int32_t pattern_length, i18n_uset_h *set); + +/** + * @brief Creates a set based on a given pattern. + * @details See the UnicodeSet class description for the syntax of the pattern language. + * + * @since_tizen 2.3.1 + * @param[in] pattern A string specifying what characters are in the set + * @param[in] pattern_length The length of the pattern, >= 0, or -1 if NULL-terminated + * @param[in] options Bitmask for options to apply to the pattern. + * Valid options are #I18N_USET_IGNORE_SPACE and #I18N_USET_CASE_INSENSITIVE. + * @param[out] set A pointer to the newly created #i18n_uset_h object. The caller must call i18n_uset_destroy() on + * it when done. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_uset_destroy() + */ +int i18n_uset_create_pattern_options (const i18n_uchar *pattern, int32_t pattern_length, uint32_t options, i18n_uset_h *set); + +/** + * @brief Disposes of the storage used by a #i18n_uset_h object. + * @details This function should be called exactly once for objects returned by i18n_uset_create(). + * @since_tizen 2.3.1 + * + * @param[in] set The object to dispose of + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_uset_destroy (i18n_uset_h set); + +/** + * @brief Returns a copy of this object. + * @details If this set is frozen, then the clone will be frozen as well. + * Uses i18n_uset_clone_as_thawed() for a mutable clone of a frozen set. + * + * @since_tizen 2.3.1 + * @param[in] set The original set. Must not be @c NULL. + * @param[out] set_clone The newly allocated copy of the set + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_uset_clone_as_thawed() + */ +int i18n_uset_clone (const i18n_uset_h set, i18n_uset_h *set_clone); + +/** + * @brief Determines whether the set has been frozen (made immutable) or not. + * @details See the ICU4J Freezable interface for details. + * + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * + * @since_tizen 2.3.1 + * @param[in] set The set. Must not be @c NULL. + * @return true/false for whether the set has been frozen + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_uset_freeze() + * @see i18n_uset_clone_as_thawed() + */ +i18n_ubool i18n_uset_is_frozen (const i18n_uset_h set); + +/** + * @brief Freezes the set (make it immutable). + * @details Once frozen, it cannot be unfrozen and is therefore thread-safe + * until it is deleted. + * See the ICU4J Freezable interface for details. + * Freezing the set may also make some operations faster, for example + * i18n_uset_contains() and i18n_uset_span(). + * A frozen set will not be modified. (It remains frozen.) + * + * @since_tizen 2.3.1 + * @param[in] set The set. Must not be @c NULL. + * @return the same set, now frozen + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_uset_is_frozen() + * @see i18n_uset_clone_as_thawed() + */ +int i18n_uset_freeze (i18n_uset_h set); + +/** + * @brief Clones the set and make the clone mutable. + * @details See the ICU4J Freezable interface for details. + * @since_tizen 2.3.1 + * + * @param[in] set The set. Must not be @c NULL. + * @param[out] set_copy The mutable clone + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_uset_freeze() + * @see i18n_uset_is_frozen() + * @see i18n_uset_clone() + */ +int i18n_uset_clone_as_thawed (const i18n_uset_h set, i18n_uset_h *set_copy); + +/** + * @brief Causes the #i18n_uset_h object to represent the range start - end. + * @details If start > end then this #i18n_uset_h is set to an empty range. + * A frozen set will not be modified. + * + * @since_tizen 2.3.1 + * @param[in] set The object to set to the given range. Must not be @c NULL. + * @param[in] start First character in the set, inclusive + * @param[in] end Last character in the set, inclusive + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_uset_set (i18n_uset_h set, i18n_uchar32 start, i18n_uchar32 end); + +/** + * @brief Modifies the set to represent the set specified by the given + * pattern. + * @details See the UnicodeSet class description for the syntax of + * the pattern language. See also the User Guide chapter about UnicodeSet. + * Empties the set passed before applying the pattern. + * A frozen set will not be modified. + * + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and in #i18n_error_code_e description. + * + * @since_tizen 2.3.1 + * @param[in] set The set to which the pattern is to be applied. Must not be @c NULL. + * @param[in] pattern A pointer to #i18n_uchar string specifying what characters are in the set. + * The character at pattern[0] must be a '['. + * @param[in] pattern_length The length of the #i18n_uchar string, >= 0, or -1 if NULL terminated. + * @param[in] options A bitmask for options to apply to the pattern. + * Valid options are #I18N_USET_IGNORE_SPACE and #I18N_USET_CASE_INSENSITIVE. + * @return Upon successful parse, the value is either + * the index of the character after the closing ']' + * of the parsed pattern. + * If the status code indicates failure, then the return value + * is the index of the error in the source. + * If @a set is NULL, 0 is returned. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_uset_apply_pattern (i18n_uset_h set, const i18n_uchar *pattern, int32_t pattern_length, uint32_t options); + +/** + * @brief Modifies the set to contain those code points which have the given value + * for the given binary or enumerated property, as returned by + * i18n_uchar_get_int_property_value(). + * @details Prior contents of this set are lost. + * A frozen set will not be modified. + * + * @since_tizen 2.3.1 + * @param[in] set The object to contain the code points defined by the property. Must not be @c NULL. + * @param[in] prop A property in the range #I18N_UCHAR_INT_START..#I18N_UCHAR_INT_LIMIT-1 + * or #I18N_UCHAR_MASK_START..#I18N_UCHAR_MASK_LIMIT-1. + * @param[in] value A value in the range i18n_uchar_get_int_property_min_value(prop).. + * i18n_uchar_get_int_property_max_value(prop), with one exception. If prop is + * #I18N_UCHAR_GENERAL_CATEGORY_MASK, then value should not be a #i18n_uchar_category_e, but + * rather a mask value produced by I18N_U_GET_GC_MASK(). This allows grouped + * categories such as [:L:] to be represented. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_uset_apply_int_property_value (i18n_uset_h set, i18n_uchar_uproperty_e prop, int32_t value); + +/** + * @brief Modifies the set to contain those code points which have the + * given value for the given property. + * @details Prior contents of this set are lost. A frozen set will not be modified. + * @since_tizen 2.3.1 + * + * @param[in] set The object to contain the code points defined by the given + * property and value alias. Must not be @c NULL. + * @param[in] prop A string specifying a property alias, either short or long. + * The name is matched loosely. See PropertyAliases.txt for names and a + * description of loose matching. If the value string is empty, then this + * string is interpreted as either a General_Category value alias, a Script + * value alias, a binary property alias, or a special ID. Special IDs are + * matched loosely and correspond to the following sets: + * + * "ANY" = [\\u0000-\\U0010FFFF], + * "ASCII" = [\\u0000-\\u007F], + * "Assigned" = [:^Cn:]. + * + * @param[in] prop_length The length of the @a prop, >= 0, or @c -1 if @c NULL. + * @param[in] value A string specifying a value alias, either short or long. + * The name is matched loosely. See PropertyValueAliases.txt for names + * and a description of loose matching. In addition to aliases listed, + * numeric values and canonical combining classes may be expressed + * numerically, e.g., ("nv", "0.5") or ("ccc", "220"). The value string + * may also be empty. + * @param[in] value_length The length of the value, >= 0, or -1 if NULL. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_uset_apply_property_alias (i18n_uset_h set, const i18n_uchar *prop, int32_t prop_length, const i18n_uchar *value, int32_t value_length); + +/** + * @brief Return true if the given position, in the given pattern, appears + * to be the start of a UnicodeSet pattern. + * @since_tizen 2.3.1 + * + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * + * @param[in] pattern A string specifying the pattern. + * @param[in] pattern_length The length of the pattern, >= 0, or @c -1 if @c NULL. + * @param[in] pos The given position, >= 0. + * + * @return @c true if the given position, in the given pattern, appears to be the start of a UnicodeSet pattern. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_ubool i18n_uset_resembles_pattern (const i18n_uchar *pattern, int32_t pattern_length, int32_t pos); + +/** + * @brief Returns a string representation of the given @a set. + * @details If the result of calling this function is passed to an i18n_uset_pattern_create(), + * it will produce another set that is equal to this one. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] set The set. Must not be @c NULL. + * @param[in,out] result The string to receive the rules, may be @c NULL. + * @param[in] result_capacity The capacity of @a result, >= 0, may be @c 0 if result is @c NULL. + * @param[in] escape_unprintable If true then convert unprintable character to their hex escape representations, + * \\uxxxx or \\Uxxxxxxxx. Unprintable characters are those other than U+000A, U+0020..U+007E. + * + * @return Length of string, >= 0, possibly larger than @a result_capacity. If @a set is NULL, 0 is returned. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_uset_pattern_create() + */ +int32_t i18n_uset_to_pattern (const i18n_uset_h set, i18n_uchar *result, int32_t result_capacity, i18n_ubool escape_unprintable); + +/** + * @brief Adds the given character to the given #i18n_uset_h. + * @details After this call, i18n_uset_contains(set, character) will return true. + * A frozen set will not be modified. + * @since_tizen 2.3.1 + * + * @param[in] set The object to which to add the @a character. Must not be @c NULL. + * @param[in] character The character to add. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_uset_contains() + */ +int i18n_uset_add (i18n_uset_h set, i18n_uchar32 character); + + +/** + * @brief Adds all of the elements in the specified set to this set if + * they are not already present. + * @details This operation effectively modifies this set so that its value is the union of the two + * sets. The behavior of this operation is unspecified if the specified + * collection is modified while the operation is in progress. + * A frozen set will not be modified. + * + * @since_tizen 2.3.1 + * @param[in] set The object to which to add the set. Must not be @c NULL. + * @param[in] additional_set The source set whose elements are to be added to this set. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_uset_add_all (i18n_uset_h set, const i18n_uset_h additional_set); + +/** + * @brief Adds the given range of characters to the given #i18n_uset_h. After this call, + * i18n_uset_contains(set, start, end) will return true. + * A frozen set will not be modified. + * + * @since_tizen 2.3.1 + * @param[in] set The object to which to add the character. Must not be @c NULL. + * @param[in] start The first character of the range to add, inclusive + * @param[in] end The last character of the range to add, inclusive + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_uset_contains() + */ +int i18n_uset_add_range (i18n_uset_h set, i18n_uchar32 start, i18n_uchar32 end); + +/** + * @brief Adds the given string to the given #i18n_uset_h. + * @details After this call, i18n_uset_contains_string(set, str, str_len) will return true. + * A frozen set will not be modified. + * + * @since_tizen 2.3.1 + * @param[in] set The object to which to add the character. Must not be @c NULL. + * @param[in] str The string to add. + * @param[in] str_len The length of the string, >= 0, or -1 if NULL terminated. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_uset_contains_string() + */ +int i18n_uset_add_string (i18n_uset_h set, const i18n_uchar *str, int32_t str_len); + +/** + * @brief Adds each of the characters in this string to the set. Thus "ch" => {"c", "h"} + * @details If this set already any particular character, it has no effect on that character. + * A frozen set will not be modified. + * + * @since_tizen 2.3.1 + * @param[in] set The object to which to add the character. Must not be @c NULL. + * @param[in] str The source string. + * @param[in] str_len The length of the string, >= 0, or -1 if NULL terminated. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_uset_add_all_code_points (i18n_uset_h set, const i18n_uchar *str, int32_t str_len); + +/** + * @brief Removes the given @a character from the given #i18n_uset_h. + * @details After this call, i18n_uset_contains(set, character) will return @c false. + * A frozen set will not be modified. + * @since_tizen 2.3.1 + * + * @param[in] set the object from which to remove the @a character. Must not be @c NULL. + * @param[in] character the character to remove + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_uset_contains() + */ +int i18n_uset_remove (i18n_uset_h set, i18n_uchar32 character); + +/** + * @brief Removes the given range of characters from the given #i18n_uset_h. + * @details After this call, i18n_uset_contains(set, start, end) will return false. + * A frozen set will not be modified. + * + * @since_tizen 2.3.1 + * @param[in] set The object to which to add the character. Must not be @c NULL. + * @param[in] start The first character of the range to remove, inclusive + * @param[in] end The last character of the range to remove, inclusive + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_uset_contains() + */ +int i18n_uset_remove_range (i18n_uset_h set, i18n_uchar32 start, i18n_uchar32 end); + +/** + * @brief Removes the given string to the given #i18n_uset_h. + * @details After this call, i18n_uset_contains_string(set, str, str_len) will return false. + * A frozen set will not be modified. + * + * @since_tizen 2.3.1 + * @param[in] set The object to which to add the character. Must not be @c NULL. + * @param[in] str The string to remove. + * @param[in] str_len The length of the string, >= 0, or -1 if NULL terminated. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_uset_contains_string() + */ +int i18n_uset_remove_string (i18n_uset_h set, const i18n_uchar *str, int32_t str_len); + +/** + * @brief Removes from this set all of its elements that are contained in the specified set. + * @details This operation effectively modifies this set so that its value is the asymmetric set difference of + * the two sets. + * A frozen set will not be modified. + * + * @since_tizen 2.3.1 + * @param[in] set The object from which the elements are to be removed. Must not be @c NULL. + * @param[in] remove_set The object that defines which elements will be + * removed from this set. Must not be @c NULL. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_uset_remove_all (i18n_uset_h set, const i18n_uset_h remove_set); + +/** + * @brief Retains only the elements in this set that are contained in the specified range. + * @details If start > end then an empty range is retained, leaving the set empty. This is equivalent to + * a boolean logic AND, or a set INTERSECTION. + * A frozen set will not be modified. + * + * @since_tizen 2.3.1 + * @param[in] set The object for which to retain only the specified range. Must not be @c NULL. + * @param[in] start First character, inclusive, of range to be retained + * to this set. + * @param[in] end Last character, inclusive, of range to be retained + * to this set. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_uset_retain (i18n_uset_h set, i18n_uchar32 start, i18n_uchar32 end); + +/** + * @brief Retains only the elements in this set that are contained in the + * specified set. + * @details In other words, removes from this set all of + * its elements that are not contained in the specified set. This + * operation effectively modifies this set so that its value is + * the intersection of the two sets. + * A frozen set will not be modified. + * + * @since_tizen 2.3.1 + * @param[in] set The object on which to perform the retain. Must not be @c NULL. + * @param[in] retain Set that defines which elements this set will retain. Must not be @c NULL. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_uset_retain_all (i18n_uset_h set, const i18n_uset_h retain); + +/** + * @brief Reallocates this objects internal structures to take up the least + * possible space, without changing this object's value. + * + * @details A frozen set will not be modified. + * @since_tizen 2.3.1 + * @param[in] set The object on which to perfrom the compact. Must not be @c NULL. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_uset_compact (i18n_uset_h set); + +/** + * @brief Inverts this set. This operation modifies this set so that + * its value is its complement. + * @details This operation does not affect + * the multicharacter strings, if any. + * A frozen set will not be modified. + * + * @since_tizen 2.3.1 + * @param[in] set The set. Must not be @c NULL. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_uset_complement (i18n_uset_h set); + +/** + * @brief Complements in this set all elements contained in the specified set. + * @details Any character in the other set will be removed if it is + * in this set, or will be added if it is not in this set. + * A frozen set will not be modified. + * + * @since_tizen 2.3.1 + * @param[in] set The set with which to complement. Must not be @c NULL. + * @param[in] complement Set that defines which elements will be xor'ed + * from this set. Must not be @c NULL. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_uset_complement_all (i18n_uset_h set, const i18n_uset_h complement); + +/** + * @brief Removes all of the elements from this set. + * @details This set will be empty after this call returns. + * A frozen set will not be modified. + * + * @since_tizen 2.3.1 + * @param[in] set The set. Must not be @c NULL. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_uset_clear (i18n_uset_h set); + +/** + * @brief Closes this set over the given attribute. + * @details For the attribute + * #I18N_USET_CASE_INSENSITIVE, the result is to modify this set so that: + * + * 1. For each character or string 'a' in this set, all strings or + * characters 'b' such that foldCase(a) == foldCase(b) are added + * to this set. + * + * 2. For each string 'e' in the resulting set, if e != + * foldCase(e), 'e' will be removed. + * + * Example: [aq\\u00DF{Bc}{bC}{Fi}] => [aAqQ\\u00DF\\uFB01{ss}{bc}{fi}] + * + * (Here foldCase(x) refers to the operation i18n_ustring_fold_case(), and a + * == b denotes that the contents are the same, not pointer + * comparison.) + * + * A frozen set will not be modified. + * + * @since_tizen 2.3.1 + * @param[in] set The set. Must not be @c NULL. + * @param[in] attributes Bitmask for attributes to close over. + * Currently only the #I18N_USET_CASE_INSENSITIVE bit is supported. Any undefined bits + * are ignored. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ustring_fold_case() + */ +int i18n_uset_destroy_over (i18n_uset_h set, int32_t attributes); + +/** + * @brief Removes all strings from this set. + * + * @since_tizen 2.3.1 + * @param[in] set The set. Must not be @c NULL. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_uset_remove_all_strings (i18n_uset_h set); + +/** + * @brief Returns true if the given #i18n_uset_h contains no characters and no + * strings. + * + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * + * @since_tizen 2.3.1 + * @param[in] set The set. Must not be @c NULL. + * @return true if set is empty + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_ubool i18n_uset_is_empty (const i18n_uset_h set); + +/** + * @brief Returns @c true if the given #i18n_uset_h contains the given @a character. + * @details This function works faster with a frozen set. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] set the set. Must not be @c NULL. + * @param[in] character the codepoint to check for within the @a set + * + * @return @c true if @a set contains the given @a character + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_ubool i18n_uset_contains (const i18n_uset_h set, i18n_uchar32 character); + +/** + * @brief Returns true if the given #i18n_uset_h contains all characters c + * where start <= c && c <= end. + * + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * + * @since_tizen 2.3.1 + * @param[in] set The set. Must not be @c NULL. + * @param[in] start The first character of the range to test, inclusive + * @param[in] end The last character of the range to test, inclusive + * @return true if set contains the range + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_ubool i18n_uset_contains_range (const i18n_uset_h set, i18n_uchar32 start, i18n_uchar32 end); + +/** + * @brief Returns true if the given #i18n_uset_h contains the given string. + * @since_tizen 2.3.1 + * + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * + * @param[in] set The set. Must not be @c NULL. + * @param[in] str The string. + * @param[in] str_len The length of the string, >= 0, or -1 if NULL terminated + * @return true if set contains str + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_ubool i18n_uset_contains_string (const i18n_uset_h set, const i18n_uchar *str, int32_t str_len); + +/** + * @brief Returns the index of the given @a character within this @a set, where + * the @a set is ordered by ascending code point. + * @details If the @a character is not in this @a set, return @c -1. + * The inverse of this function is i18n_uset_char_at(). + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] set the set. Must not be @c NULL. + * @param[in] character the character to obtain the index for + * + * @return An index from 0..size()-1, or @c -1 + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_uset_index_of (const i18n_uset_h set, i18n_uchar32 character); + +/** + * @brief Returns the character at the given index within this set, where + * the set is ordered by ascending code point. + * @details If the index is out of range, return (i18n_uchar32)-1. The inverse of this function is + * i18n_uset_index_of(). + * + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * + * @since_tizen 2.3.1 + * @param[in] set The set. Must not be @c NULL. + * @param[in] char_index An index from 0..size()-1 to obtain the char for + * @return The character at the given index, or (i18n_uchar32)-1. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_uchar32 i18n_uset_char_at (const i18n_uset_h set, int32_t char_index); + +/** + * @brief Returns the number of characters and strings contained in the given #i18n_uset_h. + * + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * + * @since_tizen 2.3.1 + * @param[in] set The set. Must not be @c NULL. + * @return A non-negative integer counting the characters and strings + * contained in set. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_uset_size (const i18n_uset_h set); + +/** + * @brief Returns the number of items in this set. + * @details An item is either a range of characters or a single multicharacter string. + * + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * + * @since_tizen 2.3.1 + * @param[in] set The set. Must not be @c NULL. + * @return A non-negative integer counting the character ranges + * and/or strings contained in set. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_uset_get_item_count (const i18n_uset_h set); + +/** + * @brief Returns an item of this set. + * @details An item is either a range of characters or a single multicharacter string. + * + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * + * @since_tizen 2.3.1 + * @param[in] set The set. Must not be @c NULL. + * @param[in] item_index A non-negative integer in the range [0; i18n_uset_get_item_count(set)-1]. + * @param[in] start Pointer to variable to receive first character + * in range, inclusive + * @param[in] end Pointer to variable to receive last character in range, + * inclusive + * @param[out] str Buffer to receive the string, may be NULL + * @param[in] str_capacity Capacity of @a str, or 0 if str is NULL + * @return The length of the string (>= 2), or 0 if the item is a + * range, in which case it is the range *start..*end, or -1 if + * item_index is out of range + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_uset_get_item (const i18n_uset_h set, int32_t item_index, i18n_uchar32 *start, i18n_uchar32 *end, i18n_uchar *str, int32_t str_capacity); + +/** + * @brief Returns true if set1 contains all the characters and strings of set2. It answers the question, 'Is set1 a superset of set2?' + * + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * + * @since_tizen 2.3.1 + * @param[in] set1 Set to be checked for containment. Must not be @c NULL. + * @param[in] set2 Set to be checked for containment. Must not be @c NULL. + * @return true if the test condition is met + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_ubool i18n_uset_contains_all (const i18n_uset_h set1, const i18n_uset_h set2); + +/** + * @brief Returns true if this set contains all the characters of the given string. + * @details This is does not check containment of grapheme + * clusters, like i18n_uset_contains_string(). + * + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * + * @since_tizen 2.3.1 + * @param[in] set Set of characters to be checked for containment. Must not be @c NULL. + * @param[in] str String containing codepoints to be checked for containment + * @param[in] str_len The length of the string, >= 0, or -1 if NULL terminated. + * @return true if the test condition is met. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_ubool i18n_uset_contains_all_code_points (const i18n_uset_h set, const i18n_uchar *str, int32_t str_len); + +/** + * @brief Returns true if set1 contains none of the characters and strings of set2. + * @details It answers the question, 'Is set1 a disjoint set of set2?' + * + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * + * @since_tizen 2.3.1 + * @param[in] set1 Set to be checked for containment. Must not be @c NULL. + * @param[in] set2 Set to be checked for containment. Must not be @c NULL. + * @return true if the test condition is met + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_ubool i18n_uset_contains_none (const i18n_uset_h set1, const i18n_uset_h set2); + +/** + * @brief Returns true if set1 contains some of the characters and strings of set2. + * @details It answers the question, 'Does set1 and set2 have an intersection?' + * + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * + * @since_tizen 2.3.1 + * @param[in] set1 Set to be checked for containment. Must not be @c NULL. + * @param[in] set2 Set to be checked for containment. Must not be @c NULL. + * @return true if the test condition is met + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_ubool i18n_uset_contains_some (const i18n_uset_h set1, const i18n_uset_h set2); + +/** + * @brief Returns the length of the initial substring of the input string which + * consists only of characters and strings that are contained in this set + * (#I18N_USET_SPAN_CONTAINED, #I18N_USET_SPAN_SIMPLE), + * or only of characters and strings that are not contained + * in this set (#I18N_USET_SPAN_NOT_CONTAINED). + * @details See #i18n_uset_span_condition_e for details. + * Similar to the strspn() C library function. + * Unpaired surrogates are treated according to contains() of their surrogate code points. + * This function works faster with a frozen set and with a non-negative string length argument. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] set the set. Must not be @c NULL. + * @param[in] str start of the input string. + * @param[in] length length of the @a string; >= 0, can be @c -1 for NULL-terminated + * @param[in] span_condition specifies the containment condition + * + * @return The length of the initial substring according to the @a span_condition; + * @c 0 if the start of the string does not fit the @a span_condition + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see #i18n_uset_span_condition_e + */ +int32_t i18n_uset_span (const i18n_uset_h set, const i18n_uchar *str, int32_t length, i18n_uset_span_condition_e span_condition); + +/** + * @brief Returns the start of the trailing substring of the input string which + * consists only of characters and strings that are contained in this set + * (#I18N_USET_SPAN_CONTAINED, #I18N_USET_SPAN_SIMPLE), + * or only of characters and strings that are not contained + * in this set (#I18N_USET_SPAN_NOT_CONTAINED). + * @details See #i18n_uset_span_condition_e for details. + * Unpaired surrogates are treated according to contains() of their surrogate code points. + * This function works faster with a frozen set and with a non-negative string length argument. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] set the set. Must not be @c NULL. + * @param[in] str start of the input string + * @param[in] length length of the @ string; >= 0, can be @c -1 for NULL-terminated + * @param[in] span_condition specifies the containment condition + * + * @return the start of the trailing substring according to the @a span_condition; + * the string length if the end of the string does not fit the @a span_condition + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see #i18n_uset_span_condition_e + */ +int32_t i18n_uset_span_back (const i18n_uset_h set, const i18n_uchar *str, int32_t length, i18n_uset_span_condition_e span_condition); + +/** + * @brief Returns the length of the initial substring of the input string which + * consists only of characters and strings that are contained in this set + * (#I18N_USET_SPAN_CONTAINED, #I18N_USET_SPAN_SIMPLE), + * or only of characters and strings that are not contained + * in this set (#I18N_USET_SPAN_NOT_CONTAINED). + * @details See #i18n_uset_span_condition_e for details. + * Similar to the strspn() C library function. + * Malformed byte sequences are treated according to contains(0xfffd). + * This function works faster with a frozen set and with a non-negative string length argument. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] set the set. Must not be @c NULL. + * @param[in] str start of the string (UTF-8) + * @param[in] length length of the string; >= 0, can be @c -1 for NULL-terminated + * @param[in] span_condition specifies the containment condition + * + * @return the length of the initial substring according to the @a span_condition; + * @c 0 if the start of the string does not fit the @a span_condition + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see #i18n_uset_span_condition_e + */ +int32_t i18n_uset_span_utf8 (const i18n_uset_h set, const char *str, int32_t length, i18n_uset_span_condition_e span_condition); + +/** + * @brief Returns the start of the trailing substring of the input string which + * consists only of characters and strings that are contained in this set + * (#I18N_USET_SPAN_CONTAINED, #I18N_USET_SPAN_SIMPLE), + * or only of characters and strings that are not contained + * in this set (#I18N_USET_SPAN_NOT_CONTAINED). + * @details See #i18n_uset_span_condition_e for details. + * Malformed byte sequences are treated according to contains(0xfffd). + * This function works faster with a frozen set and with a non-negative string length argument. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] set the set. Must not be @c NULL. + * @param[in] str start of the string (UTF-8) + * @param[in] length length of the string; >= 0, can be @c -1 for NULL-terminated + * @param[in] span_condition specifies the containment condition + * + * @return the start of the trailing substring according to the @a span_condition; + * the string length if the end of the string does not fit the @a span_condition + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see #i18n_uset_span_condition_e + */ +int32_t i18n_uset_span_back_utf8 (const i18n_uset_h set, const char *str, int32_t length, i18n_uset_span_condition_e span_condition); + +/** + * @brief Returns true if set1 contains all of the characters and strings + * of set2, and vice versa. It answers the question, 'Is set1 equal to set2?' + * + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * + * @since_tizen 2.3.1 + * @param[in] set1 Set to be checked for containment. Must not be @c NULL. + * @param[in] set2 Set to be checked for containment. Must not be @c NULL. + * @return true if the test condition is met + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_ubool i18n_uset_equals (const i18n_uset_h set1, const i18n_uset_h set2); + +/********************************************************************* + * Serialized set API + *********************************************************************/ + +/** + * @brief Serializes this @a set into an array of 16-bit integers. + * @details Serialization (currently) only records the characters in the set; + * multicharacter strings are ignored. + * + * The array has following format (each line is one 16-bit integer): + * + * length = (n+2*m) | (m!=0?0x8000:0) + * bmpLength = n; + * present if m!=0 + * bmp[0] + * bmp[1] + * ... + * bmp[n-1] + * supp-high[0] + * supp-low[0] + * supp-high[1] + * supp-low[1] + * ... + * supp-high[m-1] + * supp-low[m-1] + * + * The array starts with a header. After the header are n bmp + * code points, then m supplementary code points. Either n or m + * or both may be zero. n+2*m is always <= 0x7FFF. + * + * If there are no supplementary characters (if m==0) then the + * header is one 16-bit integer, 'length', with value n. + * + * If there are supplementary characters (if m!=0) then the header + * is two 16-bit integers. The first, 'length', has value + * (n+2*m)|0x8000. The second, 'bmpLength', has value n. + * + * After the header the code points are stored in ascending order. + * Supplementary code points are stored as most significant 16 + * bits followed by least significant 16 bits. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] set the set. Must not be @c NULL. + * @param[out] dest pointer to buffer of @a dest_capacity 16-bit integers + * May be NULL only if @a dest_capacity is zero. + * @param[in] dest_capacity size of @a dest, or zero + * Must not be negative. + * + * @return the total length of the serialized format, including + * the header, that is, n+2*m+(m != 0 ? 2 : 1), + * or @c 0 on error other than #I18N_ERROR_BUFFER_OVERFLOW. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @exception #I18N_ERROR_INDEX_OUTOFBOUNDS If n+2*m > 0x7FFF + * @exception #I18N_ERROR_BUFFER_OVERFLOW If n+2*m+(m != 0 ? 2 : 1) > dest_capacity. + */ +int32_t i18n_uset_serialize (const i18n_uset_h set, uint16_t *dest, int32_t dest_capacity); + +/** + * @brief Given a serialized array, fill in the given serialized set object. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] src pointer to start of array. Must not be @c NULL. + * @param[in] src_length length of @a src array, >= 0. + * @param[out] fill_set the serialized set to be filled + * + * @return @c true if the given array is valid, otherwise @c false + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see #i18n_userialized_set_s + */ +i18n_ubool i18n_uset_get_serialized_set (const uint16_t *src, int32_t src_length, i18n_userialized_set_s* fill_set); + +/** + * @brief Sets the #i18n_userialized_set_s to contain the given @a character (and nothing else). + * @since_tizen 2.3.1 + * + * @param[in] character the code point to set + * @param[out] fill_set the serialized set to be filled + * + * @return Error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see #i18n_userialized_set_s + */ +int i18n_uset_set_serialized_to_one (i18n_uchar32 character, i18n_userialized_set_s* fill_set); + +/** + * @brief Returns @c true if the given #i18n_userialized_set_s contains the given @a character. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] set the serialized set. Must not be @c NULL. + * @param[in] character the code point to check for within the @a set + * + * @return @c true if @a set contains @a character + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see #i18n_userialized_set_s + */ +i18n_ubool i18n_uset_serialized_contains (const i18n_userialized_set_s* set, i18n_uchar32 character); + +/** + * @brief Returns the number of disjoint ranges of characters contained in + * the given serialized set. + * @details Ignores any strings contained in the set. + * + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * + * @since_tizen 2.3.1 + * @param[in] set The serialized set. Must not be @c NULL. + * @return A non-negative integer counting the character ranges contained in set + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see #i18n_userialized_set_s + */ +int32_t i18n_uset_get_serialized_range_count (const i18n_userialized_set_s* set); + +/** + * @brief Returns a range of characters contained in the given serialized set. + * + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * + * @since_tizen 2.3.1 + * @param[in] set The serialized set. Must not be @c NULL. + * @param[in] range_index A non-negative integer in the range 0.. + * i18n_uset_get_serialized_range_count(set)-1 + * @param[out] p_start Pointer to variable to receive first character + * in range, inclusive + * @param[out] p_end Pointer to variable to receive last character in range, + * inclusive + * @return true if range_index is valid, otherwise false + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see #i18n_userialized_set_s + */ +i18n_ubool i18n_uset_get_serialized_range (const i18n_userialized_set_s* set, int32_t range_index, i18n_uchar32 *p_start, i18n_uchar32 *p_end); + +/** + * @} + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/include/mobile/utils_i18n_ustring.h b/src/include/mobile/utils_i18n_ustring.h new file mode 100644 index 0000000..d4bbc94 --- /dev/null +++ b/src/include/mobile/utils_i18n_ustring.h @@ -0,0 +1,1380 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + * + * Copyright (C) 1998-2012, International Business Machines + * Corporation and others. All Rights Reserved. + */ + +#ifndef __UTILS_I18N_USTRING_H__ +#define __UTILS_I18N_USTRING_H__ + +#include + +/** + * @file utils_i18n_ustring.h + * @version 0.1 + * @brief utils_i18n_ustring + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @ingroup CAPI_BASE_UTILS_I18N_MODULE + * @defgroup CAPI_BASE_UTILS_I18N_USTRING_MODULE Ustring + * @brief The Ustring module provides general unicode string handling information. + * + * @section CAPI_BASE_UTILS_I18N_USTRING_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_BASE_UTILS_I18N_USTRING_MODULE_OVERVIEW Overview + * @details The Ustring module provides general unicode string handling information. + * + * @section CAPI_BASE_UTILS_I18N_USTIRING_MODULE_SAMPLE_CODE_1 Sample Code 1 + * @brief It converts a byte string to a unicode string and then to uppercase letters. + * @code + char str_1[64] = {0,}; + i18n_uchar uchar_str_1[64] = {0,}; + i18n_uchar uchar_str_2[64] = {0,}; + int uchar_len = 0; + i18n_uerror_code_e err_code = I18N_ERROR_NONE; + + strcpy(str_1, "tizen"); + dlog_print(DLOG_INFO, LOG_TAG, "str_1 is %s\n", str_1); // str_1 is tizen + + // converts a byte string to a unicode string + i18n_ustring_copy_ua_n(uchar_str_1, str_1, strlen(str_1)); + + // converts to uppercase letters + i18n_ustring_to_upper(uchar_str_2, 64, uchar_str_1, i18n_ustring_get_length( uchar_str_1 ), "en_US", &err_code); + + i18n_ustring_copy_au(str_1, uchar_str_2); + dlog_print(DLOG_INFO, LOG_TAG, "str_1 is %s\n", str_1); // str_1 is TIZEN + * @endcode + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_USTRING_MODULE + * @{ + */ + +/** + * @brief Determines the length of an array of #i18n_uchar. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s The array of #i18n_uchar characters, @c NULL (U+0000) terminated. + * + * @return The number of #i18n_uchar characters in @c chars, minus the terminator + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ustring_get_length ( const i18n_uchar *s ); + +/** + * @brief Counts Unicode code points in the length #i18n_uchar code units of the string. + * @details A code point may occupy either one or two #i18n_uchar code units. + * Counting code points involves reading all code units. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s The input string. + * @param[in] length The number of #i18n_uchar code units to be checked, or @c -1 to count + * all code points before the first NULL (U+0000). + * + * @return The number of code points in the specified code units. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ustring_count_char32 ( const i18n_uchar *s, int32_t length ); + +/** + * @brief Checks if the string contains more Unicode code points than a certain number. + * @details This is more efficient than counting all code points in the entire string and comparing that number with a threshold. + * This function may not need to scan the string at all if the length is known (not @c -1 for NULL-termination) and falls within a certain range, + * and never needs to count more than 'number+1' code points. + * Logically equivalent to ( i18n_ustring_count_char32 (s, length, &number_of_code_points); number_of_code_points > number ). + * A Unicode code point may occupy either one or two #i18n_uchar code units. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s The input string. + * @param[in] length The length of the string, or @c -1 if it is NULL-terminated. + * @param[in] number The number of code points in the string is compared against the @a number parameter. + * + * @return Boolean value for whether the string contains more Unicode code points than @a number. Same as ( i18n_ustring_count_char32 (s, length, &number_of_code_points); number_of_code_points > number). + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_ubool i18n_ustring_has_more_char32_than ( const i18n_uchar *s, int32_t length, int32_t number ); + +/** + * @brief Concatenates two ustrings. + * @details Appends a copy of @a src, including the NULL terminator, to @a dest. + * The initial copied character from @a src overwrites the NULL terminator in @a dest. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest The destination string. + * @param[in] src The source string. + * + * @return A pointer to @a dest. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_uchar* i18n_ustring_cat ( i18n_uchar *dest, const i18n_uchar *src ); + +/** + * @brief Concatenate two ustrings. + * @details Appends a copy of @a src, including the NULL terminator, to @a dest. + * The initial copied character from @a src overwrites the NULL terminator in @a dest. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest The destination string. + * @param[in] src The source string. + * @param[in] n The maximum number of characters to append; no-op if <=0. + * + * @return A pointer to @a dest. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_uchar* i18n_ustring_cat_n ( i18n_uchar *dest, const i18n_uchar *src, int32_t n ); + +/** + * @brief Finds the first occurrence of a substring in a string. + * @details The substring is found at code point boundaries. That means that if the substring begins with a trail surrogate + * or ends with a lead surrogate, then it is found only if these surrogates stand alone in the text. + * Otherwise, the substring edge units would be matched against halves of surrogate pairs. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s The string to search (NULL-terminated). + * @param[in] sub_string The substring to find (NULL-terminated). + * + * @return A pointer to the first occurrence of @a sub_string in @a s, + * or @a s itself if the @a sub_string is empty, + * or @c NULL if @a sub_string is not in @a s. + * + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_ustring_r_string() + * @see i18n_ustring_find_first() + * @see i18n_ustring_find_last() + */ +i18n_uchar* i18n_ustring_string ( const i18n_uchar *s, const i18n_uchar *sub_string ); + +/** + * @brief Finds the first occurrence of a substring in a string. + * @details The substring is found at code point boundaries. That means that if the substring begins with a trail surrogate + * or ends with a lead surrogate, then it is found only if these surrogates stand alone in the text. + * Otherwise, the substring edge units would be matched against halves of surrogate pairs. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s The string to search (NULL-terminated). + * @param[in] length The length of @a s (number of #i18n_uchar characters), or @c -1 if it is NULL-terminated. + * @param[in] sub_string The substring to find (NULL-terminated). + * @param[in] sub_length The length of substring (number of #i18n_uchar characters), or @c -1 if it is NULL-terminated. + * + * @return A pointer to the first occurrence of @a sub_string in @a s, + * or @a s itself if the @a sub_string is empty, + * or @c NULL if @a sub_string is not in @a s. + * + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_ustring_string() + * @see i18n_ustring_find_last() + */ +i18n_uchar* i18n_ustring_find_first ( const i18n_uchar *s, int32_t length, const i18n_uchar *sub_string, int32_t sub_length ); + +/** + * @brief Finds the first occurrence of a BMP code point in a string. + * @details A surrogate code point is found only if its match in the text is not part of a surrogate pair. A NULL character is found at the string terminator. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s The string to search (NULL-terminated). + * @param[in] c The BMP code point to find. + * + * @return A pointer to the first occurrence of @a c in @a s + * or @c NULL if @a c is not in @a s. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ustring_char32() + * @see i18n_ustring_mem_char() + * @see i18n_ustring_string() + * @see i18n_ustring_find_first() + */ +i18n_uchar* i18n_ustring_char ( const i18n_uchar *s, i18n_uchar c ); + +/** + * @brief Finds the first occurrence of a code point in a string. + * @details A surrogate code point is found only if its match in the text is not part of a surrogate pair. A NULL character is found at the string terminator. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s The string to search (NULL-terminated). + * @param[in] c The code point to find. + * + * @return A pointer to the first occurrence of @a c in @a s + * or @c NULL if @a c is not in @a s. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ustring_char() + * @see i18n_ustring_mem_char32() + * @see i18n_ustring_string() + * @see i18n_ustring_find_first() + */ +i18n_uchar* i18n_ustring_char32 ( const i18n_uchar *s, i18n_uchar32 c ); + +/** + * @brief Finds the last occurrence of a substring in a string. + * @details The substring is found at code point boundaries. That means that if the substring begins with a trail surrogate + * or ends with a lead surrogate, then it is found only if these surrogates stand alone in the text. + * Otherwise, the substring edge units would be matched against halves of surrogate pairs. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s The string to search (NULL-terminated). + * @param[in] sub_string The substring to find (NULL-terminated). + * + * @return A pointer to the last occurrence of @a substring in @a s, + * or @a s itself if the @a sub_string is empty, + * or @c NULL if @a sub_string is not in @a s. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ustring_string() + * @see i18n_ustring_find_first() + * @see i18n_ustring_find_last() + */ +i18n_uchar* i18n_ustring_r_string ( const i18n_uchar *s, const i18n_uchar *sub_string ); + +/** + * @brief Finds the last occurrence of a substring in a string. + * @details The substring is found at code point boundaries. That means that if the substring begins with a trail surrogate + * or ends with a lead surrogate, then it is found only if these surrogates stand alone in the text. + * Otherwise, the substring edge units would be matched against halves of surrogate pairs. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s The string to search. + * @param[in] length The length of s (number of #i18n_uchar), or @c -1 if it is NULL-terminated. + * @param[in] sub_string The sub_string to find (NULL-terminated). + * @param[in] sub_length The length of sub_string (number of #i18n_uchar), or @c -1 if it is NULL-terminated. + * + * @return A pointer to the last occurrence of @a sub_string in @a s, + * or @a s itself if the @a substring is empty, + * or @c NULL if @a sub_string is not in @a s. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ustring_string() + * @see i18n_ustring_find_first() + */ +i18n_uchar* i18n_ustring_find_last( const i18n_uchar *s, int32_t length, const i18n_uchar *sub_string, int32_t sub_length ); + +/** + * @brief Finds the last occurrence of a BMP code point in a string. + * @details A surrogate code point is found only if its match in the text is not part of a surrogate pair. A NULL character is found at the string terminator. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s The string to search (NULL-terminated). + * @param[in] c The BMP code point to find. + * + * @return A pointer to the last occurrence of @a c in @a s + * or @c NULL if @a c is not in @a s. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ustring_char32() + * @see i18n_ustring_mem_char() + * @see i18n_ustring_string() + * @see i18n_ustring_find_first() + */ +i18n_uchar* i18n_ustring_r_char ( const i18n_uchar *s, i18n_uchar c ); + +/** + * @brief Finds the last occurrence of a code point in a string. + * @details A surrogate code point is found only if its match in the text is not part of a surrogate pair. A NULL character is found at the string terminator. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s The string to search (NULL-terminated). + * @param[in] c The code point to find. + * + * @return A pointer to the last occurrence of @a c in @a s + * or @c NULL if @a c is not in @a s. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ustring_char() + * @see i18n_ustring_mem_char32() + * @see i18n_ustring_string() + * @see i18n_ustring_find_first() + */ +i18n_uchar* i18n_ustring_r_char32 ( const i18n_uchar *s, i18n_uchar32 c ); + +/** + * @brief Locates the first occurrence in the string of any of the characters in the string matchSet. + * @details Works just like C's strpbrk but with Unicode. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] string The string in which to search, NULL-terminated. + * @param[in] match_set A NULL-terminated string defining a set of code points for which to search in the text string. + * + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @return A pointer to the character in @a string that matches one of the + * characters in @a match_set, or NULL if no such character is found. + */ +i18n_uchar* i18n_ustring_pbrk ( const i18n_uchar *string, const i18n_uchar *match_set ); + +/** + * @brief Returns the number of consecutive characters in string, beginning with the first, that do not occur somewhere in match_set. + * @details Works just like C's strcspn but with Unicode. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] string The string in which to search, NULL-terminated. + * @param[in] match_set A NULL-terminated string defining a set of code points for which to search in the text string. + * + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @return The number of initial characters in @a string that do not + * occur in @a match_set. + */ +int32_t i18n_ustring_cspn ( const i18n_uchar *string, const i18n_uchar *match_set ); + +/** + * @brief Returns the number of consecutive characters in string, beginning with the first, that occur somewhere in match_set. + * @details Works just like C's strspn but with Unicode. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] string The string in which to search, NULL-terminated. + * @param[in] match_set A NULL-terminated string defining a set of code points for which to search in the text string. + * @return The number of initial characters in @a string that do + * occur in @a match_set. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ustring_spn() + */ +int32_t i18n_ustring_spn ( const i18n_uchar *string, const i18n_uchar *match_set ); + +/** + * @brief The string tokenizer API allows an application to break a string into tokens. + * @details Works just like C's strspn but with Unicode. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] src String containing token(s). This string will be modified. After the first call to #i18n_ustring_tokenizer_r(), this argument must be NULL to get to the next token. + * @param[in] delim Set of delimiter characters (Unicode code points). + * @param[out] save_state The current pointer within the original string, which is set by this function. + * The save_state parameter should the address of a local variable of type #i18n_uchar *. + * @return A pointer to the next token found in src, or NULL + * when there are no more tokens. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_uchar* i18n_ustring_tokenizer_r ( i18n_uchar *src, const i18n_uchar *delim, i18n_uchar **save_state ); + +/** + * @brief Compares two Unicode strings for bitwise equality (code unit order). + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s1 A string to compare. + * @param[in] s2 A string to compare. + * @return 0 if @a s1 and @a s2 are bitwise equal; a negative + * value if @a s1 is bitwise less than @a s2; a positive + * value if @a s1 is bitwise greater than @a s2. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ustring_compare ( const i18n_uchar *s1, const i18n_uchar *s2 ); + +/** + * @brief Compare two Unicode strings in code point order. + * @details See #i18n_ustring_compare() for details. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s1 A string to compare. + * @param[in] s2 A string to compare. + * @return a negative/zero/positive integer corresponding to whether + * the first string is less than/equal to/greater than the second one + * in code point order + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ustring_compare_code_point_order( const i18n_uchar *s1, const i18n_uchar *s2 ); + +/** + * @brief Compare two Unicode strings (binary order). + * @details The comparison can be done in code unit order or in code point order. They differ only in UTF-16 when comparing supplementary code points + * (U+10000..U+10ffff) to BMP code points near the end of the BMP (i.e., U+e000..U+ffff). In code unit order, high BMP code points sort after + * supplementary code points because they are stored as pairs of surrogates which are at U+d800..U+dfff.\n + * This functions works with strings of different explicitly specified lengths unlike the ANSI C-like #i18n_ustring_compare() and #i18n_ustring_mem_compare() etc. + * NULL-terminated strings are possible with length arguments of -1. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s1 First source string. + * @param[in] length1 Length of first source string, or @c -1 if NULL-terminated. + * @param[in] s2 Second source string. + * @param[in] length2 Length of second source string, or @c -1 if NULL-terminated. + * @param[in] code_point_order Choose between code unit order (false) and code point order (true). + * @return < 0, 0 or > 0 as usual for string comparisons + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ustring_compare_binary_order( const i18n_uchar *s1, int32_t length1, const i18n_uchar *s2, int32_t length2, i18n_ubool code_point_order ); + +/** + * @brief Compare two strings case-insensitively using full case folding. + * @details The comparison can be done in UTF-16 code unit order or in code point order. They differ only when comparing + * supplementary code points (U+10000..U+10ffff) to BMP code points near the end of the BMP (i.e., U+e000..U+ffff). + * In code unit order, high BMP code points sort after supplementary code points because they are stored as pairs of surrogates which are at U+d800..U+dfff.\n + * This functions works with strings of different explicitly specified lengths unlike the ANSI C-like #i18n_ustring_compare() and i18n_ustring_mem_compare() etc. + * NULL-terminated strings are possible with length arguments of -1. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s1 First source string. + * @param[in] length1 Length of first source string, or @c -1 if NULL-terminated. + * @param[in] s2 Second source string. + * @param[in] length2 Length of second source string, or @c -1 if NULL-terminated. + * @param[in] options A bit set of options:\n + * - #I18N_USTRING_U_FOLD_CASE_DEFAULT or 0 is used for default options: Comparison in code unit order with default case folding.\n + * - #I18N_USTRING_U_COMPARE_CODE_POINT_ORDER Set to choose code point order instead of code unit order (see i18n_ustring_compare_code_pointer_order() for details).\n + * - #I18N_USTRING_U_FOLD_CASE_EXCLUDE_SPECIAL_I + * @param[out] error_code Must be a valid pointer to an error code value, + * which must not indicate a failure before the function call. + * @return <0 or 0 or >0 as usual for string comparisons + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ustring_case_compare_with_length( const i18n_uchar *s1, int32_t length1, const i18n_uchar *s2, int32_t length2, uint32_t options, i18n_error_code_e *error_code ); + +/** + * @brief Compare two ustrings for bitwise equality. + * @details Compares at most n characters. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s1 A string to compare (can be NULL/invalid if n<=0). + * @param[in] s2 A string to compare (can be NULL/invalid if n<=0). + * @param[in] n The maximum number of characters to compare; always returns 0 if n<=0. + * @return 0 if @a s1 and @a s2 are bitwise equal; a negative + * value if @a s1 is bitwise less than @a s2; a positive + * value if @a s1 is bitwise greater than @a s2. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ustring_compare_n( const i18n_uchar *s1, const i18n_uchar *s2, int32_t n ); + +/** + * @brief Compare two Unicode strings in code point order. + * @details This is different in UTF-16 from #i18n_ustring_compare_n() if supplementary characters are present. For details, see #i18n_ustring_compare_binary_order(). + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s1 A string to compare. + * @param[in] s2 A string to compare. + * @param[in] n The maximum number of characters to compare. + * @return a negative/zero/positive integer corresponding to whether + * the first string is less than/equal to/greater than the second one + * in code point order + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ustring_compare_n_code_point_order( const i18n_uchar *s1, const i18n_uchar *s2, int32_t n ); + +/** + * @brief Compare two strings case-insensitively using full case folding. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s1 A string to compare. + * @param[in] s2 A string to compare. + * @param[in] options bit set of options:\n + * - #I18N_USTRING_U_FOLD_CASE_DEFAULT or 0 is used for default options: Comparison in code unit order with default case folding. + * - #I18N_USTRING_U_COMPARE_CODE_POINT_ORDER Set to choose code point order instead of code unit order (see u_strCompare for details). + * - #I18N_USTRING_U_FOLD_CASE_EXCLUDE_SPECIAL_I + * @return A negative, zero, or positive integer indicating the comparison result. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ustring_case_compare( const i18n_uchar *s1, const i18n_uchar *s2, uint32_t options ); + +/** + * @brief Compare two strings case-insensitively using full case folding. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s1 A string to compare. + * @param[in] s2 A string to compare. + * @param[in] n The maximum number of characters each string to case-fold and then compare. + * @param[in] options A bit set of options:\n + * - #I18N_USTRING_U_FOLD_CASE_DEFAULT or 0 is used for default options: Comparison in code unit order with default case folding. + * - #I18N_USTRING_U_COMPARE_CODE_POINT_ORDER Set to choose code point order instead of code unit order (see u_strCompare for details). + * - #I18N_USTRING_U_FOLD_CASE_EXCLUDE_SPECIAL_I + * @return A negative, zero, or positive integer indicating the comparison result. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ustring_case_compare_n( const i18n_uchar *s1, const i18n_uchar *s2, int32_t n, uint32_t options ); + +/** + * @brief Compare two strings case-insensitively using full case folding. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s1 A string to compare. + * @param[in] s2 A string to compare. + * @param[in] length The number of characters in each string to case-fold and then compare. + * @param[in] options A bit set of options:\n + * - #I18N_USTRING_U_FOLD_CASE_DEFAULT or 0 is used for default options: Comparison in code unit order with default case folding. + * - #I18N_USTRING_U_COMPARE_CODE_POINT_ORDER Set to choose code point order instead of code unit order (see u_strCompare for details). + * - #I18N_USTRING_U_FOLD_CASE_EXCLUDE_SPECIAL_I + * @return A negative, zero, or positive integer indicating the comparison result. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ustring_mem_case_compare( const i18n_uchar *s1, const i18n_uchar *s2, int32_t length, uint32_t options ); + +/** + * @brief Copies a ustring. Adds a NULL terminator. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest The destination string + * @param[in] src The source string + * + * @return A pointer to @a dest. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_uchar* i18n_ustring_copy ( i18n_uchar *dest, const i18n_uchar *src ); + +/** + * @brief Copies a ustring. + * @details Copies at most @a n characters. The result will be NULL terminated + * if the length of @a src is less than @a n. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest The destination string + * @param[in] src The source string + * @param[in] n The maximum number of characters to copy + * + * @return A pointer to @a dest. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_uchar* i18n_ustring_copy_n ( i18n_uchar *dest, const i18n_uchar *src, int32_t n ); + +/** + * @brief Copies a byte string encoded in the default codepage to a ustring. + * @details Adds a NULL terminator. Performs a host byte to #i18n_uchar conversion. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest The destination string + * @param[in] src The source string + * + * @return A pointer to @a dest. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_uchar* i18n_ustring_copy_ua ( i18n_uchar *dest, const char *src ); + +/** + * @brief Copies a byte string encoded in the default codepage to a ustring. + * @details Copies at most @a n characters. The result will be NULL terminated + * if the length of @a src is less than @a n. + * Performs a host byte to #i18n_uchar conversion. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest The destination string + * @param[in] src The source string + * @param[in] n The maximum number of characters to copy + * + * @return A pointer to @a dest. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_uchar* i18n_ustring_copy_ua_n ( i18n_uchar *dest, const char *src, int32_t n ); + +/** + * @brief Copies a ustring to a byte string encoded in the default codepage. + * @details Adds a NULL terminator. Performs an #i18n_uchar to host byte conversion. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest The destination string + * @param[in] src The source string + * + * @return A pointer to @a dest. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +char* i18n_ustring_copy_au ( char *dest, const i18n_uchar *src ); + +/** + * @brief Copies a ustring to a byte string encoded in the default codepage. + * @details Copies at most @a n characters. The result will be NULL terminated + * if the length of @a src is less than @a n. + * Performs an #i18n_uchar to host byte conversion. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest The destination string + * @param[in] src The source string + * @param[in] n The maximum number of characters to copy + * + * @return A pointer to @a dest. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +char* i18n_ustring_copy_au_n ( char *dest, const i18n_uchar *src, int32_t n ); + +/** + * @brief Synonym for memcpy(), but with #i18n_uchar characters only. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest The destination string + * @param[in] src The source string (can be NULL/invalid if count<=0) + * @param[in] count The number of characters to copy; no-op if <=0 + * + * @return A pointer to @a dest + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_uchar* i18n_ustring_mem_copy ( i18n_uchar *dest, const i18n_uchar *src, int32_t count ); + +/** + * @brief Synonym for memmove(), but with #i18n_uchar characters only. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest The destination string + * @param[in] src The source string (can be NULL/invalid if count<=0) + * @param[in] count The number of characters to copy; no-op if <=0 + * + * @return A pointer to @a dest + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_uchar* i18n_ustring_mem_move ( i18n_uchar *dest, const i18n_uchar *src, int32_t count ); + +/** + * @brief Initialize count characters of dest to c. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest The destination string + * @param[in] c The character to initialize the string. + * @param[in] count The maximum number of characters to set. + * + * @return A pointer to @a dest. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_uchar* i18n_ustring_mem_set ( i18n_uchar *dest, const i18n_uchar c, int32_t count ); + +/** + * @brief Compare the first count #i18n_uchar characters of each buffer. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] buf1 The first string to compare. + * @param[in] buf2 The second string to compare. + * @param[in] count The maximum number of #i18n_uchar characters to compare. + * @return When buf1 < buf2, a negative number is returned. + * When buf1 == buf2, 0 is returned. + * When buf1 > buf2, a positive number is returned. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ustring_mem_compare ( const i18n_uchar *buf1, const i18n_uchar *buf2, int32_t count ); + +/** + * @brief Compare two Unicode strings in code point order. + * @details This is different in UTF-16 from #i18n_ustring_mem_compare() if supplementary characters are present. For details, see #i18n_ustring_compare_binary_order(). + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s1 A string to compare. + * @param[in] s2 A string to compare. + * @param[in] count The maximum number of characters to compare. + * @return a negative/zero/positive integer corresponding to whether + * the first string is less than/equal to/greater than the second one + * in code point order + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ustring_mem_compare_code_point_order ( const i18n_uchar *s1, const i18n_uchar *s2, int32_t count ); + +/** + * @brief Finds the first occurrence of a BMP code point in a string. + * @details A surrogate code point is found only if its match in the text is not part of a surrogate pair. A NULL character is found at the string terminator. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s The string to search (contains count #i18n_uchar characters). + * @param[in] c The BMP code point to find. + * @param[in] count The length of the string. + * @return A pointer to the first occurrence of @a c in @a s + * or @c NULL if @a c is not in @a s. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ustring_char() + * @see i18n_ustring_mem_char32() + * @see i18n_ustring_find_first() + */ +i18n_uchar* i18n_ustring_mem_char ( const i18n_uchar *s, i18n_uchar c, int32_t count ); + +/** + * @brief Finds the first occurrence of a code point in a string. + * @details A surrogate code point is found only if its match in the text is not part of a surrogate pair. A NULL character is found at the string terminator. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s The string to search (contains count #i18n_uchar characters). + * @param[in] c The code point to find. + * @param[in] count The length of the string. + * @return A pointer to the first occurrence of @a c in @a s + * or @c NULL if @a c is not in @a s. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_uchar* i18n_ustring_mem_char32 ( const i18n_uchar *s, i18n_uchar32 c, int32_t count ); + +/** + * @brief Finds the last occurrence of a BMP code point in a string. + * @details A surrogate code point is found only if its match in the text is not part of a surrogate pair. A NULL character is found at the string terminator. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s The string to search (contains count #i18n_uchar characters). + * @param[in] c The BMP code point to find. + * @param[in] count The length of the string. + * @return A pointer to the last occurrence of @a c in @a s + * or @c NULL if @a c is not in @a s. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see #i18n_ustring_r_char + * @see #i18n_ustring_mem_r_char32 + * @see #i18n_ustring_find_last + */ +i18n_uchar* i18n_ustring_mem_r_char ( const i18n_uchar *s, i18n_uchar c, int32_t count ); + +/** + * @brief Finds the last occurrence of a code point in a string. + * @details A surrogate code point is found only if its match in the text is not part of a surrogate pair. A NULL character is found at the string terminator. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s The string to search (contains count #i18n_uchar characters). + * @param[in] c The code point to find. + * @param[in] count The length of the string. + * @return A pointer to the last occurrence of @a c in @a s + * or @c NULL if @a c is not in @a s. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see #i18n_ustring_r_char32 + * @see #i18n_ustring_mem_r_char + * @see #i18n_ustring_find_last + */ +i18n_uchar* i18n_ustring_mem_r_char32 ( const i18n_uchar *s, i18n_uchar32 c, int32_t count ); + +/** + * @brief Unescape a string of characters and write the resulting Unicode characters to the destination buffer. + * @details The following escape sequences are recognized:\n + * \\uhhhh 4 hex digits; h in [0-9A-Fa-f] \\Uhhhhhhhh 8 hex digits \\xhh 1-2 hex digits \\x{h...} 1-8 hex digits \\ooo 1-3 octal digits; o in [0-7] \\cX control-X; X is masked with 0x1F\n + * as well as the standard ANSI C escapes:\n + * \\a => U+0007, \\b => U+0008, \\t => U+0009, \\n => U+000A, \\v => U+000B, \\f => U+000C, \\r => U+000D, \\e => U+001B, \\" => U+0022, \\' => U+0027, \\? => U+003F, \\\\ => U+005C\n + * Anything else following a backslash is generically escaped. For example, "[a\-z]" returns "[a-z]".\n + * If an escape sequence is ill-formed, this method returns an empty string. An example of an ill-formed sequence is "\\u" followed by fewer than 4 hex digits. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] src a zero-terminated string of invariant characters + * @param[in] dest pointer to buffer to receive converted and unescaped text and, if there is room, a zero terminator. May be NULL for preflighting, in which case no #i18n_uchar characters will be written, + * but the return value will still be valid. On error, an empty string is stored here (if possible). + * @param[in] dest_capacity the number of #i18n_uchar characters that may be written at dest. Ignored if dest == NULL. + * @return the length of unescaped string. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ustring_unescape_at() + */ +int32_t i18n_ustring_unescape ( const char *src, i18n_uchar *dest, int32_t dest_capacity ); + +/** + * @brief Unescape a single sequence. + * @details The character at offset-1 is assumed (without checking) to be a backslash. This method takes a callback pointer to a function that returns the #i18n_uchar at a given offset. + * By varying this callback, I18N functions are able to unescape char* strings, and UnicodeString objects.\n + * If offset is out of range, or if the escape sequence is ill-formed, (i18n_uchar32)0xFFFFFFFF is returned. + * See documentation of #i18n_ustring_unescape() for a list of recognized sequences. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] char_at callback function that returns a #i18n_uchar of the source text given an offset and a context pointer. + * @param[in] offset pointer to the offset that will be passed to char_at. The offset value will be updated upon return to point after the last parsed character of the escape sequence. + * On error the offset is unchanged. + * @param[in] length the number of #i18n_uchar characters that may be written at dest. Ignored if dest == NULL. + * @param[in] context an opaque pointer passed directly into char_at. + * + * @return the character represented by the escape sequence at + * offset, or (i18n_uchar32)0xFFFFFFFF on error. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ustring_unescape() + */ +i18n_uchar32 i18n_ustring_unescape_at ( i18n_ustring_unescape_char_at_cb char_at, int32_t *offset, int32_t length, void *context ); + +/** + * @brief Uppercases the characters in a string. + * @details Casing is locale-dependent and context-sensitive. + * The result may be longer or shorter than the original. + * The source string and the destination buffer are allowed to overlap. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest A buffer for the result string\n The result will be zero-terminated if + * the buffer is large enough. + * @param[in] dest_capacity The size of the buffer (number of #i18n_uchar characters)\n + * If it is @c 0, then @a dest may be @c NULL and the function will only return the length of the result + * without writing any of the result string. + * @param[in] src The original string + * @param[in] src_len The length of the original string\n + * If @c -1, then @a src must be zero-terminated. + * @param[in] locale The locale to consider, or "" for the root locale or @c NULL for the default locale. + * @param[out] error_code Must be a valid pointer to an error code value, + * which must not indicate a failure before the function call. + * @return The length of the result string. It may be greater than destCapacity. In that case, + * only some of the result was written to the destination buffer. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ustring_to_upper ( i18n_uchar *dest, int32_t dest_capacity, const i18n_uchar *src, int32_t src_len, const char *locale, i18n_error_code_e *error_code ); + +/** + * @brief Lowercase the characters in a string. + * @details Casing is locale-dependent and context-sensitive. The result may be longer or shorter than the original. The source string and the destination buffer are allowed to overlap. + * The result may be longer or shorter than the original. + * The source string and the destination buffer are allowed to overlap. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest A buffer for the result string. The result will be zero-terminated if the buffer is large enough. + * @param[in] dest_capacity The size of the buffer (number of #i18n_uchar characters)\n + * If it is 0, then dest may be NULL and the function will only return the length of the result without writing any of the result string. + * @param[in] src The original string + * @param[in] src_len The length of the original string.\n + * If @c -1, then @a src must be zero-terminated. + * @param[in] locale The locale to consider, or "" for the root locale or @c NULL for the default locale. + * @param[out] error_code Must be a valid pointer to an error code value, + * which must not indicate a failure before the function call. + * @return The length of the result string. It may be greater than destCapacity. In that case, + * only some of the result was written to the destination buffer. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ustring_to_lower ( i18n_uchar *dest, int32_t dest_capacity, const i18n_uchar *src, int32_t src_len, const char *locale, i18n_error_code_e *error_code ); + +/** + * @brief Titlecases a string. + * @details Casing is locale-dependent and context-sensitive. + * Titlecasing uses a break iterator to find the first characters of words + * that are to be titlecased. It titlecases those characters and lowercases + * all others. + * @remarks The titlecase break iterator can be provided to customize arbitrary + * styles, using rules and dictionaries beyond the standard iterators. + * It may be more efficient to always provide an iterator to avoid + * opening and closing one for each string. + * The standard titlecase iterator for the root locale implements the + * algorithm of Unicode TR 21.\n + * The result may be longer or shorter than the original. + * The source string and the destination buffer are allowed to overlap. + * @since_tizen 2.3 + * + * @deprecated Deprecated since 2.3.1. Use i18n_ustring_to_title_new() instead. + * + * @param[out] dest A buffer for the result string\n + * The result will be zero-terminated if the buffer is large enough. + * @param[in] dest_capacity The size of the buffer (number of #i18n_uchar characters)\n + * If it is @c 0, then @a dest may be @c NULL and the function will only return the length of the result + * without writing any of the result string. + * @param[in] src The original string + * @param[in] src_len The length of the original string.\n If @c -1, then @a src must be zero-terminated. + * @param[in] title_iter A break iterator to find the first characters of words + * that are to be titlecased\n + * If none are provided (NULL), then a standard titlecase + * break iterator is opened. + * @param[in] locale The locale to consider, or "" for the root locale or @c NULL for the default locale. + * @param[out] error_code Must be a valid pointer to an error code value, + * which must not indicate a failure before the function call. + * @return The length of the result string. It may be greater than destCapacity. In that case, + * only some of the result was written to the destination buffer. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ustring_to_title ( i18n_uchar *dest, int32_t dest_capacity, const i18n_uchar *src, int32_t src_len, i18n_ubreak_iterator_s *title_iter, + const char *locale, i18n_error_code_e *error_code ); + +/** + * @brief Titlecases a string. + * @details Casing is locale-dependent and context-sensitive. + * Titlecasing uses a break iterator to find the first characters of words + * that are to be titlecased. It titlecases those characters and lowercases + * all others. + * + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and in #i18n_error_code_e description. + * + * The titlecase break iterator can be provided to customize arbitrary + * styles, using rules and dictionaries beyond the standard iterators. + * It may be more efficient to always provide an iterator to avoid + * opening and closing one for each string. + * The standard titlecase iterator for the root locale implements the + * algorithm of Unicode TR 21.\n + * The result may be longer or shorter than the original. + * The source string and the destination buffer are allowed to overlap. + * @since_tizen 2.3.1 + * + * @param[out] dest A buffer for the result string.\n + * The result will be zero-terminated if the buffer is large enough. + * @param[in] dest_capacity The size of the buffer (number of #i18n_uchar characters.\n + * If it is @c 0, then @a dest may be @c NULL and the function will only return the length of the result + * without writing any of the result string. + * @param[in] src The original string + * @param[in] src_len The length of the original string.\n If @c -1, then @a src must be zero-terminated. + * @param[in] title_iter A break iterator to find the first characters of words + * that are to be titlecased.\n + * If none are provided (@c NULL), then a standard titlecase + * break iterator is opened. + * @param[in] locale The locale to consider, or "" for the root locale or @c NULL for the default locale. + * @return The length of the result string. It may be greater than dest_capacity. In that case, + * only some of the result were written to the destination buffer. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ustring_to_title() + */ +int32_t i18n_ustring_to_title_new ( i18n_uchar *dest, int32_t dest_capacity, const i18n_uchar *src, int32_t src_len, i18n_ubreak_iterator_h title_iter, const char *locale); + +/** + * @brief Case-folds the characters in a string. + * @details Case-folding is locale-independent and not context-sensitive, + * but there is an option for whether to include or exclude mappings for dotted I and dotless i.\n + * The result may be longer or shorter than the original. + * The source string and the destination buffer are allowed to overlap. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest A buffer for the result string\n + * The result will be zero-terminated if the buffer is large enough. + * @param[in] dest_capacity The size of the buffer (number of #i18n_uchar characters)\n + * If it is @c 0, then @a dest may be @c NULL and the function will only return the length of the result + * without writing any of the result string. + * @param[in] src The original string + * @param[in] src_len The length of the original string.\n If @c -1, then @a src must be zero-terminated. + * @param[in] options Either #I18N_USTRING_U_FOLD_CASE_DEFAULT or #I18N_USTRING_U_FOLD_CASE_EXCLUDE_SPECIAL_I + * @param[out] error_code Must be a valid pointer to an error code value, + * which must not indicate a failure before the function call. + * @return The length of the result string. It may be greater than destCapacity. In that case, + * only some of the result was written to the destination buffer. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ustring_fold_case ( i18n_uchar *dest, int32_t dest_capacity, const i18n_uchar *src, int32_t src_len, uint32_t options, i18n_error_code_e *error_code ); + +/** + * @brief Convert a UTF-16 string to a wchar_t string. + * @details If it is known at compile time that wchar_t strings are in UTF-16 or UTF-32, then this function simply calls the fast, dedicated function for that. + * Otherwise, two conversions UTF-16 -> default charset -> wchar_t* are performed. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest A buffer for the result string. The result will be zero-terminated if the buffer is large enough. + * @param[in] dest_capacity The size of the buffer (number of wchar_t's).\n + * If it is @c 0, then @a dest may be @c NULL and the function will only return the length of the result + * without writing any of the result string (pre-flighting). + * @param[out] dest_len A pointer to receive the number of units written to the destination.\n + * If dest_len!=NULL then *dest_len is always set to the number of output units corresponding to the transformation of all the input units, even in case of a buffer overflow. + * @param[in] src The original source string. + * @param[in] src_len The length of the original string.\n If @c -1, then @a src must be zero-terminated. + * @param[out] error_code Must be a valid pointer to an error code value, + * which must not indicate a failure before the function call. + * @return The pointer to destination buffer. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +wchar_t* i18n_ustring_to_WCS ( wchar_t *dest, int32_t dest_capacity, int32_t *dest_len, const i18n_uchar *src, int32_t src_len, i18n_error_code_e *error_code ); + +/** + * @brief Convert a wchar_t string to UTF-16. + * @details If it is known at compile time that wchar_t strings are in UTF-16 or UTF-32, then this function simply calls the fast, dedicated function for that. + * Otherwise, two conversions wchar_t* -> default charset -> UTF-16 are performed. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest A buffer for the result string. The result will be zero-terminated if the buffer is large enough. + * @param[in] dest_capacity The size of the buffer (number of #i18n_uchar characters).\n + * If it is @c 0, then @a dest may be @c NULL and the function will only return the length of the result + * without writing any of the result string (pre-flighting). + * @param[out] dest_len A pointer to receive the number of units written to the destination.\n + * If dest_len!=NULL then *dest_len is always set to the number of output units corresponding to the transformation of all the input units, even in case of a buffer overflow. + * @param[in] src The original source string. + * @param[in] src_len The length of the original string.\n If @c -1, then @a src must be zero-terminated. + * @param[out] error_code Must be a valid pointer to an error code value, + * which must not indicate a failure before the function call. + * @return The pointer to destination buffer. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_uchar* i18n_ustring_from_WCS ( i18n_uchar *dest, int32_t dest_capacity, int32_t *dest_len, const wchar_t *src, int32_t src_len, i18n_error_code_e *error_code ); + +/** + * @brief Converts a UTF-16 string to UTF-8. + * @details If the input string is not well-formed, then the #I18N_ERROR_INVALID_CHAR_FOUND error code is set. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest A buffer for the result string.\n + * The result will be zero-terminated if the buffer is large enough. + * @param[in] dest_capacity The size of the buffer (number of chars)\n + * If it is @c 0, then @a dest may be @c NULL and the function will only return the length of the + * result without writing any of the result string (pre-flighting). + * @param[out] dest_len A pointer to receive the number of units written to the destination.\n + * If dest_len!=NULL then *dest_len is always set to the + * number of output units corresponding to the transformation of + * all the input units, even in case of a buffer overflow. + * @param[in] src The original source string + * @param[in] src_len The length of the original string.\n + * If @c -1, then @a src must be zero-terminated. + * @param[out] error_code Must be a valid pointer to an error code value, + * which must not indicate a failure before the function call. + * @return The pointer to destination buffer. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ustring_from_UTF8() + */ +char* i18n_ustring_to_UTF8 ( char *dest, int32_t dest_capacity, int32_t *dest_len, const i18n_uchar *src, int32_t src_len, i18n_error_code_e *error_code ); + +/** + * @brief Converts a UTF-8 string to UTF-16. + * @details If the input string is not well-formed, then the #I18N_ERROR_INVALID_CHAR_FOUND error code is set. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest A buffer for the result string.\n + * The result will be zero-terminated if the buffer is large enough. + * @param[in] dest_capacity The size of the buffer (number of #i18n_uchar characters)\n + * If it is @c 0, then @a dest may be @c NULL and the function will only return the length of the + * result without writing any of the result string (pre-flighting). + * @param[out] dest_len A pointer to receive the number of units written to the destination.\n + * If dest_len!=NULL then *dest_len is always set to the + * number of output units corresponding to the transformation of + * all the input units, even in case of a buffer overflow. + * @param[in] src The original source string + * @param[in] src_len The length of the original string.\n + * If @c -1, then @a src must be zero-terminated. + * @param[out] error_code Must be a valid pointer to an error code value, + * which must not indicate a failure before the function call. + * @return The pointer to destination buffer. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_uchar* i18n_ustring_from_UTF8 ( i18n_uchar *dest, int32_t dest_capacity, int32_t *dest_len, const char *src, int32_t src_len, i18n_error_code_e *error_code ); + +/** + * @brief Convert a UTF-16 string to UTF-8. + * @details If the input string is not well-formed, then the #I18N_ERROR_INVALID_CHAR_FOUND error code is set. + * Same as #i18n_ustring_to_UTF8() except for the additional sub_char which is output for illegal input sequences, instead of stopping with the #I18N_ERROR_INVALID_CHAR_FOUND error code. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest A buffer for the result string.\n + * The result will be zero-terminated if the buffer is large enough. + * @param[in] dest_capacity The size of the buffer (number of chars)\n + * If it is @c 0, then @a dest may be @c NULL and the function will only return the length of the + * result without writing any of the result string (pre-flighting). + * @param[out] dest_len A pointer to receive the number of units written to the destination.\n + * If dest_len!=NULL then *dest_len is always set to the + * number of output units corresponding to the transformation of + * all the input units, even in case of a buffer overflow. + * @param[in] src The original source string + * @param[in] src_len The length of the original string.\n + * If @c -1, then @a src must be zero-terminated. + * @param[in] sub_char The substitution character to use in place of an illegal input sequence, or U_SENTINEL if the function is to return with #I18N_ERROR_INVALID_CHAR_FOUND instead. + * A substitution character can be any valid Unicode code point (up to U+10FFFF) except for surrogate code points (U+D800..U+DFFF). + * The recommended value is U+FFFD "REPLACEMENT CHARACTER". + * @param[out] num_substitutions Output parameter receiving the number of substitutions if sub_char>=0. Set to 0 if no substitutions occur or sub_char<0. num_substitutions can be NULL. + * @param[out] error_code Pointer to a standard ICU error code. Its input value must + * pass the U_SUCCESS() test, or else the function returns + * immediately. Check for U_FAILURE() on output or use with + * function chaining. (See User Guide for details.) + * @return The pointer to destination buffer. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ustring_to_UTF8() + * @see i18n_ustring_from_UTF8_with_sub() + */ +char* i18n_ustring_to_UTF8_with_sub ( char *dest, int32_t dest_capacity, int32_t *dest_len, const i18n_uchar *src, int32_t src_len, i18n_uchar32 sub_char, int32_t *num_substitutions, i18n_error_code_e *error_code ); + +/** + * @brief Convert a UTF-8 string to UTF-16. + * @details Same as #i18n_ustring_from_UTF8() except for the additional sub_char which is output for illegal input sequences, instead of stopping with the #I18N_ERROR_INVALID_CHAR_FOUND error code. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest A buffer for the result string.\n + * The result will be zero-terminated if the buffer is large enough. + * @param[in] dest_capacity The size of the buffer (number of #i18n_uchar characters)\n + * If it is @c 0, then @a dest may be @c NULL and the function will only return the length of the + * result without writing any of the result string (pre-flighting). + * @param[out] dest_len A pointer to receive the number of units written to the destination.\n + * If dest_len!=NULL then *dest_len is always set to the + * number of output units corresponding to the transformation of + * all the input units, even in case of a buffer overflow. + * @param[in] src The original source string + * @param[in] src_len The length of the original string.\n + * If @c -1, then @a src must be zero-terminated. + * @param[in] sub_char The substitution character to use in place of an illegal input sequence, or U_SENTINEL if the function is to return with #I18N_ERROR_INVALID_CHAR_FOUND instead. + * A substitution character can be any valid Unicode code point (up to U+10FFFF) except for surrogate code points (U+D800..U+DFFF). + * The recommended value is U+FFFD "REPLACEMENT CHARACTER". + * @param[out] num_substitutions Output parameter receiving the number of substitutions if sub_char>=0. Set to 0 if no substitutions occur or sub_char<0. num_substitutions can be NULL. + * @param[out] error_code Pointer to a standard ICU error code. Its input value must + * pass the U_SUCCESS() test, or else the function returns + * immediately. Check for U_FAILURE() on output or use with + * function chaining. (See User Guide for details.) + * @return The pointer to destination buffer. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ustring_from_UTF8() + * @see i18n_ustring_from_UTF8_lenient() + * @see i18n_ustring_to_UTF8_with_sub() + */ +i18n_uchar* i18n_ustring_from_UTF8_with_sub ( i18n_uchar *dest, int32_t dest_capacity, int32_t *dest_len, const char *src, int32_t src_len, i18n_uchar32 sub_char, + int32_t *num_substitutions, i18n_error_code_e *error_code ); + +/** + * @brief Convert a UTF-8 string to UTF-16. + * @details Same as i18n_ustring_from_UTF8() except that this function is designed to be very fast, which it achieves by being lenient about malformed UTF-8 sequences. + * This function is intended for use in environments where UTF-8 text is expected to be well-formed.\n + * Its semantics are: + * - Well-formed UTF-8 text is correctly converted to well-formed UTF-16 text.\n + * - The function will not read beyond the input string, nor write beyond the dest_capacity.\n + * - Malformed UTF-8 results in "garbage" 16-bit Unicode strings which may not be well-formed UTF-16. The function will resynchronize to valid code point boundaries within a small number of code points after an illegal sequence.\n + * - Non-shortest forms are not detected and will result in "spoofing" output.\n + * For further performance improvement, if src_len is given (>=0), then it must be dest_capacity>=src_len.\n + * There is no inverse i18n_ustring_to_UTF8_lenient() function because there is practically no performance gain from not checking that a UTF-16 string is well-formed. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest A buffer for the result string.\n + * The result will be zero-terminated if the buffer is large enough. + * @param[in] dest_capacity The size of the buffer (number of #i18n_uchar characters)\n + * If it is @c 0, then @a dest may be @c NULL and the function will only return the length of the + * result without writing any of the result string (pre-flighting). + * Unlike for other I18N functions, if src_len>=0 then it must be dest_capacity>=src_len. + * @param[out] dest_len A pointer to receive the number of units written to the destination.\n + * If dest_len!=NULL then *dest_len is always set to the number of output units corresponding + * to the transformation of all the input units, even in case of a buffer overflow. + * Unlike for other I18N functions, if src_len>=0 but dest_capacity=0. Set to 0 if no substitutions occur or sub_char<0. num_substitutions can be NULL. + * @param[out] error_code Pointer to a standard ICU error code. Its input value must + * pass the U_SUCCESS() test, or else the function returns + * immediately. Check for U_FAILURE() on output or use with + * function chaining. (See User Guide for details.) + * @return The pointer to destination buffer. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ustring_to_UTF32() + * @see i18n_ustring_from_UTF32_with_sub() + */ +i18n_uchar32* i18n_ustring_to_UTF32_with_sub ( i18n_uchar32 *dest, int32_t dest_capacity, int32_t *dest_len, const i18n_uchar *src, int32_t src_len, + i18n_uchar32 sub_char, int32_t *num_substitutions, i18n_error_code_e *error_code ); + +/** + * @brief Convert a UTF-32 string to UTF-16. + * @details If the input string is not well-formed, then the #I18N_ERROR_INVALID_CHAR_FOUND error code is set. + * Same as #i18n_ustring_from_UTF32() except for the additional sub_char which is output for illegal input sequences, instead of stopping with the #I18N_ERROR_INVALID_CHAR_FOUND error code. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest A buffer for the result string.\n + * The result will be zero-terminated if the buffer is large enough. + * @param[in] dest_capacity The size of the buffer (number of i18n_chars)\n + * If it is @c 0, then @a dest may be @c NULL and the function will only return the length of the + * result without writing any of the result string (pre-flighting). + * @param[out] dest_len A pointer to receive the number of units written to the destination.\n + * If dest_len!=NULL then *dest_len is always set to the number of output units corresponding + * to the transformation of all the input units, even in case of a buffer overflow. + * @param[in] src The original source string + * @param[in] src_len The length of the original string.\n + * If @c -1, then @a src must be zero-terminated. + * @param[in] sub_char The substitution character to use in place of an illegal input sequence, or U_SENTINEL if the function is to return with #I18N_ERROR_INVALID_CHAR_FOUND instead. + * A substitution character can be any valid Unicode code point (up to U+10FFFF) except for surrogate code points (U+D800..U+DFFF). + * The recommended value is U+FFFD "REPLACEMENT CHARACTER". + * @param[out] num_substitutions Output parameter receiving the number of substitutions if sub_char>=0. Set to 0 if no substitutions occur or sub_char<0. num_substitutions can be NULL. + * @param[out] error_code Pointer to a standard ICU error code. Its input value must + * pass the U_SUCCESS() test, or else the function returns + * immediately. Check for U_FAILURE() on output or use with + * function chaining. (See User Guide for details.) + * @return[out] The pointer to destination buffer. + * + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ustring_from_UTF32() + * @see i18n_ustring_to_UTF32_with_sub() + */ +i18n_uchar* i18n_ustring_from_UTF32_with_sub ( i18n_uchar *dest, int32_t dest_capacity, int32_t *dest_len, const i18n_uchar32 *src, int32_t src_len, i18n_uchar32 sub_char, int32_t *num_substitutions, i18n_error_code_e *error_code ); + +#ifdef __cplusplus +} +#endif + +/** + * @} + * @} + */ +#endif /* __UTILS_I18N_USTRING_H__*/ diff --git a/src/include/wearable/utils_i18n.h b/src/include/wearable/utils_i18n.h new file mode 100755 index 0000000..94a07bd --- /dev/null +++ b/src/include/wearable/utils_i18n.h @@ -0,0 +1,1779 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +#ifndef __UTILS_I18N_H__ +#define __UTILS_I18N_H__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** + * @file utils_i18n.h + * @version 0.1 + * @brief utils_i18n + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @ingroup CAPI_BASE_UTILS_MODULE + * @defgroup CAPI_BASE_UTILS_I18N_MODULE i18n + * @brief The i18n module contains uchar, ucollator, unormalization, usearch, ustring, ucalendar, udate, udatepg, ulocale and unumber. + * This module provides flexible generation of number or date format patterns and helps you format and parse dates/number for any locale. + * @section CAPI_BASE_UTILS_I18N_MODULE_HEADER Required Header + * \#include + * @section CAPI_BASE_UTILS_I18N_MODULE_OVERVIEW Overview + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
APIDescription
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULEThe Timezone module represents a time zone offset, and also figures out daylight savings.
@ref CAPI_BASE_UTILS_I18N_UENUMERATION_MODULEUEnumeration defines functions for handling String Enumeration.
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULEUbrk module defines methods for finding the location of boundaries in text.
@ref CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULEUcollator module performs locale-sensitive string comparison. It builds searching and sorting routines for natural language text and provides correct sorting orders for most locales.
@ref CAPI_BASE_UTILS_I18N_UCHAR_MODULEUchar module provides low-level access to the Unicode Character Database.
@ref CAPI_BASE_UTILS_I18N_UNORMALIZATION_MODULEUnormalization module provides Unicode normalization functionality for standard unicode normalization.
@ref CAPI_BASE_UTILS_I18N_USEARCH_MODULEUsearch module provides language-sensitive text searching based on the comparison rules defined in a ucollator data struct.
@ref CAPI_BASE_UTILS_I18N_USET_MODULEUset module allows to specify a subset of character used in strings.
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULEUstring module provides general unicode string handling.
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULEUcalendar is used for converting between a i18n_udate type and a set of integer fields + such as #I18N_UCALENDAR_YEAR, #I18N_UCALENDAR_MONTH, #I18N_UCALENDAR_DATE, #I18N_UCALENDAR_HOUR, and so on.
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULEUdate module consists of functions that convert dates and times from their + internal representations to textual form and back again in a language-independent manner.
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE Udatepg module provides flexible generation of date format patterns, like "yy-MM-dd".
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULEA ulocale represents a specific geographical, political, or cultural region.
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULEUnumber helps you format and parse numbers for any locale.
+ * + * @section CAPI_BASE_UTILS_I18N_MODULE_MAPPING_TABLE Mapping Table + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
ModuleNative APIICU API
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_create_unknowngetUnknown
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_create_gmtgetGMT
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_createcreateTimeZone
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_destroy
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_foreach_timezone_id_by_regioncreateTimeZoneIDEnumeration
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_foreach_timezone_idcreateEnumeration
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_foreach_timezone_id_with_offsetcreateEnumeration
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_foreach_timezone_id_by_countrycreateEnumeration
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_count_equivalent_idscountEquivalentIDs
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_get_equivalent_idgetEquivalentID
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_create_defaultcreateDefault
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_set_defaultsetDefault
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_get_tzdata_versiongetTZDataVersion
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_get_regiongetRegion
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_get_offset_with_dategetOffset
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_set_raw_offsetsetRawOffset
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_get_raw_offsetgetRawOffset
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_get_idgetID
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_set_idsetID
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_get_display_namegetDisplayName
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_get_display_name_with_localegetDisplayName
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_get_display_name_with_typegetDisplayName
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_get_display_name_with_type_localegetDisplayName
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_use_daylight_timeuseDaylightTime
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_has_same_rulehasSameRules
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_cloneclone
@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE#i18n_timezone_get_dst_savingsgetDSTSavings
@ref CAPI_BASE_UTILS_I18N_UENUMERATION_MODULE#i18n_uenumeration_destroyuenum_close
@ref CAPI_BASE_UTILS_I18N_UENUMERATION_MODULE#i18n_uenumeration_countuenum_count
@ref CAPI_BASE_UTILS_I18N_UENUMERATION_MODULE#i18n_uenumeration_unextuenum_unext
@ref CAPI_BASE_UTILS_I18N_UENUMERATION_MODULE#i18n_uenumeration_nextuenum_next
@ref CAPI_BASE_UTILS_I18N_UENUMERATION_MODULE#i18n_uenumeration_resetuenum_reset
@ref CAPI_BASE_UTILS_I18N_UENUMERATION_MODULE#i18n_uenumeration_uchar_strings_enumeration_createuenum_openUCharStringsEnumeration
@ref CAPI_BASE_UTILS_I18N_UENUMERATION_MODULE#i18n_uenumeration_char_strings_enumeration_createuenum_openCharStringsEnumeration
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULE#i18n_ubrk_createubrk_open
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULE#i18n_ubrk_create_rulesubrk_openRules
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULE#i18n_ubrk_safe_cloneubrk_safeClone
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULE#i18n_ubrk_destroyubrk_close
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULE#i18n_ubrk_set_textubrk_setText
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULE#i18n_ubrk_currentubrk_current
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULE#i18n_ubrk_nextubrk_next
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULE#i18n_ubrk_precedingubrk_preceding
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULE#i18n_ubrk_previousubrk_previous
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULE#i18n_ubrk_firstubrk_first
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULE#i18n_ubrk_lastubrk_last
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULE#i18n_ubrk_followingubrk_following
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULE#i18n_ubrk_get_availableubrk_getAvailable
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULE#i18n_ubrk_count_availableubrk_countAvailable
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULE#i18n_ubrk_is_boundaryubrk_isBoundary
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULE#i18n_ubrk_get_rule_statusubrk_getRuleStatus
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULE#i18n_ubrk_get_rule_status_vecubrk_getRuleStatusVec
@ref CAPI_BASE_UTILS_I18N_UBRK_MODULE#i18n_ubrk_get_locale_by_typeubrk_getLocaleByType
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_set_default_timezoneucal_setDefaultTimeZone
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_get_nowucal_getNow
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_createucal_open
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_destroyucal_close
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_cloneucal_clone
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_get_timezone_displaynameucal_getTimeZoneDisplayName
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_is_in_daylight_timeucal_inDaylightTime
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_setucal_set
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_set_attributeucal_setAttribute
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_get_attributeucal_getAttribute
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_get_millisecondsucal_getMillis
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_set_millisecondsucal_setMillis
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_set_date_timeucal_setDateTime
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_is_equivalent_toucal_equivalentTo
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_adducal_add
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_getucal_get
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_clearucal_clear
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_clear_fielducal_clearField
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_count_availableucal_countAvailable
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_country_timezones_createucal_openCountryTimeZones
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_get_availableucal_getAvailable
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_get_canonical_timezone_iducal_getCanonicalTimeZoneID
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_get_day_of_week_typeucal_getDayOfWeekType
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_get_default_timezoneucal_getDefaultTimeZone
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_get_field_differenceucal_getFieldDifference
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_get_gregorian_changeucal_getGregorianChange
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_get_keyword_values_for_localeucal_getKeywordValuesForLocale
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_get_limitucal_getLimit
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_get_locale_by_typeucal_getLocaleByType
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_get_timezone_iducal_getTimeZoneID
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_get_timezone_transition_dateucal_getTimeZoneTransitionDate
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_get_typeucal_getType
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_get_tz_data_versionucal_getTZDataVersion
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_get_weekend_transitionucal_getWeekendTransition
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_is_setucal_isSet
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_is_weekenducal_isWeekend
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_rollucal_roll
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_set_dateucal_setDate
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_set_gregorian_changeucal_setGregorianChange
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_set_timezoneucal_setTimeZone
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_timezones_createucal_openTimeZones
@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE#i18n_ucalendar_timezone_id_enumeration_createucal_openTimeZoneIDEnumeration
@ref CAPI_BASE_UTILS_I18N_UCHAR_MODULE#i18n_uchar_get_int_property_valueu_getIntpropertyValue
@ref CAPI_BASE_UTILS_I18N_UCHAR_MODULE#i18n_uchar_get_ublock_codeublock_getCode
@ref CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULE#i18n_ucollator_createucol_open
@ref CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULE#i18n_ucollator_destroyucol_close
@ref CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULE#i18n_ucollator_str_collatorucol_strcoll
@ref CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULE#i18n_ucollator_equalucol_equal
@ref CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULE#i18n_ucollator_set_strengthucol_setStrength
@ref CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULE#i18n_ucollator_set_attributeucol_setAttribute
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_createudat_open
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_destroyudat_close
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_format_dateudat_format
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_apply_patternudat_applyPattern
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_cloneudat_clone
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_count_availableudat_countAvailable
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_count_symbolsudat_countSymbols
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_get_2digit_year_startudat_get2DigitYearStart
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_get_availableudat_getAvailable
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_get_calendarudat_getCalendar
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_get_locale_by_typeudat_getLocaleByType
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_get_number_formatudat_getNumberFormat
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_get_symbolsudat_getSymbols
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_is_lenientudat_isLenient
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_parseudat_parse
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_parse_calendarudat_parseCalendar
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_set_2digit_year_startudat_set2DigitYearStart
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_set_calendarudat_setCalendar
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_set_contextudat_setContext
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_set_lenientudat_setLenient
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_set_number_formatudat_setNumberFormat
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_set_symbolsudat_setSymbols
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_to_calendar_date_fieldudat_toCalendarDateField
@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE#i18n_udate_to_patternudat_toPattern
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_createudatpg_open
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_destroyudatpg_close
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_get_best_patternudatpg_getBestPattern
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_add_patternudatpg_addPattern
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_base_skeletons_createudatpg_openBaseSkeletons
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_cloneudatpg_clone
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_create_emptyudatpg_openEmpty
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_get_append_item_formatudatpg_getAppendItemFormat
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_get_append_item_nameudatpg_getAppendItemName
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_get_base_skeletonudatpg_getBaseSkeleton
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_get_best_pattern_with_optionsudatpg_getBestPatternWithOptions
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_get_date_time_formatudatpg_getDateTimeFormat
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_get_decimaludatpg_getDecimal
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_get_pattern_for_skeletonudatpg_getPatternForSkeleton
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_get_skeletonudatpg_getSkeleton
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_replace_field_typesudatpg_replaceFieldTypes
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_replace_field_types_with_optionsudatpg_replaceFieldTypesWithOptions
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_set_append_item_formatudatpg_setAppendItemFormat
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_set_append_item_nameudatpg_setAppendItemName
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_set_date_time_formatudatpg_setDateTimeFormat
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_set_decimaludatpg_setDecimal
@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE#i18n_udatepg_skeletons_createudatpg_openSkeletons
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_defaultuloc_getDefault
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_set_defaultuloc_setDefault
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_languageuloc_getLanguage
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_countryuloc_getCountry
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_display_nameuloc_getDisplayName
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_add_likely_subtagsuloc_addLikelySubtags
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_canonicalizeuloc_canonicalize
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_for_language_taguloc_forLanguageTag
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_base_nameuloc_getBaseName
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_character_orientationuloc_getCharacterOrientation
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_display_countryuloc_getDisplayCountry
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_display_keyworduloc_getDisplayKeyword
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_display_keyword_valueuloc_getDisplayKeywordValue
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_display_languageuloc_getDisplayLanguage
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_display_scriptuloc_getDisplayScript
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_display_variantuloc_getDisplayVariant
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_iso3_countryuloc_getISO3Country
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_iso3_languageuloc_getISO3Language
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_iso_countriesuloc_getISOCountries
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_iso_languagesuloc_getISOLanguages
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_keyword_valueuloc_getKeywordValue
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_lciduloc_getLCID
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_line_orientationuloc_getLineOrientation
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_locale_for_lciduloc_getLocaleForLCID
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_nameuloc_getName
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_parentuloc_getParent
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_scriptuloc_getScript
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_variantuloc_getVariant
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_keywords_createuloc_openKeywords
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_minimize_subtagsuloc_minimizeSubtags
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_set_keyword_valueuloc_setKeywordValue
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_to_language_taguloc_toLanguageTag
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_get_availableuloc_getAvailable
@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE#i18n_ulocale_count_availableuloc_countAvailable
@ref CAPI_BASE_UTILS_I18N_UNORMALIZATION_MODULE#i18n_unormalization_get_instanceunorm2_getInstance
@ref CAPI_BASE_UTILS_I18N_UNORMALIZATION_MODULE#i18n_unormalization_normalizeunorm2_normalize
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_createunum_open
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_destroyunum_close
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_get_symbolunum_getSymbol
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_apply_patternunum_applyPattern
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_cloneunum_clone
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_count_availableunum_countAvailable
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_formatunum_format
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_format_decimalunum_formatDecimal
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_format_doubleunum_formatDouble
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_format_double_currencyunum_formatDoubleCurrency
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_format_int64unum_formatInt64
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_get_attributeunum_getAttribute
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_get_availableunum_getAvailable
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_get_double_attributeunum_getDoubleAttribute
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_get_locale_by_typeunum_getLocaleByType
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_get_text_attributeunum_getTextAttribute
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_parseunum_parse
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_parse_decimalunum_parseDecimal
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_parse_doubleunum_parseDouble
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_parse_double_currencyunum_parseDoubleCurrency
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_parse_int64unum_parseInt64
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_set_attributeunum_setAttribute
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_set_double_attributeunum_setDoubleAttribute
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_set_symbolunum_setSymbol
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_set_text_attributeunum_setTextAttribute
@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE#i18n_unumber_to_patternunum_toPattern
@ref CAPI_BASE_UTILS_I18N_USEARCH_MODULE#i18n_usearch_create_newusearch_open
@ref CAPI_BASE_UTILS_I18N_USEARCH_MODULE#i18n_usearch_destroyusearch_close
@ref CAPI_BASE_UTILS_I18N_USEARCH_MODULE#i18n_usearch_get_matched_textusearch_getMatchedText
@ref CAPI_BASE_UTILS_I18N_USEARCH_MODULE#i18n_usearch_get_collatorusearch_getCollator
@ref CAPI_BASE_UTILS_I18N_USEARCH_MODULE#i18n_usearch_firstusearch_first
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_create_emptyuset_openEmpty
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_createuset_open
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_create_patternuset_openPattern
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_create_pattern_optionsuset_openPatternOptions
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_destroyuset_close
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_cloneuset_clone
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_is_frozenuset_isFrozen
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_freezeuset_freeze
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_clone_as_thaweduset_cloneAsThawed
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_setuset_set
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_apply_patternuset_applyPattern
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_apply_int_property_valueuset_applyIntPropertyValue
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_apply_property_aliasuset_applyPropertyAlias
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_resembles_patternuset_resemblesPattern
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_to_patternuset_toPattern
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_adduset_add
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_add_alluset_addAll
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_add_rangeuset_addRange
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_add_stringuset_addString
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_add_all_code_pointsuset_addAllCodePoints
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_removeuset_remove
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_remove_rangeuset_removeRange
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_remove_stringuset_removeString
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_remove_alluset_removeAll
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_retainuset_retain
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_retain_alluset_retainAll
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_compactuset_compact
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_complementuset_complement
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_complement_alluset_complementAll
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_clearuset_clear
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_destroy_overuset_closeOver
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_remove_all_stringsuset_removeAllStrings
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_is_emptyuset_isEmpty
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_containsuset_contains
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_contains_rangeuset_containsRange
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_contains_stringuset_containsString
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_index_ofuset_indexOf
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_char_atuset_charAt
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_sizeuset_size
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_get_item_countuset_getItemCount
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_get_itemuset_getItem
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_contains_alluset_containsAll
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_contains_all_code_pointsuset_containsAllCodePoints
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_contains_noneuset_containsNone
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_contains_someuset_containsSome
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_spanuset_span
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_span_backuset_spanBack
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_span_utf8uset_spanUTF8
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_span_back_utf8uset_spanBackUTF8
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_equalsuset_equals
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_serializeuset_serialize
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_get_serialized_setuset_getSerializedSet
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_set_serialized_to_oneuset_setSerializedToOne
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_serialized_containsuset_serializedContains
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_get_serialized_range_countuset_getSerializedRangeCount
@ref CAPI_BASE_UTILS_I18N_USET_MODULE#i18n_uset_get_serialized_rangeuset_getSerializedRange
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_get_lengthu_strlen
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_count_char32u_countChar32
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_has_more_char32_thanu_strHasMoreChar32Than
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_catu_strcat
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_cat_nu_strncat
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_stringu_strstr
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_find_firstu_strFindFirst
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_charu_strchr
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_char32u_strchr32
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_r_stringu_strrstr
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_find_lastu_strFindLast
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_r_charu_strrchr
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_r_char32u_strrchr32
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_pbrku_strpbrk
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_cspnu_strcspn
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_spnu_strspn
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_tokenizer_ru_strtok_r
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_compareu_strcmp
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_compare_code_point_orderu_strcmpCodePointOrder
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_compare_binary_orderu_strCompare
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_case_compare_with_lengthu_strCaseCompare
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_compare_nu_strncmp
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_compare_n_code_point_orderu_strncmpCodePointOrder
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_case_compareu_strcasecmp
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_case_compare_nu_strncasecmp
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_mem_case_compareu_memcasecmp
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_copyu_strcpy
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_copy_nu_strncpy
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_copy_uau_uastrcpy
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_copy_ua_nu_uastrncpy
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_copy_auu_austrcpy
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_copy_au_nu_austrncpy
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_mem_copyu_memcpy
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_mem_moveu_memmove
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_mem_setu_memset
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_mem_compareu_memcmp
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_mem_compare_code_point_orderu_memcmpCodePointOrder
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_mem_charu_memchr
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_mem_char32u_memchr32
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_mem_r_charu_memrchr
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_mem_r_char32u_memrchr32
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_unescapeu_unescape
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_unescape_atu_unescapeAt
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_to_upperu_strToUpper
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_to_loweru_strToLower
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_to_title_newu_strToTitle
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_fold_caseu_strFoldCase
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_to_WCSu_strToWCS
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_from_WCSu_strFromWCS
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_to_UTF8u_strToUTF8
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_from_UTF8u_strFromUTF8
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_to_UTF8_with_subu_strToUTF8WithSub
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_from_UTF8_with_subu_strFromUTF8WithSub
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_from_UTF8_lenientu_strFromUTF8Lenient
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_to_UTF32u_strToUTF32
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_from_UTF32u_strFromUTF32
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_to_UTF32_with_subu_strToUTF32WithSub
@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE#i18n_ustring_from_UTF32_with_subu_strFromUTF32WithSub
+ */ + +#ifdef __cplusplus +} +#endif + +#endif /* __UTILS_I18N_H__*/ diff --git a/src/include/wearable/utils_i18n_private.h b/src/include/wearable/utils_i18n_private.h new file mode 100755 index 0000000..d0eb671 --- /dev/null +++ b/src/include/wearable/utils_i18n_private.h @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +#ifndef __UTILS_I18N_PRIVATE_H__ +#define __UTILS_I18N_PRIVATE_H__ + +#include +#include +#include +#include + +/** + * @file utils_i18n_private.h + * @version 0.1 + * @brief utils_i18n_private + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "BASE_UTILS" + +#define ERR(fmt, arg...) SLOGE("%s:%d " fmt, __FUNCTION__, __LINE__, ##arg) + +#define ret_if(expr) do { \ + if (expr) { \ + ERR("(%s)", #expr); \ + return; \ + } \ +} while (0) +#define retv_if(expr, val) do { \ + if (expr) { \ + ERR("(%s)", #expr); \ + return (val); \ + } \ +} while (0) +#define retm_if(expr, fmt, arg...) do { \ + if (expr) { \ + ERR(fmt, ##arg); \ + return; \ + } \ +} while (0) +#define retvm_if(expr, val, fmt, arg...) do { \ + if (expr) { \ + ERR(fmt, ##arg); \ + return (val); \ + } \ +} while (0) + +#define retex_if(expr, val, fmt, arg...) do { \ + if(expr) { \ + ERR(fmt, ##arg); \ + val; \ + goto CATCH; \ + } \ + } while (0); + +#define ERR_MAPPING_REVERSE(BASE_UTILS_ERROR, ICU_ERROR) ICU_ERROR = \ + (UErrorCode)_i18n_error_mapping_reverse((int)BASE_UTILS_ERROR) + +#define ERR_MAPPING(ICU_ERROR, BASE_UTILS_ERROR) BASE_UTILS_ERROR = \ + (i18n_error_code_e)_i18n_error_mapping((int)ICU_ERROR) + +int _i18n_error_mapping ( int err ); +int _i18n_error_mapping_reverse ( int err ); + +#ifdef __cplusplus +} +#endif + +#endif /* __UTILS_I18N_PRIVATE_H__*/ diff --git a/src/include/wearable/utils_i18n_timezone.h b/src/include/wearable/utils_i18n_timezone.h new file mode 100755 index 0000000..f049329 --- /dev/null +++ b/src/include/wearable/utils_i18n_timezone.h @@ -0,0 +1,452 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +#ifndef __UTILS_I18N_TIMEZONE_H__ +#define __UTILS_I18N_TIMEZONE_H__ + +#include + +/** + * @file utils_i18n_timezone.h + * @version 0.1 + * @brief utils_i18n_timezone + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @ingroup CAPI_BASE_UTILS_I18N_MODULE + * @defgroup CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE Timezone + * @brief The Timezone module represents a time zone offset, and also figures out daylight savings. + * @section CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE_OVERVIEW Overview + * @details The Timezone module represents a time zone offset, and also figures out daylight savings.\n + * Typically, you get an i18n_timezone_h using #i18n_timezone_create_default which creates a TimeZone based on the time zone + * where the program is running. For example, for a program running in Japan, + * #i18n_timezone_create_default creates an i18n_timezone_h based on Japanese Standard Time.\n + * You can also get an i18n_timezone_h using #i18n_timezone_create along with a time zone ID. + * For instance, the time zone ID for the US Pacific Time zone is "America/Los_Angeles". + * So, you can get a Pacific Time i18n_timezone_h with:\n + * + * i18n_timezone_h timezone;\n + * i18n_timezone_create(&timezone, "America/Los_Angeles");\n + * + * To create a new i18n_timezone_h, you call the factory function #i18n_timezone_create() and pass it a time zone ID. + * You can use the int #i18n_timezone_foreach_timezone_id() function to obtain a list of all the time zone IDs recognized by #i18n_timezone_create().\n + * You can also use #i18n_timezone_create_default() to create an i18n_timezone_h. This function uses platform-specific APIs to produce + * an i18n_timezone_h for the time zone corresponding to the client's computer's physical location. + * For example, if you're in Japan (assuming your machine is set up correctly), #i18n_timezone_create_default() + * will return an i18n_timezone_h for Japanese Standard Time ("Asia/Tokyo"). + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE + * @{ + */ + +/** + * @brief Returns the "unknown" time zone. + * @details #i18n_timezone_create() returns a mutable clone of this time zone if the input ID is not recognized. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] timezone the "unknown" time zone. + * + * @retval #I18N_ERROR_NONE Successful + * @see i18n_timezone_create() + * @see i18n_timezone_create_gmt() + */ +int i18n_timezone_create_unknown ( i18n_timezone_h *timezone ); + +/** + * @brief The GMT (=UTC) time zone has a raw offset of zero and does not use daylight savings time. + * @details This is a commonly used time zone.\n + * Note: For backward compatibility reason, the ID used by the time zone returned by this method is "GMT", although the I18N's canonical ID for the GMT time zone is "Etc/GMT". + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] timezone the GMT/UTC time zone. + * + * @retval #I18N_ERROR_NONE Successful + * @see i18n_timezone_create_unknown() + */ +int i18n_timezone_create_gmt ( i18n_timezone_h *timezone ); + +/** + * @brief Creates an i18n_timezone_h for the given timezone_id. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] timezone the GMT/UTC time zone. + * @param[in] timezone_id the ID for an i18n_timezone_h, such as "America/Los_Angeles", or a custom ID such as "GMT-8:00". + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_create ( i18n_timezone_h *timezone, const char *timezone_id ); + +/** + * @brief Destroys an i18n_timezone_h. + * @details Once destroyed, an i18n_timezone_h may no longer be used. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] timezone The i18n_timezone_h to destroy. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_destroy(i18n_timezone_h timezone); + +/** + * @brief Returns an enumeration over system time zone IDs with the given filter conditions. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] timezone_type The system time zone type. + * @param[in] region The ISO 3166 two-letter country code or UN M.49 three-digit area code. When NULL, no filtering done by region. + * @param[in] raw_offset An offset from GMT in milliseconds, ignoring the effect of daylight savings time, if any. When NULL, no filtering done by zone offset. + * @param[in] cb The callback function to get an enumeration object, owned by the caller. + * @param[in] user_data The user data to be passed to the callback function. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_foreach_timezone_id_by_region(i18n_system_timezone_type_e timezone_type, const char *region, const int32_t *raw_offset, i18n_timezone_id_cb cb, void* user_data); + +/** + * @brief Returns an enumeration over all recognized time zone IDs. + * (i.e., all strings that #i18n_timezone_create() accepts) + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] cb The callback function to get an enumeration object, owned by the caller. + * @param[in] user_data The user data to be passed to the callback function. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_foreach_timezone_id(i18n_timezone_id_cb cb, void* user_data); + +/** + * @brief Returns an enumeration over time zone IDs with a given raw offset from GMT. + * @details There may be several times zones with the same GMT offset that differ in the way they + * handle daylight savings time. For example, the state of Arizona doesn't observe daylight + * savings time. If you ask for the time zone IDs corresponding to GMT-7:00, + * you'll get back an enumeration over two time zone IDs: "America/Denver," + * which corresponds to Mountain Standard Time in the winter and Mountain Daylight Time in the summer, + * and "America/Phoenix", which corresponds to Mountain Standard Time year-round, even in the summer. + * + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] raw_offset an offset from GMT in milliseconds, ignoring the effect of daylight savings time, if any + * @param[in] cb The callback function to get an enumeration object, owned by the caller. + * @param[in] user_data The user data to be passed to the callback function. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_foreach_timezone_id_with_offset(int32_t raw_offset, i18n_timezone_id_cb cb, void* user_data); + +/** + * @brief Returns an enumeration over time zone IDs associated with the given country. + * @details Some zones are affiliated with no country (e.g., "UTC"); these may also be retrieved, as a group. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] country The ISO 3166 two-letter country code, or NULL to retrieve zones not affiliated with any country. + * @param[in] cb The callback function to get an enumeration object, owned by the caller. + * @param[in] user_data The user data to be passed to the callback function. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_foreach_timezone_id_by_country(const char *country, i18n_timezone_id_cb cb, void* user_data); + +/** + * @brief Returns the number of IDs in the equivalency group that includes the given ID. + * @details An equivalency group contains zones that have the same GMT offset and rules.\n + * The returned count includes the given ID; it is always >= 1. The given ID must be a system time zone. If it is not, returns zero. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] timezone_id a system time zone ID + * @param[out] count the number of zones in the equivalency group containing 'timezone_id', or zero if 'timezone_id' is not a valid system ID + * + * @retval #I18N_ERROR_NONE Successful + * @see i18n_timezone_get_equivalent_id() + */ +int i18n_timezone_count_equivalent_ids(const char *timezone_id, int32_t *count); + +/** + * @brief Returns an ID in the equivalency group that includes the given ID. + * @details An equivalency group contains zones that have the same GMT offset and rules.\n + * The given index must be in the range 0..n-1, where n is the out parameter value + * from i18n_timezone_count_equivalent_ids(timezone_id, &n). + * For some value of 'index', the returned value will be equal to the given id. + * If the given id is not a valid system time zone, + * or if 'index' is out of range, then returns an empty string. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] timezone_id a system time zone ID + * @param[in] index a value from 0 to n-1, where n is the out parameter value from i18n_timezone_count_equivalent_ids(timezone_id, &n) + * @param[out] equivalent_timezone_id the ID of the index-th zone in the equivalency group containing 'timezone_id', + * or an empty string if 'timezone_id' is not a valid system ID or 'index' is out of range + * + * @retval #I18N_ERROR_NONE Successful + * @see i18n_timezone_count_equivalent_ids() + */ +int i18n_timezone_get_equivalent_id(const char *timezone_id, int32_t index, char **equivalent_timezone_id); + +/** + * @brief Creates a new copy of the default i18n_timezone_h for this host. + * @details Unless the default time zone has already been set using #i18n_timezone_set_default(), + * the default is determined by querying the system using methods in TPlatformUtilities. + * If the system routines fail, or if they specify an i18n_timezone_h or i18n_timezone_h offset + * which is not recognized, the i18n_timezone_h indicated by the ID kLastResortID + * is instantiated and made the default. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] timezone A default i18n_timezone_h. Clients are responsible for deleting the time zone object returned. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_create_default ( i18n_timezone_h *timezone ); + +/** + * @brief Sets the default time zone (i.e., what's returned by #i18n_timezone_create_default()) to be the specified time zone. + * @details If NULL is specified for the time zone, the default time zone is set to the default host time zone. + * The caller remains responsible for deleting it. \n + * This function is not thread safe. It is an error for multiple threads to concurrently attempt to set + * the default time zone, or for any thread to attempt to reference the default zone while another thread is setting it. + * + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @remarks Do not use unless you know what you are doing. + * + * @param[in] timezone The given timezone. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_set_default( i18n_timezone_h timezone ); + +/** + * @brief Returns the timezone data version currently used by I18N. + * @remarks The specific error code can be obtained using the get_last_result() + * method. Error codes are described in #i18n_error_code_e description. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @return the version string, such as "2007f" + * @exception #I18N_ERROR_NONE Successful + */ +const char* i18n_timezone_get_tzdata_version(void); + +/** + * @brief Gets the region code associated with the given system time zone ID. + * @details The region code is either ISO 3166 2-letter country code or UN M.49 3-digit area code. + * When the time zone is not associated with a specific location, for example - "Etc/UTC", + * "EST5EDT", then this method returns "001" (UN M.49 area code for World). + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] timezone_id The system time zone ID. + * @param[out] region Output buffer for receiving the region code. + * @param[out] region_len The length of the region code. + * @param[in] region_capacity The size of the output buffer. If it is lower than required @a region buffer size, + * then I18N_ERROR_BUFFER_OVERFLOW error is returned. + * + * @return the version string, such as "2007f" + */ +int i18n_timezone_get_region(const char *timezone_id, char *region, int32_t *region_len, int32_t region_capacity); + +/** + * @brief Returns the time zone raw and GMT offset for the given moment in time. + * @details Upon return, local-millis = GMT-millis + rawOffset + dstOffset. All computations are performed + * in the proleptic Gregorian calendar. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] timezone The i18n_timezone_h to get an offset. + * @param[in] date moment in time for which to return offsets, in units of milliseconds from January 1, 1970 0:00 GMT, either GMT time or local wall time, depending on `local'. + * @param[in] local output if true, `date' is local wall time; otherwise it is in GMT time. + * @param[out] raw_offset parameter to receive the raw offset, that is, the offset not including DST adjustments + * @param[out] dst_offset output parameter to receive the DST offset, that is, the offset to be added to `raw_offset' to obtain the total offset between local and GMT time. If DST is not in effect, this value is zero; otherwise it is a positive value, typically one hour. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_get_offset_with_date(i18n_timezone_h timezone, i18n_udate date, i18n_ubool local, int32_t *raw_offset, int32_t *dst_offset); + +/** + * @brief Sets the i18n_timezone_h's raw GMT offset + * (i.e., the number of milliseconds to add to GMT to get local time, before taking daylight savings time into account). + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] timezone The i18n_timezone_h to set a raw offset. + * @param[in] offset_milliseconds The new raw GMT offset for this time zone. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_set_raw_offset(i18n_timezone_h timezone, int32_t offset_milliseconds); + +/** + * @brief Gets the region code associated with the given system time zone ID. + * @details The region code is either ISO 3166 2-letter country code or UN M.49 3-digit area code. When the time zone is not associated with a specific location, for example - "Etc/UTC", "EST5EDT", then this method returns "001" (UN M.49 area code for World). + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] timezone The i18n_timezone_h to get a raw offset. + * @param[out] offset_milliseconds The i18n_timezone_h's raw GMT offset. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_get_raw_offset(i18n_timezone_h timezone, int32_t *offset_milliseconds); + +/** + * @brief Fills in "timezone_id" with the i18n_timezone_h's ID. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] timezone The i18n_timezone_h to get a timezone ID. + * @param[out] timezone_id Receives this i18n_timezone_h's ID. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_get_id(i18n_timezone_h timezone, char **timezone_id); + +/** + * @brief Sets the i18n_timezone_h's ID to the specified value. + * @details This doesn't affect any other fields. for example,\n + * \n + * i18n_timezone_h timezone = NULL;\n + * i18n_timezone_create ( &timezone, "America/New_York" );\n + * i18n_timezone_set_id ( "America/Los_Angeles" );\n + * \n + * the timezone's GMT offset and daylight-savings rules don't change to those for Los Angeles. + * They're still those for New York. Only the ID has changed. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] timezone The i18n_timezone_h to set a timezone ID. + * @param[in] timezone_id The new time zone ID. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_set_id(i18n_timezone_h timezone, const char *timezone_id); + +/** + * @brief Returns a name of this time zone suitable for presentation to the user in the default locale. + * @details This method returns the long name, not including daylight savings. + * If the display name is not available for the locale, then this method returns a string in the localized GMT offset format such as GMT[+-]HH:mm. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] timezone The i18n_timezone_h to get a display name. + * @param[out] display_name The human-readable name of this time zone in the default locale. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_get_display_name(i18n_timezone_h timezone, char **display_name); + +/** + * @brief Returns a name of this time zone suitable for presentation to the user in the default locale. + * @details This method returns the long name, not including daylight savings. + * If the display name is not available for the locale, then this method returns a string in the localized GMT offset format such as GMT[+-]HH:mm. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] timezone The i18n_timezone_h to get a display name. + * @param[in] language The language in which to supply the display name. This parameter can be NULL; if so, the locale is initialized to match the current default locale. + * @param[in] country The country in which to supply the display name. This parameter can be NULL. + * @param[out] display_name The human-readable name of this time zone in the default locale. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_get_display_name_with_locale(i18n_timezone_h timezone, const char *language, const char *country , char **display_name); + +/** + * @brief Returns a name of this time zone suitable for presentation to the user in the default locale. + * @details If the display name is not available for the locale, + * then this method returns a string in the localized GMT offset format such as GMT[+-]HH:mm. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] timezone The i18n_timezone_h to get a display name. + * @param[in] daylight If true, display_name is filled with the daylight savings name. + * @param[in] style The style displayed on. + * @param[out] display_name The human-readable name of this time zone in the default locale. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_get_display_name_with_type(i18n_timezone_h timezone, i18n_ubool daylight, i18n_timezone_display_type_e style, char **display_name); + +/** + * @brief Returns a name of this time zone suitable for presentation to the user in the default locale. + * @details If the display name is not available for the locale, + * then this method returns a string in the localized GMT offset format such as GMT[+-]HH:mm. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] timezone The i18n_timezone_h to get a display name. + * @param[in] daylight If true, display_name is filled with the daylight savings name. + * @param[in] style The style displayed on. + * @param[in] language The language in which to supply the display name. This parameter can be NULL; if so, the locale is initialized to match the current default locale. + * @param[in] country The country in which to supply the display name. This parameter can be NULL. + * @param[out] display_name The human-readable name of this time zone in the default locale. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_get_display_name_with_type_locale(i18n_timezone_h timezone, i18n_ubool daylight, i18n_timezone_display_type_e style, const char *language, const char *country, char **display_name); + +/** + * @brief Queries if this time zone uses daylight savings time. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] timezone The i18n_timezone_h to know whether uses daylight savings time or not. + * @param[out] daylight_time True if this time zone uses daylight savings time, False, otherwise. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_use_daylight_time(i18n_timezone_h timezone, i18n_ubool *daylight_time); + +/** + * @brief Returns true if this zone has the same rule and offset as another zone. + * @details That is, if this zone differs only in ID, if at all. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] timezone The i18n_timezone_h to know whether has the same rule or not. + * @param[in] other The i18n_timezone_h to be compared with. + * @param[out] same_rule True if the given zone is the same as this one, with the possible exception of the ID. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_has_same_rule(i18n_timezone_h timezone, i18n_timezone_h other, i18n_ubool *same_rule); + +/** + * @brief Clones i18n_timezone_h polymorphically. + * @details Clients are responsible for deleting the i18n_timezone_h cloned. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] timezone The i18n_timezone_h to clone. + * @param[out] clone A new copy of this i18n_timezone_h. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_clone(i18n_timezone_h timezone, i18n_timezone_h *clone); + +/** + * @brief Returns the amount of time to be added to local standard time to get local wall clock time. + * @details The default implementation always returns 3600000 milliseconds (i.e., one hour) if this time zone observes Daylight Saving Time. + * Otherwise, 0 (zero) is returned.\n + * If an underlying TimeZone implementation subclass supports historical Daylight Saving Time changes, + * this method returns the known latest daylight saving value. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] timezone The i18n_timezone_h to get DST savings. + * @param[out] dst_savings The amount of saving time in milliseconds. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_timezone_get_dst_savings(i18n_timezone_h timezone, int32_t *dst_savings); + +#ifdef __cplusplus +} +#endif + +/** + * @} + * @} + */ +#endif /* __UTILS_I18N_TIMEZONE_H__*/ diff --git a/src/include/wearable/utils_i18n_types.h b/src/include/wearable/utils_i18n_types.h new file mode 100644 index 0000000..a833e08 --- /dev/null +++ b/src/include/wearable/utils_i18n_types.h @@ -0,0 +1,1989 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + * + * Copyright (C) 1999-2012, International Business Machines + * Corporation and others. All Rights Reserved. + */ + + + +#ifndef __UTILS_I18N_TYPES_H__ +#define __UTILS_I18N_TYPES_H__ + +#include +#include +#include + +/** + * @file utils_i18n_types.h + * @version 0.1 + * @brief utils_i18n_types + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_MODULE + * @{ + */ + +/** + * @brief Enumeration for error codes to replace exception handlings. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { + I18N_ERROR_NONE = TIZEN_ERROR_NONE, /**< No error, no warning */ + I18N_ERROR_MISSING_RESOURCE = TIZEN_ERROR_UTILITY_ICU | 0x01, /**< The requested resource cannot be found */ + I18N_ERROR_INVALID_FORMAT = TIZEN_ERROR_UTILITY_ICU | 0x02, /**< Data format is not what is expected */ + I18N_ERROR_FILE_ACCESS = TIZEN_ERROR_UTILITY_ICU | 0x03, /**< The requested file cannot be found */ + I18N_ERROR_INTERNAL_PROGRAM = TIZEN_ERROR_UTILITY_ICU | 0x04, /**< Indicates a bug in the library code */ + I18N_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ + I18N_ERROR_INDEX_OUTOFBOUNDS = TIZEN_ERROR_UTILITY_ICU | 0x05, /**< Trying to access the index that is out of bounds */ + I18N_ERROR_INVALID_CHAR_FOUND = TIZEN_ERROR_UTILITY_ICU | 0x06, /**< Character conversion: Unmappable input sequence. In other APIs: Invalid character */ + I18N_ERROR_BUFFER_OVERFLOW = TIZEN_ERROR_UTILITY_ICU | 0x07, /**< A result would not fit in the supplied buffer */ + I18N_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Requested operation is not supported in the current context */ + I18N_ERROR_COLLATOR_VERSION_MISMATCH = TIZEN_ERROR_UTILITY_ICU | 0x08, /**< Collator version is not compatible with the base version */ + I18N_ERROR_USELESS_COLLATOR = TIZEN_ERROR_UTILITY_ICU | 0x09, /**< Collator is options only and no base is specified */ + I18N_ERROR_NO_WRITE_PERMISSION = TIZEN_ERROR_UTILITY_ICU | 0x0A, /**< Attempt to modify read-only or constant data */ + I18N_ERROR_RESOURCE_TYPE_MISMATCH = TIZEN_ERROR_UTILITY_ICU | 0x0B, /**< An operation is requested over a resource that does not support it */ + I18N_ERROR_TOO_MANY_ALIASES = TIZEN_ERROR_UTILITY_ICU | 0x0C, /**< Too many aliases in the path to the requested resource */ + I18N_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid function parameter */ + I18N_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ + + I18N_ERROR_MESSAGE_PARSE = TIZEN_ERROR_UTILITY_ICU | 0x0D, /**< Unable to parse a message (message format). @if MOBILE (Since 2.3.1) @endif*/ + I18N_ERROR_PARSE = TIZEN_ERROR_UTILITY_ICU | 0x0E, /**< Equivalent to Java ParseException. @if MOBILE (Since 2.3.1) @endif*/ + I18N_ERROR_TRUNCATED_CHAR_FOUND = TIZEN_ERROR_UTILITY_ICU | 0x0F, /**< Character conversion: Incomplete input sequence. @if MOBILE (Since 2.3.1) @endif*/ + I18N_ERROR_ILLEGAL_CHAR_FOUND = TIZEN_ERROR_UTILITY_ICU | 0x10, /**< Character conversion: Illegal input sequence/combination of input units. @if MOBILE (Since 2.3.1) @endif*/ + I18N_ERROR_INVALID_TABLE_FORMAT = TIZEN_ERROR_UTILITY_ICU | 0x11, /**< Conversion table file found, but corrupted. @if MOBILE (Since 2.3.1) @endif*/ + I18N_ERROR_INVALID_TABLE_FILE = TIZEN_ERROR_UTILITY_ICU | 0x12, /**< Conversion table file not found. @if MOBILE (Since 2.3.1) @endif*/ + I18N_ERROR_ILLECAL_ESCAPE_SEQUENCE = TIZEN_ERROR_UTILITY_ICU | 0x13, /**< ISO-2022 illlegal escape sequence. @if MOBILE (Since 2.3.1) @endif*/ + I18N_ERROR_UNSUPPORTED_ESCAPE_SEQUENCE = TIZEN_ERROR_UTILITY_ICU | 0x14, /**< ISO-2022 unsupported escape sequence. @if MOBILE (Since 2.3.1) @endif*/ + I18N_ERROR_NO_SPACE_AVAILABLE = TIZEN_ERROR_UTILITY_ICU | 0x15, /**< No space available for in-buffer expansion for Arabic shaping. @if MOBILE (Since 2.3.1) @endif*/ + I18N_ERROR_CE_NOT_FOUND = TIZEN_ERROR_UTILITY_ICU | 0x16, /**< Currently used only while setting variable top, but can be used generally. @if MOBILE (Since 2.3.1) @endif*/ + I18N_ERROR_PRIMARY_TOO_LONG = TIZEN_ERROR_UTILITY_ICU | 0x17, /**< User tried to set variable top to a primary that is longer than two bytes. @if MOBILE (Since 2.3.1) @endif*/ + I18N_ERROR_STATE_TOO_OLD = TIZEN_ERROR_UTILITY_ICU | 0x18, /**< ICU cannot construct a service from this state, as it is no longer supported. @if MOBILE (Since 2.3.1) @endif*/ + I18N_ERROR_ENUM_OUT_OF_SYNC = TIZEN_ERROR_UTILITY_ICU | 0x19, /**< UEnumeration out of sync with underlying collection. @if MOBILE (Since 2.3.1) @endif*/ + I18N_ERROR_INVARIANT_CONVERSION = TIZEN_ERROR_UTILITY_ICU | 0x1A, /**< Unable to convert a UChar* string to char* with the invariant converter. @if MOBILE (Since 2.3.1) @endif*/ + I18N_ERROR_INVALID_STATE = TIZEN_ERROR_UTILITY_ICU | 0x1B, /**< Requested operation can not be completed with ICU in its current state. @if MOBILE (Since 2.3.1) @endif*/ + I18N_ERROR_MALFORMED_SET = TIZEN_ERROR_UTILITY_ICU | 0x1C, /**< A UnicodeSet pattern is invalid. @if MOBILE (Since 2.3.1) @endif*/ + I18N_WARNING_STRING_NOT_TERMINATED = TIZEN_ERROR_UTILITY_ICU | 0x1D, /**< String not terminated with NULL. @if MOBILE (Since 2.3.1) @endif*/ + I18N_ERROR_STD3_ASCII_RULES = TIZEN_ERROR_UTILITY_ICU | 0x1E, /**< Argument does not satisfy STD3 rules. @if MOBILE (Since 2.3.1) @endif*/ + I18N_ERROR_UNASSIGNED = TIZEN_ERROR_UTILITY_ICU | 0x1F, /**< Unassigned code points are found. @if MOBILE (Since 2.3.1) @endif*/ + I18N_WARNING_SORT_KEY_TOO_SHORT = TIZEN_ERROR_UTILITY_ICU | 0x20, /**< Number of levels requested in getBound is higher than the number of levels in the sort key. @if MOBILE (Since 2.3.1) @endif*/ + I18N_ERROR_UNKNOWN = TIZEN_ERROR_UNKNOWN, /**< Unknown error. @if MOBILE (Since 2.3.1) @endif*/ +} i18n_error_code_e; + +/** + * @} + * @} + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_UCHAR_MODULE + * @{ + */ + +#define I18N_U_MASK(x) ((uint32_t)1<<(x)) /**< Get a single-bit bit set (a flag) from a bit number 0..31. @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif*/ + +#define I18N_U_GC_CN_MASK I18N_U_MASK(I18N_UCHAR_U_GENERAL_OTHER_TYPES) /** comment... * / + * U_<[A-Z_]+> = , + */ + I18N_UCHAR_U_LEFT_TO_RIGHT, /**< L */ + I18N_UCHAR_U_RIGHT_TO_LEFT, /**< R */ + I18N_UCHAR_U_EUROPEAN_NUMBER, /**< EN */ + I18N_UCHAR_U_EUROPEAN_NUMBER_SEPARATOR, /**< ES */ + I18N_UCHAR_U_EUROPEAN_NUMBER_TERMINATOR, /**< ET */ + I18N_UCHAR_U_ARABIC_NUMBER, /**< AN */ + I18N_UCHAR_U_COMMON_NUMBER_SEPARATOR, /**< CS */ + I18N_UCHAR_U_BLOCK_SEPARATOR, /**< B */ + I18N_UCHAR_U_SEGMENT_SEPARATOR, /**< S */ + I18N_UCHAR_U_WHITE_SPACE_NEUTRAL, /**< WS */ + I18N_UCHAR_U_OTHER_NEUTRAL, /**< ON */ + I18N_UCHAR_U_LEFT_TO_RIGHT_EMBEDDING, /**< LRE */ + I18N_UCHAR_U_LEFT_TO_RIGHT_OVERRIDE, /**< LRO */ + I18N_UCHAR_U_RIGHT_TO_LEFT_ARABIC, /**< AL */ + I18N_UCHAR_U_RIGHT_TO_LEFT_EMBEDDING, /**< RLE */ + I18N_UCHAR_U_RIGHT_TO_LEFT_OVERRIDE, /**< RLO */ + I18N_UCHAR_U_POP_DIRECTIONAL_FORMAT, /**< PDF */ + I18N_UCHAR_U_DIR_NON_SPACING_MARK, /**< NSM */ + I18N_UCHAR_U_BOUNDARY_NEUTRAL, /**< BN */ + I18N_UCHAR_U_CHAR_DIRECTION_COUNT /**< */ +} i18n_uchar_direction_e; + +/** + * @brief Enumeration for Decomposition Type constants. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { +/* + * Note: UDecompositionType constants are parsed by preparseucd.py. + * It matches lines like + * U_DT_ + */ + I18N_UCHAR_U_DT_NONE, /**< [none] */ + I18N_UCHAR_U_DT_CANONICAL, /**< [can] */ + I18N_UCHAR_U_DT_COMPAT, /**< [com] */ + I18N_UCHAR_U_DT_CIRCLE, /**< [enc] */ + I18N_UCHAR_U_DT_FINAL, /**< [fin] */ + I18N_UCHAR_U_DT_FONT, /**< [font] */ + I18N_UCHAR_U_DT_FRACTION, /**< [fra] */ + I18N_UCHAR_U_DT_INITIAL, /**< [init] */ + I18N_UCHAR_U_DT_ISOLATED, /**< [iso] */ + I18N_UCHAR_U_DT_MEDIAL, /**< [med] */ + I18N_UCHAR_U_DT_NARROW, /**< [nar] */ + I18N_UCHAR_U_DT_NOBREAK, /**< [nb] */ + I18N_UCHAR_U_DT_SMALL, /**< [sml] */ + I18N_UCHAR_U_DT_SQUARE, /**< [sqr] */ + I18N_UCHAR_U_DT_SUB, /**< [sub] */ + I18N_UCHAR_U_DT_SUPER, /**< [sup] */ + I18N_UCHAR_U_DT_VERTICAL, /**< [vert] */ + I18N_UCHAR_U_DT_WIDE, /**< [wide] */ + I18N_UCHAR_U_DT_COUNT /**< 18 */ +} i18n_uchar_u_decomposition_type_e; + +/** + * @brief Enumeration for East Asian Width constants. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { + I18N_UCHAR_U_EA_NEUTRAL, /**< [N] */ + I18N_UCHAR_U_EA_AMBIGUOUS, /**< [A] */ + I18N_UCHAR_U_EA_HALFWIDTH, /**< [H] */ + I18N_UCHAR_U_EA_FULLWIDTH, /**< [F] */ + I18N_UCHAR_U_EA_NARROW, /**< [Na] */ + I18N_UCHAR_U_EA_WIDE, /**< [W] */ + I18N_UCHAR_U_EA_COUNT +} i18n_uchar_u_east_asian_width_e; + +/** + * @brief Enumeration for Unicode general category types. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { + I18N_UCHAR_U_UNASSIGNED, /**< Non-category for unassigned and non-character code points */ + I18N_UCHAR_U_GENERAL_OTHER_TYPES = 0, /**< Cn "Other, Not Assigned (no characters in [UnicodeData.txt] have this property)" (same as #I18N_UCHAR_U_UNASSIGNED!) */ + I18N_UCHAR_U_UPPERCASE_LETTER, /**< Lu */ + I18N_UCHAR_U_LOWERCASE_LETTER, /**< Ll */ + I18N_UCHAR_U_TITLECASE_LETTER, /**< Lt */ + I18N_UCHAR_U_MODIFIER_LETTER, /**< Lm */ + I18N_UCHAR_U_OTHER_LETTER, /**< Lo */ + I18N_UCHAR_U_NON_SPACING_MARK, /**< Mn */ + I18N_UCHAR_U_ENCLOSING_MARK, /**< Me */ + I18N_UCHAR_U_COMBINING_SPACING_MARK, /**< Mc */ + I18N_UCHAR_U_DECIMAL_DIGIT_NUMBER, /**< Nd */ + I18N_UCHAR_U_LETTER_NUMBER, /**< Nl */ + I18N_UCHAR_U_OTHER_NUMBER, /**< No */ + I18N_UCHAR_U_SPACE_SEPARATOR, /**< Zs */ + I18N_UCHAR_U_LINE_SEPARATOR, /**< Zl */ + I18N_UCHAR_U_PARAGRAPH_SEPARATOR, /**< Zp */ + I18N_UCHAR_U_CONTROL_CHAR, /**< Cc */ + I18N_UCHAR_U_FORMAT_CHAR, /**< Cf */ + I18N_UCHAR_U_PRIVATE_USE_CHAR, /**< Co */ + I18N_UCHAR_U_SURROGATE, /**< Cs */ + I18N_UCHAR_U_DASH_PUNCTUATION, /**< Pd */ + I18N_UCHAR_U_START_PUNCTUATION, /**< Ps */ + I18N_UCHAR_U_END_PUNCTUATION, /**< Pe */ + I18N_UCHAR_U_CONNECTOR_PUNCTUATION, /**< Pc */ + I18N_UCHAR_U_OTHER_PUNCTUATION, /**< Po */ + I18N_UCHAR_U_MATH_SYMBOL, /**< Sm */ + I18N_UCHAR_U_CURRENCY_SYMBOL, /**< Sc */ + I18N_UCHAR_U_MODIFIER_SYMBOL, /**< Sk */ + I18N_UCHAR_U_OTHER_SYMBOL, /**< So */ + I18N_UCHAR_U_INITIAL_PUNCTUATION, /**< Pi */ + I18N_UCHAR_U_FINAL_PUNCTUATION, /**< Pf */ + I18N_UCHAR_U_CHAR_CATEGORY_COUNT /**< One higher than the last enum #i18n_uchar_category_e constant */ +} i18n_uchar_category_e; + +/** + * @brief Enumeration for Joining Group constants. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { +/* + * Note: UJoiningGroup constants are parsed by preparseucd.py. + * It matches lines like + * U_JG_ + */ + I18N_UCHAR_U_JG_NO_JOINING_GROUP, /**< */ + I18N_UCHAR_U_JG_AIN, /**< */ + I18N_UCHAR_U_JG_ALAPH, /**< */ + I18N_UCHAR_U_JG_ALEF, /**< */ + I18N_UCHAR_U_JG_BEH, /**< */ + I18N_UCHAR_U_JG_BETH, /**< */ + I18N_UCHAR_U_JG_DAL, /**< */ + I18N_UCHAR_U_JG_DALATH_RISH, /**< */ + I18N_UCHAR_U_JG_E, /**< */ + I18N_UCHAR_U_JG_FEH, /**< */ + I18N_UCHAR_U_JG_FINAL_SEMKATH, /**< */ + I18N_UCHAR_U_JG_GAF, /**< */ + I18N_UCHAR_U_JG_GAMAL, /**< */ + I18N_UCHAR_U_JG_HAH, /**< */ + I18N_UCHAR_U_JG_TEH_MARBUTA_GOAL, /**< */ + I18N_UCHAR_U_JG_HAMZA_ON_HEH_GOAL = I18N_UCHAR_U_JG_TEH_MARBUTA_GOAL, /**< */ + I18N_UCHAR_U_JG_HE, /**< */ + I18N_UCHAR_U_JG_HEH, /**< */ + I18N_UCHAR_U_JG_HEH_GOAL, /**< */ + I18N_UCHAR_U_JG_HETH, /**< */ + I18N_UCHAR_U_JG_KAF, /**< */ + I18N_UCHAR_U_JG_KAPH, /**< */ + I18N_UCHAR_U_JG_KNOTTED_HEH, /**< */ + I18N_UCHAR_U_JG_LAM, /**< */ + I18N_UCHAR_U_JG_LAMADH, /**< */ + I18N_UCHAR_U_JG_MEEM, /**< */ + I18N_UCHAR_U_JG_MIM, /**< */ + I18N_UCHAR_U_JG_NOON, /**< */ + I18N_UCHAR_U_JG_NUN, /**< */ + I18N_UCHAR_U_JG_PE, /**< */ + I18N_UCHAR_U_JG_QAF, /**< */ + I18N_UCHAR_U_JG_QAPH, /**< */ + I18N_UCHAR_U_JG_REH, /**< */ + I18N_UCHAR_U_JG_REVERSED_PE, /**< */ + I18N_UCHAR_U_JG_SAD, /**< */ + I18N_UCHAR_U_JG_SADHE, /**< */ + I18N_UCHAR_U_JG_SEEN, /**< */ + I18N_UCHAR_U_JG_SEMKATH, /**< */ + I18N_UCHAR_U_JG_SHIN, /**< */ + I18N_UCHAR_U_JG_SWASH_KAF, /**< */ + I18N_UCHAR_U_JG_SYRIAC_WAW, /**< */ + I18N_UCHAR_U_JG_TAH, /**< */ + I18N_UCHAR_U_JG_TAW, /**< */ + I18N_UCHAR_U_JG_TEH_MARBUTA, /**< */ + I18N_UCHAR_U_JG_TETH, /**< */ + I18N_UCHAR_U_JG_WAW, /**< */ + I18N_UCHAR_U_JG_YEH, /**< */ + I18N_UCHAR_U_JG_YEH_BARREE, /**< */ + I18N_UCHAR_U_JG_YEH_WITH_TAIL, /**< */ + I18N_UCHAR_U_JG_YUDH, /**< */ + I18N_UCHAR_U_JG_YUDH_HE, /**< */ + I18N_UCHAR_U_JG_ZAIN, /**< */ + I18N_UCHAR_U_JG_FE, /**< */ + I18N_UCHAR_U_JG_KHAPH, /**< */ + I18N_UCHAR_U_JG_ZHAIN, /**< */ + I18N_UCHAR_U_JG_BURUSHASKI_YEH_BARREE, /**< */ + I18N_UCHAR_U_JG_FARSI_YEH, /**< */ + I18N_UCHAR_U_JG_NYA, /**< */ + I18N_UCHAR_U_JG_ROHINGYA_YEH, + I18N_UCHAR_U_JG_COUNT /**< */ + } i18n_uchar_u_joining_group_e; + +/** + * @brief Enumeration for Joining Type constants. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { +/* + * Note: i18n_uchar_u_joining_type_e constants are parsed by preparseucd.py. + * It matches lines like + * U_JT_ + */ + I18N_UCHAR_U_JT_NON_JOINING, /**< [U] */ + I18N_UCHAR_U_JT_JOIN_CAUSING, /**< [C] */ + I18N_UCHAR_U_JT_DUAL_JOINING, /**< [D] */ + I18N_UCHAR_U_JT_LEFT_JOINING, /**< [L] */ + I18N_UCHAR_U_JT_RIGHT_JOINING, /**< [R] */ + I18N_UCHAR_U_JT_TRANSPARENT, /**< [T] */ + I18N_UCHAR_U_JT_COUNT /**< 6 */ +} i18n_uchar_u_joining_type_e; + +/** + * @brief Enumeration for Line Break constants. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { +/* + * Note: i18n_uchar_u_line_break_e constants are parsed by preparseucd.py. + * It matches lines like + * U_LB_ + */ + I18N_UCHAR_U_LB_UNKNOWN, /**< [XX] */ + I18N_UCHAR_U_LB_AMBIGUOUS, /**< [AI] */ + I18N_UCHAR_U_LB_ALPHABETIC, /**< [AL] */ + I18N_UCHAR_U_LB_BREAK_BOTH, /**< [B2] */ + I18N_UCHAR_U_LB_BREAK_AFTER, /**< [BA] */ + I18N_UCHAR_U_LB_BREAK_BEFORE, /**< [BB] */ + I18N_UCHAR_U_LB_MANDATORY_BREAK, /**< [BK] */ + I18N_UCHAR_U_LB_CONTINGENT_BREAK, /**< [CB] */ + I18N_UCHAR_U_LB_CLOSE_PUNCTUATION, /**< [CL] */ + I18N_UCHAR_U_LB_COMBINING_MARK, /**< [CM] */ + I18N_UCHAR_U_LB_CARRIAGE_RETURN, /**< [CR] */ + I18N_UCHAR_U_LB_EXCLAMATION, /**< [EX] */ + I18N_UCHAR_U_LB_GLUE, /**< [GL] */ + I18N_UCHAR_U_LB_HYPHEN, /**< [HY] */ + I18N_UCHAR_U_LB_IDEOGRAPHIC, /**< [ID] */ + I18N_UCHAR_U_LB_INSEPARABLE, /**< [IN] */ + I18N_UCHAR_U_LB_INSEPERABLE = I18N_UCHAR_U_LB_INSEPARABLE, + I18N_UCHAR_U_LB_INFIX_NUMERIC, /**< [IS] */ + I18N_UCHAR_U_LB_LINE_FEED, /**< [LF] */ + I18N_UCHAR_U_LB_NONSTARTER, /**< [NS] */ + I18N_UCHAR_U_LB_NUMERIC, /**< [NU] */ + I18N_UCHAR_U_LB_OPEN_PUNCTUATION, /**< [OP] */ + I18N_UCHAR_U_LB_POSTFIX_NUMERIC, /**< [PO] */ + I18N_UCHAR_U_LB_PREFIX_NUMERIC, /**< [PR] */ + I18N_UCHAR_U_LB_QUOTATION, /**< [QU] */ + I18N_UCHAR_U_LB_COMPLEX_CONTEXT, /**< [SA] */ + I18N_UCHAR_U_LB_SURROGATE, /**< [SG] */ + I18N_UCHAR_U_LB_SPACE, /**< [SP] */ + I18N_UCHAR_U_LB_BREAK_SYMBOLS, /**< [SY] */ + I18N_UCHAR_U_LB_ZWSPACE, /**< [ZW] */ + I18N_UCHAR_U_LB_NEXT_LINE, /**< [NL] */ + I18N_UCHAR_U_LB_WORD_JOINER, /**< [WJ] */ + I18N_UCHAR_U_LB_H2, /**< [H2] */ + I18N_UCHAR_U_LB_H3, /**< [H3] */ + I18N_UCHAR_U_LB_JL, /**< [JL] */ + I18N_UCHAR_U_LB_JT, /**< [JT] */ + I18N_UCHAR_U_LB_JV, /**< [JV] */ + I18N_UCHAR_U_LB_CLOSE_PARENTHESIS, /**< [CP] */ + I18N_UCHAR_U_LB_COUNT + } i18n_uchar_u_line_break_e; + +/** + * @brief Enumeration for Numeric Type constants. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { +/* + * Note: i18n_uchar_u_numeric_type_e constants are parsed by preparseucd.py. + * It matches lines like + * U_NT_ + */ + I18N_UCHAR_U_NT_NONE, /**< [None] */ + I18N_UCHAR_U_NT_DECIMAL, /**< [de] */ + I18N_UCHAR_U_NT_DIGIT, /**< [di] */ + I18N_UCHAR_U_NT_NUMERIC, /**< [nu] */ + I18N_UCHAR_U_NT_COUNT /**< */ +} i18n_uchar_u_numeric_type_e; + +/** + * @brief Enumeration for Hangul Syllable Type constants. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { +/* + * Note: i18n_uchar_u_hangul_syllable_type_e constants are parsed by preparseucd.py. + * It matches lines like + * U_HST_ + */ + I18N_UCHAR_U_HST_NOT_APPLICABLE, /**< [NA] */ + I18N_UCHAR_U_HST_LEADING_JAMO, /**< [L] */ + I18N_UCHAR_U_HST_VOWEL_JAMO, /**< [V] */ + I18N_UCHAR_U_HST_TRAILING_JAMO, /**< [T] */ + I18N_UCHAR_U_HST_LV_SYLLABLE, /**< [LV] */ + I18N_UCHAR_U_HST_LVT_SYLLABLE, /**< [LVT] */ + I18N_UCHAR_U_HST_COUNT /**< */ +} i18n_uchar_u_hangul_syllable_type_e; + +/** + * @brief Enumeration for Sentence Break constants. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { +/* + * Note: i18n_uchar_u_sentence_break_e constants are parsed by preparseucd.py. + * It matches lines like + * U_SB_ + */ + I18N_UCHAR_U_SB_OTHER, /**< [XX] */ + I18N_UCHAR_U_SB_ATERM, /**< [AT] */ + I18N_UCHAR_U_SB_CLOSE, /**< [CL] */ + I18N_UCHAR_U_SB_FORMAT, /**< [FO] */ + I18N_UCHAR_U_SB_LOWER, /**< [LO] */ + I18N_UCHAR_U_SB_NUMERIC, /**< [NU] */ + I18N_UCHAR_U_SB_OLETTER, /**< [LE] */ + I18N_UCHAR_U_SB_SEP, /**< [SE] */ + I18N_UCHAR_U_SB_SP, /**< [SP] */ + I18N_UCHAR_U_SB_STERM, /**< [ST] */ + I18N_UCHAR_U_SB_UPPER, /**< [UP] */ + I18N_UCHAR_U_SB_CR, /**< [CR] */ + I18N_UCHAR_U_SB_EXTEND, /**< [EX] */ + I18N_UCHAR_U_SB_LF, /**< [LF] */ + I18N_UCHAR_U_SB_SCONTINUE, /**< [SC] */ + I18N_UCHAR_U_SB_COUNT /**< */ +} i18n_uchar_u_sentence_break_e; + +/** + * @brief Enumeration for Word Break constants. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { +/* + * Note: i18n_uchar_u_word_break_values_e constants are parsed by preparseucd.py. + * It matches lines like + * U_WB_ + */ + I18N_UCHAR_U_WB_OTHER, /**< [XX] */ + I18N_UCHAR_U_WB_ALETTER, /**< [LE] */ + I18N_UCHAR_U_WB_FORMAT, /**< [FO] */ + I18N_UCHAR_U_WB_KATAKANA, /**< [KA] */ + I18N_UCHAR_U_WB_MIDLETTER, /**< [ML] */ + I18N_UCHAR_U_WB_MIDNUM, /**< [MN] */ + I18N_UCHAR_U_WB_NUMERIC, /**< [NU] */ + I18N_UCHAR_U_WB_EXTENDNUMLET, /**< [EX] */ + I18N_UCHAR_U_WB_CR, /**< [CR] */ + I18N_UCHAR_U_WB_EXTEND, /**< [Extend] */ + I18N_UCHAR_U_WB_LF, /**< [LF] */ + I18N_UCHAR_U_WB_MIDNUMLET, /**< [MB] */ + I18N_UCHAR_U_WB_NEWLINE, /**< [NL] */ + I18N_UCHAR_U_WB_COUNT /**< */ +} i18n_uchar_u_word_break_values_e; + +/** + * @brief Enumeration for Grapheme Cluster Break constants. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { +/* + * Note: i18n_uchar_u_grapheme_cluster_break_e constants are parsed by preparseucd.py. + * It matches lines like + * U_GCB_ + */ + I18N_UCHAR_U_GCB_OTHER, /**< [XX] */ + I18N_UCHAR_U_GCB_CONTROL, /**< [CN] */ + I18N_UCHAR_U_GCB_CR, /**< [CR] */ + I18N_UCHAR_U_GCB_EXTEND, /**< [EX] */ + I18N_UCHAR_U_GCB_L, /**< [L] */ + I18N_UCHAR_U_GCB_LF, /**< [LF] */ + I18N_UCHAR_U_GCB_LV, /**< [LV] */ + I18N_UCHAR_U_GCB_LVT, /**< [LVT] */ + I18N_UCHAR_U_GCB_T, /**< [T] */ + I18N_UCHAR_U_GCB_V, /**< [V] */ + I18N_UCHAR_U_GCB_SPACING_MARK, /**< [SM] */ + I18N_UCHAR_U_GCB_PREPEND, /**< [PP] */ + I18N_UCHAR_UCHAR_U_GCB_COUNT /**< */ +} i18n_uchar_u_grapheme_cluster_break_e; + +/** + * @} + * @} + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULE + * @{ + */ + +/** + * @brief Structure representing a collator object instance. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef void *i18n_ucollator_h; + +/** + * @brief Enumeration for attributes that collation service understands. + * All the attributes can take #I18N_UCOLLATOR_DEFAULT value, as well as the values specific to each one. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { + I18N_UCOLLATOR_FRENCH_COLLATION, /**< Attribute for direction of secondary weights - used in Canadian French. Acceptable values are #I18N_UCOLLATOR_ON, which results in secondary weights being considered backwards, and #I18N_UCOLLATOR_OFF which treats secondary weights in the order they appear */ + I18N_UCOLLATOR_ALTERNATE_HANDLING, /**< Attribute for handling variable elements. Acceptable values are #I18N_UCOLLATOR_NON_IGNORABLE (default) which treats all the codepoints with non-ignorable primary weights in the same way, and #I18N_UCOLLATOR_SHIFTED which causes codepoints with primary weights that are equal or below the variable top value to be ignored at the primary level and moved to the quaternary level */ + I18N_UCOLLATOR_CASE_FIRST, /**< Controls the ordering of upper and lower case letters. Acceptable values are #I18N_UCOLLATOR_OFF (default), which orders upper and lower case letters in accordance to their tertiary weights, #I18N_UCOLLATOR_UPPER_FIRST which forces upper case letters to sort before lower case letters, and #I18N_UCOLLATOR_LOWER_FIRST which does the opposite */ + I18N_UCOLLATOR_CASE_LEVEL, /**< Controls whether an extra case level (positioned before the third level) is generated or not. Acceptable values are #I18N_UCOLLATOR_OFF (default), when case level is not generated, and #I18N_UCOLLATOR_ON which causes the case level to be generated. Contents of the case level are affected by the value of the #I18N_UCOLLATOR_CASE_FIRST attribute. A simple way to ignore accent differences in a string is to set the strength to #I18N_UCOLLATOR_PRIMARY and enable case level */ + I18N_UCOLLATOR_NORMALIZATION_MODE, /**< Controls whether the normalization check and necessary normalizations are performed. When set to #I18N_UCOLLATOR_OFF (default) no normalization check is performed. The correctness of the result is guaranteed only if the input data is in so-called FCD form (see users manual for more info). When set to #I18N_UCOLLATOR_ON, an incremental check is performed to see whether the input data is in the FCD form. If the data is not in the FCD form, incremental NFD normalization is performed */ + I18N_UCOLLATOR_DECOMPOSITION_MODE = I18N_UCOLLATOR_NORMALIZATION_MODE, /**< An alias for the #I18N_UCOLLATOR_NORMALIZATION_MODE attribute */ + I18N_UCOLLATOR_STRENGTH, /**< The strength attribute. Can be either #I18N_UCOLLATOR_PRIMARY, #I18N_UCOLLATOR_SECONDARY, #I18N_UCOLLATOR_TERTIARY, #I18N_UCOLLATOR_QUATERNARY, or #I18N_UCOLLATOR_IDENTICAL. The usual strength for most locales (except Japanese) is tertiary. Quaternary strength is useful when combined with shifted setting for the alternate handling attribute and for JIS X 4061 collation, when it is used to distinguish between Katakana and Hiragana. Otherwise, quaternary level is affected only by the number of non-ignorable code points in the string. Identical strength is rarely useful, as it amounts to codepoints of the NFD form of the string */ + I18N_UCOLLATOR_NUMERIC_COLLATION = I18N_UCOLLATOR_STRENGTH + 2, /**< When turned on, this attribute makes substrings of digits that are sort according to their numeric values. This is a way to get '100' to sort AFTER '2'. Note that the longest digit substring that can be treated as a single unit is 254 digits (not counting leading zeros). If a digit substring is longer than that, the digits beyond the limit will be treated as a separate digit substring. A "digit" in this sense is a code point with General_Category=Nd, which does not include circled numbers, roman numerals, and so on. Only a contiguous digit substring is considered, that is, non-negative integers without separators. There is no support for plus/minus signs, decimals, exponents, and so on */ + I18N_UCOLLATOR_ATTRIBUTE_COUNT /**< The number of i18n_ucollator_attribute_e constants */ +} i18n_ucollator_attribute_e; + +/** + * @brief Enumeration containing attribute values for controlling collation behavior. + * Here are all the allowable values. Not every attribute can take every value. + * The only universal value is #I18N_UCOLLATOR_DEFAULT, which resets the attribute value to the predefined value for that locale. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { + I18N_UCOLLATOR_DEFAULT = -1, /**< Accepted by most attributes */ + I18N_UCOLLATOR_PRIMARY = 0, /**< Primary collation strength */ + I18N_UCOLLATOR_SECONDARY = 1, /**< Secondary collation strength */ + I18N_UCOLLATOR_TERTIARY = 2, /**< Tertiary collation strength */ + I18N_UCOLLATOR_DEFAULT_STRENGTH = I18N_UCOLLATOR_TERTIARY, /**< Default collation strength */ + I18N_UCOLLATOR_CE_STRENGTH_LIMIT, + I18N_UCOLLATOR_QUATERNARY = 3, /**< Quaternary collation strength */ + I18N_UCOLLATOR_IDENTICAL = 15, /**< Identical collation strength */ + I18N_UCOLLATOR_STRENGTH_LIMIT, + + I18N_UCOLLATOR_OFF = 16, /**< Turn the feature off - works for #I18N_UCOLLATOR_FRENCH_COLLATION, #I18N_UCOLLATOR_CASE_LEVEL & #I18N_UCOLLATOR_DECOMPOSITION_MODE */ + I18N_UCOLLATOR_ON = 17, /**< Turn the feature on - works for #I18N_UCOLLATOR_FRENCH_COLLATION, #I18N_UCOLLATOR_CASE_LEVEL & #I18N_UCOLLATOR_DECOMPOSITION_MODE */ + + I18N_UCOLLATOR_SHIFTED = 20, /**< Valid for #I18N_UCOLLATOR_ALTERNATE_HANDLING. Alternate handling will be shifted. */ + I18N_UCOLLATOR_NON_IGNORABLE = 21, /**< Valid for #I18N_UCOLLATOR_ALTERNATE_HANDLING. Alternate handling will be non ignorable. */ + I18N_UCOLLATOR_LOWER_FIRST = 24, /**< Valid for #I18N_UCOLLATOR_CASE_FIRST - lower case sorts before upper case. */ + I18N_UCOLLATOR_UPPER_FIRST = 25, /**< Upper case sorts before lower case. */ + I18N_UCOLLATOR_ATTRIBUTE_VALUE_COUNT +} i18n_ucollator_attribute_value_e; + +/** + * @brief Enumeration in which the base letter represents a primary difference. Set comparison level to #I18N_UCOLLATOR_PRIMARY to ignore secondary and tertiary differences. Use this to set the strength of an #i18n_ucollator_h. Example of primary difference, "abc" < "abd" + * Diacritical differences on the same base letter represent a secondary difference. Set comparison level to #I18N_UCOLLATOR_SECONDARY to ignore tertiary differences. Use this to set the strength of an #i18n_ucollator_h. Example of secondary difference, "ä" >> "a". + * Uppercase and lowercase versions of the same character represent a tertiary difference. Set comparison level to #I18N_UCOLLATOR_TERTIARY to include all comparison differences. Use this to set the strength of an #i18n_ucollator_h. Example of tertiary difference, "abc" <<< "ABC". + * Two characters are considered "identical" when they have the same unicode spellings. #I18N_UCOLLATOR_IDENTICAL. For example, "ä" == "ä". + * #i18n_ucollator_strength_e is also used to determine the strength of sort keys generated from #i18n_ucollator_h. These values can now be found in the #i18n_ucollator_attribute_value_e enum. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef i18n_ucollator_attribute_value_e i18n_ucollator_strength_e; + +/** + * @brief Enumeration for source and target string comparison result. + * #I18N_UCOLLATOR_LESS is returned if the source string is compared to be less than the target string in the {@link i18n_ucollator_str_collator() } method. + * #I18N_UCOLLATOR_EQUAL is returned if the source string is compared to be equal to the target string in the {@link i18n_ucollator_str_collator() } method. + * #I18N_UCOLLATOR_GREATER is returned if the source string is compared to be greater than the target string in the {@link #i18n_ucollator_str_collator() } method. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { + I18N_UCOLLATOR_EQUAL = 0, /**< string a == string b */ + I18N_UCOLLATOR_GREATER = 1, /**< string a > string b */ + I18N_UCOLLATOR_LESS = -1 /**< string a < string b */ +} i18n_ucollator_result_e; + +/** + * @} + * @} + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_UNORMALIZATION_MODULE + * @{ + */ + + +/** + * @brief i18n_unormalizer_h. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + */ + +typedef const void* i18n_unormalizer_h; + +/** + * @brief Enumeration of constants for normalization modes. + * For details about standard Unicode normalization forms and about the algorithms which are also used with custom mapping tables see http://www.unicode.org/unicode/reports/tr15/ + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { + I18N_UNORMALIZATION_COMPOSE, /**< Decomposition followed by composition. Same as standard NFC when using an "nfc" instance. Same as standard NFKC when using an "nfkc" instance. + For details about standard Unicode normalization forms see http://www.unicode.org/unicode/reports/tr15/ */ + I18N_UNORMALIZATION_DECOMPOSE, /**< Map and reorder canonically. Same as standard NFD when using an "nfc" instance. Same as standard NFKD when using an "nfkc" instance. + For details about standard Unicode normalization forms see http://www.unicode.org/unicode/reports/tr15/ */ + I18N_UNORMALIZATION_FCD, /**< "Fast C or D" form. If a string is in this form, then further decomposition without reordering would yield the same form as DECOMPOSE. + Text in "Fast C or D" form can be processed efficiently with data tables that are "canonically closed", + that is, that provide equivalent data for equivalent text, without having to be fully normalized. + Not a standard Unicode normalization form. Not a unique form: Different FCD strings can be canonically equivalent. + For details see http://www.unicode.org/notes/tn5/#FCD */ + I18N_UNORMALIZATION_COMPOSE_CONTIGUOUS /**< Compose only contiguously. Also known as "FCC" or "Fast C Contiguous". The result will often but not always be in NFC. + The result will conform to FCD which is useful for processing. Not a standard Unicode normalization form. + For details see http://www.unicode.org/notes/tn5/#FCC */ +} i18n_unormalization_mode_e; + +/** + * @} + * @} + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_USEARCH_MODULE + * @{ + */ + +/** + * @brief i18n_usearch_h. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef void* i18n_usearch_h; + +/** + * @} + * @} + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE + * @{ + */ + +/** + * @brief i18n_ucalendar_h. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef void* i18n_ucalendar_h; + +/** + * @brief The time zone ID reserved for unknown time zone. + * @since_tizen 2.3.1 + */ +#define I18N_UCALENDAR_UNKNOWN_ZONE_ID "Etc/Unknown" + +/** + * @brief Enumeration for possible fields in an #i18n_ucalendar_h. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { + I18N_UCALENDAR_ERA, /**< Field number indicating the era, e.g., AD or BC in the Gregorian (Julian) calendar */ + I18N_UCALENDAR_YEAR, /**< Field number indicating the year */ + I18N_UCALENDAR_MONTH, /**< Field number indicating the month. This is a calendar-specific value. \n The first month of the year is JANUARY; + the last depends on the number of months in a year */ + I18N_UCALENDAR_WEEK_OF_YEAR, /**< Field number indicating the week number within the current year. \n + The first week of the year, as defined by the #I18N_UCALENDAR_FIRST_DAY_OF_WEEK and #I18N_UCALENDAR_MINIMAL_DAYS_IN_FIRST_WEEK attributes, has value 1. + Subclasses define the value of #I18N_UCALENDAR_WEEK_OF_YEAR for days before the first week of the year */ + I18N_UCALENDAR_WEEK_OF_MONTH, /**< Field number indicating the week number within the current month. \n + The first week of the month, as defined by the #I18N_UCALENDAR_FIRST_DAY_OF_WEEK and #I18N_UCALENDAR_MINIMAL_DAYS_IN_FIRST_WEEK attributes, has value 1. + Subclasses define the value of WEEK_OF_MONTH for days before the first week of the month */ + I18N_UCALENDAR_DATE, /**< Field number indicating the day of the month. \n This is a synonym for DAY_OF_MONTH. The first day of the month has value 1 */ + I18N_UCALENDAR_DAY_OF_YEAR, /**< Field number indicating the day number within the current year. \n The first day of the year has value 1. */ + I18N_UCALENDAR_DAY_OF_WEEK, /**< Field number indicating the day of the week. \n + This field takes values "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", and "Saturday" */ + I18N_UCALENDAR_DAY_OF_WEEK_IN_MONTH, /**< Field number indicating the ordinal number of the day of the week within the current month. \n + Together with the "day of week" field, this uniquely specifies a day within a month. + "day of month" 1 through 7 always correspond to "day of week in month" 1; 8 through 15 correspond to "day of week in month" 2, and so on. + "day of week in month" 0 indicates the week before "day of week in month" 1. + Negative values count back from the end of the month, so the last Sunday of a month is specified as "day of week" = "Sunday", + "day of week in month" = -1. Because negative values count backward they will usually be aligned differently within the month than positive values. + For example, if a month has 31 days, "day of week in month" -1 will overlap "day of week in month" 5 and the end of 4 */ + I18N_UCALENDAR_AM_PM, /**< Field number indicating whether the "hour" is before or after noon. \n E.g., at 10:04:15.250 PM the AM_PM is PM */ + I18N_UCALENDAR_HOUR, /**< Field number indicating the hour of the morning or afternoon. \n "hour" is used for the 12-hour clock. E.g., at 10:04:15.250 PM the "Hour" is 10 */ + I18N_UCALENDAR_HOUR_OF_DAY, /**< Field number indicating the hour of the day. \n "Hour of day" is used for the 24-hour clock. E.g., at 10:04:15.250 PM the "Hour of day" is 22 */ + I18N_UCALENDAR_MINUTE, /**< Field number indicating the minute within the hour. \n E.g., at 10:04:15.250 PM the #I18N_UCALENDAR_MINUTE is 4 */ + I18N_UCALENDAR_SECOND, /**< Field number indicating the second within the minute. \n E.g., at 10:04:15.250 PM the #I18N_UCALENDAR_SECOND is 15 */ + I18N_UCALENDAR_MILLISECOND, /**< Field number indicating the millisecond within the second. \n E.g., at 10:04:15.250 PM the #I18N_UCALENDAR_MILLISECOND is 250 */ + I18N_UCALENDAR_ZONE_OFFSET, /**< Field number indicating the raw offset from GMT in milliseconds */ + I18N_UCALENDAR_DST_OFFSET, /**< Field number indicating the daylight savings offset in milliseconds */ + I18N_UCALENDAR_YEAR_WOY, /**< Field number indicating the extended year corresponding to the #I18N_UCALENDAR_WEEK_OF_YEAR field. \n + This may be one greater or less than the value of #I18N_UCALENDAR_EXTENDED_YEAR */ + I18N_UCALENDAR_DOW_LOCAL, /**< Field number indicating the localized day of the week. \n + This will be a value from 1 to 7 inclusive, with 1 being the localized first day of the week */ + I18N_UCALENDAR_EXTENDED_YEAR, /**< Year of this calendar system, encompassing all supra-year fields. \n + For example, in Gregorian/Julian calendars, positive Extended Year values indicate years AD, 1 BC = 0 extended, 2 BC = -1 extended, and so on */ + I18N_UCALENDAR_JULIAN_DAY, /**< Field number indicating the modified Julian day number. \n + This is different from the conventional Julian day number in two regards. + First, it demarcates days at local zone midnight, rather than noon GMT. Second, it is a local number; that is, it depends on the local time zone. + It can be thought of as a single number that encompasses all the date-related fields */ + I18N_UCALENDAR_MILLISECONDS_IN_DAY, /**< Ranges from 0 to 23:59:59.999 (regardless of DST). \n + This field behaves exactly like a composite of all time-related fields, not including the zone fields. + As such, it also reflects discontinuities in those fields on DST transition days. On a day of DST onset, it will jump forward. + On a day of DST cessation, it will jump backward. + This reflects the fact that it must be combined with the DST offset field to obtain a unique local time value */ + I18N_UCALENDAR_IS_LEAP_MONTH, /**< Whether or not the current month is a leap month (0 or 1) */ + I18N_UCALENDAR_FIELD_COUNT, /**< Number of enumerators */ + I18N_UCALENDAR_DAY_OF_MONTH = I18N_UCALENDAR_DATE /**< Field number indicating the day of the month. \n This is a synonym for #I18N_UCALENDAR_DATE. The first day of the month has value 1 */ +} i18n_ucalendar_date_fields_e; + +/** + * @brief Enumeration for possible months in an #i18n_ucalendar_h. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { + I18N_UCALENDAR_TRADITIONAL, /**< Despite the name, #I18N_UCALENDAR_TRADITIONAL designates the locale's default calendar, which may be the Gregorian calendar or some other calendar */ + I18N_UCALENDAR_DEFAULT = I18N_UCALENDAR_TRADITIONAL, /**< A better name for #I18N_UCALENDAR_TRADITIONAL */ + I18N_UCALENDAR_GREGORIAN /**< Unambiguously designates the Gregorian calendar for the locale */ +} i18n_ucalendar_type_e; + +/** + * @brief Enumeration for possible months in an #i18n_ucalendar_h. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { + I18N_UCALENDAR_JANUARY, /**< January */ + I18N_UCALENDAR_FEBRUARY, /**< February */ + I18N_UCALENDAR_MARCH, /**< March */ + I18N_UCALENDAR_APRIL, /**< April */ + I18N_UCALENDAR_MAY, /**< May */ + I18N_UCALENDAR_JUNE, /**< June */ + I18N_UCALENDAR_JULY, /**< July */ + I18N_UCALENDAR_AUGUST, /**< August */ + I18N_UCALENDAR_SEPTEMBER, /**< September */ + I18N_UCALENDAR_OCTOBER, /**< October */ + I18N_UCALENDAR_NOVEMBER, /**< November */ + I18N_UCALENDAR_DECEMBER /**< December */ +} i18n_ucalendar_months_e; + +/** + * @brief Enumeration for possible formats of an #i18n_ucalendar_h's display name. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { + I18N_UCALENDAR_STANDARD, /**< Standard display name */ + I18N_UCALENDAR_SHORT_STANDARD, /**< Short standard display name */ + I18N_UCALENDAR_DST, /**< Daylight savings display name */ + I18N_UCALENDAR_SHORT_DST /**< Short daylight savings display name */ +} i18n_ucalendar_displayname_type_e; + +/** + * @brief Enumeration for types of #i18n_ucalendar_h attributes. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { + I18N_UCALENDAR_LENIENT, /**< Lenient parsing */ + I18N_UCALENDAR_FIRST_DAY_OF_WEEK, /**< First day of the week */ + I18N_UCALENDAR_MINIMAL_DAYS_IN_FIRST_WEEK /**< Minimum number of days in the first week */ +} i18n_ucalendar_attribute_e; + +/** + * @brief System time zone type constants. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { + I18N_UCALENDAR_ZONE_TYPE_ANY, /**< Any system zones. */ + I18N_UCALENDAR_ZONE_TYPE_CANONICAL, /**< Canonical system zones. */ + I18N_UCALENDAR_ZONE_TYPE_CANONICAL_LOCATION /**< Canonical system zones associated with actual locations. */ +} i18n_system_timezone_type_e; + +/** + * @brief Possible limit values for an #i18n_ucalendar_h. + * @since_tizen 2.3.1 + */ +typedef enum { + I18N_UCALENDAR_MINIMUM, /**< Minimum value */ + I18N_UCALENDAR_MAXIMUM, /**< Maximum value */ + I18N_UCALENDAR_GREATEST_MINIMUM, /**< Greatest minimum value */ + I18N_UCALENDAR_LEAST_MAXIMUM, /**< Least maximum value */ + I18N_UCALENDAR_ACTUAL_MINIMUM, /**< Actual minimum value */ + I18N_UCALENDAR_ACTUAL_MAXIMUM /**< Actual maximum value */ +} i18n_ucalendar_limit_type_e; + +/** + * @brief Weekday types, as returned by i18n_ucalendar_get_day_of_week_type(). + * @since_tizen 2.3.1 + */ +typedef enum { + I18N_UCALENDAR_WEEKDAY, /**< Designates a full weekday (no part of the day is included in the weekend). */ + I18N_UCALENDAR_WEEKEND, /**< Designates a full weekend day (the entire day is included in the weekend). */ + I18N_UCALENDAR_WEEKEND_ONSET, /**< Designates a day that starts as a weekday and transitions to the weekend. + Call i18n_ucalendar_get_weekend_transition() to get the time of transition. */ + I18N_UCALENDAR_WEEKEND_CEASE, /**< Designates a day that starts as the weekend and transitions to a weekday. + Call i18n_ucalendar_get_weekend_transition() to get the time of transition. */ +} i18n_ucalendar_weekday_type_e; + +/** + * @brief Useful constants for days of week. + * @details Note: Calendar day-of-week is 1-based. Clients who create locale resources for the field of first-day-of-week should be aware of this. + * For instance, in US locale, first-day-of-week is set to 1, i.e., #I18N_UCALENDAR_SUNDAY. Possible days of the week in an #i18n_ucalendar_h. + * @since_tizen 2.3.1 + */ +typedef enum { + I18N_UCALENDAR_SUNDAY = 1, /**< Sunday */ + I18N_UCALENDAR_MONDAY, /**< Monday */ + I18N_UCALENDAR_TUESDAY, /**< Tuesday */ + I18N_UCALENDAR_WEDNESDAY, /**< Wednesday */ + I18N_UCALENDAR_THURSDAY, /**< Thursday */ + I18N_UCALENDAR_FRIDAY, /**< Friday */ + I18N_UCALENDAR_SATURDAY /**< Saturday */ +} i18n_ucalendar_days_of_week_e; + +/** + * @brief Time zone transition types for i18n_ucalendar_get_timezone_transition_date(). + * @since_tizen 2.3.1 + * + * @see i18n_ucalendar_get_timezone_transition_date() + */ +typedef enum { + I18N_UCALENDAR_TZ_TRANSITION_NEXT, /**< Get the next transition after the current date, i.e. excludes the current date */ + I18N_UCALENDAR_TZ_TRANSITION_NEXT_INCLUSIVE, /**< Get the next transition on or after the current date, i.e. may include the current date */ + I18N_UCALENDAR_TZ_TRANSITION_PREVIOUS, /**< Get the previous transition before the current date, i.e. excludes the current date */ + I18N_UCALENDAR_TZ_TRANSITION_PREVIOUS_INCLUSIVE, /**< Get the previous transition on or before the current date, i.e. may include the current date */ +} i18n_utimezone_transition_type_e; + +/** + * @} + * @} + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_UDATE_MODULE + * @{ + */ + +/** + * @brief Date and Time data type. \n This is a primitive data type that holds the date and time as the number of milliseconds since 1970-jan-01, 00:00 UTC. UTC leap seconds are ignored. + */ + +/** + * @brief Date and Time data type. + * @details This is a primitive data type that holds the date and time as the number of milliseconds since 1970-jan-01, 00:00 UTC. UTC leap seconds are ignored. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef double i18n_udate; + +/** + * @brief A date formatter. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef void *i18n_udate_format_h; + +/** + * @brief A struct representing a range of text containing a specific field. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef struct { + int32_t field; /**< The field. */ + int32_t beginIndex; /**< The start of the text range containing field.*/ + int32_t endIndex; /**< The limit of the text range containing field.*/ +} i18n_ufield_position_s; + +/** + * @brief Handle to struct representing a range of text containing a specific field. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef i18n_ufield_position_s* i18n_ufield_position_h; + +/** + * @brief Enumeration for the possible date/time format styles. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { + I18N_UDATE_FULL, /**< Full style */ + I18N_UDATE_LONG, /**< Long style */ + I18N_UDATE_MEDIUM, /**< Medium style */ + I18N_UDATE_SHORT, /**< Short style */ + I18N_UDATE_DEFAULT = I18N_UDATE_MEDIUM, /**< Default style */ + I18N_UDATE_RELATIVE = (1 << 7), /**< Bitfield for relative date */ + I18N_UDATE_FULL_RELATIVE = I18N_UDATE_FULL | I18N_UDATE_RELATIVE, /**< #I18N_UDATE_FULL | #I18N_UDATE_RELATIVE */ + I18N_UDATE_LONG_RELATIVE = I18N_UDATE_LONG | I18N_UDATE_RELATIVE, /**< #I18N_UDATE_LONG | #I18N_UDATE_RELATIVE */ + I18N_UDATE_MEDIUM_RELATIVE = I18N_UDATE_MEDIUM | I18N_UDATE_RELATIVE, /**< #I18N_UDATE_MEDIUM | #I18N_UDATE_RELATIVE */ + I18N_UDATE_SHORT_RELATIVE = I18N_UDATE_SHORT | I18N_UDATE_RELATIVE, /**< #I18N_UDATE_SHORT | #I18N_UDATE_RELATIVE */ + I18N_UDATE_NONE = -1, /**< No style */ + I18N_UDATE_PATTERN = -2 /**< Use the pattern given in the parameter to i18n_udate_create(). */ +} i18n_udate_format_style_e; + +/** + * @brief Enumeration for format fields. + * @since_tizen 2.3.1 + */ +typedef enum { + I18N_UDATE_FORMAT_ERA_FIELD, /**< Era field */ + I18N_UDATE_FORMAT_YEAR_FIELD, /**< Year field */ + I18N_UDATE_FORMAT_MONTH_FIELD, /**< Month field */ + I18N_UDATE_FORMAT_DATE_FIELD, /**< Date field */ + I18N_UDATE_FORMAT_HOUR_OF_DAY1_FIELD, /**< Hour of day1 field */ + I18N_UDATE_FORMAT_HOUR_OF_DAY0_FIELD, /**< Hour of day0 field */ + I18N_UDATE_FORMAT_MINUTE_FIELD, /**< Minute field */ + I18N_UDATE_FORMAT_SECOND_FIELD, /**< Second field */ + I18N_UDATE_FORMAT_FRACTIONAL_SECOND_FIELD, /**< Fractional second field */ + I18N_UDATE_FORMAT_DAY_OF_WEEK_FIELD, /**< Day of week field */ + I18N_UDATE_FORMAT_DAY_OF_YEAR_FIELD, /**< Day of year field */ + I18N_UDATE_FORMAT_DAY_OF_WEEK_IN_MONTH_FIELD, /**< Day of week in month field */ + I18N_UDATE_FORMAT_WEEK_OF_YEAR_FIELD, /**< Week of year field */ + I18N_UDATE_FORMAT_WEEK_OF_MONTH_FIELD, /**< Week of month field */ + I18N_UDATE_FORMAT_AM_PM_FIELD, /**< a.m. / p.m. field */ + I18N_UDATE_FORMAT_HOUR1_FIELD, /**< Hour1 field */ + I18N_UDATE_FORMAT_HOUR0_FIELD, /**< Hour0 field */ + I18N_UDATE_FORMAT_TIMEZONE_FIELD, /**< Timezone field */ + I18N_UDATE_FORMAT_YEAR_WOY_FIELD, /**< Year woy field */ + I18N_UDATE_FORMAT_DOW_LOCAL_FIELD, /**< Dow local field */ + I18N_UDATE_FORMAT_EXTENDED_YEAR_FIELD, /**< Extended year field */ + I18N_UDATE_FORMAT_JULIAN_DAY_FIELD, /**< Julian day field */ + I18N_UDATE_FORMAT_MILLISECONDS_IN_DAY_FIELD, /**< Milliseconds in day field */ + I18N_UDATE_FORMAT_TIMEZONE_RFC_FIELD, /**< Timezone RFC field */ + I18N_UDATE_FORMAT_TIMEZONE_GENERIC_FIELD, /**< Timezone generic field */ + I18N_UDATE_FORMAT_STANDALONE_DAY_FIELD, /**< Standalone day field */ + I18N_UDATE_FORMAT_STANDALONE_MONTH_FIELD, /**< Standalone month field */ + I18N_UDATE_FORMAT_QUARTER_FIELD, /**< Quarter field */ + I18N_UDATE_FORMAT_STANDALONE_QUARTER_FIELD, /**< Standalone quarter field */ + I18N_UDATE_FORMAT_TIMEZONE_SPECIAL_FIELD, /**< Timezone special field */ + I18N_UDATE_FORMAT_YEAR_NAME_FIELD, /**< Year name field */ + I18N_UDATE_FORMAT_TIMEZONE_LOCALIZED_GMT_OFFSET_FIELD, /**< Timezone localized gmt offset field */ + I18N_UDATE_FORMAT_TIMEZONE_ISO_FIELD, /**< Timezone ISO field */ + I18N_UDATE_FORMAT_TIMEZONE_ISO_LOCAL_FIELD, /**< Timezone ISO local field */ + I18N_UDATE_FORMAT_FIELD_COUNT /**< Field count */ +} i18n_udate_format_field_e; + +/** + * @brief Enumeration for symbol types. + * @since_tizen 2.3.1 + */ +typedef enum { + I18N_UDATE_FORMAT_SYMBOL_TYPE_ERAS, /**< Eras */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_MONTHS, /**< Months */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_SHORT_MONTHS, /**< Short months */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_WEEKDAYS, /**< Weekdays */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_SHORT_WEEKDAYS, /**< Short weekdays */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_AM_PMS, /**< AM PMs */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_LOCALIZED_CHARS, /**< Localized chars */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_ERA_NAMES, /**< Era names */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_NARROW_MONTHS, /**< Narrow months */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_NARROW_WEEKDAYS, /**< Narrow weekdays */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_STANDALONE_MONTHS, /**< Standalone months */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_STANDALONE_SHORT_MONTHS, /**< Standalone short months */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_STANDALONE_NARROW_MONTHS, /**< Standalone narrow months */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_STANDALONE_WEEKDAYS, /**< Standalone weekdays */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_STANDALONE_SHORT_WEEKDAYS, /**< Standalone short weekdays */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_STANDALONE_NARROW_WEEKDAYS, /**< Standalone narrow weekdays */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_QUARTERS, /**< Quarters */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_SHORT_QUARTERS, /**< Short quarters */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_STANDALONE_QUARTERS, /**< Standalone quarters */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_STANDALONE_SHORT_QUARTERS, /**< Standalone short quarters */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_SHORTER_WEEKDAYS, /**< Shorter weekdays */ + I18N_UDATE_FORMAT_SYMBOL_TYPE_STANDALONE_SHORTER_WEEKDAYS, /**< Standalone shorter weekdays */ +} i18n_udate_format_symbol_type_e; + +/** + * @brief Display context types, for getting values of a particular setting. + * @details Note, the specific numeric values are internal and may change. + * @since_tizen 2.3.1 + + */ +typedef enum{ + I18N_UDISPCTX_TYPE_DIALECT_HANDLING, /** + +/** + * @file utils_i18n_ubrk.h + * @version 0.1 + * @brief utils_i18n_ubrk + */ + +/** + * @ingroup CAPI_BASE_UTILS_I18N_MODULE + * @defgroup CAPI_BASE_UTILS_I18N_UBRK_MODULE Ubrk + * @brief Ubrk defines methods for finding the location of boundaries in text. + * + * @section CAPI_BASE_UTILS_I18N_UBRK_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_BASE_UTILS_I18N_UBRK_MODULE_OVERVIEW Overview + * @details Pointer to a #i18n_ubreak_iterator_h maintains a current position and scans over text returning the index of characters where boundaries occur. + * + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_UBRK_MODULE + * @{ + */ + +/** + * @brief Opens a new #i18n_ubreak_iterator_h for locating text boundaries for a specified locale. + * @details A #i18n_ubreak_iterator_h may be used for detecting character, line, word, + * and sentence breaks in text. + * @remarks Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * @param[in] type The type of #i18n_ubreak_iterator_h to open: one of #I18N_UBRK_CHARACTER, #I18N_UBRK_WORD, + * #I18N_UBRK_LINE, #I18N_UBRK_SENTENCE + * @param[in] locale The locale specifying the text-breaking conventions. + * If @c NULL, the default locale will be used. + * @param[in] text The text to be iterated over. May be @c NULL, then the iterator will be created without any text. + * The text can be set later with i18n_ubrk_set_text() function. + * @param[in] text_length The number of characters in text, or -1 if NULL-terminated. + * @param[out] break_iter A pointer to the #i18n_ubreak_iterator_h for the specified locale. + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ubrk_create_rules() + */ +int i18n_ubrk_create (i18n_ubreak_iterator_type_e type, const char *locale, const i18n_uchar *text, int32_t text_length, i18n_ubreak_iterator_h *break_iter); + +/** + * @brief Opens a new #i18n_ubreak_iterator_h for locating text boundaries using specified breaking rules. + * @remarks Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * @param[in] rules A set of rules specifying the text breaking conventions. + * @param[in] rules_length The number of characters in rules, or -1 if NULL-terminated. + * @param[in] text The text to be iterated over. May be @c NULL, in which case i18n_ubrk_set_text() is + * used to specify the text to be iterated. + * @param[in] text_length The number of characters in text, or -1 if NULL-terminated. + * @param[out] break_iter A pointer to the #i18n_ubreak_iterator_h for the specified rules. + * @param[out] parse_err Receives position and context information for any syntax errors + * detected while parsing the rules. + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ubrk_create() + */ +int i18n_ubrk_create_rules (const i18n_uchar *rules, int32_t rules_length, const i18n_uchar *text, int32_t text_length, i18n_ubreak_iterator_h *break_iter, i18n_uparse_error_s *parse_err); + +/** + * @brief Thread safe cloning operation. + * @remarks Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * @param[in] break_iter iterator to be cloned. Must not be @c NULL. + * @param[in] stack_buffer User allocated space for the new clone. If @c NULL new memory will be allocated. + * If buffer is not large enough, new memory will be allocated. + * Clients can use the #I18N_U_BRK_SAFECLONE_BUFFERSIZE. This will probably be enough to avoid memory allocations. + * @param[in] p_buffer_size A pointer to size of allocated space. + * If *p_buffer_size == 0, a sufficient size for use in cloning will + * be returned ('pre-flighting') + * If *p_buffer_size is not enough for a stack-based safe clone, + * new memory will be allocated. + * @param[out] break_iter_clone A pointer to the cloned #i18n_ubreak_iterator_h. + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ubrk_safe_clone (const i18n_ubreak_iterator_h break_iter, void *stack_buffer, int32_t *p_buffer_size, i18n_ubreak_iterator_h *break_iter_clone); + +/** + * @brief Closes a #i18n_ubreak_iterator_h. + * @details Once closed, a #i18n_ubreak_iterator_h may no longer be used. + * @remarks Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * @param[in] break_iter The break iterator to close. Must not be @c NULL. + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter +*/ +int i18n_ubrk_destroy (i18n_ubreak_iterator_h break_iter); + +/** + * @brief Sets an existing iterator to point to a new piece of text. + * @remarks Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * @param[in] break_iter The iterator to use. Must not be @c NULL. + * @param[in] text The text to be set. Must not be @c NULL. + * @param[in] text_length The length of the text. + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ubrk_set_text (i18n_ubreak_iterator_h break_iter, const i18n_uchar *text, int32_t text_length); + +/** + * @brief Determines the most recently-returned text boundary. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * @param[in] break_iter The break iterator to use. Must not be @c NULL. + * @return The character index most recently returned by, i18n_ubrk_next(), i18n_ubrk_previous(), + * i18n_ubrk_first(), or i18n_ubrk_last(). + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ubrk_current (const i18n_ubreak_iterator_h break_iter); + +/** + * @brief Advances the iterator to the boundary following the current boundary. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * @param[in] break_iter The break iterator to use. Must not be @c NULL. + * @return The character index of the next text boundary, or #I18N_UBRK_DONE + * if all text boundaries have been returned. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ubrk_previous() + */ +int32_t i18n_ubrk_next (i18n_ubreak_iterator_h break_iter); + +/** + * @brief Sets the iterator position to the boundary preceding the current boundary. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * @param[in] break_iter The break iterator to use. Must not be @c NULL. + * @return The character index of the preceding text boundary, or #I18N_UBRK_DONE + * if all text boundaries have been returned. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ubrk_next() + */ +int32_t i18n_ubrk_previous (i18n_ubreak_iterator_h break_iter); + +/** + * @brief Sets the iterator position to the index of the first character in the text being scanned. + * @details This is not always the same as index @c 0 of the text. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * @param[in] break_iter The break iterator to use. Must not be @c NULL. + * @return The character index of the first character in the text being scanned. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ubrk_last() + */ +int32_t i18n_ubrk_first (i18n_ubreak_iterator_h break_iter); + +/** + * @brief Sets the iterator position to the index immediately beyond the last character in the text being scanned. + * @details This is not the same as the last character. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * @param[in] break_iter The break iterator to use. Must not be @c NULL. + * @return The character offset immediately beyond the last character in the + * text being scanned. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ubrk_first() + */ +int32_t i18n_ubrk_last (i18n_ubreak_iterator_h break_iter); + +/** + * @brief Sets the iterator position to the first boundary preceding the specified @c offset. + * @details The new position is always smaller than @c offset, or #I18N_UBRK_DONE. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * @param[in] break_iter The break iterator to use. Must not be @c NULL. + * @param[in] offset The offset to begin scanning. + * @return The text boundary preceding offset, or #I18N_UBRK_DONE. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ubrk_following() + */ +int32_t i18n_ubrk_preceding (i18n_ubreak_iterator_h break_iter, int32_t offset); + +/** + * @brief Advances the iterator to the first boundary following the specified @c offset. + * @details The value returned is always greater than @c offset, or #I18N_UBRK_DONE. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * @param[in] break_iter The break iterator to use. Must not be @c NULL. + * @param[in] offset The offset to begin scanning. + * @return The text boundary following offset, or #I18N_UBRK_DONE. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ubrk_preceding() + */ +int32_t i18n_ubrk_following (i18n_ubreak_iterator_h break_iter, int32_t offset); + +/** + * @brief Gets a locale for which text breaking information is available. + * @details A #i18n_ubreak_iterator_h in a locale returned by this function will perform the correct + * text breaking for the locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * @param[in] index The index of the desired locale. + * @return A locale for which number text breaking information is available, or @c 0 if none. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ubrk_count_available() + */ +const char *i18n_ubrk_get_available (int32_t index); + +/** + * @brief Determines how many locales have text breaking information available. + * @details This function is most useful as determining the loop ending condition for + * calls to i18n_ubrk_get_available(). + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * @return The number of locales for which text breaking information is available. + * @exception #I18N_ERROR_NONE Successful + * @see i18n_ubrk_get_available() + */ +int32_t i18n_ubrk_count_available (void); + +/** + * @brief Returns true if the specfied position is a boundary position. + * @details As a side effect, leaves the iterator pointing to the first boundary position at + * or after @c offset. + * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are + * described in Exceptions section. + * @since_tizen 2.3.1 + * @param[in] break_iter The break iterator to use. Must not be @c NULL. + * @param[in] offset The offset to check. + * @return True if "offset" is a boundary position. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_ubool i18n_ubrk_is_boundary (i18n_ubreak_iterator_h break_iter, int32_t offset); + +/** + * @brief Returns the status from the break rule that determined the most recently + * returned break position. + * @details The values appear in the rule source + * within brackets, {123}, for example. For rules that do not specify a + * status, a default value of 0 is returned. + *

+ * For word break iterators, the possible values are defined in enum #i18n_uchar_u_word_break_values_e. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * @param[in] break_iter The break iterator to use. Must not be @c NULL. + * @return The status from the break rule that determined the most recently returned break position. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ubrk_get_rule_status (i18n_ubreak_iterator_h break_iter); + +/** + * @brief Gets the statuses from the break rules that determined the most recently + * returned break position. + * @details The values appear in the rule source within brackets, {123}, for example. The default status value for rules + * that do not explicitly provide one is zero. + *

+ * For word break iterators, the possible values are defined in enum #i18n_uchar_u_word_break_values_e. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and in #i18n_error_code_e description. + * + * @since_tizen 2.3.1 + * @param[in] break_iter The break iterator to use. Must not be @c NULL. + * @param[out] fill_in_vec An array to be filled in with the status values. + * @param[in] capacity The length of the supplied vector. A length of zero causes + * the function to return the number of status values, in the + * normal way, without attempting to store any values. + * @return The number of rule status values from rules that determined + * the most recent boundary returned by the break iterator. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ubrk_get_rule_status_vec (i18n_ubreak_iterator_h break_iter, int32_t *fill_in_vec, int32_t capacity); + +/** + * @brief Returns the locale of the break iterator. You can choose between the valid and + * the actual locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and in #i18n_error_code_e description. + * + * @since_tizen 2.3.1 + * @param[in] break_iter Break iterator. Must not be @c NULL. + * @param[in] type Locale type (valid or actual). + * @return locale string + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +const char *i18n_ubrk_get_locale_by_type (const i18n_ubreak_iterator_h break_iter, i18n_ulocale_data_locale_type_e type); + +#ifdef __cplusplus +} +#endif + +/** + * @} + * @} + */ + +#endif diff --git a/src/include/wearable/utils_i18n_ucalendar.h b/src/include/wearable/utils_i18n_ucalendar.h new file mode 100644 index 0000000..8dae458 --- /dev/null +++ b/src/include/wearable/utils_i18n_ucalendar.h @@ -0,0 +1,910 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +#ifndef __UTILS_I18N_UCALENDAR_H__ +#define __UTILS_I18N_UCALENDAR_H__ + +#include + +/** + * @file utils_i18n_ucalendar.h + * @version 0.1 + * @brief utils_i18n_ucalendar + */ + +/** + * @ingroup CAPI_BASE_UTILS_I18N_MODULE + * @defgroup CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE Ucalendar + * @brief The Ucalendar is used for converting between an udate module and a set of integer fields + * such as #I18N_UCALENDAR_YEAR, #I18N_UCALENDAR_MONTH, #I18N_UCALENDAR_DATE, #I18N_UCALENDAR_HOUR, and so on. + * @section CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE_HEADER Required Header + * \#include + * @section CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE_OVERVIEW Overview + * @details The Ucalendar is used for converting between an udate module and a set of integer fields + * such as #I18N_UCALENDAR_YEAR, #I18N_UCALENDAR_MONTH, #I18N_UCALENDAR_DATE, #I18N_UCALENDAR_HOUR, and so on. + * (An udate module represents a specific instant in time with millisecond precision. See udate for + * information about the udate.) + * + * @section CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE_SAMPLE_CODE_1 Sample Code 1 + * @brief Converts the given date and time to the corresponding UTC time(number of seconds that have elapsed since January 1, 1970), considering the given time zone + * @code + + #define ms2sec(ms) (long long int)(ms)/1000.0 + + // get time in sec from input date and time + long long int _time_convert_itol(char *tzid, int y, int mon, int d, int h, int min, int s) + { + long long int lli; + i18n_ucalendar_h ucal; + i18n_udate date; + int ret = I18N_ERROR_NONE; + int year, month, day, hour, minute, second; + int len; + + i18n_uchar *_tzid = NULL; + + if (tzid == NULL) { + tzid = "Etc/GMT"; + } + _tzid = (i18n_uchar*)calloc(strlen(tzid) + 1, sizeof(i18n_uchar)); + if (_tzid == NULL) { + return -1; + } + // converts 'tzid' to unicode string + i18n_ustring_copy_ua(_tzid, tzid); + + // gets length of '_tzid' + i18n_ustring_get_length(_tzid, &len); + // creates i18n_ucalendar_h + ret = i18n_ucalendar_create(_tzid, len, "en_US", I18N_UCALENDAR_TRADITIONAL, &ucal); + if (ret) { + dlog_print(DLOG_INFO, LOG_TAG, "i18n_ucalendar_create failed.\n"); + return -1; + } + + // sets i18n_ucalendar_h's date + i18n_ucalendar_set_date_time(ucal, y, mon-1, d, h, min, s); + + // gets the current value of a field from i18n_ucalendar_h + i18n_ucalendar_get(ucal, I18N_UCALENDAR_YEAR, &year); + i18n_ucalendar_get(ucal, I18N_UCALENDAR_MONTH, &month); + i18n_ucalendar_get(ucal, I18N_UCALENDAR_DATE, &day); + i18n_ucalendar_get(ucal, I18N_UCALENDAR_HOUR, &hour); + i18n_ucalendar_get(ucal, I18N_UCALENDAR_MINUTE, &minute); + i18n_ucalendar_get(ucal, I18N_UCALENDAR_SECOND, &second); + dlog_print(DLOG_INFO, LOG_TAG, "Date from ucal, year:%d month:%d day:%d hour:%d minute:%d second:%d.\n",year, month, day, hour, minute, second); + + // gets i18n_ucalendar's current time and converts it from milliseconds to seconds + i18n_ucalendar_get_milliseconds(ucal, &date); + lli = ms2sec(date); + // destroys i18n_ucalendar_h + i18n_ucalendar_destroy(ucal); + if (_tzid) { + free(_tzid); + } + + return lli; + } + * @endcode + * + * @section CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE_SAMPLE_CODE_2 Sample Code 2 + * @brief Describes an example that uses _time_convert_itol from 'Sample Code 2' + * @code + // converts the given time to UTC time(number of seconds that have elapsed since January 1, 1970) + long long int time = _time_convert_itol("Etc/GMT", 2014, 5, 28, 15, 14, 0); + dlog_print(DLOG_INFO, LOG_TAG, "Time Zone: %s\t, %d/%d/%d/%d/%d/%d\n", "Etc/GMT", 2014, 5, 28, 15, 14, 0); + dlog_print(DLOG_INFO, LOG_TAG, "_time_convert_itol test : %lld\n", time); + * @endcode + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE + * @{ + */ + +/** + * @brief Sets the default time zone. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] zone_id null-terminated time zone ID + * + * @return An #i18n_error_code_e error code + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucalendar_set_default_timezone ( const i18n_uchar *zone_id ); + +/** + * @brief Gets the current date and time. + * @details The value returned is represented as milliseconds from the epoch. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] date The current date and time + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucalendar_get_now ( i18n_udate *date ); + +/** + * @brief Creates an #i18n_ucalendar_h. + * An #i18n_ucalendar_h may be used to convert a millisecond value to a year, + * month, and day. + * @details Note: When an unknown TimeZone ID is specified, the #i18n_ucalendar_h returned + * by the function is initialized with GMT ("Etc/GMT") without any + * errors/warnings. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @remarks Must release @a calendar using i18n_ucalendar_destroy(). + * + * @param[in] zone_id The desired TimeZone ID \n + * If @c 0, use the default time zone. + * @param[in] len The length of the zone ID, + * otherwise @c -1 if null-terminated + * @param[in] locale The desired locale + * If @c NULL, the default locale will be used. + * @param[in] type The type of #I18N_UCALENDAR_DEFAULT to create \n + * This can be #I18N_UCALENDAR_GREGORIAN to create the Gregorian + * calendar for the locale, or #I18N_UCALENDAR_DEFAULT to create the default calendar for the locale (the + * default calendar may also be Gregorian). + * @param[out] calendar A pointer to an #i18n_ucalendar_h, + * otherwise @c 0 if an error occurs + * + * @return An #i18n_error_code_e error code + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @retval #I18N_ERROR_OUT_OF_MEMORY Out of memory + */ +int i18n_ucalendar_create ( const i18n_uchar *zone_id, int32_t len, const char *locale, i18n_ucalendar_type_e type, i18n_ucalendar_h *calendar ); + +/** + * @brief Destroys an #i18n_ucalendar_h. + * @details Once destroyed, an #i18n_ucalendar_h may no longer be used. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] calendar The #i18n_ucalendar_h to destroy + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucalendar_destroy ( i18n_ucalendar_h calendar ); + +/** + * @brief Creates a copy of a #i18n_ucalendar_h. + * This function performs a deep copy. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] cal The #i18n_ucalendar_h to copy + * @param[out] identical_to_cal A pointer to a #i18n_ucalendar_h identical to @a cal. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucalendar_clone ( const i18n_ucalendar_h cal, i18n_ucalendar_h *identical_to_cal ); + +/** + * @brief Gets the display name for a calendar's TimeZone. + * @details A display name is suitable for presentation to a user. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] calendar The #i18n_ucalendar_h to query + * @param[in] type The desired display name format \n + * One of #I18N_UCALENDAR_STANDARD, #I18N_UCALENDAR_SHORT_STANDARD, #I18N_UCALENDAR_DST, or #I18N_UCALENDAR_SHORT_DST + * @param[in] locale The desired locale for the display name + * @param[out] result A pointer to a buffer to receive the formatted number + * @param[in] result_len The maximum size of the result + * @param[out] buf_size_needed The total buffer size needed \n + * If greater than @a result_len, the output is truncated + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucalendar_get_timezone_displayname ( const i18n_ucalendar_h calendar, i18n_ucalendar_displayname_type_e type, const char *locale, i18n_uchar *result, int32_t result_len, int32_t *buf_size_needed ); + +/** + * @brief Determines if an #i18n_ucalendar_h is currently in daylight savings time. + * @details Daylight savings time is not used in all parts of the world. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] calendar The #i18n_ucalendar_h to query + * @param[out] is_in If @c true @a calendar is currently in daylight savings time, + * otherwise @c false + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucalendar_is_in_daylight_time ( const i18n_ucalendar_h calendar, i18n_ubool *is_in ); + +/** + * @brief Sets the value of a field in a #i18n_ucalendar_h. + * @details All fields are represented as 32-bit integers. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] cal The #i18n_ucalendar_h to modify + * @param[in] field The field to set \n + * One of #I18N_UCALENDAR_ERA, #I18N_UCALENDAR_YEAR, + * #I18N_UCALENDAR_MONTH, #I18N_UCALENDAR_WEEK_OF_YEAR, #I18N_UCALENDAR_WEEK_OF_MONTH, + * #I18N_UCALENDAR_DATE, #I18N_UCALENDAR_DAY_OF_YEAR, #I18N_UCALENDAR_DAY_OF_WEEK, + * #I18N_UCALENDAR_DAY_OF_WEEK_IN_MONTH, #I18N_UCALENDAR_AM_PM, #I18N_UCALENDAR_HOUR, + * #I18N_UCALENDAR_HOUR_OF_DAY, #I18N_UCALENDAR_MINUTE, #I18N_UCALENDAR_SECOND, + * #I18N_UCALENDAR_MILLISECOND, #I18N_UCALENDAR_ZONE_OFFSET, #I18N_UCALENDAR_DST_OFFSET. + * @param[in] val The desired value of @a field. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucalendar_set ( i18n_ucalendar_h cal, i18n_ucalendar_date_fields_e field, int32_t val ); + +/** + * @brief Sets a numeric attribute associated with an #i18n_ucalendar_h. + * @details Numeric attributes include the first day of the week, or the minimal number + * of days in the first week of the month. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] calendar The #i18n_ucalendar_h to modify + * @param[in] attr The desired attribute \n + * One of #I18N_UCALENDAR_LENIENT, #I18N_UCALENDAR_FIRST_DAY_OF_WEEK, + * or #I18N_UCALENDAR_MINIMAL_DAYS_IN_FIRST_WEEK. + * + * @param[in] val The new value of @a attr + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucalendar_set_attribute ( i18n_ucalendar_h calendar, i18n_ucalendar_attribute_e attr, int32_t val ); + +/** + * @brief Gets a numeric attribute associated with an i18n_ucalendar. + * @details Numeric attributes include the first day of the week, or the minimal numbers of days + * in the first week of the month. + * + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] calendar The i18n_ucalendar to query + * @param[in] attr The desired attribute \n + * One of #I18N_UCALENDAR_LENIENT, #I18N_UCALENDAR_FIRST_DAY_OF_WEEK, + * or #I18N_UCALENDAR_MINIMAL_DAYS_IN_FIRST_WEEK. + * + * @param[out] val The value of @a attr + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucalendar_get_attribute ( i18n_ucalendar_h calendar, i18n_ucalendar_attribute_e attr, int32_t *val); + +/** + * @brief Gets a calendar's current time in milliseconds. + * @details The time is represented as milliseconds from the epoch. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] calendar The #i18n_ucalendar_h to query + * @param[out] date The calendar's current time in milliseconds + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ucalendar_set_milliseconds() + * @see i18n_ucalendar_set_date_time() + */ +int i18n_ucalendar_get_milliseconds( const i18n_ucalendar_h calendar, i18n_udate *date ); + +/** + * @brief Sets a calendar's current time in milliseconds. + * @details The time is represented as milliseconds from the epoch. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] calendar The #i18n_ucalendar_h to set + * @param[in] milliseconds The desired date and time + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ucalendar_get_milliseconds() + * @see i18n_ucalendar_set_date_time() + */ +int i18n_ucalendar_set_milliseconds ( i18n_ucalendar_h calendar, i18n_udate milliseconds ); + +/** + * @brief Sets a calendar's current date. + * @details The date is represented as a series of 32-bit integers. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] calendar The #i18n_ucalendar_h to set + * @param[in] year The desired year + * @param[in] month The desired month\n + * One of #I18N_UCALENDAR_JANUARY, #I18N_UCALENDAR_FEBRUARY, #I18N_UCALENDAR_MARCH, #I18N_UCALENDAR_APRIL, #I18N_UCALENDAR_MAY, + * #I18N_UCALENDAR_JUNE, #I18N_UCALENDAR_JULY, #I18N_UCALENDAR_AUGUST, #I18N_UCALENDAR_SEPTEMBER, #I18N_UCALENDAR_OCTOBER, #I18N_UCALENDAR_NOVEMBER, or #I18N_UCALENDAR_DECEMBER + * @param[in] date The desired day of the month + * @param[in] hour The desired hour of the day + * @param[in] min The desired minute + * @param[in] sec The desired second + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ucalendar_get_milliseconds() + * @see i18n_ucalendar_set_milliseconds() + */ +int i18n_ucalendar_set_date_time ( i18n_ucalendar_h calendar, int32_t year, int32_t month, int32_t date, int32_t hour, int32_t min, int32_t sec ); + +/** + * @brief Returns @c true if two #i18n_ucalendar_h calendars are equivalent. + * @details Equivalent #i18n_ucalendar_h calendars will behave identically, but they may be set to + * different times. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] calendar1 The first of the calendars to compare + * @param[in] calendar2 The second of the calendars to compare + * @param[out] equiv If @c true @a cal1 and @a cal2 are equivalent, otherwise @c false + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucalendar_is_equivalent_to ( const i18n_ucalendar_h calendar1, const i18n_ucalendar_h calendar2, i18n_ubool *equiv ); + +/** + * @brief Adds a specified signed amount to a particular field in a #i18n_ucalendar_h. + * @details This can modify more significant fields in the calendar. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] calendar The #i18n_ucalendar_h to which to add + * @param[in] field The field to which to add the signed value\n One of #I18N_UCALENDAR_ERA, #I18N_UCALENDAR_YEAR, #I18N_UCALENDAR_MONTH, + * #I18N_UCALENDAR_WEEK_OF_YEAR, #I18N_UCALENDAR_WEEK_OF_MONTH, #I18N_UCALENDAR_DATE, #I18N_UCALENDAR_DAY_OF_YEAR, #I18N_UCALENDAR_DAY_OF_WEEK, + * #I18N_UCALENDAR_DAY_OF_WEEK_IN_MONTH, #I18N_UCALENDAR_AM_PM, #I18N_UCALENDAR_HOUR, #I18N_UCALENDAR_HOUR_OF_DAY, #I18N_UCALENDAR_MINUTE, #I18N_UCALENDAR_SECOND, + * #I18N_UCALENDAR_MILLISECOND. + * @param[in] amount The signed amount to add to the field \n + * If the amount causes the value to exceed to maximum or minimum values for that field, + * other fields are modified to preserve the magnitude of the change. + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + + */ +int i18n_ucalendar_add ( i18n_ucalendar_h calendar, i18n_ucalendar_date_fields_e field, int32_t amount ); + +/** + * @brief Gets the current value of a field from an #i18n_ucalendar_h. + * @details All fields are represented as 32-bit integers. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] calendar The #i18n_ucalendar_h to query + * @param[in] field The desired field\n One of I18N_UCALENDAR_ERA, I18N_UCALENDAR_YEAR, I18N_UCALENDAR_MONTH, + * #I18N_UCALENDAR_WEEK_OF_YEAR, #I18N_UCALENDAR_WEEK_OF_MONTH, #I18N_UCALENDAR_DATE, #I18N_UCALENDAR_DAY_OF_YEAR, #I18N_UCALENDAR_DAY_OF_WEEK, + * #I18N_UCALENDAR_DAY_OF_WEEK_IN_MONTH, #I18N_UCALENDAR_AM_PM, #I18N_UCALENDAR_HOUR, #I18N_UCALENDAR_HOUR_OF_DAY, #I18N_UCALENDAR_MINUTE, #I18N_UCALENDAR_SECOND, + * #I18N_UCALENDAR_MILLISECOND, #I18N_UCALENDAR_ZONE_OFFSET, or #I18N_UCALENDAR_DST_OFFSET. + * @param[out] val The value of the desired field. + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucalendar_get ( const i18n_ucalendar_h calendar, i18n_ucalendar_date_fields_e field, int32_t *val ); + + +// Newly Added APIs + + + +/** + * @brief Returns the difference between the target time and the time this calendar object is currently set to. + * @details If the target time is after the current calendar setting, the the returned value will be positive. + * The field parameter specifies the units of the return value. + * For example, if field is I18N_UCALENDAR_MONTH and i18n_ucalendar_get_field_difference returns 3, + * then the target time is 3 to less than 4 months after the current calendar setting.
+ * As a side effect of this call, this calendar is advanced toward target by the given amount. + * That is, calling this function has the side effect of calling i18n_ucalendar_add on this calendar with the + * specified field and an amount equal to the return value from this function.
+ * A typical way of using this function is to call it first with the largest field of interest, then with progressively smaller fields. + * @since_tizen 2.3.1 + * + * @param[in] calendar The i18n_ucalendar_h to compare and update. + * @param[in] target The target date to compare to the current calendar setting. + * @param[in] field One of #I18N_UCALENDAR_ERA, #I18N_UCALENDAR_YEAR, #I18N_UCALENDAR_MONTH, + * #I18N_UCALENDAR_WEEK_OF_YEAR, #I18N_UCALENDAR_WEEK_OF_MONTH, #I18N_UCALENDAR_DATE, + * #I18N_UCALENDAR_DAY_OF_YEAR, #I18N_UCALENDAR_DAY_OF_WEEK, #I18N_UCALENDAR_DAY_OF_WEEK_IN_MONTH, + * #I18N_UCALENDAR_AM_PM, #I18N_UCALENDAR_HOUR, #I18N_UCALENDAR_HOUR_OF_DAY, #I18N_UCALENDAR_MINUTE, + * #I18N_UCALENDAR_SECOND, #I18N_UCALENDAR_MILLISECOND. + * Please note that the returned value type is int32_t. In case of #I18N_UCALENDAR_MILLISECOND, maximal + * difference between dates may be equal to the maximal value of the int32_t, which is 2147483647 (about one month difference). + * If the difference is bigger, then the #I18N_ERROR_INVALID_PARAMETER error will be returned. + * @param[out] status A pointer to an i18n_error_code_e to receive any errors + * + * @return The date difference for the specified field. + */ +int32_t i18n_ucalendar_get_field_difference ( i18n_ucalendar_h calendar, i18n_udate target, i18n_ucalendar_date_fields_e field, i18n_error_code_e *status ); + +/** + * @brief Creates an enumeration over system time zone IDs with the given filter conditions. + * @since_tizen 2.3.1 + * + * @param[in] zone_type The system time zone type. + * @param[in] region The ISO 3166 two-letter country code or UN M.49 three-digit + * area code. When @c NULL, no filtering done by region. + * @param[in] raw_offset An offset from GMT in milliseconds, ignoring the effect + * of daylight savings time, if any. When @c NULL, no filtering done by zone offset. + * + * @param[out] enumeration A Pointer to the enumeration object that the caller must dispose of using + * i18n_uenumeration_destroy(), or@c NULL upon failure. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucalendar_timezone_id_enumeration_create ( i18n_system_timezone_type_e zone_type, const char *region, const int32_t *raw_offset, i18n_uenumeration_h *enumeration); + +/** + * @brief Creates an enumeration over all time zones. + * @since_tizen 2.3.1 + * + * @param[out] enumeration A pointer to the enumeration object that the caller must dispose of using + * i18n_uenumeration_destroy(), or @c NULL upon failure. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucalendar_timezones_create (i18n_uenumeration_h * enumeration); + +/** + * @brief Creates an enumeration over all time zones associated with the given country. + * @details Some zones are affiliated with no country (e.g., "UTC"); these may also be retrieved, as a group. + * @since_tizen 2.3.1 + * + * @param[in] country The ISO 3166 two-letter country code, or @c NULL to retrieve zones not affiliated with any country + * + * @param[out] enumeration A pointer to the enumeration object that the caller must dispose of using + * i18n_uenumeration_destroy(), or @c NULL upon failure. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucalendar_country_timezones_create (const char *country, i18n_uenumeration_h * enumeration); + +/** + * @brief Returns the default time zone. + * @details The default is determined initially by querying the host operating system. + * It may be changed with i18n_ucalendar_set_default_timezone() + * or with the C++ TimeZone API. + * @remarks The specific error code can be obtained using the get_last_result() + * method. Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[out] result A buffer to receive the result, or @c NULL + * @param[in] result_capacity The capacity of the @c result buffer + * + * @return The @c result string length, not including the terminating @c NULL. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid parameter + */ +int32_t i18n_ucalendar_get_default_timezone (i18n_uchar *result, int32_t result_capacity); + +/** + * @brief Sets the TimeZone used by a #i18n_ucalendar_h. + * @details A #i18n_ucalendar_h uses a timezone for converting from Greenwich time to local time. + * @since_tizen 2.3.1 + * + * @param[in] calendar The #i18n_ucalendar_h to set. + * @param[in] zone_id The desired TimeZone ID. If NULL, use the default time zone. + * @param[in] length The length of @c zone_id, or -1 if NULL-terminated. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucalendar_set_timezone ( i18n_ucalendar_h calendar, const i18n_uchar *zone_id, int32_t length ); + +/** + * @brief Gets the ID of the calendar's time zone. + * @remarks The specific error code can be obtained using the get_last_result() + * method. Error codes are described in Exceptions section and + * #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] calendar The #i18n_ucalendar_h to query. + * @param[out] result Receives the calendar's time zone ID. + * @param[in] result_length The maximum size of the @c result. + * + * @return The total buffer size needed; if greater than @c result_length, the output was truncated. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ucalendar_get_timezone_id (const i18n_ucalendar_h calendar, i18n_uchar *result, int32_t result_length); + +/** + * @brief Sets the Gregorian Calendar change date. + * @details This is the point when the switch from Julian dates to Gregorian dates + * occurred. Default is 00:00:00 local time, October 15, 1582. + * Previous to this time and date will be Julian dates. + * This function works only for Gregorian calendars. If the #i18n_ucalendar_h + * is not an instance of a Gregorian calendar, then a + * #I18N_ERROR_NOT_SUPPORTED error code is set. + * @since_tizen 2.3.1 + * + * @param[in] calendar The calendar object. + * @param[in] date The given Gregorian cutover date. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_ucalendar_get_gregorian_change() + */ +int i18n_ucalendar_set_gregorian_change ( i18n_ucalendar_h calendar, i18n_udate date); + +/** + * @brief Gets the Gregorian Calendar change date. + * @details This is the point when the switch from Julian dates to Gregorian dates + * occurred. Default is 00:00:00 local time, October 15, 1582. + * Previous to this time and date will be Julian dates. + * This function works only for Gregorian calendars. If the #i18n_ucalendar_h + * is not an instance of a Gregorian calendar, then a + * #I18N_ERROR_NOT_SUPPORTED error code is set. + * @since_tizen 2.3.1 + * + * @param[in] calendar The calendar object. + * @param[out] date A pointer to the Gregorian cutover time for this calendar. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_ucalendar_set_gregorian_change() + */ +int i18n_ucalendar_get_gregorian_change (const i18n_ucalendar_h calendar, i18n_udate *date); + +/** + * @brief Gets a locale for which calendars are available. + * @details A #i18n_ucalendar_h in a locale returned by this function will contain + * the correct day and month names for the locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] locale_index The index of the desired locale. + * + * @return A locale for which calendars are available, or 0 if none. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid parameter + * @see i18n_ucalendar_count_available() + */ +const char * i18n_ucalendar_get_available (int32_t locale_index); + +/** + * @brief Determines how many locales have calendars available. + * @details This function is most useful as determining the loop ending condition for calls to i18n_ucalendar_get_available(). + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @return The number of locales for which calendars are available. + * @exception #I18N_ERROR_NONE Successful + * @see i18n_ucalendar_get_available() + */ +int32_t i18n_ucalendar_count_available (void); + +/** + * @brief Sets a calendar's current date. + * @details The date is represented as a series of 32-bit integers. + * @since_tizen 2.3.1 + * + * @param[in] calendar The #i18n_ucalendar_h to set. + * @param[in] year The desired year. + * @param[in] month The desired month; one of #I18N_UCALENDAR_JANUARY, #I18N_UCALENDAR_FEBRUARY, #I18N_UCALENDAR_MARCH, + * #I18N_UCALENDAR_APRIL, #I18N_UCALENDAR_MAY, #I18N_UCALENDAR_JUNE, #I18N_UCALENDAR_JULY, #I18N_UCALENDAR_AUGUST, + * #I18N_UCALENDAR_SEPTEMBER, #I18N_UCALENDAR_OCTOBER, #I18N_UCALENDAR_NOVEMBER, #I18N_UCALENDAR_DECEMBER + * @param[in] date The desired day of the month. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_ucalendar_add() + * @see i18n_ucalendar_set_milliseconds() + * @see i18n_ucalendar_set_milliseconds() + * @see i18n_ucalendar_set_date_time() + */ +int i18n_ucalendar_set_date (i18n_ucalendar_h calendar, int32_t year, int32_t month, int32_t date); + +/** + * @brief Adds a specified signed amount to a particular field in a #i18n_ucalendar_h. + * @details This will not modify more significant fields in the calendar. + * Rolling by a positive value always means moving forward in time + * (unless the limit of the field is reached, in which case it may pin or wrap), + * so for Gregorian calendar, starting with 100 BC and + * rolling the year by +1 results in 99 BC. + * When eras have a definite beginning and end (as in the Chinese calendar, + * or as in most eras in the Japanese calendar) then rolling the year past either + * limit of the era will cause the year to wrap around. When eras only have a limit at one end, + * then attempting to roll the year past that limit will result in pinning the year at that limit. + * Note that for most calendars in which era 0 years move forward in time (such as Buddhist, Hebrew, or Islamic), + * it is possible for add or roll to result in negative years for era 0 (that is the + * only way to represent years before the calendar epoch). + * @since_tizen 2.3.1 + * + * @param[in] calendar The #i18n_ucalendar_h to which to add. + * @param[in] field The field to which to add the signed value; one of #I18N_UCALENDAR_ERA, + * #I18N_UCALENDAR_YEAR, #I18N_UCALENDAR_MONTH, #I18N_UCALENDAR_WEEK_OF_YEAR, + * #I18N_UCALENDAR_WEEK_OF_MONTH, #I18N_UCALENDAR_DATE, #I18N_UCALENDAR_DAY_OF_YEAR, + * #I18N_UCALENDAR_DAY_OF_WEEK, #I18N_UCALENDAR_DAY_OF_WEEK_IN_MONTH, #I18N_UCALENDAR_AM_PM, + * #I18N_UCALENDAR_HOUR, #I18N_UCALENDAR_HOUR_OF_DAY, #I18N_UCALENDAR_MINUTE, + * #I18N_UCALENDAR_SECOND, #I18N_UCALENDAR_MILLISECOND. + * @param[in] amount The signed amount to add to the @c field. If the amount causes the + * value to exceed to maximum or minimum values for that field, the field is pinned + * to a permissible value. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @remarks #I18N_UCALENDAR_ZONE_OFFSET and #I18N_UCALENDAR_DST_OFFSET are not supported by this function. + * @see i18n_ucalendar_add() + */ +int i18n_ucalendar_roll (i18n_ucalendar_h calendar, i18n_ucalendar_date_fields_e field, int32_t amount); + +/** + * @brief Determines if a field in a #i18n_ucalendar_h is set. + * @details All fields are represented as 32-bit integers. + * @remarks The specific error code can be obtained using the get_last_result() + * method. Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] calendar The #i18n_ucalendar_h to query. + * @param[in] field The desired field. + * + * @return @c true if field is set, @c false otherwise. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ucalendar_get() + * @see i18n_ucalendar_set() + * @see i18n_ucalendar_clear_field() + * @see i18n_ucalendar_clear() + * + */ +i18n_ubool i18n_ucalendar_is_set (const i18n_ucalendar_h calendar, i18n_ucalendar_date_fields_e field); + +/** + * @brief Clears a field in a #i18n_ucalendar_h. + * @details All fields are represented as 32-bit integers. + * @since_tizen 2.3.1 + * + * @param[in] calendar The #i18n_ucalendar_h containing the field to clear. + * @param[in] field The field to clear. + * + * @return Error code + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_ucalendar_get() + * @see i18n_ucalendar_set() + * @see i18n_ucalendar_is_set() + * @see i18n_ucalendar_clear() + * + */ +int i18n_ucalendar_clear_field (i18n_ucalendar_h calendar, i18n_ucalendar_date_fields_e field); + +/** + * @brief Clears all fields in a #i18n_ucalendar_h. + * @details All fields are represented as 32-bit integers. + * @since_tizen 2.3.1 + * + * @param[in] calendar #i18n_ucalendar_h to clear. + * + * @return Error code + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_ucalendar_is_set() + * @see i18n_ucalendar_clear_field() + * + */ +int i18n_ucalendar_clear (i18n_ucalendar_h calendar); + +/** + * @brief Determines a limit for a field in an #i18n_ucalendar_h. + * @details A limit is a maximum or minimum value for a field. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] calendar The #i18n_ucalendar_h to query. + * @param[in] field The desired field; one of #I18N_UCALENDAR_ERA, #I18N_UCALENDAR_YEAR, #I18N_UCALENDAR_MONTH, + * #I18N_UCALENDAR_WEEK_OF_YEAR, #I18N_UCALENDAR_WEEK_OF_MONTH, #I18N_UCALENDAR_DATE, + * #I18N_UCALENDAR_DAY_OF_YEAR, #I18N_UCALENDAR_DAY_OF_WEEK, #I18N_UCALENDAR_DAY_OF_WEEK_IN_MONTH, + * #I18N_UCALENDAR_AM_PM, #I18N_UCALENDAR_HOUR, #I18N_UCALENDAR_HOUR_OF_DAY, + * #I18N_UCALENDAR_MINUTE, #I18N_UCALENDAR_SECOND, #I18N_UCALENDAR_MILLISECOND, + * #I18N_UCALENDAR_ZONE_OFFSET, #I18N_UCALENDAR_DST_OFFSET, #I18N_UCALENDAR_YEAR_WOY, + * #I18N_UCALENDAR_DOW_LOCAL, #I18N_UCALENDAR_EXTENDED_YEAR, #I18N_UCALENDAR_JULIAN_DAY, + * #I18N_UCALENDAR_MILLISECONDS_IN_DAY, #I18N_UCALENDAR_IS_LEAP_MONTH. + * @param[in] type The desired critical point; one of #I18N_UCALENDAR_MINIMUM, #I18N_UCALENDAR_MAXIMUM, + * #I18N_UCALENDAR_GREATEST_MINIMUM, #I18N_UCALENDAR_LEAST_MAXIMUM, + * #I18N_UCALENDAR_ACTUAL_MINIMUM, #I18N_UCALENDAR_ACTUAL_MAXIMUM. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @return The requested value. + */ +int32_t i18n_ucalendar_get_limit (const i18n_ucalendar_h calendar, i18n_ucalendar_date_fields_e field, i18n_ucalendar_limit_type_e type); + +/** + * @brief Gets the locale for this @c calendar object. + * @details You can choose between valid and actual locale. + * @remarks The specific error code can be obtained using the get_last_result() + * method. Error codes are described in Exceptions section and + * #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] calendar The calendar object + * @param[in] type Type of the locale we're looking for (valid or actual) + * + * @return The requested value. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +const char *i18n_ucalendar_get_locale_by_type (const i18n_ucalendar_h calendar, i18n_ulocale_data_locale_type_e type); + +/** + * @brief Returns the timezone data version currently used by ICU. + * @remarks The specific error code can be obtained using the get_last_result() + * method. Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @return The version string, such as "2007f". + * @exception #I18N_ERROR_NONE Successful + */ +const char *i18n_ucalendar_get_tz_data_version (void); + +/** + * @brief Returns the canonical system timezone ID or the normalized custom time zone ID for the given time zone ID. + * @remarks The specific error code can be obtained using the get_last_result() + * method. Error codes are described in Exceptions section and + * #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] id The input timezone ID to be canonicalized. + * @param[in] length The length of the @c id, or @c -1 if NULL-terminated. + * @param[out] result The buffer receives the canonical system timezone ID or the custom timezone ID in normalized format. + * @param[in] result_capacity The capacity of the @c result buffer. + * @param[out] is_system_id Receives if the given @c id is a known system timezone ID. + * + * @return The result string length, not including the terminating NULL. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ucalendar_get_canonical_timezone_id (const i18n_uchar *id, int32_t length, i18n_uchar *result, int32_t result_capacity, i18n_ubool *is_system_id); + +/** + * @brief Gets the resource keyword value string designating the calendar type for the #i18n_ucalendar_h. + * @remarks The specific error code can be obtained using the get_last_result() + * method. Error codes are described in Exceptions section and + * #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] calendar The #i18n_ucalendar_h to query. + * + * @return The resource keyword value string. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +const char *i18n_ucalendar_get_type (const i18n_ucalendar_h calendar); + +/** + * @brief Given a key and a locale, returns an array of string values in a preferred order that would make a difference. + * @details These are all and only those values where the open (creation) of the service with the + * locale formed from the input locale plus input keyword and that value + * has different behavior than creation with the input locale alone. + * @since_tizen 2.3.1 + * + * @param[in] key One of the keys supported by this service. For now, only "calendar" is supported. + * @param[in] locale The locale + * @param[in] commonly_used If set to @c true it will return only commonly used values with + * the given locale in preferred order. Otherwise, it will return all the available + * values for the locale. + * + * @param[out] enumeration A pointer to the string enumeration over keyword values for the given key and the locale. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucalendar_get_keyword_values_for_locale (const char *key, const char *locale, i18n_ubool commonly_used, i18n_uenumeration_h *enumeration); + +/** + * @brief Returns whether the given day of the week is a weekday, a weekend day, + * or a day that transitions from one to the other, for the locale and calendar system + * associated with this @c #i18n_ucalendar_h (the locale's region is often the most determinant factor). + * @details If a transition occurs at midnight, then the days before and after the + * transition will have the type #I18N_UCALENDAR_WEEKDAY or #I18N_UCALENDAR_WEEKEND. + * If a transition occurs at a time other than midnight, then the day of the + * transition will have the type #I18N_UCALENDAR_WEEKEND_ONSET or #I18N_UCALENDAR_WEEKEND_CEASE. + * In this case, the function i18n_ucalendar_get_weekend_transition() will + * return the point of transition. + * @since_tizen 2.3.1 + * + * @param[in] calendar The #i18n_ucalendar_h to query. + * @param[in] day_of_week The day of the week whose type is desired (#I18N_UCALENDAR_SUNDAY..#I18N_UCALENDAR_SATURDAY). + * + * @param [out] weekday A pointer to the #i18n_ucalendar_weekday_type_e for the day of the week. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucalendar_get_day_of_week_type (const i18n_ucalendar_h calendar, i18n_ucalendar_days_of_week_e day_of_week, i18n_ucalendar_weekday_type_e *weekday); + +/** + * @brief Returns the time during the day at which the weekend begins or ends in this calendar system. + * @details If i18n_ucalendar_get_day_of_week_type() returns #I18N_UCALENDAR_WEEKEND_ONSET + * for the specified @c day_of_week, return the time at which the weekend begins. If + * i18n_ucalendar_get_day_of_week_type() returns #I18N_UCALENDAR_WEEKEND_CEASE for + * the specified @c day_of_week, return the time at which the weekend ends. If + * i18n_ucalendar_get_day_of_week_type() returns some other #i18n_ucalendar_weekday_type_e + * for the specified @c day_of_week, it is an error condition (#I18N_ERROR_INVALID_PARAMETER). + * @remarks The specific error code can be obtained using the get_last_result() + * method. Error codes are described in Exceptions section and + * #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] calendar The #i18n_ucalendar_h to query. + * @param[in] day_of_week The day of the week whose type is desired (#I18N_UCALENDAR_SUNDAY..#I18N_UCALENDAR_SATURDAY). + * + * @return The milliseconds after midnight at which the weekend begins or ends. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ucalendar_get_weekend_transition (const i18n_ucalendar_h calendar, i18n_ucalendar_days_of_week_e day_of_week); + +/** + * @brief Returns @c true if the given #i18n_udate is in the weekend in this calendar system. + * @remarks The specific error code can be obtained using the get_last_result() + * method. Error codes are described in Exceptions section and + * #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] calendar The #i18n_ucalendar_h to query. + * @param[in] date The #i18n_udate in question. + * + * @return @c true if the given #i18n_udate is in the weekend in this calendar system, @c false otherwise. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_ubool i18n_ucalendar_is_weekend (i18n_ucalendar_h calendar, i18n_udate date); + +/** + * @brief Get the #i18n_udate for the next/previous time zone transition relative + * to the calendar's current date, in the time zone to which the calendar is currently set. + * @details If there is no known time zone transition of the requested type relative + * to the calendar's date, the function returns @c false. + * @remarks The specific error code can be obtained using the get_last_result() + * method. Error codes are described in Exceptions section and + * #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] calendar The #i18n_ucalendar_h to query. + * @param[in] type The type of transition desired. + * @param[out] transition A pointer to a #i18n_udate to be set to the transition time. + * If the function returns @c false, the value set is unspecified. + * + * @return @c true if the given #i18n_udate is in the weekend in this calendar system, @c false otherwise. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_ubool i18n_ucalendar_get_timezone_transition_date (const i18n_ucalendar_h calendar, i18n_utimezone_transition_type_e type, i18n_udate *transition); + +/** + * @} + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __I18N_UCALENDAR_H__*/ diff --git a/src/include/wearable/utils_i18n_uchar.h b/src/include/wearable/utils_i18n_uchar.h new file mode 100644 index 0000000..4194c05 --- /dev/null +++ b/src/include/wearable/utils_i18n_uchar.h @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +#ifndef __UTILS_I18N_UCHAR_H__ +#define __UTILS_I18N_UCHAR_H__ + +#include + +/** + * @file utils_i18n_uchar.h + * @version 0.1 + * @brief utils_i18n + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @ingroup CAPI_BASE_UTILS_I18N_MODULE + * @defgroup CAPI_BASE_UTILS_I18N_UCHAR_MODULE Uchar + * @brief The Uchar module provides low-level access to the Unicode Character Database. + * + * @section CAPI_BASE_UTILS_I18N_UCHAR_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_BASE_UTILS_I18N_UCHAR_MODULE_OVERVIEW Overview + * @details The Uchar module provides low-level access to the Unicode Character Database. + * + * @section CAPI_BASE_UTILS_I18N_UCHAR_MODULE_SAMPLE_CODE_1 Sample Code 1 + * @brief Gets the property value of 'east asian width' among an enumerated property, + * and the unicode allocation block that contains the character. + * @code + int ret = I18N_ERROR_NONE; + i18n_uchar32 code_point = 0; + int property_value = 0; + i18n_uchar_u_east_asian_width_e east_asian_width = I18N_UCHAR_U_EA_NEUTRAL; + i18n_uchar_ublock_code_e block_code = I18N_UCHAR_UBLOCK_NO_BLOCK; + + // How to get the east asian width type for 's' + code_point = 0x73; // 's' + ret = i18n_uchar_get_int_property_value(code_point, I18N_UCHAR_EAST_ASIAN_WIDTH, &property_value); + if (ret != I18N_ERROR_NONE) { + dlog_print(DLOG_INFO, LOG_TAG, "Error occured!!\n"); + } else { + east_asian_width = (i18n_uchar_u_east_asian_width_e)property_value; + dlog_print(DLOG_INFO, LOG_TAG, "East Asian Width Type for ( %.4x ) is ( %d )\n", code_point, east_asian_width); + // East Asian Width Type for ( 0073 ) is ( 4 ) which is I18N_UCHAR_U_EA_NARROW + } + + // How to get the block code for 's' + ret = i18n_uchar_get_ublock_code(code_point, &block_code); + if (ret != I18N_ERROR_NONE) { + dlog_print(DLOG_INFO, LOG_TAG, "Error occured!!\n"); + } else { + dlog_print(DLOG_INFO, LOG_TAG, "block name for ( %.4x ) is ( %d )\n", code_point, block_code); + // block code for ( 0073 ) is ( 1 ) which is I18N_UCHAR_UBLOCK_BASIC_LATIN + } + + // How to get the east asian width type for 'sung' as ideographs + code_point = 0x661F; // 'sung' as ideographs + ret = i18n_uchar_get_int_property_value(code_point, I18N_UCHAR_EAST_ASIAN_WIDTH, &property_value); + if (ret != I18N_ERROR_NONE) { + dlog_print(DLOG_INFO, LOG_TAG, "Error occured!!\n"); + } else { + east_asian_width = (i18n_uchar_u_east_asian_width_e)property_value; + dlog_print(DLOG_INFO, LOG_TAG, "East Asian Width Type for ( %.4x ) is ( %d )\n", code_point, east_asian_width); + // East Asian Width Type for ( 661f ) is ( 5 ) which is I18N_UCHAR_U_EA_WIDE + } + + // How to get the block code for 'sung' as ideographs + ret = i18n_uchar_get_ublock_code(code_point, &block_code); + if (ret != I18N_ERROR_NONE) { + dlog_print(DLOG_INFO, LOG_TAG, "Error occured!!\n"); + } else { + dlog_print(DLOG_INFO, LOG_TAG, "block name for ( %.4x ) is ( %d )\n", code_point, block_code); + // block code for ( 661f ) is ( 71 ) which is I18N_UCHAR_UBLOCK_CJK_UNIFIED_IDEOGRAPHS + } + + // How to get the east asian width type for 'sung' as hangul + code_point = 0xC131; // 'sung' as hangul + ret = i18n_uchar_get_int_property_value(code_point, I18N_UCHAR_EAST_ASIAN_WIDTH, &property_value); + if (ret != I18N_ERROR_NONE) { + dlog_print(DLOG_INFO, LOG_TAG, "Error occured!!\n"); + } else { + east_asian_width = (i18n_uchar_u_east_asian_width_e)property_value; + dlog_print(DLOG_INFO, LOG_TAG, "East Asian Width Type for ( %.4x ) is ( %d )\n", code_point, east_asian_width); + // East Asian Width Type for ( c131 ) is ( 5 ) which is I18N_UCHAR_U_EA_WIDE + } + + // How to get the block code for 'sung' as hangul + ret = i18n_uchar_get_ublock_code(code_point, &block_code); + if (ret != I18N_ERROR_NONE) { + dlog_print(DLOG_INFO, LOG_TAG, "Error occured!!\n"); + } else { + dlog_print(DLOG_INFO, LOG_TAG, "block name for ( %.4x ) is ( %d )\n", code_point, block_code); + // block code for ( c131 ) is ( 74 ) which is I18N_UCHAR_UBLOCK_HANGUL_SYLLABLES + } + + * @endcode + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_UCHAR_MODULE + * @{ + */ + +/** + * @brief Gets the property value for an enumerated property for a code point. + * @details + * + * int property_value;\n + * #i18n_uchar_u_east_asian_width_e east_asian_width;\n + * #i18n_uchar_get_int_property_value (c, #I18N_UCHAR_EAST_ASIAN_WIDTH, &property_value);\n + * east_asian_width = (#i18n_uchar_u_east_asian_width_e)property_value;\n + * + * int property_value;\n + * bool is_ideographic;\n + * #i18n_uchar_get_int_property_value(c, #I18N_UCHAR_IDEOGRAPHIC, &property_value);\n + * is_ideographic = (bool)property_value;\n + * + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] c The code point to test. + * @param[in] which The #i18n_uchar_uproperty_e selector constant, identifies which property to check \n + * Must be #I18N_UCHAR_BINARY_START<=which<#I18N_UCHAR_BINARY_LIMIT + * or #I18N_UCHAR_INT_START<=which<#I18N_UCHAR_INT_LIMIT + * or #I18N_UCHAR_MASK_START<=which<#I18N_UCHAR_MASK_LIMIT. + * @param[out] property_val The numeric value that is directly the property value or, + * for enumerated properties, corresponds to the numeric value of the enumerated + * constant of the respective property value enumeration type (cast to enum type if necessary)\n + * Returns @c 0 or @c 1 (for false/true) for binary Unicode properties\n + * Returns a bit-mask for mask properties \n + * Returns @c 0 if 'which' is out of bounds or if the Unicode version does not have data for the property at all, or not for this code point. + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_uchar_get_int_property_value ( i18n_uchar32 c, i18n_uchar_uproperty_e which, int32_t *property_val ); + +/** + * @brief Gets the Unicode allocation block that contains the character. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] c The code point to test + * @param[out] block_val The block value for the code point + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_uchar_get_ublock_code ( i18n_uchar32 c, i18n_uchar_ublock_code_e *block_val ); + +#ifdef __cplusplus +} +#endif + +/** + * @} + * @} + */ + +#endif /* __UTILS_I18N_UCHAR_H__*/ diff --git a/src/include/wearable/utils_i18n_ucollator.h b/src/include/wearable/utils_i18n_ucollator.h new file mode 100755 index 0000000..cd129da --- /dev/null +++ b/src/include/wearable/utils_i18n_ucollator.h @@ -0,0 +1,230 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +#ifndef __UTILS_I18N_UCOLLATOR_H__ +#define __UTILS_I18N_UCOLLATOR_H__ + +#include + +/** + * @file utils_i18n_ucollator.h + * @version 0.1 + * @brief utils_i18n_ucollator + */ + +#ifdef __cplusplus +extern "C" { +# endif + +/** + * @ingroup CAPI_BASE_UTILS_I18N_MODULE + * @defgroup CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULE Ucollator + * @brief The Ucollator module performs locale-sensitive string comparison. + * + * @section CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULE_OVERVIEW Overview + * @details The Ucollator module performs locale-sensitive string comparison. It builds searching and sorting routines for natural language text and provides correct sorting orders for most locales supported. + * + * @section CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULE_SAMPLE_CODE_1 Sample Code 1 + * @brief Converts two different byte strings to two different unicode strings and compares the unicode strings to check if the strings are equal to each other. + * @code + i18n_uchar uchar_src[64] = {0,}; + i18n_uchar uchar_target[64] = {0,}; + char *src = "tizen"; + char *target = "bada"; + int uchar_src_len = 0; + int uchar_target_len = 0; + i18n_ucollator_h coll = NULL; + i18n_ubool result = NULL; + + i18n_ustring_from_UTF8( uchar_src, 64, NULL, src, -1 ); + i18n_ustring_from_UTF8( uchar_target, 64, NULL, target, -1 ); + + // creates a collator + i18n_ucollator_create( "en_US", &coll ); + + // sets strength for coll + i18n_ucollator_set_strength( coll, I18N_UCOLLATOR_PRIMARY ); + + // compares uchar_src with uchar_target + i18n_ustring_get_length( uchar_src, &uchar_src_len ); + i18n_ustring_get_length( uchar_target, &uchar_target_len ); + i18n_ucollator_equal( coll, uchar_src, uchar_src_len, uchar_target, uchar_target_len, &result ); + dlog_print(DLOG_INFO, LOG_TAG, "%s %s %s\n", src, result == 1 ? "is equal to" : "is not equal to", target ); // tizen is not equal to bada + + // destroys the collator + i18n_ucollator_destroy( coll ); + * @endcode + * @section CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULE_SAMPLE_CODE_2 Sample Code 2 + * @brief Sorts in ascending order on the given data using string_ucollator + * @code + i18n_ucollator_h coll = NULL; + char *src[3] = { "cat", "banana", "airplane" }; + char *tmp = NULL; + i18n_uchar buf_01[16] = {0,}; + i18n_uchar buf_02[16] = {0,}; + i18n_ucollator_result_e result = I18N_UCOLLATOR_EQUAL; + int i = 0, j = 0; + int ret = I18N_ERROR_NONE; + int buf_01_len = 0, buf_02_len = 0; + + for ( i = 0; i < sizeof( src ) / sizeof( src[0] ); i++ ) { + dlog_print(DLOG_INFO, LOG_TAG, "%s\n", src[i] ); + } // cat banana airplane + + // creates a collator + ret = i18n_ucollator_create( "en_US", &coll ); + + // compares and sorts in ascending order + if ( ret == I18N_ERROR_NONE ) { + i18n_ucollator_set_strength( coll, I18N_UCOLLATOR_TERTIARY ); + for ( i = 0; i < 2; i++ ) { + for ( j = 0; j < 2 - i; j++ ) { + i18n_ustring_copy_ua( buf_01, src[j] ); + i18n_ustring_copy_ua( buf_02, src[j+1] ); + i18n_ustring_get_length( buf_01, &buf_01_len ); + i18n_ustring_get_length( buf_02, &buf_02_len ); + // compares buf_01 with buf_02 + i18n_ucollator_str_collator( coll, buf_01, buf_01_len, buf_02, buf_02_len, &result ); + if ( result == I18N_UCOLLATOR_GREATER ) { + tmp = src[j]; + src[j] = src[j+1]; + src[j+1] = tmp; + } + } + } + } + // destroys the collator + i18n_ucollator_destroy( coll ); // deallocate memory for collator + + for ( i = 0; i < sizeof( src ) / sizeof( src[0] ); i++ ) { + dlog_print(DLOG_INFO, LOG_TAG, "%s\n", src[i] ); + } // ariplane banana cat + * @endcode + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULE + * @{ + */ + +/** + * @brief Creates a i18n_ucollator_h for comparing strings. + * @details The i18n_ucollator_h is used in all the calls to the Collation service.\n + * After finished, collator must be disposed off by calling {@link #i18n_ucollator_destroy()}. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @remarks Must release @a collator using i18n_ucollator_destroy(). + * + * @param[in] locale The locale containing the required collation rules\n + * Special values for locales can be passed in - if @c NULL is passed for the locale, the default locale collation rules will be used \n + * If empty string ("") or "root" is passed, UCA rules will be used. + * @param[out] collator i18n_ucollator_h, otherwise @c 0 if an error occurs + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ucollator_destroy() + */ +int i18n_ucollator_create ( const char *locale, i18n_ucollator_h *collator ); + +/** + * @brief Closes a i18n_ucollator_h. + * @details Once closed, a string_ucollator_h should not be used. Every an open collator should be closed. Otherwise, a memory leak will result. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] collator The i18n_ucollator_h to close + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ucollator_create() + */ +int i18n_ucollator_destroy ( i18n_ucollator_h collator ); + +/** + * @brief Compares two strings. + * @details The strings will be compared using the options already specified. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] collator The i18n_ucollator_h containing the comparison rules + * @param[in] src The source string + * @param[in] src_len The length of the source, otherwise @c -1 if null-terminated + * @param[in] target The target string. + * @param[in] target_len The length of the target, otherwise @c -1 if null-terminated + * @param[out] result The result of comparing the strings \n + * One of #I18N_UCOLLATOR_EQUAL, #I18N_UCOLLATOR_GREATER, or #I18N_UCOLLATOR_LESS + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ucollator_equal() + */ +int i18n_ucollator_str_collator ( const i18n_ucollator_h collator, const i18n_uchar *src, int32_t src_len, const i18n_uchar *target, int32_t target_len, i18n_ucollator_result_e *result ); + +/** + * @brief Compares two strings for equality. + * @details This function is equivalent to {@link #i18n_ucollator_str_collator()}. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] collator The i18n_ucollator_h containing the comparison rules + * @param[in] src The source string + * @param[in] src_len The length of the source, otherwise @c -1 if null-terminated + * @param[in] target The target string + * @param[in] target_len The length of the target, otherwise @c -1 if null-terminated + * @param[out] equal If @c true source is equal to target, otherwise @c false + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ucollator_str_collator() + */ +int i18n_ucollator_equal ( const i18n_ucollator_h collator, const i18n_uchar *src, int32_t src_len, const i18n_uchar *target, int32_t target_len, i18n_ubool *equal ); + +/** + * @brief Sets the collation strength used in a collator. + * @details The strength influences how strings are compared. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] collator The i18n_collator_h to set. + * @param[in] strength The desired collation strength.\n + * One of #i18n_ucollator_strength_e + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucollator_set_strength ( i18n_ucollator_h collator, i18n_ucollator_strength_e strength ); + +/** + * @brief Sets a universal attribute setter. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] collator The i18n_collator_h containing attributes to be changed + * @param[in] attr The attribute type + * @param[in] val The attribute value + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ucollator_set_attribute ( i18n_ucollator_h collator, i18n_ucollator_attribute_e attr, i18n_ucollator_attribute_value_e val ); + +#ifdef __cplusplus +} +#endif + +/** + * @} + * @} + */ + +#endif /* __UTILS_I18N_UCOLLATOR_H__*/ diff --git a/src/include/wearable/utils_i18n_udate.h b/src/include/wearable/utils_i18n_udate.h new file mode 100644 index 0000000..f5eb738 --- /dev/null +++ b/src/include/wearable/utils_i18n_udate.h @@ -0,0 +1,632 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +#ifndef __UTILS_I18N_UDATE_H__ +#define __UTILS_I18N_UDATE_H__ + +#include + +/** + * @file utils_i18n_udate.h + * @version 0.1 + * @brief utils_i18n_udate + */ + +/** + * @ingroup CAPI_BASE_UTILS_I18N_MODULE + * @defgroup CAPI_BASE_UTILS_I18N_UDATE_MODULE Udate + * @brief The Udate module consists of functions that convert dates and time from their + * internal representations to textual form and back again in a language-independent + * manner. + * + * @section CAPI_BASE_UTILS_I18N_UDATE_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_BASE_UTILS_I18N_UDATE_MODULE_OVERVIEW Overview + * @details The Udate module consists of functions that convert dates and time from their + * internal representations to textual form and back again in a language-independent + * manner. Converting from the internal representation (milliseconds since midnight, + * January 1, 1970) to text is known as "formatting," and converting from text to + * milliseconds is known as "parsing". We currently define only one concrete handle + * #i18n_udate_format_h, which can handle pretty much all normal date formatting and parsing + * actions.\n + * The Udate module helps you format and parse dates for any locale. Your code can be + * completely independent of the locale conventions for months, days of the week, + * or even the calendar format: lunar vs. solar. + * + * @section CAPI_BASE_UTILS_I18N_UDATE_MODULE_SAMPLE_CODE_1 Sample Code 1 + * @brief Gets the best pattern according to a given locale and formats a current date and time using a locale_udate_format_h + * @code + i18n_udatepg_h pattern_generator = NULL; + char *locale = I18N_ULOCALE_US; + + dlog_print(DLOG_INFO, LOG_TAG, "pattern_generator\n"); + + if(!pattern_generator) { + // create a pattern generator according to a given locale + i18n_udatepg_create(locale, &pattern_generator); + } + + if(!pattern_generator) { + dlog_print(DLOG_INFO, LOG_TAG, "i18n_udatepg_create fail"); + return ; + } + + i18n_uchar bestPattern[64] = {0,}; + char bestPatternString[64] = {0,}; + int bestPatternLength, len; + const char *custom_format = "yyyy.MM.dd G 'at' HH:mm:ss zzz"; + i18n_uchar uch_custom_format[64]; + int ret = I18N_ERROR_NONE; + + dlog_print(DLOG_INFO, LOG_TAG, "getBestPattern\n"); + + i18n_ustring_copy_ua(uch_custom_format, custom_format); + len = i18n_ustring_get_length(uch_custom_format); + + // gets the best pattern that matches the given custom_format + i18n_udatepg_get_best_pattern(pattern_generator, uch_custom_format, len, bestPattern, 64, &bestPatternLength); + + i18n_ustring_copy_au_n(bestPatternString, bestPattern, 64); + // gets "MM/dd/yyyy G h:mm:ss a zzz" as the best pattern + dlog_print(DLOG_INFO, LOG_TAG, "getBestPattern(char[]) : %s \n", bestPatternString); + + // closes a generator + i18n_udatepg_destroy(pattern_generator); + + i18n_udate_format_h formatter_KR = NULL; + i18n_udate_format_h formatter_LA = NULL; + i18n_udate_format_h formatter_SaoPaulo = NULL; + i18n_uchar formatted[64] = {0,}; + char result[64] = {0,}; + int formattedLength; + i18n_udate date; + const char *timezone_KR = "GMT+9:00"; // TimeZone for Korea/Seoul + const char *timezone_LA = "America/Los_Angeles"; + const char *timezone_SaoPaulo = "America/Sao_Paulo"; // Brazil/East + i18n_uchar utf16_timezone_KR[64] = {0,}; + i18n_uchar utf16_timezone_LA[64] = {0,}; + i18n_uchar utf16_timezone_SaoPaulo[64] = {0,}; + + i18n_ustring_copy_ua_n(utf16_timezone_KR, timezone_KR, strlen(timezone_KR)); + i18n_ustring_copy_ua_n(utf16_timezone_LA, timezone_LA, strlen(timezone_LA)); + i18n_ustring_copy_ua_n(utf16_timezone_SaoPaulo, timezone_SaoPaulo, strlen(timezone_SaoPaulo)); + + // creates new i18n_udate_format_h to format dates and times + ret = i18n_udate_create(I18N_UDATE_FULL , I18N_UDATE_FULL , locale, utf16_timezone_KR, -1, bestPattern, -1, &formatter_KR); + if ( ret != I18N_ERROR_NONE ) { + dlog_print(DLOG_INFO, LOG_TAG, "i18n_udate_create failed !!! \n"); + } + if (!formatter_KR) { + dlog_print(DLOG_INFO, LOG_TAG, "formatter is NULL\n"); + } + ret = i18n_udate_create(I18N_UDATE_FULL , I18N_UDATE_FULL , locale, utf16_timezone_LA, -1, bestPattern, -1, &formatter_LA); + if ( ret != I18N_ERROR_NONE ) { + dlog_print(DLOG_INFO, LOG_TAG, "i18n_udate_create failed !!! \n"); + } + if (!formatter_LA) { + dlog_print(DLOG_INFO, LOG_TAG, "formatter is NULL\n"); + } + ret = i18n_udate_create(I18N_UDATE_PATTERN , I18N_UDATE_PATTERN , locale, utf16_timezone_SaoPaulo, -1, bestPattern, -1, &formatter_SaoPaulo); + if ( ret != I18N_ERROR_NONE ) { + dlog_print(DLOG_INFO, LOG_TAG, "i18n_udate_create failed !!! \n"); + } + if (!formatter_LA) { + dlog_print(DLOG_INFO, LOG_TAG, "formatter is NULL\n"); + } + + dlog_print(DLOG_INFO, LOG_TAG, "i18n_udate_format_date\n"); + + // gets the current date and time + i18n_ucalendar_get_now(&date); + + // formats a date using i18n_udate_format_h + i18n_udate_format_date(formatter_KR, date, formatted, 64, NULL, &formattedLength); + i18n_ustring_copy_au_n(result, formatted, 64); + //ex) KOREA/Seoul - Current date : Wednesday, June 18, 2014 1:34:54 PM GMT+09:00 + dlog_print(DLOG_INFO, LOG_TAG, "KOREA/Seoul - Current date : %s\n",result); + + // formats a date using i18n_udate_format + i18n_udate_format_date(formatter_LA, date, formatted, 64, NULL, &formattedLength); + i18n_ustring_copy_au_n(result, formatted, 64); + //ex) America/LOS Angeles - Current date : Tuesday, June 17, 2014 9:34:54 PM Pacific Daylight Time + dlog_print(DLOG_INFO, LOG_TAG, "America/LOS Angeles - Current date : %s\n",result); + + // formats a date using i18n_udate_format_h + i18n_udate_format_date(formatter_SaoPaulo, date, formatted, 64, NULL, &formattedLength); + i18n_ustring_copy_au_n(result, formatted, 64); + //ex) Brazil/Sao Paulo - Current date : 6 18, 2014 AD, 1:34:54 PM GMT-2 + dlog_print(DLOG_INFO, LOG_TAG, "Brazil/Sao Paulo - Current date : %s\n",result); + + dlog_print(DLOG_INFO, LOG_TAG, "i18n_udate_destroy\n"); + // destroy an i18n_udate_format_h + i18n_udate_destroy(formatter_KR); + i18n_udate_destroy(formatter_LA); + i18n_udate_destroy(formatter_SaoPaulo); + * @endcode + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_UDATE_MODULE + * @{ + */ + +/** + * @brief Creates a new #i18n_udate_format_h for formatting and parsing dates and times. + * @details A #i18n_udate_format_h may be used to format dates in calls to {@link i18n_udate_create()}. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @remarks Must release @a format using i18n_udate_destroy(). + * + * @param[in] time_style The style used to format times\n One of #I18N_UDATE_FULL, #I18N_UDATE_LONG, + * #I18N_UDATE_MEDIUM, #I18N_UDATE_SHORT, #I18N_UDATE_DEFAULT, or #I18N_UDATE_NONE (relative time styles + * are not currently supported). + * @param[in] date_style The style used to format dates\n One of #I18N_UDATE_FULL, #I18N_UDATE_LONG, + * #I18N_UDATE_MEDIUM, #I18N_UDATE_SHORT, #I18N_UDATE_DEFAULT, #I18N_UDATE_RELATIVE, #I18N_UDATE_LONG_RELATIVE, + * #I18N_UDATE_MEDIUM_RELATIVE, #I18N_UDATE_SHORT_RELATIVE, #I18N_UDATE_PATTERN, or #I18N_UDATE_NONE + * @param[in] locale The locale specifying the formatting conventions. + * @param[in] tz_id A timezone ID specifying the timezone to use\n If @c 0, use the default timezone. + * @param[in] tz_id_len The length of @a tz_id, otherwise @c -1 if NULL-terminated. + * @param[in] pattern A pattern specifying the format to use. The pattern is generated by Udatepg module. + * When the pattern parameter is used, pass in #I18N_UDATE_PATTERN for both time_style and date_style. + * @param[in] pattern_len The number of characters in the pattern, or otherwise @c -1 if NULL-terminated. + * @param[out] format A pointer to an #i18n_udate_format_h to use for formatting dates and times, otherwise @c 0 if an error occurs. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_udate_create ( i18n_udate_format_style_e time_style, i18n_udate_format_style_e date_style, const char *locale, const i18n_uchar *tz_id, int32_t tz_id_len, const i18n_uchar *pattern, int pattern_len, i18n_udate_format_h *format ); + +/** + * @brief Destroys an #i18n_udate_format_h. + * @details Once destroyed, an #i18n_udate_format_h may no longer be used. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] format The formatter to destroy. + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_udate_destroy ( i18n_udate_format_h format ); + +/** + * @brief Formats a date using an #i18n_udate_format_h. + * @details The date will be formatted using the conventions specified in {@link i18n_udate_create()} + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] format The formatter to use. + * @param[in] date_to_format The date to format. + * @param[out] result A pointer to a buffer to receive the formatted number. + * @param[in] result_len The maximum size of the result. + * @param[in] pos A pointer to an i18n_ufield_position\n + * On input, position->field is read\n + * On output, position->beginIndex and position->endIndex indicate + * the beginning and ending indices of field number position->field, if such a field exists\n + * This parameter may be @c NULL, in which case no field + * position data is returned. + * @param[out] buf_size_needed The total buffer size needed\n + * If greater than @a result_len, the output was truncated. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_udate_format_date ( const i18n_udate_format_h format, i18n_udate date_to_format, i18n_uchar *result, int32_t result_len, i18n_ufield_position_h pos, int32_t *buf_size_needed ); + + +// Newly Added APIs + +/** + * @brief Maps from an #i18n_udate_format_h to the corresponding #i18n_ucalendar_date_fields_e. + * @details Note: since the mapping is many-to-one, there is no inverse mapping. + * @since_tizen 2.3.1 + * + * @param[in] field The #i18n_udate_format_h to map. + * #I18N_UDATE_FORMAT_TIMEZONE_LOCALIZED_GMT_OFFSET_FIELD, #I18N_UDATE_FORMAT_TIMEZONE_ISO_FIELD, + * #I18N_UDATE_FORMAT_TIMEZONE_ISO_LOCAL_FIELD and #I18N_UDATE_FORMAT_FIELD_COUNT are not supported. + * @param[out] date_field_type A pointer to the #i18n_ucalendar_date_fields_e. + * + * @return Error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_udate_to_calendar_date_field ( i18n_udate_format_field_e field, i18n_ucalendar_date_fields_e *date_field_type ); + +/** + * @brief Creates a copy of an #i18n_udate_format_h. + * @details This function performs a deep copy. + * @since_tizen 2.3.1 + * + * @param[in] format The format to copy. + * @param[out] format_clone A pointer to clone of @c format. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_udate_clone ( const i18n_udate_format_h format, i18n_udate_format_h *format_clone ); + +/** + * @brief Parses a string into an date/time using an #i18n_udate_format_h. + * @details The date will be parsed using the conventions specified in {@link i18n_udate_create()}.
+ * Note that the normal date formats associated with some calendars - such as the Chinese lunar calendar - do not specify enough fields to enable dates to be parsed unambiguously. + * In the case of the Chinese lunar calendar, while the year within the current 60-year cycle is specified, + * the number of such cycles since the start date of the calendar (in the #I18N_UCALENDAR_ERA field of the i18n_ucalendar_h) is not normally part of the format, + * and parsing may assume the wrong era. + * For such cases it is recommended that clients parse using i18n_udate_parse_calendar() with the calendar passed in set to the current date, + * or to a date within the era/cycle that should be assumed if absent in the format. + * @since_tizen 2.3.1 + * + * @param[in] format The formatter to use. + * @param[in] text The text to parse. + * @param[in] text_length The length of text, or -1 if NULL-terminated. + * @param[in] parse_pos If not 0, on input a pointer to an integer specifying the offset at which to begin parsing. + * If not 0, on output the offset at which parsing ended. + * @param[out] parsed_date A pointer to the value of the parsed date/time. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udate_format_date() + */ +int i18n_udate_parse ( const i18n_udate_format_h format, const i18n_uchar *text, int32_t text_length, int32_t *parse_pos, i18n_udate *parsed_date ); + +/** + * @brief Parses a string into an date/time using an #i18n_udate_format_h. + * @details The date will be parsed using the conventions specified in {@link i18n_udate_create()}. + * @since_tizen 2.3.1 + * + * @param[in] format The formatter to use. + * @param[in,out] calendar A pointer to calendar set on input to the date and time to be used for missing values in the date/time string being parsed, + * and set on output to the parsed date/time. + * When the calendar type is different from the internal calendar held by the #i18n_udate_format_h instance, + * the internal calendar will be cloned to a work calendar set to the same milliseconds and time zone as this calendar parameter, + * field values will be parsed based on the work calendar, then the result (milliseconds and time zone) will be set in this calendar. + * @param[in] text The text to parse. + * @param[in] text_length The length of text, or -1 if NULL-terminated. + * @param[in] parse_pos If not 0, on input a pointer to an integer specifying the offset at which to begin parsing. + * If not 0, on output the offset at which parsing ended. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udate_format_date() + */ +int i18n_udate_parse_calendar (const i18n_udate_format_h format, i18n_ucalendar_h *calendar, const i18n_uchar *text, + int32_t text_length, int32_t *parse_pos ); + +/** + * @brief Determines if an #i18n_udate_format_h will perform lenient parsing. + * @details With lenient parsing, the parser may use heuristics to interpret inputs that do not precisely match the pattern. + * With strict parsing, inputs must match the pattern. + * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] format The #i18n_udate_format_h to query. + * + * @return true if format is set to perform lenient parsing, false otherwise. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udate_set_lenient() + */ +i18n_ubool i18n_udate_is_lenient ( const i18n_udate_format_h format ); + +/** + * @brief Specifies whether an #i18n_udate_format_h will perform lenient parsing. + * @details With lenient parsing, the parser may use heuristics to interpret inputs that do not precisely match the pattern. + * With strict parsing, inputs must match the pattern. + * @since_tizen 2.3.1 + * + * @param[in] format The #i18n_udate_format_h to set. + * @param[in] is_lenient true if fmt should perform lenient parsing, false otherwise. + * + * @return Error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udate_is_lenient() + */ +int i18n_udate_set_lenient ( i18n_udate_format_h format, i18n_ubool is_lenient ); + +/** + * @brief Gets the #i18n_ucalendar_h associated with an #i18n_udate_format_h. + * @details An #i18n_udate_format_h uses an #i18n_ucalendar_h to convert a raw value to, for example, the day of the week. + * @since_tizen 2.3.1 + * + * @param[in] format The #i18n_udate_format_h to query. + * @param[out] calendar A pointer to the #i18n_ucalendar_h used by format. + * + * @return Error code. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udate_set_calendar() + */ +int i18n_udate_get_calendar ( const i18n_udate_format_h format, i18n_ucalendar_h *calendar); + +/** + * @brief Sets the #i18n_ucalendar_h associated with an #i18n_udate_format_h. + * @details An #i18n_udate_format_h uses an #i18n_ucalendar_h to convert a raw value to, for example, the day of the week. + * @since_tizen 2.3.1 + * + * @param[in] format The #i18n_udate_format_h. + * @param[in] calendar_to_set An #i18n_ucalendar_h to be used by the format. + * + * @return Error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udate_get_calendar() + */ +int i18n_udate_set_calendar ( i18n_udate_format_h format, const i18n_ucalendar_h calendar_to_set ); + +/** + * @brief Gets the #i18n_unumber_format_h associated with an #i18n_udate_format_h. + * @details An #i18n_udate_format_h uses an #i18n_unumber_format_h to format numbers within a date, for example the day number. + * @since_tizen 2.3.1 + * + * @param[in] format The formatter to query. + * @param[out] number_format A pointer to the #i18n_unumber_format_h used by @a format to format numbers. + * + * @return Error code. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udate_set_number_format() + */ +int i18n_udate_get_number_format ( const i18n_udate_format_h format, i18n_unumber_format_h *number_format ); + +/** + * @brief Sets the #i18n_unumber_format_h associated with an #i18n_udate_format_h. + * @details An #i18n_udate_format_h uses an #i18n_unumber_format_h to format numbers within a date, for example the day number. + * @since_tizen 2.3.1 + * + * @param[in] format The #i18n_udate_format_h to set. + * @param[in] number_format_to_set An #i18n_unumber_format_h to be used by @a format to format numbers. + * + * @return Error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udate_get_number_format() + */ +int i18n_udate_set_number_format ( i18n_udate_format_h format, const i18n_unumber_format_h number_format_to_set ); + +/** + * @brief Gets a locale for which date/time formatting patterns are available. + * @details An #i18n_udate_format_h in a locale returned by this function will perform the correct formatting and parsing for the locale. + * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] locale_index The index of the desired locale. + * + * @return A locale for which date/time formatting patterns are available, or 0 if none. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + + * @see i18n_udate_count_available() + */ +const char *i18n_udate_get_available ( int32_t locale_index ); + +/** + * @brief Determines how many locales have date/time formatting patterns available. + * @details This function is the most useful for determining the loop ending condition for calls to {@link #i18n_udate_get_available()}. + * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @return The number of locales for which date/time formatting patterns are available. + * + * @exception #I18N_ERROR_NONE Successful + * + * @see i18n_udate_get_available() + */ +int32_t i18n_udate_count_available ( void ); + +/** + * @brief Gets the year relative to which all 2-digit years are interpreted. + * @details For example, if the 2-digit start year is 2100, the year 99 will be interpreted as 2199. + * + * @since_tizen 2.3.1 + * + * @param[in] format The #i18n_udate_format_h to get. + * @param[out] year A pointer to the year relative to which all 2-digit years are interpreted. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udate_set_2digit_year_start() + */ +int i18n_udate_get_2digit_year_start ( const i18n_udate_format_h format, i18n_udate *year ); + +/** + * @brief Sets the year relative to which all 2-digit years will be interpreted. + * @details For example, if the 2-digit start year is 2100, the year 99 will be interpreted as 2199. + * + * @since_tizen 2.3.1 + * + * @param[in] format The #i18n_udate_format_h to map. + * @param[in] date The year relative to which all 2-digit years will be interpreted. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udate_get_2digit_year_start() + */ +int i18n_udate_set_2digit_year_start ( i18n_udate_format_h format, i18n_udate date ); + +/** + * @brief Extracts the pattern from an #i18n_udate_format_h. + * @details The pattern will follow the pattern syntax rules. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] format The #i18n_udate_format_h to query. + * @param[in] localized true if the pattern should be localized, false otherwise. + * @param[out] result A pointer to a buffer to receive the pattern. + * @param[in] result_length The maximum size of result. + * + * @return The total buffer size needed; if greater than result_length, the output was truncated. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udate_apply_pattern() + */ +int32_t i18n_udate_to_pattern ( const i18n_udate_format_h format, i18n_ubool localized, i18n_uchar *result, + int32_t result_length ); + +/** + * @brief Sets the pattern used by an #i18n_udate_format_h. + * @details The pattern should follow the pattern syntax rules. + * @since_tizen 2.3.1 + * + * @param[in] format The #i18n_udate_format_h to set. + * @param[in] localized true if the pattern is localized, false otherwise. + * @param[in] pattern The new pattern. + * @param[in] pattern_length The length of pattern, or -1 if NULL-terminated. + * + * @return Error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udate_to_pattern() + */ +int i18n_udate_apply_pattern ( i18n_udate_format_h format, i18n_ubool localized, const i18n_uchar *pattern, + int32_t pattern_length ); + +/** + * @brief Gets the symbols associated with an #i18n_udate_format_h. + * @details The symbols are what an #i18n_udate_format_h uses to represent locale-specific data, for example month or day names. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] format The #i18n_udate_format_h to query. + * @param[in] type The type of symbols to get. + * All the types defined in the #i18n_udate_format_symbol_type_e enumeration are supported. + * @param[in] symbol_index The desired symbol of type type. + * @param[out] result A pointer to a buffer to receive the pattern. + * @param[in] result_length The maximum size of the result buffer. + * + * @return The total buffer size needed; if greater than result_length, the output was truncated. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udate_count_symbols() + * @see #i18n_udate_set_symbols() + */ +int32_t i18n_udate_get_symbols ( const i18n_udate_format_h format, i18n_udate_format_symbol_type_e type, int32_t symbol_index, + i18n_uchar *result, int32_t result_length ); + +/** + * @brief Counts the number of particular symbols for an #i18n_udate_format_h. + * @details This function is most useful for determining the loop termination condition for calls to {@link #i18n_udate_get_symbols()}. + * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] format The #i18n_udate_format_h to query. + * @param[in] type The type of symbols to count. + * If wrong type is passed, 0 will be returned. + * + * @return The number of symbols of type @a type. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udate_get_symbols() + * @see #i18n_udate_set_symbols() + */ +int32_t i18n_udate_count_symbols ( const i18n_udate_format_h format, i18n_udate_format_symbol_type_e type ); + +/** + * @brief Sets the symbols associated with an #i18n_udate_format_h. + * @details The symbols are what an #i18n_udate_format_h uses to represent locale-specific data, for example month or day names. + * + * @since_tizen 2.3.1 + * + * @param[in] format The #i18n_udate_format_h to set. + * @param[in] type The type of symbols to set. + * All the types defined in the #i18n_udate_format_symbol_type_e enumeration are supported. + * If a type not defined in the enumeration is passed, then the #I18N_ERROR_NOT_SUPPORTED error is returned. + * @param[in] symbol_index The index of the symbol to set of type type. + * @param[in] value The new value. + * @param[in] value_length The length of @a value, or @c -1 if NULL-terminated. + * + * @return Error code. Error codes not listed below are described in the #i18n_error_code_e enumeration. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udate_count_symbols() + * @see #i18n_udate_get_symbols() + */ +int i18n_udate_set_symbols ( i18n_udate_format_h format, i18n_udate_format_symbol_type_e type, int32_t symbol_index, + i18n_uchar *value, int32_t value_length ); + +/** + * @brief Gets the locale for this date format object. + * @details You can choose between valid and actual locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] format The #i18n_udate_format_h to get the locale from. + * @param[in] type The type of the locale we're looking for (valid or actual). + * + * @return The locale name. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +const char * i18n_udate_get_locale_by_type ( const i18n_udate_format_h format, i18n_ulocale_data_locale_type_e type ); + +/** + * @brief Sets a particular #i18n_udisplay_context_e value in the formatter, such as #I18N_UDISPLAY_CONTEXT_CAPITALIZATION_FOR_STANDALONE. + * @remarks I18N_UDISPLAY_CONTEXT_STANDARD_NAMES and I18N_UDISPLAY_CONTEXT_DIALECT_NAMES are not supported. + * + * @since_tizen 2.3.1 + * + * @param[in] format The #i18n_udate_format_h to set a #i18n_udisplay_context_e value. + * @param[in] value The #i18n_udisplay_context_e value to set. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_udate_set_context ( i18n_udate_format_h format, i18n_udisplay_context_e value ); + + +/** + * @} + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __UTILS_I18N_UDATE_H__*/ diff --git a/src/include/wearable/utils_i18n_udatepg.h b/src/include/wearable/utils_i18n_udatepg.h new file mode 100755 index 0000000..174690b --- /dev/null +++ b/src/include/wearable/utils_i18n_udatepg.h @@ -0,0 +1,642 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +#ifndef __UTILS_I18N_UDATEPG_H__ +#define __UTILS_I18N_UDATEPG_H__ + +#include + +/** + * @file utils_i18n_udatepg.h + * @version 0.1 + * @brief utils_i18n_udatepg + */ + +/** + * @ingroup CAPI_BASE_UTILS_I18N_MODULE + * @defgroup CAPI_BASE_UTILS_I18N_UDATEPG_MODULE Udatepg + * @brief The Udatepg module provides flexible generation of date format patterns, like "yy-MM-dd". The user can build up the generator by adding successive patterns. + * + * @section CAPI_BASE_UTILS_I18N_UDATEPG_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_BASE_UTILS_I18N_UDATEPG_MODULE_OVERVIEW Overview + * @details The Udatepg module provides flexible generation of date format patterns, + * like "yy-MM-dd". The user can build up the generator by adding successive patterns. + * Once that is done, a query can be made using a "skeleton", which is a pattern that + * just includes the desired fields and lengths. The generator will return the + * "best fit" pattern corresponding to that skeleton.\n + * The main method people will use is i18n_udatepg_get_best_pattern(), since normally + * #i18n_udatepg_h is pre-built with data from a particular locale. + * However, generators can be built directly from other data as well. + * + * All input handlers must not be @c NULL. + * + * @section CAPI_BASE_UTILS_I18N_UDATEPG_MODULE_SAMPLE_CODE_1 Sample Code 1 + * @brief Gets the best pattern according to a given locale and formats a current date and time using an i18n_udate_format_h + * @code + i18n_udatepg_h pattern_generator = NULL; + char *locale = I18N_ULOCALE_US; + + dlog_print(DLOG_INFO, LOG_TAG, "pattern_generator\n"); + + if(!pattern_generator) { + // create a pattern generator according to a given locale + i18n_udatepg_create(locale, &pattern_generator); + } + + if(!pattern_generator) { + dlog_print(DLOG_INFO, LOG_TAG, "i18n_udatepg_create fail"); + return ; + } + + i18n_uchar bestPattern[64] = {0,}; + char bestPatternString[64] = {0,}; + int bestPatternLength, len; + const char *custom_format = "yyyy.MM.dd G 'at' HH:mm:ss zzz"; + i18n_uchar uch_custom_format[64]; + int ret = I18N_ERROR_NONE; + + dlog_print(DLOG_INFO, LOG_TAG, "getBestPattern\n"); + + i18n_ustring_copy_ua(uch_custom_format, custom_format); + len = i18n_ustring_get_length(uch_custom_format); + + // gets the best pattern that matches the given custom_format + i18n_udatepg_get_best_pattern(pattern_generator, uch_custom_format, len, bestPattern, 64, &bestPatternLength); + + i18n_ustring_copy_au_n(bestPatternString, bestPattern, 64); + // gets "MM/dd/yyyy G h:mm:ss a zzz" as the best pattern + dlog_print(DLOG_INFO, LOG_TAG, "getBestPattern(char[]) : %s \n", bestPatternString); + + // closes a generator + i18n_udatepg_destroy(pattern_generator); + + i18n_udate_format_h formatter_KR = NULL; + i18n_udate_format_h formatter_LA = NULL; + i18n_udate_format_h formatter_SaoPaulo = NULL; + i18n_uchar formatted[64] = {0,}; + char result[64] = {0,}; + int formattedLength; + i18n_udate date; + const char *timezone_KR = "GMT+9:00"; // TimeZone for Korea/Seoul + const char *timezone_LA = "America/Los_Angeles"; + const char *timezone_SaoPaulo = "America/Sao_Paulo"; // Brazil/East + i18n_uchar utf16_timezone_KR[64] = {0,}; + i18n_uchar utf16_timezone_LA[64] = {0,}; + i18n_uchar utf16_timezone_SaoPaulo[64] = {0,}; + + i18n_ustring_copy_ua_n(utf16_timezone_KR, timezone_KR, strlen(timezone_KR)); + i18n_ustring_copy_ua_n(utf16_timezone_LA, timezone_LA, strlen(timezone_LA)); + i18n_ustring_copy_ua_n(utf16_timezone_SaoPaulo, timezone_SaoPaulo, strlen(timezone_SaoPaulo)); + + // creates new i18n_udate_format to format dates and times + ret = i18n_udate_create(I18N_UDATE_FULL , I18N_UDATE_FULL , locale, utf16_timezone_KR, -1, bestPattern, -1, &formatter_KR); + if ( ret != I18N_ERROR_NONE ) { + dlog_print(DLOG_INFO, LOG_TAG, "i18n_udate_create failed !!! \n"); + } + if (!formatter_KR) { + dlog_print(DLOG_INFO, LOG_TAG, "formatter is NULL\n"); + } + ret = i18n_udate_create(I18N_UDATE_FULL , I18N_UDATE_FULL , locale, utf16_timezone_LA, -1, bestPattern, -1, &formatter_LA); + if ( ret != I18N_ERROR_NONE ) { + dlog_print(DLOG_INFO, LOG_TAG, "i18n_udate_create failed !!! \n"); + } + if (!formatter_LA) { + dlog_print(DLOG_INFO, LOG_TAG, "formatter is NULL\n"); + } + ret = i18n_udate_create(I18N_UDATE_PATTERN , I18N_UDATE_PATTERN , locale, utf16_timezone_SaoPaulo, -1, bestPattern, -1, &formatter_SaoPaulo); + if ( ret != I18N_ERROR_NONE ) { + dlog_print(DLOG_INFO, LOG_TAG, "i18n_udate_create failed !!! \n"); + } + if (!formatter_LA) { + dlog_print(DLOG_INFO, LOG_TAG, "formatter is NULL\n"); + } + + dlog_print(DLOG_INFO, LOG_TAG, "i18n_udate_format_date\n"); + + // gets the current date and time + i18n_ucalendar_get_now(&date); + + // formats a date using i18n_udate_format + i18n_udate_format_date(formatter_KR, date, formatted, 64, NULL, &formattedLength); + i18n_ustring_copy_au_n(result, formatted, 64); + //ex) KOREA/Seoul - Current date : Wednesday, June 18, 2014 1:34:54 PM GMT+09:00 + dlog_print(DLOG_INFO, LOG_TAG, "KOREA/Seoul - Current date : %s\n",result); + + // formats a date using i18n_udate_format + i18n_udate_format_date(formatter_LA, date, formatted, 64, NULL, &formattedLength); + i18n_ustring_copy_au_n(result, formatted, 64); + //ex) America/LOS Angeles - Current date : Tuesday, June 17, 2014 9:34:54 PM Pacific Daylight Time + dlog_print(DLOG_INFO, LOG_TAG, "America/LOS Angeles - Current date : %s\n",result); + + // formats a date using i18n_udate_format + i18n_udate_format_date(formatter_SaoPaulo, date, formatted, 64, NULL, &formattedLength); + i18n_ustring_copy_au_n(result, formatted, 64); + //ex) Brazil/Sao Paulo - Current date : 6 18, 2014 AD, 1:34:54 PM GMT-2 + dlog_print(DLOG_INFO, LOG_TAG, "Brazil/Sao Paulo - Current date : %s\n",result); + + dlog_print(DLOG_INFO, LOG_TAG, "i18n_udate_destroy\n"); + // destroy an #i18n_udate_format_h + i18n_udate_destroy(formatter_KR); + i18n_udate_destroy(formatter_LA); + i18n_udate_destroy(formatter_SaoPaulo); + * @endcode + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_UDATEPG_MODULE + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Opens a generator according to a given locale. + * @remarks Must release @a dtpg using i18n_udatepg_destroy(). + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] locale If @c NULL - default locale will be used. + * @param[out] dtpg A pointer to #i18n_udatepg_h. Must not be @c NULL. + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_udatepg_create ( const char *locale, i18n_udatepg_h *dtpg ); + +/** + * @brief Destroys a generator. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] dtpg A pointer to #i18n_udatepg_h. Must not be @c NULL. + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_udatepg_destroy ( i18n_udatepg_h dtpg ); + +/** + * @brief Gets the best pattern matching the input skeleton. + * @details It is guaranteed to have all of the fields in the skeleton. + * @remarks This function uses a non-const #i18n_udatepg_h: + * It uses a stateful pattern parser which is set up for each generator object, + * rather than creating one for each function call. + * Consecutive calls to this function do not affect each other, + * but this function cannot be used concurrently on a single generator object. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] dtpg A pointer to #i18n_udatepg_h. Must not be @c NULL. + * @param[in] skeleton The skeleton is a pattern containing only the variable fields.\n + * For example, "MMMdd" and "mmhh" are skeletons. Must not be @c NULL. + * @param[in] len The length of the @a skeleton, >= 0. + * @param[out] best_pattern The best pattern found from the given @a skeleton. + * @param[in] capacity The capacity of @a best_pattern, >= 0 + * @param[out] best_pattern_len The length of @a best_pattern. + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @retval #I18N_ERROR_BUFFER_OVERFLOW A result would not fit in the supplied buffer + */ +int i18n_udatepg_get_best_pattern ( i18n_udatepg_h dtpg, const i18n_uchar *skeleton, int32_t len, i18n_uchar *best_pattern, int32_t capacity, int32_t *best_pattern_len ); + + +// Newly Added APIs + + +/** + * @brief Creates an empty generator, to be constructed with i18n_udatepg_add_pattern() etc. + * @since_tizen 2.3.1 + * + * @param[out] dtpg A pointer to the #i18n_udatepg_h handle. + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_udatepg_create_empty (i18n_udatepg_h *dtpg); + +/** + * @brief Creates a copy of a generator. + * @since_tizen 2.3.1 + * + * @param[in] dtpg An #i18n_udatepg_h handle to be copied. Must not be @c NULL. + * @param[out] dtpg_clone A pointer to clone of @c dtpg handle. + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_udatepg_clone ( const i18n_udatepg_h dtpg, i18n_udatepg_h * dtpg_clone); + +/** + * @brief Gets the best pattern matching the input @a skeleton. + * @details It is guaranteed to have all of the fields in the @a skeleton. + * + * Note that this function uses a non-const #i18n_udatepg_h: + * It uses a stateful pattern parser which is set up for each generator object, + * rather than creating one for each function call. + * Consecutive calls to this function do not affect each other, + * but this function cannot be used concurrently on a single generator object. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] dtpg An #i18n_udatepg_h handle. Must not be @c NULL. + * @param[in] skeleton The @c skeleton is a pattern containing only the variable fields; + * for example, "MMMdd" and "mmhh" are skeletons. Must not be @c NULL. + * @param[in] length The length of @c skeleton, >= 0. + * @param[in] options Options for forcing the length of specified fields in the + * returned pattern to match those in the @c skeleton (when this + * would not happen otherwise). For default behavior, use + * #I18N_UDATEPG_MATCH_NO_OPTIONS. + * @param[out] best_pattern The best pattern found from the given @c skeleton. + * @param[in] capacity The capacity of @c best_pattern, >= 0. + * + * @return The length of @c best_pattern. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_udatepg_get_best_pattern_with_options ( i18n_udatepg_h dtpg, const i18n_uchar *skeleton, int32_t length, + i18n_udatepg_date_time_pattern_match_options_e options, i18n_uchar *best_pattern, int32_t capacity ); + +/** + * @brief Gets a unique skeleton from a given pattern. For example, both "MMM-dd" and "dd/MMM" produce the skeleton "MMMdd". + * @details Note that this function uses a non-const #i18n_udatepg_h: + * It uses a stateful pattern parser which is set up for each generator object, + * rather than creating one for each function call. + * Consecutive calls to this function do not affect each other, + * but this function cannot be used concurrently on a single generator object. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] dtpg An #i18n_udatepg_h handle. Must not be @c NULL. + * @param[in] pattern Input pattern, such as "dd/MMM". Must not be @c NULL. + * @param[in] length The length of @c pattern, >= 0. + * @param[out] skeleton Such as "MMMdd". + * @param[in] capacity The capacity of @c skeleton, >= 0. + * + * @return The length of @c skeleton. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_udatepg_get_skeleton ( i18n_udatepg_h dtpg, const i18n_uchar *pattern, int32_t length, i18n_uchar *skeleton, int32_t capacity ); + +/** + * @brief Gets a unique base skeleton from a given pattern. + * @details This is the same as the skeleton, except that differences in length are minimized so + * as to only preserve the difference between string and numeric form. So + * for example, both "MMM-dd" and "d/MMM" produce the skeleton "MMMd"(notice the single d).
+ * Note that this function uses a non-const #i18n_udatepg_h : + * It uses a stateful pattern parser which is set up for each generator object, + * rather than creating one for each function call. + * Consecutive calls to this function do not affect each other, + * but this function cannot be used concurrently on a single generator object. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] dtpg An #i18n_udatepg_h handle. Must not be @c NULL. + * @param[in] pattern Input pattern, such as "dd/MMM". Must not be @c NULL. + * @param[in] length The length of @c pattern, >= 0. + * @param[out] base_skeleton Such as "Md". + * @param[in] capacity The capacity of base @c skeleton, >= 0. + * + * @return The length of @c base_skeleton. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_udatepg_get_base_skeleton ( i18n_udatepg_h dtpg, const i18n_uchar *pattern, int32_t length, i18n_uchar *base_skeleton, int32_t capacity ); + +/** + * @brief Adds a pattern to the generator. + * @details If the pattern has the same skeleton as an existing pattern, + * and the override parameter is set, then the previous + * value is overridden. Otherwise, the previous value is retained. + * In either case, the conflicting status is set and previous value is stored in conflicting pattern.
+ * Note that single-field patterns (like "MMM") are automatically added, and don't need to be added explicitly! + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] dtpg An #i18n_udatepg_h handle. Must not be @c NULL. + * @param[in] pattern Input pattern, such as "dd/MMM". Must not be @c NULL. + * @param[in] pattern_length The length of @c pattern, >= 0. + * @param[in] override when existing values are to be overridden use true, + * otherwise use false. + * @param[out] conflicting_pattern Previous pattern with the same skeleton. + * @param[in] capacity The capacity of @c conflicting_pattern. + * @param[out] conflict_status A pointer to the conflicting status + * The value could be #I18N_UDATEPG_NO_CONFLICT, #I18N_UDATEPG_BASE_CONFLICT or #I18N_UDATEPG_CONFLICT. + * + * @return Length of @c conflicting_pattern. -1 if @c conflict_status is #I18N_UDATEPG_NO_CONFLICT + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_udatepg_add_pattern ( i18n_udatepg_h dtpg, const i18n_uchar *pattern, int32_t pattern_length, i18n_ubool override, i18n_uchar *conflicting_pattern, int32_t capacity, i18n_udatepg_date_time_pattern_conflict_e * conflict_status ); + +/** + * @brief An append_item_format is a pattern used to append a field if there is no good match. + * @details For example, suppose that the input skeleton is "GyyyyMMMd", + * and there is no matching pattern internally, but there is a pattern + * matching "yyyyMMMd", say "d-MM-yyyy". Then that pattern is used, plus the G. + * The way these two are conjoined is by using the append_item_format for G (era). + * So if that value is, say "{0}, {1}" then the final resulting + * pattern is "d-MM-yyyy, G".
+ * There are actually three available variables : {0} is the pattern so far, + * {1} is the element we are adding, and {2} is the name of the element.
+ * This reflects the way that the CLDR data is organized. + * @since_tizen 2.3.1 + * + * @param[in] dtpg An #i18n_udatepg_h handle. Must not be @c NULL. + * @param[in] field One of #i18n_udatepg_date_time_pattern_field_e, such as #I18N_UDATEPG_ERA_FIELD. + * @param[in] value Pattern, such as "{0}, {1}". Must not be @c NULL. + * @param[in] length The length of @c value, >= 0. + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udatepg_get_append_item_format() + */ +int i18n_udatepg_set_append_item_format ( i18n_udatepg_h dtpg, i18n_udatepg_date_time_pattern_field_e field, const i18n_uchar *value, int32_t length ); + +/** + * @brief Getter corresponding to i18n_udatepg_set_append_item_format(). + * @details Values below 0 or at or above #I18N_UDATEPG_FIELD_COUNT are illegal arguments. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] dtpg An #i18n_udatepg_h handle. Must not be @c NULL. + * @param[in] field One of #i18n_udatepg_date_time_pattern_field_e, such as #I18N_UDATEPG_ERA_FIELD. + * @param[out] pattern_length A pointer that will receive the length of append item format @a value. + * + * @return The append_item_format for @a field + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udatepg_set_append_item_format() + */ +const i18n_uchar *i18n_udatepg_get_append_item_format ( const i18n_udatepg_h dtpg, i18n_udatepg_date_time_pattern_field_e field, int32_t *pattern_length ); + +/** + * @brief Sets the name of field, e.g. "era" in English for ERA. + * @details These are only used if the corresponding append_item_format is used, and if it contains a {2} variable. + * This reflects the way that the CLDR data is organized. + * @since_tizen 2.3.1 + * + * @param[in] dtpg An #i18n_udatepg_h handle. Must not be @c NULL. + * @param[in] field #i18n_udatepg_date_time_pattern_field_e, such as #I18N_UDATEPG_ERA_FIELD. + * @param[in] value Name for the @c field. Must not be @c NULL. + * @param[in] length The length of @c value, >= 0. + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udatepg_get_append_item_name() + */ +int i18n_udatepg_set_append_item_name ( i18n_udatepg_h dtpg, i18n_udatepg_date_time_pattern_field_e field, const i18n_uchar *value, + int32_t length ); + +/** + * @brief Getter corresponding to i18n_udatepg_set_append_item_name(). + * @details Values below 0 or at or above #I18N_UDATEPG_FIELD_COUNT are illegal arguments. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] dtpg The #i18n_udate_format_h handle. Must not be @c NULL. + * @param[in] field #i18n_udatepg_date_time_pattern_field_e, such as #I18N_UDATEPG_ERA_FIELD. + * @param[out] pattern_length A pointer that will receive the length of the name for @c field. + * + * @return The name for @c field + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udatepg_set_append_item_name() + */ +const i18n_uchar *i18n_udatepg_get_append_item_name ( const i18n_udatepg_h dtpg, i18n_udatepg_date_time_pattern_field_e field, + int32_t *pattern_length ); + +/** + * @brief The date time format is a message format pattern used to compose date and time patterns. + * @brief The default value is "{0} {1}", where {0} will be replaced by the date pattern and {1} will be replaced by the time pattern. + * This is used when the input skeleton contains both date and time fields, + * but there is not a close match among the added patterns. + * For example, suppose that this object was created by adding "dd-MMM" and "hh:mm", + * and its date time format is the default "{0} {1}". Then if the input skeleton is "MMMdhmm", + * there is not an exact match, so the input skeleton is broken up into two components "MMMd" and "hmm". + * There are close matches for those two skeletons, so the result is put together with this pattern, resulting in "d-MMM h:mm". + * @since_tizen 2.3.1 + * + * @param[in] dtpg An #i18n_udate_format_h handle. Must not be @c NULL. + * @param[in] date_time_format A message format pattern, here {0} will be replaced by the date pattern + * and {1} will be replaced by the time pattern. Must not be @c NULL. + * @param[in] length The length of @c date_time_format, >= 0. + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udatepg_get_date_time_format() + */ +int i18n_udatepg_set_date_time_format ( const i18n_udatepg_h dtpg, const i18n_uchar *date_time_format, int32_t length ); + +/** + * @brief Getter corresponding to i18n_udatepg_set_date_time_format(). + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] dtpg An #i18n_udate_format_h handle. Must not be @c NULL. + * @param[out] pattern_length A pointer that will receive the length of the @a date_time_format. + * + * @return A date_time_format + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udatepg_set_date_time_format() + */ +const i18n_uchar *i18n_udatepg_get_date_time_format ( const i18n_udatepg_h dtpg, int32_t *pattern_length ); + +/** + * @brief The decimal value is used in formatting fractions of seconds. + * @details If the skeleton contains fractional seconds, then this is used with the fractional seconds. + * For example, suppose that the input pattern is "hhmmssSSSS", + * and the best matching pattern internally is "H:mm:ss", and the decimal string is ",". + * Then the resulting pattern is modified to be "H:mm:ss,SSSS" + * @since_tizen 2.3.1 + * + * @param[in] dtpg The #i18n_udate_format_h handle. Must not be @c NULL. + * @param[in] decimal Decimal. Must not be @c NULL. + * @param[in] length The length of @c decimal, >= 0. + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udatepg_get_decimal() + */ +int i18n_udatepg_set_decimal ( i18n_udatepg_h dtpg, const i18n_uchar *decimal, int32_t length ); + +/** + * @brief Getter corresponding to i18n_udatepg_set_decimal(). + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] dtpg The #i18n_udate_format_h handle. Must not be @c NULL. + * @param[out] pattern_length A pointer that will receive the length of the @a decimal string. + * + * @return Corresponding to the decimal point. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_udatepg_set_decimal() + */ +const i18n_uchar *i18n_udatepg_get_decimal ( const i18n_udatepg_h dtpg, int32_t *pattern_length ); + +/** + * @brief Adjusts the field types (width and subtype) of a @a pattern to match what is in a @a skeleton. + * @details That is, if you supply a @a pattern like "d-M H:m", and a @a skeleton of "MMMMddhhmm", + * then the input pattern is adjusted to be "dd-MMMM hh:mm". + * This is used internally to get the best match for the input @a skeleton, but can also be used externally.
+ * Note that this function uses a non-const #i18n_udatepg_h: + * It uses a stateful pattern parser which is set up for each generator object, + * rather than creating one for each function call. Consecutive calls to this function do not affect each other, + * but this function cannot be used concurrently on a single generator object. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] dtpg The #i18n_udate_format_h handle. Must not be @c NULL. + * @param[in] pattern Input pattern. Must not be @c NULL. + * @param[in] pattern_length The length of input @a pattern, >= 0. + * @param[in] skeleton The skeleton. Must not be @c NULL. + * @param[in] skeleton_length The length of input @a skeleton, >= 0. + * @param[out] dest Pattern adjusted to match the @a skeleton fields widths and subtypes. + * @param[in] dest_capacity The capacity of @a dest, >= 0. + * + * @return The length of @a dest. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_udatepg_replace_field_types ( i18n_udatepg_h dtpg, const i18n_uchar *pattern, int32_t pattern_length, + const i18n_uchar *skeleton, int32_t skeleton_length, i18n_uchar *dest, int32_t dest_capacity ); + +/** + * @brief Adjusts the field types (width and subtype) of a pattern to match what is in a @a skeleton. + * @details That is, if you supply a @a pattern like "d-M H:m", and a @a skeleton of "MMMMddhhmm", + * then the input @a pattern is adjusted to be "dd-MMMM hh:mm". + * This is used internally to get the best match for the input @a skeleton, but can also be used externally.
+ * Note that this function uses a non-const #i18n_udatepg_h: + * It uses a stateful pattern parser which is set up for each generator object, + * rather than creating one for each function call. Consecutive calls to this function do not affect each other, + * but this function cannot be used concurrently on a single generator object. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] dtpg The #i18n_udate_format_h handle. Must not be @c NULL. + * @param[in] pattern Input pattern. Must not be @c NULL. + * @param[in] pattern_length The length of input @a pattern, >= 0. + * @param[in] skeleton The skeleton. Must not be @c NULL. + * @param[in] skeleton_length The length of input @a skeleton, >= 0. + * @param[in] options Options controlling whether the length of specified + * fields in the @a pattern are adjusted to match those in the @a skeleton + * (when this would not happen otherwise). + * For default behavior, use #I18N_UDATEPG_MATCH_NO_OPTIONS. + * @param[out] dest Pattern adjusted to match the @a skeleton fields widths and subtypes. + * @param[in] dest_capacity The capacity of @a dest, >= 0. + * + * @return The length of @a dest. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_udatepg_replace_field_types_with_options ( i18n_udatepg_h dtpg, const i18n_uchar *pattern, int32_t pattern_length, + const i18n_uchar *skeleton, int32_t skeleton_length, i18n_udatepg_date_time_pattern_match_options_e options, + i18n_uchar *dest, int32_t dest_capacity ); + +/** + * @brief Creates an #i18n_uenumeration_h for list of all the skeletons in canonical form. + * @details Call i18n_udatepg_get_pattern_for_skeleton() to get the corresponding pattern. + * @since_tizen 2.3.1 + * + * @param[in] dtpg An #i18n_udate_format_h handle. Must not be @c NULL. + * @param[out] enumeration A pointer to the #i18n_uenumeration_h for list of all the skeletons. The caller must destroy the object. + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_udatepg_skeletons_create ( const i18n_udatepg_h dtpg, i18n_uenumeration_h *enumeration ); + +/** + * @brief Creates an #i18n_uenumeration_h for list of all the base skeletons in canonical form. + * @since_tizen 2.3.1 + * + * @param[in] dtpg An #i18n_udate_format_h handle. Must not be @c NULL. + * @param[out] enumeration A pointer to the #i18n_uenumeration_h for list of all the base skeletons. The caller must destroy the object. + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_udatepg_base_skeletons_create ( const i18n_udatepg_h dtpg, i18n_uenumeration_h *enumeration ); + +/** + * @brief Gets the pattern corresponding to a given skeleton. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] dtpg The #i18n_udate_format_h handle. Must not be @c NULL. + * @param[in] skeleton The skeleton. Must not be @c NULL. + * @param[in] skeleton_length The length of @a skeleton, >= 0. + * @param[out] pattern_length The pointer to the length of return pattern + * + * @return Pattern corresponding to a given skeleton + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +const i18n_uchar *i18n_udatepg_get_pattern_for_skeleton ( const i18n_udatepg_h dtpg, const i18n_uchar *skeleton, int32_t skeleton_length, int32_t *pattern_length ); + + +#ifdef __cplusplus +} +#endif + +/** + * @} + * @} + */ + +#endif /* __UTILS_I18N_UDATEPG_H__*/ diff --git a/src/include/wearable/utils_i18n_uenumeration.h b/src/include/wearable/utils_i18n_uenumeration.h new file mode 100755 index 0000000..bbfe620 --- /dev/null +++ b/src/include/wearable/utils_i18n_uenumeration.h @@ -0,0 +1,194 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +#ifndef __UTILS_I18N_UENUMERATION_PRODUCT_H__ +#define __UTILS_I18N_UENUMERATION_PRODUCT_H__ + +#include + +/** + * @file utils_i18n_uenumeration.h + * @version 0.1 + * @brief utils_i18n_uenumeration + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @ingroup CAPI_BASE_UTILS_I18N_MODULE + * @defgroup CAPI_BASE_UTILS_I18N_UENUMERATION_MODULE UEnumeration + * @brief UEnumeration defines functions for handling String Enumeration. + * + * @section CAPI_BASE_UTILS_I18N_UENUMERATION_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_BASE_UTILS_I18N_UENUMERATION_MODULE_OVERVIEW Overview + * @details The UEnumeration module allows to create String Enumeration + * from chars and uchars. + * +*/ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_UENUMERATION_MODULE + * @{ + */ + +/** + * @brief Disposes of resources in use by the iterator. + * @details If @c enumeration is NULL, does nothing. After this call, any char* or i18n_uchar* returned + * by i18n_uenumeration_unext() or i18n_uenumeration_next() is invalid. + * @remarks Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] enumeration An #i18n_uenumeration_h to destroy + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_uenumeration_destroy ( i18n_uenumeration_h enumeration ); + +/** + * @brief Returns the number of elements that the iterator traverses. + * @details If the iterator is out-of-sync with its service, error code is set to #I18N_ERROR_ENUM_OUT_OF_SYNC. + * This is a convenience function. It can end up being very expensive as all the items might have to be pre-fetched + * (depending on the type of data being traversed). + * Use with caution and only when necessary. + * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] enumeration An #i18n_uenumeration_h to count + * + * @return The number of elements in the iterator + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @exception #I18N_ERROR_ENUM_OUT_OF_SYNC The iterator is out of sync + */ +int32_t i18n_uenumeration_count ( i18n_uenumeration_h enumeration ); + +/** + * @brief Returns the next element in the iterator's list. + * @details If there are no more elements, returns NULL. + * If the iterator is out-of-sync with its service, error code is set to #I18N_ERROR_ENUM_OUT_OF_SYNC and NULL is returned. + * If the native service string is a char* string, it is converted to i18n_uchar* with the invariant converter. + * The result is terminated by (i18n_uchar)0. + * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] enumeration An #i18n_uenumeration_h + * @param[out] result_length A pointer to receive the length of the result (not including the terminating \\0). + * If the pointer is NULL it is ignored. + * + * @return A pointer to the string. The string will be zero-terminated. + * The return pointer is owned by this iterator and must not be deleted by the caller. + * The pointer is valid until the next call to any i18n_uenumeration_... method, including i18n_uenumeration_next() or i18n_uenumeration_unext(). + * When all strings have been traversed, returns NULL. + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @exception #I18N_ERROR_ENUM_OUT_OF_SYNC The iterator is out of sync + */ +const i18n_uchar *i18n_uenumeration_unext ( i18n_uenumeration_h enumeration, int32_t *result_length ); + +/** + * @brief Returns the next element in the iterator's list. + * @details If there are no more elements, returns NULL. If the iterator is out-of-sync with its service, + * the #I18N_ERROR_ENUM_OUT_OF_SYNC error code is set and NULL is returned. + * If the native service string is a i18n_uchar* string, it is converted to char* with the invariant converter. + * The result is terminated by (char)0. If the conversion fails (because a character cannot be converted) + * then the error code is set to #I18N_ERROR_INVARIANT_CONVERSION and the return value is undefined (but non-NULL). + * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] enumeration An #i18n_uenumeration_h + * @param[out] result_length A pointer to receive the length of the result (not including the terminating \\0). + * If the pointer is NULL it is ignored. + * + * @return A pointer to the string. The string will be zero-terminated. + * The return pointer is owned by this iterator and must not be deleted by the caller. + * The pointer is valid until the next call to any i18n_uenumeration_... method, including i18n_uenumeration_next() or i18n_uenumeration_unext(). + * When all strings have been traversed, returns NULL. + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @exception #I18N_ERROR_ENUM_OUT_OF_SYNC The iterator is out of sync + * @exception #I18N_ERROR_INVARIANT_CONVERSION The underlying native string is i18n_uchar* and conversion to char* with the invariant converter fails. + * This error pertains only to current string, so iteration might be able to continue successfully. + */ +const char *i18n_uenumeration_next ( i18n_uenumeration_h enumeration, int32_t *result_length ); + +/** + * @brief Resets the iterator to the current list of service IDs. + * @details This re-establishes sync with the service and rewinds the iterator to start at the first element. + * @remarks Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] enumeration An #i18n_uenumeration_h + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_uenumeration_reset ( i18n_uenumeration_h enumeration ); + +/** + * @brief Given an array of const i18n_uchar* strings, return an #i18n_uenumeration_h. + * @details String pointers from 0..count-1 must not be NULL. + * Do not free or modify either the string array or the characters it points to until this object has been destroyed with i18n_uenumeration_destroy(). + * @remarks Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] strings An array of const i18n_uchar* strings (each null terminated). All storage is owned by the caller. + * @param[in] count The length of the array + * @param[out] enumeration A pointer to the new #i18n_uenumeration_h. Caller is responsible for calling i18n_uenumeration_destroy() to free memory. + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_uenumeration_destroy() + */ +int i18n_uenumeration_uchar_strings_enumeration_create(const i18n_uchar *const strings[], int32_t count, i18n_uenumeration_h *enumeration ); + +/** + * @brief Given an array of const char* strings (invariant chars only), return an #i18n_uenumeration_h. + * @details String pointers from 0..count-1 must not be NULL. + * Do not free or modify either the string array or the characters it points to until this object has been destroyed with i18n_uenumeration_destroy(). + * @remarks Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] strings A array of char* strings (each null terminated). All storage is owned by the caller. + * @param[in] count The length of the array + * @param[out] enumeration A pointer to the new #i18n_uenumeration_h. Caller is responsible for calling i18n_uenumeration_destroy() to free memory + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_uenumeration_destroy() + */ +int i18n_uenumeration_char_strings_enumeration_create(const char* const strings[], int32_t count, i18n_uenumeration_h *enumeration ); + +/** + * @} + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __UTILS_I18N_UENUMERATION_PRODUCT_H__*/ diff --git a/src/include/wearable/utils_i18n_ulocale.h b/src/include/wearable/utils_i18n_ulocale.h new file mode 100644 index 0000000..51d6e89 --- /dev/null +++ b/src/include/wearable/utils_i18n_ulocale.h @@ -0,0 +1,841 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + * + * Copyright (C) 1997-2013, International Business Machines + * Corporation and others. All Rights Reserved. + */ + +#ifndef __UTILS_I18N_ULOCALE_H__ +#define __UTILS_I18N_ULOCALE_H__ + +#include + +/** + * @file utils_i18n_ulocale.h + * @version 0.1 + * @brief utils_i18n_ulocale + */ + +/** + * @ingroup CAPI_BASE_UTILS_I18N_MODULE + * @defgroup CAPI_BASE_UTILS_I18N_ULOCALE_MODULE Ulocale + * @brief A Locale represents a specific geographical, political, or cultural region. + * @section CAPI_BASE_UTILS_I18N_ULOCALE_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_BASE_UTILS_I18N_ULOCALE_MODULE_OVERVIEW Overview + * @details A Locale represents a specific geographical, political, or cultural region. + * An operation that requires a Locale to perform its task is called locale-sensitive + * and uses the Locale to tailor information for the user. For example, displaying + * a number is a locale-sensitive operation. The number should be formatted according + * to the customs/conventions of the user's native country, region, or culture. + * In the C APIs, a locale is simply a const char string. + * + * @section CAPI_BASE_UTILS_I18N_ULOCALE_MODULE_SAMPLE_CODE_1 Sample Code 1 + * @brief Gets a default locale and a full name for the locale + * @code + const char *locale; + const char *in_locale_id = "en_US"; + char language[64] = {0,}; + i18n_uchar result_w[64] = {0,}; + char result[64] = {0,}; + int language_capacity = 64; + int buf_size_language; + int buf_size_display_name; + int ret = I18N_ERROR_NONE; + + // Sets default locale + ret = i18n_ulocale_set_default(getenv("LC_TIME")); + + // Gets default locale + ret = i18n_ulocale_get_default(&locale); + if ( ret != I18N_ERROR_NONE ) { + dlog_print(DLOG_ERROR, LOG_TAG, "i18n_ulocale_get_default() failed!!! \n"); + } + dlog_print(DLOG_INFO, LOG_TAG, "default locale : %s\n", locale); // default locale : en_GB.UTF-8 + + // Gets the language code for the specified locale + ret = i18n_ulocale_get_language(locale, language, language_capacity, &buf_size_language); + if ( ret != I18N_ERROR_NONE ) { + dlog_print(DLOG_ERROR, LOG_TAG, "i18n_ulocale_get_language() failed!!! \n"); + } + dlog_print(DLOG_INFO, LOG_TAG, "language code for the locale : %s\n", language); // language code for the locale : en + + // Gets the full name suitable for display for the specified locale + ret = i18n_ulocale_get_display_name(locale, in_locale_id, result_w, 64, &buf_size_display_name); + if ( ret != I18N_ERROR_NONE ) { + dlog_print(DLOG_ERROR, LOG_TAG, "i18n_ulocale_get_display_name() failed!!! \n"); + } + i18n_ustring_copy_au(result, result_w); + dlog_print(DLOG_INFO, LOG_TAG, "full name suitable for the locale : %s\n", result); // full name suitable for the locale : English (United Kingdom) + * @endcode + * + * @section CAPI_BASE_UTILS_I18N_ULOCALE_MODULE_SAMPLE_CODE_2 Sample Code 2 + * @brief See all available locales + * @code + int i = 0; + int32_t count = i18n_ulocale_count_available(); + for(i = 0; i < count; i++) + { + dlog_print(DLOG_INFO, LOG_TAG, "Available locale %d : %s " ,i, i18n_ulocale_get_available(i)); + // ... + //Available locale 5 : en_GB + //Available locale 6 : en_US + //Available locale 7 : en_US_POSIX + // ... + } + * @endcode + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_ULOCALE_MODULE + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Gets I18N's default locale. + * @details The returned string is a snapshot in time, and will remain valid + * and unchanged even when i18n_ulocale_set_default() is called. + * The returned storage is owned by I18N, and must not be altered or deleted by the caller. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] locale The I18N default locale + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ulocale_get_default ( const char **locale ); + +/** + * @brief Sets I18N's default locale. + * @details By default (without calling this function), + * I18N's default locale will be based on information obtained from the underlying system environment. + * + * Changes to I18N's default locale do not propagate back to the system environment. + * + * Changes to I18N's default locale to not affect any services that may already be open based on the previous default locale value. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] locale_id The new I18N default locale.\n + * A value of @c NULL will try to get the system's default locale. + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ulocale_set_default ( const char *locale_id ); + +/** + * @brief Gets the language code for the specified locale. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] locale_id The locale to get the ISO language code with.\n + * @c NULL may be used to specify the default. + * @param[out] language The language code for @a locale_id + * @param[in] language_capacity The size of the @a language buffer to store the language code with + * @param[out] buf_size_language The actual buffer size needed for the language code.\n + * If it's greater than @a language_capacity, the returned language code will be truncated. + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ulocale_get_language ( const char *locale_id, char *language, int32_t language_capacity, int32_t *buf_size_language ); + +/** + * @brief Gets the country code for the specified locale. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] locale_id The locale to get the country code with + * @param[out] country The country code for @a locale_id + * @param[in] country_capacity The size of the @a country buffer to store the country code with + * @param[out] error Error information if retrieving the country code failed + * + * @return The actual buffer size needed for the country code.\n + * If it's greater than @a country_capacity, the returned country code will be truncated. + */ +int32_t i18n_ulocale_get_country ( const char *locale_id, char *country, int32_t country_capacity, int *error ); + +/** + * @brief Gets the full name suitable for display for the specified locale. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] locale_id The locale to get the displayable name with.\n + * @c NULL may be used to specify the default. + * @param[in] in_locale_id The locale to be used to display the name.\n + * @c NULL may be used to specify the default. + * @param[out] result The displayable name for @a locale_id + * @param[in] max_result_size The size of the name buffer to store the displayable full name with + * @param[out] buf_size_display_name The actual buffer size needed for the displayable name.\n + * If it's greater than @a max_result_size, the returned displayable name will be truncated. + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ulocale_get_display_name ( const char *locale_id, const char *in_locale_id, i18n_uchar *result, int32_t max_result_size, int32_t *buf_size_display_name ); + +/** + * @brief Gets the specified locale from a list of all available locales. + * @details The return value is a pointer to an item of a locale name array. + * Both this array and the pointers it contains are owned by I18N + * and should not be deleted or written through by the caller. + * The locale name is terminated by a null pointer. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] n The specific locale name index of the available locale list + * + * @return A specified locale name of all available locales + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +const char* i18n_ulocale_get_available ( int32_t n ); + +/** + * @brief Gets the size of the all available locale list. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @return The size of the locale list + * @exception #I18N_ERROR_NONE Success + */ +int32_t i18n_ulocale_count_available ( void ); + +// Newly Added APIs + +/** + * @brief Gets the script code for the specified locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] locale_id The locale to get the ISO script code with + * @param[out] script The script code for @a locale_id. Must not be @c NULL. + * @param[in] script_capacity The size of the @a script buffer to store the script code with + * + * @return The actual buffer size needed for the script code. If it's greater than @a script_capacity, + * the returned script code will be truncated. If the @a script buffer is @c NULL + * or the @a script_capacity is lower than @c 0 , then the #I18N_ERROR_INVALID_PARAMETER error will be set + * and @c -1 will be returned. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ulocale_get_script ( const char *locale_id, char *script, int32_t script_capacity ); + +/** + * @brief Gets the variant code for the specified locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] locale_id The locale to get the variant code with + * @param[out] variant The variant code for @a locale_id + * @param[in] variant_capacity The size of the @a variant buffer to store the variant code with + * + * @return The actual buffer size needed for the variant code. If it's greater than @a variant_capacity, + * the returned variant code will be truncated. If the @a variant buffer is @c NULL + * or the @a variant_capacity is lower than @c 0 , then the #I18N_ERROR_INVALID_PARAMETER error will be set + * and @c -1 will be returned. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ulocale_get_variant ( const char *locale_id, char *variant, int32_t variant_capacity ); + +/** + * @brief Gets the full name for the specified locale. + * @details Note : This has the effect of 'canonicalizing' the I18N locale ID to + * a certain extent. Upper and lower case are set as needed. + * It does NOT map aliased names in any way. + * See the top of this header file. + * This API supports preflighting. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] locale_id The locale to get the full name with + * @param[out] name Fill in buffer for the name without keywords. + * @param[in] name_capacity Capacity of the fill in buffer. + * + * @return The actual buffer size needed for the full name. If it's greater than @a name_capacity, + * the returned full name will be truncated. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_BUFFER_OVERFLOW A result would not fit in the supplied buffer + */ +int32_t i18n_ulocale_get_name ( const char *locale_id, char *name, int32_t name_capacity ); + +/** + * @brief Gets the full name for the specified locale. + * @details Note : This has the effect of 'canonicalizing' the string to + * a certain extent. Upper and lower case are set as needed, + * and if the components were in 'POSIX' format they are changed to + * I18N format. It does NOT map aliased names in any way. + * See the top of this header file. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] locale_id The locale to get the full name with + * @param[out] name The full name for @a locale_id + * @param[in] name_capacity The size of the @a name buffer to store the full name with + * + * @return The actual buffer size needed for the full name. If it's greater than @a name_capacity, + * the returned full name will be truncated. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_BUFFER_OVERFLOW A result would not fit in the supplied buffer + */ +int32_t i18n_ulocale_canonicalize ( const char *locale_id, char *name, int32_t name_capacity ); + +/** + * @brief Gets the ISO language code for the specified locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] locale_id The locale to get the ISO language code with + * + * @return A language the ISO language code for @a locale_id + * + * @exception #I18N_ERROR_NONE Successful + */ +const char * i18n_ulocale_get_iso3_language ( const char *locale_id ); + +/** + * @brief Gets the ISO country code for the specified locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] locale_id The locale to get the ISO country code with + * + * @return A country the ISO country code for @a locale_id + * + * @exception #I18N_ERROR_NONE Successful + */ +const char * i18n_ulocale_get_iso3_country ( const char *locale_id ); + +/** + * @brief Gets the Win32 LCID value for the specified locale. + * @details If the I18N locale is not recognized by Windows, 0 will be returned. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] locale_id The locale to get the Win32 LCID value with + * + * @return A country the Win32 LCID for @a locale_id + * + * @exception #I18N_ERROR_NONE Successful + */ +uint32_t i18n_ulocale_get_lcid ( const char *locale_id ); + +/** + * @brief Gets the language name suitable for display for the specified locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] locale The locale to get the ISO language code with + * @param[in] display_locale The locale to be used to display the name.\n + * @c NULL may be used to specify the default. + * @param[out] language The displayable language code for @a locale. + * @param[in] language_capacity The size of the @a language buffer to store the displayable language code with + * + * @return The actual buffer size needed for the displayable language code. If it's greater than + * @a language_capacity, the returned language code will be truncated. If the @a language buffer is @c NULL + * or the @a language_capacity is lower than @c 0 , then the #I18N_ERROR_INVALID_PARAMETER error will be set + * and @c 0 will be returned. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ulocale_get_display_language ( const char *locale, const char *display_locale, i18n_uchar *language, int32_t language_capacity ); + +/** + * @brief Gets the script name suitable for display for the specified locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] locale The locale to get the displayable script code with. @c NULL may be used to specify the default. + * @param[in] display_locale The locale to be used to display the name. @c NULL may be used to specify the default. + * @param[out] script The displayable country code for @a locale + * @param[in] script_capacity The size of the script buffer to store the displayable script code with + * + * @return The actual buffer size needed for the displayable script code. If it's greater than @a script_capacity, + * the returned displayable script code will be truncated. If the @a script buffer is @c NULL + * or the @a script_capacity is lower than @c 0 , then the #I18N_ERROR_INVALID_PARAMETER error will be set + * and @c 0 will be returned. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ulocale_get_display_script ( const char *locale, const char *display_locale, i18n_uchar *script, int32_t script_capacity ); + +/** + * @brief Gets the country name suitable for display for the specified locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] locale The locale to get the displayable country code with. @c NULL may be used to specify the default. + * @param[in] display_locale The locale to be used to display the name. @c NULL may be used to specify the default. + * @param[out] country The displayable country code for @a locale + * @param[in] country_capacity The size of the @a country buffer to store the displayable country code with + * + * @return The actual buffer size needed for the displayable country code. If it's greater than @a country_capacity, + * the returned displayable country code will be truncated. If the @a country buffer is @c NULL + * or the @a country_capacity is lower than @c 0 , then the #I18N_ERROR_INVALID_PARAMETER error will be set + * and @c 0 will be returned. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ulocale_get_display_country ( const char *locale, const char *display_locale, i18n_uchar *country, int32_t country_capacity ); + +/** + * @brief Gets the variant name suitable for display for the specified locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] locale The locale to get the displayable variant code with. @c NULL may be used to specify the default. + * @param[in] display_locale The locale to be used to display the name. @c NULL may be used to specify the default. + * @param[out] variant The displayable variant code for @a locale + * @param[in] variant_capacity The size of the @a variant buffer to store the displayable variant code with + * + * @return The actual buffer size needed for the displayable variant code. If it's greater than @a variant_capacity, + * the returned displayable variant code will be truncated. If the @a variant buffer is @c NULL + * or the @a variant_capacity is lower than @c 0 , then the #I18N_ERROR_INVALID_PARAMETER error will be set + * and @c 0 will be returned. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ulocale_get_display_variant ( const char *locale, const char *display_locale, i18n_uchar *variant, int32_t variant_capacity ); + +/** + * @brief Gets the keyword name suitable for display for the specified locale. + * @details E.g : for the locale string de_DE\@collation=PHONEBOOK, this API gets the display string for the keyword collation. + * Usage : + * @code + * i18n_error_code_e status = I18N_ERROR_NONE; + * const char* keyword = NULL; + * int32_t keyword_len = 0; + * int32_t keyword_count = 0; + * i18n_uchar display_keyword[256]; + * int32_t display_keyword_len = 0; + * i18n_uenumeration_h keyword_enum = i18n_ulocale_keywords_create("de_DE@collation=PHONEBOOK;calendar=TRADITIONAL"); + * + * for(keyword_count = i18n_uenumeration_count(keyword_enum); keyword_count > 0; keyword_count--){ + * status = get_last_result(); + * if(status > 0){ + * // something went wrong so handle the error + * break; + * } + * // the uenum_next returns NULL-terminated string + * keyword = i18n_uenumeration_next(keyword_enum, &keyword_len); + * display_keyword_len = i18n_ulocale_get_display_keyword(keyword, "en_US", display_keyword, 256); + * // do something interesting + * } + * i18n_uenumeration_destroy(keyword_enum); + * @endcode + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] keyword The keyword whose display string needs to be returned. + * @param[in] display_locale The locale to be used to display the name. @c NULL may be used to specify the default. + * @param[out] dest The buffer to which the displayable keyword should be written. + * @param[in] dest_capacity The size of the buffer (number of #i18n_uchar characters). If it is 0, then + * @a dest may be @c NULL and the function will only return the length of the result without + * writing any of the result string (pre-flighting). + * + * @return The actual buffer size needed for the displayable variant code. If the @a dest buffer is @c NULL + * or the @a dest_capacity is lower than @c 0 , then the #I18N_ERROR_INVALID_PARAMETER error will be set + * and @c 0 will be returned. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_ulocale_keywords_create() + * @see i18n_uenumeration_count() + * @see i18n_uenumeration_next() + * @see i18n_uenumeration_destroy() + */ +int32_t i18n_ulocale_get_display_keyword ( const char *keyword, const char *display_locale, i18n_uchar *dest, int32_t dest_capacity ); + +/** + * @brief Gets the value of the keyword suitable for display for the specified locale. + * @details E.g : for the locale string de_DE\@collation=PHONEBOOK, this API gets the display string for PHONEBOOK, in the display locale, when "collation" is specified as the keyword. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] locale The locale to get the displayable variant code with. @c NULL may be used to specify the default. + * @param[in] keyword The keyword for whose value should be used. + * @param[in] display_locale The locale to be used to display the name. @c NULL may be used to specify the default. + * @param[out] dest The buffer to which the displayable keyword should be written. + * @param[in] dest_capacity The size of the buffer (number of #i18n_uchar characters). If it is 0, then + * @a dest may be @c NULL and the function will only return the length of the result + * without writing any of the result string (pre-flighting). + * + * @return The actual buffer size needed for the displayable variant code. If the @a dest buffer is @c NULL + * or the @a dest_capacity is lower than @c 0 , then the #I18N_ERROR_INVALID_PARAMETER error will be set + * and @c 0 will be returned. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ulocale_get_display_keyword_value ( const char *locale, const char *keyword, const char *display_locale, i18n_uchar *dest, int32_t dest_capacity ); + +/** + * @brief Gets a list of all available 2-letter language codes defined in ISO 639, + * plus additional 3-letter codes determined to be useful for locale generation as + * defined by Unicode CLDR. + * @details This is a pointer to an array of pointers to arrays of char. All of these pointers are owned + * by I18N - do not delete them, and do not write through them. + * The array is terminated with a @c NULL pointer. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @return A list of all available language codes + * + * @exception #I18N_ERROR_NONE Successful + */ +const char * const *i18n_ulocale_get_iso_languages ( void ); + +/** + * + * @brief Gets a list of all available 2-letter country codes defined in ISO 639. + * @details This is a pointer to an array of pointers to arrays of char. All of these pointers are + * owned by I18N - do not delete them, and do not write through them. + * The array is terminated with a @c NULL pointer. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @return A list of all available country codes + * + * @exception #I18N_ERROR_NONE Successful + */ +const char * const *i18n_ulocale_get_iso_countries ( void ); + +/** + * @brief Truncates the locale ID string to get the parent locale ID. + * @details Copies the part of the string before the last underscore. + * The parent locale ID will be an empty string if there is no + * underscore, or if there is only one underscore at @a locale_id[0]. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] locale_id Input locale ID string. + * @param[out] parent Output string buffer for the parent locale ID. Must not be @c NULL. + * @param[in] parent_capacity Size of the output buffer. If it's lower than the number of characters + * stored in the @a locale_id between the first character and the last occurrence + * of the underscore ("_") character, than the error code will be set to + * #I18N_ERROR_BUFFER_OVERFLOW. + * + * @return The length of the parent locale ID. If the @a parent buffer is @c NULL or the @a parent_capacity is lower than @c 0, + * then the #I18N_ERROR_INVALID_PARAMETER error will be set and @c -1 will be returned. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @exception #I18N_ERROR_BUFFER_OVERFLOW If the capacity of the @a parent is lower than the number of characters + * in the @a locale_id from index 0 to the index of the last occurrence of + * the underscore ("_") symbol. + */ +int32_t i18n_ulocale_get_parent ( const char *locale_id, char *parent, int32_t parent_capacity ); + +/** + * @brief Gets the full name for the specified locale. + * @details Note : This has the effect of 'canonicalizing' the string to a certain extent. + * Upper and lower case are set as needed, + * and if the components were in 'POSIX' format they are changed to I18N format. + * It does NOT map aliased names in any way. + * See the top of this header file. + * + * This API strips off the keyword part, so "de_DE\@collation=phonebook" will become "de_DE". + * This API supports preflighting. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] locale_id The locale to get the full name with + * @param[out] name Fill in buffer for the name without keywords. + * @param[in] name_capacity Capacity of the fill in buffer. + * + * @return The actual buffer size needed for the full name. If it's greater than @a name_capacity, + * the returned full name will be truncated. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_BUFFER_OVERFLOW A result would not fit in the supplied buffer + */ +int32_t i18n_ulocale_get_base_name ( const char *locale_id, char *name, int32_t name_capacity ); + +/** + * @brief Gets an enumeration of keywords for the specified locale. + * @details Enumeration must get disposed of by the client using i18n_uenumeration_destroy() function. + * @remarks Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] locale_id The locale to get the variant code with + * + * @param enumeration A pointer to the enumeration of keywords or @c NULL if there are no keywords. + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ulocale_keywords_create ( const char *locale_id, i18n_uenumeration_h *enumeration ); + +/** + * @brief Gets the value for a keyword. + * @details Locale name does not need to be normalized. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] locale_id A locale name containing the keyword ("de_DE@currency=EURO;collation=PHONEBOOK") + * @param[in] keyword_name The name of the keyword for which we want the value. Case insensitive. + * @param[out] buffer Receiving buffer + * @param[in] buffer_capacity Capacity of receiving @a buffer + * + * @return The length of keyword value. If the @a keyword_name or @a buffer is @c NULL or the @a buffer_capacity is lower than @c 0, + * then the #I18N_ERROR_INVALID_PARAMETER error will be set and @c -1 will be returned. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ulocale_get_keyword_value ( const char *locale_id, const char *keyword_name, char *buffer, int32_t buffer_capacity ); + +/** + * @brief Sets or removes the value of the specified keyword. + * @details For removing all keywords, use i18n_ulocale_get_base_name(). + * + * NOTE : Unlike almost every other I18N function which takes a + * buffer, this function will NOT truncate the output text. If a + * #I18N_ERROR_BUFFER_OVERFLOW is received, it means that the original + * buffer is untouched. This is done to prevent incorrect or possibly + * even malformed locales from being generated and used. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] keyword_name A name of the keyword to be set. Case insensitive. + * @param[in] keyword_value A value of the keyword to be set. If 0-length or + * @c NULL, will result in the keyword being removed. + * No error is given if that keyword does not exist. + * @param[out] buffer Input buffer containing locale to be modified. + * @param[in] buffer_capacity Capacity of receiving @a buffer + * + * @return The length needed for the @a buffer. If the @a keyword_name or @a buffer is @c NULL or the @a buffer_capacity is lower than @c 0, + * then the #I18N_ERROR_INVALID_PARAMETER error will be set and @c -1 will be returned. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_ulocale_get_keyword_value() + */ +int32_t i18n_ulocale_set_keyword_value ( const char *keyword_name, const char *keyword_value, char *buffer, int32_t buffer_capacity ); + +/** + * @brief Gets the layout character orientation for the specified locale. + * @remarks Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] locale_id locale name + * @param[out] layout_type A pointer to the enum indicating the layout orientation for characters. + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ulocale_get_character_orientation ( const char *locale_id, i18n_ulocale_layout_type_e *layout_type ); + +/** + * @brief Gets the layout line orientation for the specified locale. + * @remarks Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] locale_id locale name + * @param[out] layout_type A pointer to the enum indicating the layout orientation for lines. + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_ulocale_get_line_orientation ( const char *locale_id, i18n_ulocale_layout_type_e *layout_type ); + +/** + * @brief Gets the I18N locale ID for the specified Win32 LCID value. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] host_id The Win32 LCID to translate + * @param[out] locale The output buffer for the I18N locale ID, which will be NULL-terminated if there is room. + * @param[in] locale_capacity The size of the output buffer + * + * @return The actual size of the locale ID, not including NULL-termination. + * If the @a locale buffer is @c NULL or the @a locale_capacity is lower than @c 0, + * then the #I18N_ERROR_INVALID_PARAMETER error will be set and @c -1 will be returned. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ulocale_get_locale_for_lcid ( uint32_t host_id, char *locale, int32_t locale_capacity ); + +/** + * @brief Adds the likely subtags for a provided locale ID, per the algorithm described + * in the following CLDR technical report : http://www.unicode.org/reports/tr35/#Likely_Subtags + * @details If @a locale_id is already in the maximal form, or there is no data available + * for maximization, it will be copied to the output buffer. For example, + * "und-Zzzz" cannot be maximized, since there is no reasonable maximization. + * + * Examples : + * + * "en" maximizes to "en_Latn_US" + * + * "de" maximizes to "de_Latn_US" + * + * "sr" maximizes to "sr_Cyrl_RS" + * + * "sh" maximizes to "sr_Latn_RS" (Note this will not reverse.) + * + * "zh_Hani" maximizes to "zh_Hans_CN" (Note this will not reverse.) + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] locale_id The locale to maximize + * @param[out] maximized_locale_id The maximized locale + * @param[in] maximized_locale_id_capacity The capacity of the @a maximized_locale_id buffer + * + * @return The actual buffer size needed for the maximized locale. If it's + * greater than @a maximized_lacale_id_capacity, the returned ID will be truncated. + * On error, the return value is -1. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ulocale_add_likely_subtags ( const char *locale_id, char *maximized_locale_id, int32_t maximized_locale_id_capacity ); + +/** + * @brief Minimizes the subtags for a provided locale ID, per the algorithm described + * in the following CLDR technical report: http://www.unicode.org/reports/tr35/#Likely_Subtags + * @details If @a locale_id is already in the minimal form, or there is no data available + * for minimization, it will be copied to the output buffer. Since the + * minimization algorithm relies on proper maximization, see the comments + * for i18n_ulocale_add_likely_subtags() for reasons why there might not be any data. + * + * Examples : + * + * "en_Latn_US" minimizes to "en" + * + * "de_Latn_US" minimizes to "de" + * + * "sr_Cyrl_RS" minimizes to "sr" + * + * "zh_Hant_TW" minimizes to "zh_TW" (The region is preferred to the script, and minimizing to "zh" would imply "zh_Hans_CN".) + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] locale_id The locale to minimize + * @param[out] minimized_locale_id The minimized locale + * @param[in] minimized_locale_id_capacity The capacity of the @a minimized_locale_id buffer + * + * @return The actual buffer size needed for the minimized locale. If it's + * greater than @a minimized_locale_id_capacity, the returned ID will be truncated. + * On error, the return value is -1. + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ulocale_minimize_subtags ( const char *locale_id, char *minimized_locale_id, int32_t minimized_locale_id_capacity ); + +/** + * @brief Returns a locale ID for the specified BCP47 language tag string. + * @details If the specified language tag contains any ill-formed subtags, + * the first such subtag and all following subtags are ignored.
+ * + * This implements the 'Language-Tag' production of BCP47, and so + * supports grandfathered (regular and irregular) as well as private + * use language tags. Private use tags are represented as 'x-whatever', + * and grandfathered tags are converted to their canonical replacements + * where they exist. Note that a few grandfathered tags have no modern + * replacement, these will be converted using the fallback described in + * the first paragraph, so some information might be lost. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] langtag The input BCP47 language tag. + * @param[out] locale_id The output buffer receiving a locale ID for the + * specified BCP47 language tag. + * @param[in] locale_id_capacity The size of the @a locale_id output buffer. + * @param[in] parsed_length If not @c NULL, successfully parsed length + * for the input language tag is set. + * + * @return The length of the locale ID. If the @a langtag or @a locale_id buffer is @c NULL or the @a locale_id_capacity is lower than @c 0, + * then the #I18N_ERROR_INVALID_PARAMETER error will be set and @c -1 will be returned. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ulocale_for_language_tag ( const char *langtag, char *locale_id, int32_t locale_id_capacity, int32_t *parsed_length ); + +/** + * @brief Returns a well-formed language tag for this locale ID. + * @details Note : When @a strict is @c false, any locale + * fields which do not satisfy the BCP47 syntax requirement will + * be omitted from the result. When @a strict is + * @c true, this function sets #I18N_ERROR_INVALID_PARAMETER to the + * result if any locale fields do not satisfy the + * BCP47 syntax requirement. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] locale_id The input locale ID + * @param[out] langtag The output buffer receiving BCP47 language + * tag for the locale ID. + * @param[in] langtag_capacity The size of the BCP47 language tag + * output buffer. + * @param[in] strict Boolean value indicating if the function returns + * an error for an ill-formed input locale ID. + * + * @return The length of the BCP47 language tag. If the @a locale_id or @a langtag buffer is @c NULL or the @a langtag_capacity is lower than @c 0, + * then the #I18N_ERROR_INVALID_PARAMETER error will be set and @c -1 will be returned. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ulocale_to_language_tag ( const char *locale_id, char *langtag, int32_t langtag_capacity, i18n_ubool strict ); + +#ifdef __cplusplus +} +#endif + +/** + * @} + * @} + */ + +#endif /* __UTILS_I18N_ULOCALE_H__*/ diff --git a/src/include/wearable/utils_i18n_unormalization.h b/src/include/wearable/utils_i18n_unormalization.h new file mode 100755 index 0000000..76ecbc0 --- /dev/null +++ b/src/include/wearable/utils_i18n_unormalization.h @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +#ifndef __UTILS_I18N_UNORMALIZATION_H__ +#define __UTILS_I18N_UNORMALIZATION_H__ + +#include + +/** + * @file utils_i18n_unormalization.h + * @version 0.1 + * @brief utils_i18n_unormaliztion + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @ingroup CAPI_BASE_UTILS_I18N_MODULE + * @defgroup CAPI_BASE_UTILS_I18N_UNORMALIZATION_MODULE Unormalization + * @brief The Unormalization module provides Unicode normalization functionality for standard unicode normalization. + * + * @section CAPI_BASE_UTILS_I18N_UNORMALIZATION_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_BASE_UTILS_I18N_UNORMALIZATION_MODULE_OVERVIEW Overview + * @details The Unormalization module provides Unicode normalization functionality for standard unicode normalization. + * All instances of i18n_unormalizer_h are unmodifiable/immutable. + * Instances returned by i18n_unormalization_get_instance() are singletons that must not be deleted by the caller. + * + * @section CAPI_BASE_UTILS_I18N_UNORMALIZATION_MODULE_SAMPLE_CODE_1 Sample Code 1 + * @brief Creates a normalizer and normalizes a unicode string + * @code + i18n_unormalizer_h normalizer = NULL; + i18n_uchar src = 0xAC00; + i18n_uchar dest[4] = {0,}; + int dest_str_len = 0; + int i = 0; + + // gets instance for normalizer + i18n_unormalization_get_instance( NULL, "nfc", I18N_UNORMALIZATION_DECOMPOSE, &normalizer ); + + // normalizes a unicode string + i18n_unormalization_normalize( normalizer, &src, 1, dest, 4, &dest_str_len ); + dlog_print(DLOG_INFO, LOG_TAG, "src is 0x%x\n", src ); // src is 0xAC00 (0xAC00: A Korean character combined with consonant and vowel) + + for ( i = 0; i < dest_str_len; i++ ) { + dlog_print(DLOG_INFO, LOG_TAG, "dest[%d] is 0x%x\t", i + 1, dest[i] ); // dest[1] is 0x1100 dest[2] is 0x1161 (0x1100: consonant, 0x1161: vowel) + } + * @endcode + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_UNORMALIZATION_MODULE + * @{ + */ + +/** + * @brief Gets a i18n_unormalizer_h which uses the specified data file and composes or decomposes text according to the specified mode. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] package_name @c NULL for ICU built-in data, otherwise application data package name. + * @param[in] name "nfc" or "nfkc" or "nfkc_cf" or the name of the custom data file. + * @param[in] mode The normalization mode (compose or decompose). + * @param[out] normalizer The requested normalizer on success. + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_unormalization_get_instance (const char *package_name, const char *name, i18n_unormalization_mode_e mode, + i18n_unormalizer_h *normalizer); + +/** + * @brief Writes the normalized form of the source string to the destination string(replacing its contents). + * @details The source and destination strings must be different buffers. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] normalizer i18n normalizer handle. + * @param[in] src The source string. + * @param[in] len The length of the source string, otherwise @c -1 if NULL-terminated. + * @param[out] dest The destination string\n + * Its contents are replaced with normalized @a src. + * @param[in] capacity The number of string_uchar that can be written to @a dest + * @param[out] len_deststr The length of the destination string + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_unormalization_normalize (i18n_unormalizer_h normalizer, const i18n_uchar *src, int32_t len, i18n_uchar *dest, int32_t capacity, int32_t *len_deststr); + +#ifdef __cplusplus +} +#endif + +/** + * @} + * @} + */ + +#endif /* __UTILS_I18N_UNORMALIZATION_H__*/ diff --git a/src/include/wearable/utils_i18n_unumber.h b/src/include/wearable/utils_i18n_unumber.h new file mode 100644 index 0000000..c25d665 --- /dev/null +++ b/src/include/wearable/utils_i18n_unumber.h @@ -0,0 +1,645 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +#ifndef __UTILS_I18N_UNUMBER_H__ +#define __UTILS_I18N_UNUMBER_H__ + +#include + +/** + * @file utils_i18n_unumber.h + * @version 0.1 + * @brief utils_i18n_unumber + */ + +/** + * @ingroup CAPI_BASE_UTILS_I18N_MODULE + * @defgroup CAPI_BASE_UTILS_I18N_UNUMBER_MODULE Unumber + * @brief The Unumber module helps you format and parse numbers for any locale. + * + * @section CAPI_BASE_UTILS_I18N_UNUMBER_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_BASE_UTILS_I18N_UNUMBER_MODULE_OVERVIEW Overview + * @details The Unumber module helps you format and parse numbers for any locale. + * Your code can be completely independent of the locale conventions for decimal + * points, thousands-separators, or even the particular decimal digits used, + * or whether the number format is even decimal. There are different number format + * styles like decimal, currency, percent and spellout. + * + * @section CAPI_BASE_UTILS_I18N_UNUMBER_MODULE_SAMPLE_CODE_1 Sample Code 1 + * @brief Gets a currency symbol according to a given locale. + * @code + int buf_len; + i18n_uchar u_buffer[64]; + char a_buffer[64]; + i18n_unumber_format_h num_format; + + // creates and returns a new unumber_format + i18n_unumber_create(I18N_UNUMBER_CURRENCY, NULL, -1, "en_US", NULL, &num_format); + + // gets a symbol associated with i18n_unumber_format + i18n_unumber_get_symbol(num_format, I18N_UNUMBER_CURRENCY_SYMBOL, u_buffer, 64, &buf_len); + + i18n_ustring_copy_au(a_buffer, u_buffer); + // en_US currency symbol: $ + dlog_print(DLOG_INFO, LOG_TAG, "en_US currency symbol: %s \n", a_buffer); + + // destroys i18n_unumber_format + i18n_unumber_destroy(num_format); + * @endcode + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_UNUMBER_MODULE + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Creates and returns a new unumber_format_h for formatting and parsing numbers. + * @details A unumber_format_style_e may be used to format numbers by calling {@link i18n_unumber_create()}. + * The caller must call {@link #i18n_unumber_destroy() } when done to release resources used by this object. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @remarks Must release @a num_format using i18n_unumber_destroy(). + * + * @param[in] style The type of number format to create: one of + * #I18N_UNUMBER_DECIMAL, + * #I18N_UNUMBER_CURRENCY, + * #I18N_UNUMBER_PERCENT, + * #I18N_UNUMBER_SCIENTIFIC, + * #I18N_UNUMBER_SPELLOUT, + * #I18N_UNUMBER_ORDINAL, + * #I18N_UNUMBER_DURATION, + * #I18N_UNUMBER_NUMBERING_SYSTEM, + * #I18N_UNUMBER_PATTERN_RULEBASED, + * or #I18N_UNUMBER_DEFAULT \n + * If #I18N_UNUMBER_PATTERN_DECIMAL or #I18N_UNUMBER_PATTERN_RULEBASED is passed then the number format is created using the given pattern, which must conform + * to the syntax described in DecimalFormat or RuleBasedNumberFormat, respectively. + * @param[in] pattern A pattern specifying the format to use \n This parameter is ignored unless the style is #I18N_UNUMBER_PATTERN_DECIMAL or #I18N_UNUMBER_PATTERN_RULEBASED. + * @param[in] pattern_len The number of characters in the pattern, otherwise @c -1 if NULL-terminated\n + * This parameter is ignored unless the style is I18N_UNUMBER_PATTERN_*. + * @param[in] locale A locale identifier to use to determine formatting + * and parsing conventions, otherwise @c NULL to use the default locale. + * @param[in] parse_err A pointer to a #i18n_uparse_error_s structure to receive the + * details of any parsing errors, otherwise @c NULL if no parsing error details are desired. + * @param[out] num_format A pointer to a newly created #i18n_unumber_format_h, otherwise @c NULL if an error occurs. + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_unumber_create ( i18n_unumber_format_style_e style, const i18n_uchar *pattern, int32_t pattern_len, const char *locale, + i18n_uparse_error_s *parse_err, i18n_unumber_format_h *num_format ); + +/** + * @brief Destroys an #i18n_unumber_format_h. + * @details Once destroyed, an #i18n_unumber_format may no longer be used. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] fmt The formatter to destroy + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_unumber_destroy ( i18n_unumber_format_h fmt ); + +/** + * @brief Gets a symbol associated with an #i18n_unumber_format_h. + * @details An #i18n_unumber_format_h uses symbols to represent the special locale-dependent characters in a number, + * for example the percent sign. This API is not supported for rule-based formatters. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] fmt The formatter to query. + * @param[in] symbol The unumber_format_symbol_e constant for the symbol to get + * @param[out] buffer The string buffer that will receive the symbol string\n + * If it is @c NULL, then only the length of the symbol is returned. + * @param[in] size The size of the string buffer + * @param[out] len_symbol The length of the symbol\n + * The buffer is not modified if length >= size + * + * @retval #I18N_ERROR_NONE Successful. + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_unumber_get_symbol ( const i18n_unumber_format_h fmt, i18n_unumber_format_symbol_e symbol, i18n_uchar *buffer, int32_t size, int32_t *len_symbol ); + + +// Newly Added APIs + + +/** + * @brief Creates a copy of an #i18n_unumber_format_h. + * @details This function performs a deep copy. + * @remarks Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] fmt The format to copy. + * @param[out] fmt_clone A pointer to clone of @a fmt. + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful. + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_unumber_clone (const i18n_unumber_format_h fmt, i18n_unumber_format_h *fmt_clone); + +/** +* @brief Formats an integer using a i18n_unumber_format_h. +* @details The integer will be formatted according to the i18n_unumber_format_h's locale. +* @since_tizen 2.3.1 +* +* @param[in] fmt The formatter to use. +* @param[in] number The number to format. +* @param[out] result A pointer to a buffer to receive the NULL-terminated formatted number. +* If the formatted number fits into dest but cannot be NULL-terminated (length == resultLength) +* then the error code is set to #I18N_WARNING_STRING_NOT_TERMINATED. +* If the formatted number doesn't fit into result then the error code is set to #I18N_ERROR_BUFFER_OVERFLOW. +* @param[in] result_length The maximum size of result. +* @param[in] pos A pointer to a i18n_ufield_position. On input, position->field is read. +* On output, position->beginIndex and position->endIndex indicate the beginning and ending indices of field number position->field, if such a field exists. +* This parameter may be NULL, in which case no field +* @param[out] status A pointer to an i18n_error_code_e to receive any errors +* +* @return The total buffer size needed; if greater than result_length, the output was truncated. +*/ +int32_t i18n_unumber_format (const i18n_unumber_format_h fmt, int32_t number, i18n_uchar *result, int32_t result_length, i18n_ufield_position_s *pos, i18n_error_code_e *status); + +/** + * @brief Formats an int64 using an #i18n_unumber_format_h. + * @details The int64 will be formatted according to the #i18n_unumber_format_h's locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] fmt The formatter to use. + * @param[in] number The number to format. + * @param[out] result A pointer to a buffer to receive the NULL-terminated formatted number. + * If the formatted number fits into @a result but cannot be NULL-terminated (length == result_length) + * then the error code is set to #I18N_WARNING_STRING_NOT_TERMINATED. + * If the formatted number doesn't fit into result then the error code is set to #I18N_ERROR_BUFFER_OVERFLOW. + * @param[in] result_length The maximum size of @a result. + * @param[in,out] pos An #i18n_ufield_position_h handle. On input, position->field is read. + * On output, position->beginIndex and position->endIndex indicate the beginning and ending indices of field number position->field, if such a field exists. + * This parameter may be NULL, in which case no field + * + * @return The total buffer size needed; if greater than @a result_length, the output was truncated. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @exception #I18N_WARNING_STRING_NOT_TERMINATED If the formatted number fits into @a result but cannot be NULL-terminated (length == result_length) + * @exception #I18N_ERROR_BUFFER_OVERFLOW If the formatted number doesn't fit into the @a result buffer + */ +int32_t i18n_unumber_format_int64 (const i18n_unumber_format_h fmt, int64_t number, i18n_uchar *result, int32_t result_length, i18n_ufield_position_h pos); + +/** + * @brief Formats a double using an #i18n_unumber_format_h. + * @details The double will be formatted according to the #i18n_unumber_format_h's locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] fmt The formatter to use. + * @param[in] number The number to format. + * @param[out] result A pointer to a buffer to receive the NULL-terminated formatted number. + * If the formatted number fits into @a result but cannot be NULL-terminated (length == result_length) + * then the error code is set to #I18N_WARNING_STRING_NOT_TERMINATED. + * If the formatted number doesn't fit into result then the error code is set to #I18N_ERROR_BUFFER_OVERFLOW. + * @param[in] result_length The maximum size of @a result. + * @param[in,out] pos An #i18n_ufield_position_h handle. On input, position->field is read. + * On output, position->beginIndex and position->endIndex indicate the beginning + * and ending indices of field number position->field, if such a field exists. + * This parameter may be NULL, in which case no field + * + * @return The total buffer size needed; if greater than @a result_length, the output was truncated. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @exception #I18N_WARNING_STRING_NOT_TERMINATED If the formatted number fits into @a result but cannot be NULL-terminated (length == result_length) + * @exception #I18N_ERROR_BUFFER_OVERFLOW If the formatted number doesn't fit into the @a result buffer + */ +int32_t i18n_unumber_format_double (const i18n_unumber_format_h fmt, double number, i18n_uchar *result, int32_t result_length, i18n_ufield_position_h pos); + +/** + * @brief Formats a decimal number using an #i18n_unumber_format_h. + * @details The number will be formatted according to the #i18n_unumber_format_h's locale. The syntax of the input number + * is a "numeric string" as defined in the Decimal Arithmetic Specification, available at http://speleotrove.com/decimal + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] fmt The formatter to use. + * @param[in] number The number to format. + * @param[in] length The length of the input @a number, or -1 if the input is NULL-terminated. + * @param[out] result A pointer to a buffer to receive the NULL-terminated formatted number. + * If the formatted number fits into @a result but cannot be NULL-terminated (length == result_length) then + * the error code is set to #I18N_WARNING_STRING_NOT_TERMINATED. + * If the formatted number doesn't fit into result then the error code is set to + * #I18N_ERROR_BUFFER_OVERFLOW. + * @param[in] result_length The maximum size of @a result. + * @param[in,out] pos An #i18n_ufield_position_h handle. On input, position->field is read. + * On output, position->beginIndex and position->endIndex indicate the beginning and ending + * indices of field number position->field, if such a field exists. + * This parameter may be NULL, in which case it is ignored. + * + * @return The total buffer size needed; if greater than @a result_length, the output was truncated. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @exception #I18N_WARNING_STRING_NOT_TERMINATED If the formatted number fits into @a result but cannot be NULL-terminated (length == result_length) + * @exception #I18N_ERROR_BUFFER_OVERFLOW If the formatted number doesn't fit into the @a result buffer + */ +int32_t i18n_unumber_format_decimal (const i18n_unumber_format_h fmt, const char *number, int32_t length, i18n_uchar *result, int32_t result_length, i18n_ufield_position_h pos); + +/** + * @brief Formats a double currency amount using an #i18n_unumber_format_h. + * @details The double will be formatted according to the #i18n_unumber_format_h's locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] fmt The formatter to use. + * @param[in] number The number to format. + * @param[in] currency The 3-letter NULL-terminated ISO 4217 currency code. + * @param[out] result A pointer to a buffer to receive the NULL-terminated formatted number. + * If the formatted number fits into @a result but cannot be NULL-terminated (length == result_length) + * then the error code is set to #I18N_WARNING_STRING_NOT_TERMINATED. + * If the formatted number doesn't fit into result then the error code is set to + * #I18N_ERROR_BUFFER_OVERFLOW. + * @param[in] result_length The maximum size of @a result. + * @param[in,out] pos An #i18n_ufield_position_h handle. On input, position->field is read. + * On output, position->beginIndex and position->endIndex indicate the beginning and ending indices + * of field number position->field, if such a field exists. + * This parameter may be NULL, in which case it is ignored. + * + * @return The total buffer size needed; if greater than @a result_length, the output was truncated. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @exception #I18N_WARNING_STRING_NOT_TERMINATED If the formatted number fits into @a result but cannot be NULL-terminated (length == result_length) + * @exception #I18N_ERROR_BUFFER_OVERFLOW If the formatted number doesn't fit into the @a result buffer + */ +int32_t i18n_unumber_format_double_currency (const i18n_unumber_format_h fmt, double number, i18n_uchar *currency, i18n_uchar *result, int32_t result_length, i18n_ufield_position_h pos); + +/** + * @brief Parses a string into an integer using an #i18n_unumber_format_h. + * @details The string will be parsed according to the #i18n_unumber_format_h's locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] fmt The formatter to use. + * @param[in] text The text to parse. + * @param[in] text_length The length of @a text, or -1 if NULL-terminated. + * @param[in,out] parse_pos If not NULL, on input a pointer to an integer specifying the offset at which to begin parsing. + * If not NULL, on output the offset at which parsing ended. + * + * @return The value of the parsed integer + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_unumber_parse (const i18n_unumber_format_h fmt, const i18n_uchar *text, int32_t text_length, int32_t *parse_pos); + +/** + * @brief Parses a string into an int64 using an #i18n_unumber_format_h. + * @details The string will be parsed according to the #i18n_unumber_format_h's locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] fmt The formatter to use. + * @param[in] text The text to parse. + * @param[in] text_length The length of @a text, or -1 if NULL-terminated. + * @param[in,out] parse_pos If not NULL, on input a pointer to an integer specifying the offset at which to begin parsing. + * If not NULL, on output the offset at which parsing ended. + * + * @return The value of the parsed integer + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int64_t i18n_unumber_parse_int64 (const i18n_unumber_format_h fmt, const i18n_uchar *text, int32_t text_length, int32_t *parse_pos); + +/** + * @brief Parses a string into a double using an #i18n_unumber_format_h. + * @details The string will be parsed according to the #i18n_unumber_format_h's locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] fmt The formatter to use. + * @param[in] text The text to parse. + * @param[out] text_length The length of @a text, or -1 if NULL-terminated. + * @param[in,out] parse_pos If not NULL, on input a pointer to an integer specifying the offset at which to begin parsing. + * If not NULL, on output the offset at which parsing ended. + * + * @return The value of the parsed double + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +double i18n_unumber_parse_double (const i18n_unumber_format_h fmt, const i18n_uchar *text, int32_t text_length, int32_t *parse_pos); + +/** + * @brief Parses a number from a string into an unformatted numeric string using an #i18n_unumber_format_h. + * @details The input string will be parsed according to the #i18n_unumber_format_h's locale. + * The syntax of the output is a "numeric string" as defined in the Decimal Arithmetic Specification, available at + * http://speleotrove.com/decimal + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] fmt The formatter to use. + * @param[in] text The text to parse. + * @param[in] text_length The length of @a text, or -1 if NULL-terminated. + * @param[in,out] parse_pos If not NULL, on input a pointer to an integer specifying the offset at which to begin parsing. + * If not NULL, on output the offset at which parsing ended. + * @param[out] out_buf A (char *) buffer to receive the parsed number as a string. + * The output string will be NULL-terminated if there is sufficient space. + * @param[out] out_buf_length The size of the output buffer. May be zero, in which case the @a out_buf pointer may be NULL, + * and the function will return the size of the output string. + * + * @return The length of the output string, not including any terminating NULL. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_unumber_parse_decimal (const i18n_unumber_format_h fmt, const i18n_uchar *text, int32_t text_length, int32_t *parse_pos, char *out_buf, int32_t out_buf_length); + +/** + * @brief Parses a string into a double and a currency using an #i18n_unumber_format_h. + * @details The string will be parsed according to the #i18n_unumber_format_h's locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] fmt The formatter to use. + * @param[in] text The text to parse. + * @param[in] text_length The length of @a text, or -1 if NULL-terminated. + * @param[in,out] parse_pos A pointer to an offset index into text at which to begin parsing. On output, @a parse_pos will + * point after the last parsed character. This parameter may be NULL, in which case parsing begins + * at offset 0. + * If not NULL, on output the offset at which parsing ended. + * @param[out] currency A pointer to the buffer to receive the parsed NULL- terminated currency. + * This buffer must have a capacity of at least 4 #i18n_uchar characters. + * + * @return The parsed double + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +double i18n_unumber_parse_double_currency (const i18n_unumber_format_h fmt, const i18n_uchar *text, int32_t text_length, int32_t *parse_pos, i18n_uchar *currency); + +/** + * @brief Sets the pattern used by an #i18n_unumber_format_h. + * @details This can only be used on a DecimalFormat, other formats return #I18N_ERROR_NOT_SUPPORTED in the status. + * @remarks Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] format The formatter to set. + * @param[in] localized true if the pattern is localized, false otherwise. + * @param[in] pattern The new pattern + * @param[in] pattern_length The length of @a pattern, or -1 if NULL-terminated. + * @param[out] parse_error A pointer to #i18n_uparse_error_s to receive information about errors occurred during parsing, + * or NULL if no parse error information is desired. + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful. + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_unumber_apply_pattern (i18n_unumber_format_h format, i18n_ubool localized, const i18n_uchar *pattern, int32_t pattern_length, i18n_uparse_error_s* parse_error); + +/** + * @brief Gets a locale for which decimal formatting patterns are available. + * @details An #i18n_unumber_format_h in a locale returned by this function will perform the correct formatting and parsing for the locale. + * The results of this call are not valid for rule-based number formats. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] locale_index The index of the desired locale. + * + * @return A locale for which number formatting patterns are available, or 0 if none. + * + * @exception #I18N_ERROR_NONE Successful + */ +const char *i18n_unumber_get_available (int32_t locale_index); + +/** + * @brief Determines how many locales have decimal formatting patterns available. + * @details The results of this call are not valid for rule-based number formats. + * This function is useful for determining the loop ending condition for calls to i18n_unumber_get_available(). + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @return The number of locales for which decimal formatting patterns are available. + * + * @exception #I18N_ERROR_NONE Successful + */ +int32_t i18n_unumber_count_available (void); + +/** + * @brief Gets a numeric attribute associated with an #i18n_unumber_format_h. + * @details An example of a numeric attribute is the number of integer digits a formatter will produce. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] fmt The formatter to query. + * @param[in] attr The attribute to query; one of #I18N_UNUMBER_PARSE_INT_ONLY, #I18N_UNUMBER_GROUPING_USED, + * #I18N_UNUMBER_DECIMAL_ALWAYS_SHOWN, #I18N_UNUMBER_MAX_INTEGER_DIGITS, #I18N_UNUMBER_MIN_INTEGER_DIGITS, + * #I18N_UNUMBER_INTEGER_DIGITS, #I18N_UNUMBER_MAX_FRACTION_DIGITS, #I18N_UNUMBER_MIN_FRACTION_DIGITS, + * #I18N_UNUMBER_FRACTION_DIGITS, #I18N_UNUMBER_MULTIPLIER, #I18N_UNUMBER_GROUPING_SIZE, + * #I18N_UNUMBER_ROUNDING_MODE, #I18N_UNUMBER_FORMAT_WIDTH, #I18N_UNUMBER_PADDING_POSITION, + * #I18N_UNUMBER_SECONDARY_GROUPING_SIZE, #I18N_UNUM_SCALE. + * + * @return The value of @a attr or @c -1 if the given attribute is not supported. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_unumber_get_attribute (const i18n_unumber_format_h fmt, i18n_unumber_format_attribute_e attr); + +/** + * @brief Sets a numeric attribute associated with an #i18n_unumber_format_h. + * @details An example of a numeric attribute is the number of integer digits a formatter will produce. + * If the formatter does not understand the attribute, the call is ignored. Rule-based formatters only understand + * the lenient-parse attribute. The #I18N_UNUMBER_ROUNDING_INCREMENT attribute is not supported. + * @remarks Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] fmt The formatter to set. + * @param[in] attr The attribute to query; one of #I18N_UNUMBER_PARSE_INT_ONLY, #I18N_UNUMBER_GROUPING_USED, + * #I18N_UNUMBER_DECIMAL_ALWAYS_SHOWN, #I18N_UNUMBER_MAX_INTEGER_DIGITS, #I18N_UNUMBER_MIN_INTEGER_DIGITS, + * #I18N_UNUMBER_INTEGER_DIGITS, #I18N_UNUMBER_MAX_FRACTION_DIGITS, #I18N_UNUMBER_MIN_FRACTION_DIGITS, + * #I18N_UNUMBER_FRACTION_DIGITS, #I18N_UNUMBER_MULTIPLIER, #I18N_UNUMBER_GROUPING_SIZE, + * #I18N_UNUMBER_ROUNDING_MODE, #I18N_UNUMBER_FORMAT_WIDTH, #I18N_UNUMBER_PADDING_POSITION, + * #I18N_UNUMBER_SECONDARY_GROUPING_SIZE, #I18N_UNUMBER_SIGNIFICANT_DIGITS_USED, #I18N_UNUMBER_MIN_SIGNIFICANT_DIGITS, + * #I18N_UNUMBER_MAX_SIGNIFICANT_DIGITS, #I18N_UNUMBER_LENIENT_PARSE, #I18N_UNUM_SCALE, + * #I18N_UNUM_FORMAT_FAIL_IF_MORE_THAN_MAX_DIGITS, #I18N_UNUM_PARSE_NO_EXPONENT. + * @param[in] new_value The new value of @a attr. + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful. + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_unumber_set_attribute (i18n_unumber_format_h fmt, i18n_unumber_format_attribute_e attr, int32_t new_value); + +/** + * @brief Gets a numeric attribute associated with an #i18n_unumber_format_h. + * @details An example of a numeric attribute is the number of integer digits a formatter will produce. + * If the formatter does not understand the attribute, -1 is returned. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] fmt The formatter to query. + * @param[in] attr The attribute to query; only #I18N_UNUMBER_ROUNDING_INCREMENT is supported. + * + * @return The value of @a attr. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +double i18n_unumber_get_double_attribute (const i18n_unumber_format_h fmt, i18n_unumber_format_attribute_e attr); + +/** + * @brief Sets a numeric attribute associated with an #i18n_unumber_format_h. + * @details An example of a numeric attribute is the number of integer digits a formatter will produce. + * If the formatter does not understand the attribute, this call is ignored. + * @remarks Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] fmt The formatter to set. + * @param[in] attr The attribute to query; Only #I18N_UNUMBER_ROUNDING_INCREMENT is supported. + * @param[in] new_value The new value of @a attr. + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful. + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_unumber_set_double_attribute (i18n_unumber_format_h fmt, i18n_unumber_format_attribute_e attr, double new_value); + +/** + * @brief Gets a text attribute associated with an #i18n_unumber_format_h. + * @details An example of a text attribute is the suffix for positive numbers. If the formatter does not understand the attribute, + * #I18N_ERROR_NOT_SUPPORTED error code is set. + * Rule-based formatters only understand #I18N_UNUMBER_DEFAULT_RULESET and #I18N_UNUMBER_PUBLIC_RULESETS. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] fmt The formatter to query. + * @param[in] tag The attribute to query; one of #I18N_UNUMBER_POSITIVE_PREFIX, #I18N_UNUMBER_POSITIVE_SUFFIX, + * #I18N_UNUMBER_NEGATIVE_PREFIX, #I18N_UNUMBER_NEGATIVE_SUFFIX, #I18N_UNUMBER_PADDING_CHARACTER, + * #I18N_UNUMBER_CURRENCY_CODE, #I18N_UNUMBER_DEFAULT_RULESET, or #I18N_UNUMBER_PUBLIC_RULESETS. + * @param[out] result A pointer to a buffer to receive the attribute. + * @param[in] result_length The maximum size of @a result. + * + * @return The total buffer size needed; if greater than @a result_length, the output was truncated. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_unumber_get_text_attribute (const i18n_unumber_format_h fmt, i18n_unumber_format_text_attribute_e tag, i18n_uchar *result, int32_t result_length); + +/** + * @brief Sets a text attribute associated with an #i18n_unumber_format_h. + * @details An example of a text attribute is the suffix for positive numbers. Rule-based formatters only understand + * #I18N_UNUMBER_DEFAULT_RULESET. The #I18N_UNUMBER_PUBLIC_RULESETS tag is not supported. + * @remarks Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] fmt The formatter to set. + * @param[in] tag The attribute to set; one of #I18N_UNUMBER_POSITIVE_PREFIX, #I18N_UNUMBER_POSITIVE_SUFFIX, + * #I18N_UNUMBER_NEGATIVE_PREFIX, #I18N_UNUMBER_NEGATIVE_SUFFIX, #I18N_UNUMBER_PADDING_CHARACTER, + * #I18N_UNUMBER_CURRENCY_CODE, #I18N_UNUMBER_DEFAULT_RULESET. + * @param[in] new_value The new value of @a tag. + * @param[in] new_value_length The length of new_value, or -1 if NULL-terminated. + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful. + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_unumber_set_text_attribute (const i18n_unumber_format_h fmt, i18n_unumber_format_text_attribute_e tag, const i18n_uchar *new_value, int32_t new_value_length); + +/** + * @brief Extracts the pattern from an #i18n_unumber_format_h. + * @details The pattern will follow the DecimalFormat pattern syntax. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] fmt The formatter to query. + * @param[in] is_pattern_localized true if the pattern should be localized, false otherwise. + * This is ignored if the formatter is a rule-based formatter. + * @param[out] result A pointer to a buffer to receive the pattern. + * @param[in] result_length The maximum size of @a result. + * + * @return The total buffer size needed; if greater than @a result_length, the output was truncated. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_unumber_to_pattern (const i18n_unumber_format_h fmt, i18n_ubool is_pattern_localized, i18n_uchar *result, int32_t result_length); + +/** + * @brief Sets a symbol associated with an #i18n_unumber_format_h. + * @details An #i18n_unumber_format_h uses symbols to represent the special locale-dependent characters in a number, for example the percent sign. + * This API is not supported for rule-based formatters. + * @remarks Error codes are described in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] fmt The formatter to set. + * @param[in] symbol The #i18n_unumber_format_symbol_e constant for the symbol to set + * @param[in] value The string to set the symbol to + * @param[in] length The length of the input string, or -1 for a zero-terminated string + * + * @return The obtained error code. + * @retval #I18N_ERROR_NONE Successful. + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_unumber_set_symbol (i18n_unumber_format_h fmt, i18n_unumber_format_symbol_e symbol, const i18n_uchar *value, int32_t length); + +/** + * @brief Gets the locale for this number format object. + * @details You can choose between valid and actual locale. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] fmt The formatter to get the locale from. + * @param[in] type Type of the locale we're looking for (valid or actual) + * + * @return The locale name + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +const char *i18n_unumber_get_locale_by_type (const i18n_unumber_format_h fmt, i18n_ulocale_data_locale_type_e type); + + +#ifdef __cplusplus +} +#endif + +/** + * @} + * @} + */ + +#endif /* __UTILS_I18N_UNUMBER_H__*/ diff --git a/src/include/wearable/utils_i18n_usearch.h b/src/include/wearable/utils_i18n_usearch.h new file mode 100755 index 0000000..eb76f89 --- /dev/null +++ b/src/include/wearable/utils_i18n_usearch.h @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +#ifndef __UTILS_I18N_USEARCH_H__ +#define __UTILS_I18N_USEARCH_H__ + +#include + +/** + * @file utils_i18n_usearch.h + * @version 0.1 + * @brief utils_i18n_usearch + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @ingroup CAPI_BASE_UTILS_I18N_MODULE + * @defgroup CAPI_BASE_UTILS_I18N_USEARCH_MODULE Usearch + * @brief The Usearch module provides language-sensitive text searching based on the comparison rules defined in a ucollator data struct. + * + * @section CAPI_BASE_UTILS_I18N_USEARCH_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_BASE_UTILS_I18N_USEARCH_MODULE_OVERVIEW Overview + * @details The Usearch module provides language-sensitive text searching based on the comparison rules defined in a ucollator data struct. + * + * @section CAPI_BASE_UTILS_I18N_USEARCH_MODULE_SAMPLE_CODE_1 Sample Code 1 + * @brief Searches the pattern and gets the matched text. + * @code + char *string = "TIZEN"; + char *keyword = "ZE"; + i18n_uchar target[16] = {0,}; + i18n_uchar pattern[16] = {0,}; + i18n_uchar u_matched[16] = {0,}; + char tmp[1] = {0}; + i18n_usearch_h search = NULL; + int pos = 0; + int matched_text_len = 0; + int i = 0; + i18n_error_code_e error_code; + + i18n_ustring_from_UTF8( target, 16, NULL, string, -1, &error_code ); + i18n_ustring_from_UTF8( pattern, 16, NULL, keyword, -1, &error_code ); + + // creates a search + i18n_usearch_create_new( pattern, -1, target, -1, "en_US", NULL, &search ); + + // gets the first index of the target that matches with the pattern + i18n_usearch_first( search, &pos ); + dlog_print(DLOG_INFO, LOG_TAG, "the first index = %d", pos ); // The first index = 2 + + // gets the matched text + i18n_usearch_get_matched_text( search, u_matched, 16, &matched_text_len ); + for ( i = 0; i < matched_text_len; i++) { + i18n_ustring_copy_au_n( tmp, &u_matched[i], 1 ); + dlog_print(DLOG_INFO, LOG_TAG, "u_matched[%d] = %c", i, tmp[0] ); // u_matched[0] = Z, u_matched[1] = E + } + i18n_usearch_destroy( search ); + * @endcode + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_USEARCH_MODULE + * @{ + */ + +/** + * @brief Creates an #i18n_usearch_h using the argument locale language rule set. + * @details A collator will be created in the process, which will be owned by + * this search and will be deleted in i18n_usearch_destroy(). + * @remarks Must release @a search_iter using i18n_usearch_destroy(). + * @since_tizen 2.3.1 + * + * @param[in] pattern The pattern for matching + * @param[in] pattern_len The length of the pattern, otherwise @c -1 for NULL-termination + * @param[in] text The text string + * @param[in] text_len The length of the text string, otherwise @c -1 for NULL-termination + * @param[in] locale The name of the locale for the rules to be used + * @param[in] break_iter An #i18n_ubreak_iterator_h that will be used to restrict the points at which matches are detected. If a match is found,\n + * but the match's start or end index is not a boundary as determined by the #i18n_ubreak_iterator_h, + * the match will be rejected and another will be searched for. If this parameter is @c NULL,\n + * no break detection is attempted. + * @param[out] search_iter The #i18n_usearch_h, otherwise @c NULL if there is an error + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_usearch_create_new ( const i18n_uchar *pattern, int32_t pattern_len, const i18n_uchar *text, + int32_t text_len, const char *locale, i18n_ubreak_iterator_h break_iter, i18n_usearch_h *search_iter); + +/** + * @brief Destroys and cleans up the i18n_usearch_h. + * @details If a collator is created in i18n_usearch_create_new(), it will be destroyed here. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] search_iter The i18n_usearch_h to clean up + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_usearch_destroy ( i18n_usearch_h search_iter ); + +/** + * @brief Returns the text that matches by the most recent call to i18n_usearch_first(), or so on. + * @details If the iterator is not pointing at a valid match (e.g. just after + * construction or after #I18N_USEARCH_DONE has been returned, it returns + * an empty string. If the result is not large enough to store the matched text, + * the result will be filled with the partial text and an #I18N_ERROR_BUFFER_OVERFLOW + * will be returned in status. The result will be NULL-terminated whenever + * possible. If the buffer fits the matched text exactly, a NULL-termination + * is not possible. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] search_iter The search iterator handle + * @param[out] result i18n_uchar The buffer to store the matched string + * @param[in] result_capacity The length of the result buffer + * @param[out] len_matched_text The exact length of the matched text, not counting the NULL-termination + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @retval #I18N_ERROR_BUFFER_OVERFLOW A result would not fit in the supplied buffer + */ +int i18n_usearch_get_matched_text ( const i18n_usearch_h search_iter, i18n_uchar *result, int32_t result_capacity, int32_t *len_matched_text ); + +/** + * @brief Gets the collator used for the language rules. + * @details Deleting the returned i18n_ucollator_h before calling + * i18n_usearch_destroy() would cause the string search to fail. + * i18n_usearch_destroy() will delete the collator if this search owns it. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] search_iter The search iterator handle + * @param[out] collator The collator + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_usearch_get_collator ( const i18n_usearch_h search_iter, i18n_ucollator_h *collator ); + +/** + * @brief Returns the first index at which the string text matches the search pattern. + * @details The iterator is adjusted so that its current index + * is the match position if one is found. + * If a match is not found, #I18N_USEARCH_DONE will be returned and + * the iterator will be adjusted to the index #I18N_USEARCH_DONE. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] search_iter The search iterator handle + * @param[out] index_first The character index of the first match, + * otherwise #I18N_USEARCH_DONE if there are no matches. + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_usearch_first ( i18n_usearch_h search_iter, int32_t *index_first ); + +#ifdef __cplusplus +} +#endif + +/** + * @} + * @} + */ + +#endif /* __UTILS_I18N_USEARCH_H__*/ diff --git a/src/include/wearable/utils_i18n_uset.h b/src/include/wearable/utils_i18n_uset.h new file mode 100755 index 0000000..6cf528e --- /dev/null +++ b/src/include/wearable/utils_i18n_uset.h @@ -0,0 +1,1175 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + * + * Copyright (C) 1999-2013, International Business Machines Corporation + * and others. All Rights Reserved. + */ + +#ifndef __UTILS_I18N_USET_PRODUCT_H__ +#define __UTILS_I18N_USET_PRODUCT_H__ + +#include + +/** + * @file utils_i18n_uset.h + * @version 0.1 + * @brief utils_i18n_uset + */ + + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @ingroup CAPI_BASE_UTILS_I18N_MODULE + * @defgroup CAPI_BASE_UTILS_I18N_USET_MODULE Uset + * @brief Uset module allows to specify a subset of character used in strings. + * + * @section CAPI_BASE_UTILS_I18N_USET_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_BASE_UTILS_I18N_USET_MODULE_OVERVIEW Overview + * @details Uset module allows to specify a subset of character used in strings. + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_USET_MODULE + * @{ + */ + +/** + * @brief Creates an empty #i18n_uset_h object. + * @details Equivalent to i18n_uset_create(1, 0). + * + * @since_tizen 2.3.1 + * @param[out] set A pointer to the newly created #i18n_uset_h. The caller must call i18n_uset_destroy() on + * it when done. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_uset_destroy() + */ +int i18n_uset_create_empty (i18n_uset_h *set); + +/** + * @brief Creates an #i18n_uset_h object that contains the range of characters + * start..end, inclusive. + * @details If start > end + * then an empty set is created (same as using i18n_uset_empty_create()). + * + * @since_tizen 2.3.1 + * @param[in] start First character of the range, inclusive + * @param[in] end Last character of the range, inclusive + * @param[out] set A pointer to the newly created #i18n_uset_h object. The caller must call i18n_uset_destroy() on + * it when done. + * * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_uset_destroy() + */ +int i18n_uset_create (i18n_uchar32 start, i18n_uchar32 end, i18n_uset_h *set); + +/** + * @brief Creates a set based on a given pattern. + * @details See the UnicodeSet class description for the syntax + * of the pattern language. + * + * @since_tizen 2.3.1 + * @param[in] pattern A string specifying what characters are in the set + * @param[in] pattern_length The length of the pattern, >= 0, or -1 if NULL-terminated. + * @param[out] set A pointer to the newly created #i18n_uset_h object. The caller must call i18n_uset_destroy() on + * it when done. + * * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_uset_destroy() + */ +int i18n_uset_create_pattern (const i18n_uchar *pattern, int32_t pattern_length, i18n_uset_h *set); + +/** + * @brief Creates a set based on a given pattern. + * @details See the UnicodeSet class description for the syntax of the pattern language. + * + * @since_tizen 2.3.1 + * @param[in] pattern A string specifying what characters are in the set + * @param[in] pattern_length The length of the pattern, >= 0, or -1 if NULL-terminated + * @param[in] options Bitmask for options to apply to the pattern. + * Valid options are #I18N_USET_IGNORE_SPACE and #I18N_USET_CASE_INSENSITIVE. + * @param[out] set A pointer to the newly created #i18n_uset_h object. The caller must call i18n_uset_destroy() on + * it when done. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_uset_destroy() + */ +int i18n_uset_create_pattern_options (const i18n_uchar *pattern, int32_t pattern_length, uint32_t options, i18n_uset_h *set); + +/** + * @brief Disposes of the storage used by a #i18n_uset_h object. + * @details This function should be called exactly once for objects returned by i18n_uset_create(). + * @since_tizen 2.3.1 + * + * @param[in] set The object to dispose of + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_uset_destroy (i18n_uset_h set); + +/** + * @brief Returns a copy of this object. + * @details If this set is frozen, then the clone will be frozen as well. + * Uses i18n_uset_clone_as_thawed() for a mutable clone of a frozen set. + * + * @since_tizen 2.3.1 + * @param[in] set The original set. Must not be @c NULL. + * @param[out] set_clone The newly allocated copy of the set + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_uset_clone_as_thawed() + */ +int i18n_uset_clone (const i18n_uset_h set, i18n_uset_h *set_clone); + +/** + * @brief Determines whether the set has been frozen (made immutable) or not. + * @details See the ICU4J Freezable interface for details. + * + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * + * @since_tizen 2.3.1 + * @param[in] set The set. Must not be @c NULL. + * @return true/false for whether the set has been frozen + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_uset_freeze() + * @see i18n_uset_clone_as_thawed() + */ +i18n_ubool i18n_uset_is_frozen (const i18n_uset_h set); + +/** + * @brief Freezes the set (make it immutable). + * @details Once frozen, it cannot be unfrozen and is therefore thread-safe + * until it is deleted. + * See the ICU4J Freezable interface for details. + * Freezing the set may also make some operations faster, for example + * i18n_uset_contains() and i18n_uset_span(). + * A frozen set will not be modified. (It remains frozen.) + * + * @since_tizen 2.3.1 + * @param[in] set The set. Must not be @c NULL. + * @return the same set, now frozen + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_uset_is_frozen() + * @see i18n_uset_clone_as_thawed() + */ +int i18n_uset_freeze (i18n_uset_h set); + +/** + * @brief Clones the set and make the clone mutable. + * @details See the ICU4J Freezable interface for details. + * @since_tizen 2.3.1 + * + * @param[in] set The set. Must not be @c NULL. + * @param[out] set_copy The mutable clone + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_uset_freeze() + * @see i18n_uset_is_frozen() + * @see i18n_uset_clone() + */ +int i18n_uset_clone_as_thawed (const i18n_uset_h set, i18n_uset_h *set_copy); + +/** + * @brief Causes the #i18n_uset_h object to represent the range start - end. + * @details If start > end then this #i18n_uset_h is set to an empty range. + * A frozen set will not be modified. + * + * @since_tizen 2.3.1 + * @param[in] set The object to set to the given range. Must not be @c NULL. + * @param[in] start First character in the set, inclusive + * @param[in] end Last character in the set, inclusive + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_uset_set (i18n_uset_h set, i18n_uchar32 start, i18n_uchar32 end); + +/** + * @brief Modifies the set to represent the set specified by the given + * pattern. + * @details See the UnicodeSet class description for the syntax of + * the pattern language. See also the User Guide chapter about UnicodeSet. + * Empties the set passed before applying the pattern. + * A frozen set will not be modified. + * + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and in #i18n_error_code_e description. + * + * @since_tizen 2.3.1 + * @param[in] set The set to which the pattern is to be applied. Must not be @c NULL. + * @param[in] pattern A pointer to #i18n_uchar string specifying what characters are in the set. + * The character at pattern[0] must be a '['. + * @param[in] pattern_length The length of the #i18n_uchar string, >= 0, or -1 if NULL terminated. + * @param[in] options A bitmask for options to apply to the pattern. + * Valid options are #I18N_USET_IGNORE_SPACE and #I18N_USET_CASE_INSENSITIVE. + * @return Upon successful parse, the value is either + * the index of the character after the closing ']' + * of the parsed pattern. + * If the status code indicates failure, then the return value + * is the index of the error in the source. + * If @a set is NULL, 0 is returned. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_uset_apply_pattern (i18n_uset_h set, const i18n_uchar *pattern, int32_t pattern_length, uint32_t options); + +/** + * @brief Modifies the set to contain those code points which have the given value + * for the given binary or enumerated property, as returned by + * i18n_uchar_get_int_property_value(). + * @details Prior contents of this set are lost. + * A frozen set will not be modified. + * + * @since_tizen 2.3.1 + * @param[in] set The object to contain the code points defined by the property. Must not be @c NULL. + * @param[in] prop A property in the range #I18N_UCHAR_INT_START..#I18N_UCHAR_INT_LIMIT-1 + * or #I18N_UCHAR_MASK_START..#I18N_UCHAR_MASK_LIMIT-1. + * @param[in] value A value in the range i18n_uchar_get_int_property_min_value(prop).. + * i18n_uchar_get_int_property_max_value(prop), with one exception. If prop is + * #I18N_UCHAR_GENERAL_CATEGORY_MASK, then value should not be a #i18n_uchar_category_e, but + * rather a mask value produced by I18N_U_GET_GC_MASK(). This allows grouped + * categories such as [:L:] to be represented. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_uset_apply_int_property_value (i18n_uset_h set, i18n_uchar_uproperty_e prop, int32_t value); + +/** + * @brief Modifies the set to contain those code points which have the + * given value for the given property. + * @details Prior contents of this set are lost. A frozen set will not be modified. + * @since_tizen 2.3.1 + * + * @param[in] set The object to contain the code points defined by the given + * property and value alias. Must not be @c NULL. + * @param[in] prop A string specifying a property alias, either short or long. + * The name is matched loosely. See PropertyAliases.txt for names and a + * description of loose matching. If the value string is empty, then this + * string is interpreted as either a General_Category value alias, a Script + * value alias, a binary property alias, or a special ID. Special IDs are + * matched loosely and correspond to the following sets: + * + * "ANY" = [\\u0000-\\U0010FFFF], + * "ASCII" = [\\u0000-\\u007F], + * "Assigned" = [:^Cn:]. + * + * @param[in] prop_length The length of the @a prop, >= 0, or @c -1 if @c NULL. + * @param[in] value A string specifying a value alias, either short or long. + * The name is matched loosely. See PropertyValueAliases.txt for names + * and a description of loose matching. In addition to aliases listed, + * numeric values and canonical combining classes may be expressed + * numerically, e.g., ("nv", "0.5") or ("ccc", "220"). The value string + * may also be empty. + * @param[in] value_length The length of the value, >= 0, or -1 if NULL. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_uset_apply_property_alias (i18n_uset_h set, const i18n_uchar *prop, int32_t prop_length, const i18n_uchar *value, int32_t value_length); + +/** + * @brief Return true if the given position, in the given pattern, appears + * to be the start of a UnicodeSet pattern. + * @since_tizen 2.3.1 + * + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * + * @param[in] pattern A string specifying the pattern. + * @param[in] pattern_length The length of the pattern, >= 0, or @c -1 if @c NULL. + * @param[in] pos The given position, >= 0. + * + * @return @c true if the given position, in the given pattern, appears to be the start of a UnicodeSet pattern. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_ubool i18n_uset_resembles_pattern (const i18n_uchar *pattern, int32_t pattern_length, int32_t pos); + +/** + * @brief Returns a string representation of the given @a set. + * @details If the result of calling this function is passed to an i18n_uset_pattern_create(), + * it will produce another set that is equal to this one. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] set The set. Must not be @c NULL. + * @param[in,out] result The string to receive the rules, may be @c NULL. + * @param[in] result_capacity The capacity of @a result, >= 0, may be @c 0 if result is @c NULL. + * @param[in] escape_unprintable If true then convert unprintable character to their hex escape representations, + * \\uxxxx or \\Uxxxxxxxx. Unprintable characters are those other than U+000A, U+0020..U+007E. + * + * @return Length of string, >= 0, possibly larger than @a result_capacity. If @a set is NULL, 0 is returned. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_uset_pattern_create() + */ +int32_t i18n_uset_to_pattern (const i18n_uset_h set, i18n_uchar *result, int32_t result_capacity, i18n_ubool escape_unprintable); + +/** + * @brief Adds the given character to the given #i18n_uset_h. + * @details After this call, i18n_uset_contains(set, character) will return true. + * A frozen set will not be modified. + * @since_tizen 2.3.1 + * + * @param[in] set The object to which to add the @a character. Must not be @c NULL. + * @param[in] character The character to add. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_uset_contains() + */ +int i18n_uset_add (i18n_uset_h set, i18n_uchar32 character); + + +/** + * @brief Adds all of the elements in the specified set to this set if + * they are not already present. + * @details This operation effectively modifies this set so that its value is the union of the two + * sets. The behavior of this operation is unspecified if the specified + * collection is modified while the operation is in progress. + * A frozen set will not be modified. + * + * @since_tizen 2.3.1 + * @param[in] set The object to which to add the set. Must not be @c NULL. + * @param[in] additional_set The source set whose elements are to be added to this set. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_uset_add_all (i18n_uset_h set, const i18n_uset_h additional_set); + +/** + * @brief Adds the given range of characters to the given #i18n_uset_h. After this call, + * i18n_uset_contains(set, start, end) will return true. + * A frozen set will not be modified. + * + * @since_tizen 2.3.1 + * @param[in] set The object to which to add the character. Must not be @c NULL. + * @param[in] start The first character of the range to add, inclusive + * @param[in] end The last character of the range to add, inclusive + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_uset_contains() + */ +int i18n_uset_add_range (i18n_uset_h set, i18n_uchar32 start, i18n_uchar32 end); + +/** + * @brief Adds the given string to the given #i18n_uset_h. + * @details After this call, i18n_uset_contains_string(set, str, str_len) will return true. + * A frozen set will not be modified. + * + * @since_tizen 2.3.1 + * @param[in] set The object to which to add the character. Must not be @c NULL. + * @param[in] str The string to add. + * @param[in] str_len The length of the string, >= 0, or -1 if NULL terminated. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_uset_contains_string() + */ +int i18n_uset_add_string (i18n_uset_h set, const i18n_uchar *str, int32_t str_len); + +/** + * @brief Adds each of the characters in this string to the set. Thus "ch" => {"c", "h"} + * @details If this set already any particular character, it has no effect on that character. + * A frozen set will not be modified. + * + * @since_tizen 2.3.1 + * @param[in] set The object to which to add the character. Must not be @c NULL. + * @param[in] str The source string. + * @param[in] str_len The length of the string, >= 0, or -1 if NULL terminated. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_uset_add_all_code_points (i18n_uset_h set, const i18n_uchar *str, int32_t str_len); + +/** + * @brief Removes the given @a character from the given #i18n_uset_h. + * @details After this call, i18n_uset_contains(set, character) will return @c false. + * A frozen set will not be modified. + * @since_tizen 2.3.1 + * + * @param[in] set the object from which to remove the @a character. Must not be @c NULL. + * @param[in] character the character to remove + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_uset_contains() + */ +int i18n_uset_remove (i18n_uset_h set, i18n_uchar32 character); + +/** + * @brief Removes the given range of characters from the given #i18n_uset_h. + * @details After this call, i18n_uset_contains(set, start, end) will return false. + * A frozen set will not be modified. + * + * @since_tizen 2.3.1 + * @param[in] set The object to which to add the character. Must not be @c NULL. + * @param[in] start The first character of the range to remove, inclusive + * @param[in] end The last character of the range to remove, inclusive + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_uset_contains() + */ +int i18n_uset_remove_range (i18n_uset_h set, i18n_uchar32 start, i18n_uchar32 end); + +/** + * @brief Removes the given string to the given #i18n_uset_h. + * @details After this call, i18n_uset_contains_string(set, str, str_len) will return false. + * A frozen set will not be modified. + * + * @since_tizen 2.3.1 + * @param[in] set The object to which to add the character. Must not be @c NULL. + * @param[in] str The string to remove. + * @param[in] str_len The length of the string, >= 0, or -1 if NULL terminated. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_uset_contains_string() + */ +int i18n_uset_remove_string (i18n_uset_h set, const i18n_uchar *str, int32_t str_len); + +/** + * @brief Removes from this set all of its elements that are contained in the specified set. + * @details This operation effectively modifies this set so that its value is the asymmetric set difference of + * the two sets. + * A frozen set will not be modified. + * + * @since_tizen 2.3.1 + * @param[in] set The object from which the elements are to be removed. Must not be @c NULL. + * @param[in] remove_set The object that defines which elements will be + * removed from this set. Must not be @c NULL. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_uset_remove_all (i18n_uset_h set, const i18n_uset_h remove_set); + +/** + * @brief Retains only the elements in this set that are contained in the specified range. + * @details If start > end then an empty range is retained, leaving the set empty. This is equivalent to + * a boolean logic AND, or a set INTERSECTION. + * A frozen set will not be modified. + * + * @since_tizen 2.3.1 + * @param[in] set The object for which to retain only the specified range. Must not be @c NULL. + * @param[in] start First character, inclusive, of range to be retained + * to this set. + * @param[in] end Last character, inclusive, of range to be retained + * to this set. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_uset_retain (i18n_uset_h set, i18n_uchar32 start, i18n_uchar32 end); + +/** + * @brief Retains only the elements in this set that are contained in the + * specified set. + * @details In other words, removes from this set all of + * its elements that are not contained in the specified set. This + * operation effectively modifies this set so that its value is + * the intersection of the two sets. + * A frozen set will not be modified. + * + * @since_tizen 2.3.1 + * @param[in] set The object on which to perform the retain. Must not be @c NULL. + * @param[in] retain Set that defines which elements this set will retain. Must not be @c NULL. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_uset_retain_all (i18n_uset_h set, const i18n_uset_h retain); + +/** + * @brief Reallocates this objects internal structures to take up the least + * possible space, without changing this object's value. + * + * @details A frozen set will not be modified. + * @since_tizen 2.3.1 + * @param[in] set The object on which to perfrom the compact. Must not be @c NULL. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_uset_compact (i18n_uset_h set); + +/** + * @brief Inverts this set. This operation modifies this set so that + * its value is its complement. + * @details This operation does not affect + * the multicharacter strings, if any. + * A frozen set will not be modified. + * + * @since_tizen 2.3.1 + * @param[in] set The set. Must not be @c NULL. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_uset_complement (i18n_uset_h set); + +/** + * @brief Complements in this set all elements contained in the specified set. + * @details Any character in the other set will be removed if it is + * in this set, or will be added if it is not in this set. + * A frozen set will not be modified. + * + * @since_tizen 2.3.1 + * @param[in] set The set with which to complement. Must not be @c NULL. + * @param[in] complement Set that defines which elements will be xor'ed + * from this set. Must not be @c NULL. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_uset_complement_all (i18n_uset_h set, const i18n_uset_h complement); + +/** + * @brief Removes all of the elements from this set. + * @details This set will be empty after this call returns. + * A frozen set will not be modified. + * + * @since_tizen 2.3.1 + * @param[in] set The set. Must not be @c NULL. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_uset_clear (i18n_uset_h set); + +/** + * @brief Closes this set over the given attribute. + * @details For the attribute + * #I18N_USET_CASE_INSENSITIVE, the result is to modify this set so that: + * + * 1. For each character or string 'a' in this set, all strings or + * characters 'b' such that foldCase(a) == foldCase(b) are added + * to this set. + * + * 2. For each string 'e' in the resulting set, if e != + * foldCase(e), 'e' will be removed. + * + * Example: [aq\\u00DF{Bc}{bC}{Fi}] => [aAqQ\\u00DF\\uFB01{ss}{bc}{fi}] + * + * (Here foldCase(x) refers to the operation i18n_ustring_fold_case(), and a + * == b denotes that the contents are the same, not pointer + * comparison.) + * + * A frozen set will not be modified. + * + * @since_tizen 2.3.1 + * @param[in] set The set. Must not be @c NULL. + * @param[in] attributes Bitmask for attributes to close over. + * Currently only the #I18N_USET_CASE_INSENSITIVE bit is supported. Any undefined bits + * are ignored. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ustring_fold_case() + */ +int i18n_uset_destroy_over (i18n_uset_h set, int32_t attributes); + +/** + * @brief Removes all strings from this set. + * + * @since_tizen 2.3.1 + * @param[in] set The set. Must not be @c NULL. + * + * @return Error code. Error codes not listed below are described in #i18n_error_code_e + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int i18n_uset_remove_all_strings (i18n_uset_h set); + +/** + * @brief Returns true if the given #i18n_uset_h contains no characters and no + * strings. + * + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * + * @since_tizen 2.3.1 + * @param[in] set The set. Must not be @c NULL. + * @return true if set is empty + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_ubool i18n_uset_is_empty (const i18n_uset_h set); + +/** + * @brief Returns @c true if the given #i18n_uset_h contains the given @a character. + * @details This function works faster with a frozen set. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] set the set. Must not be @c NULL. + * @param[in] character the codepoint to check for within the @a set + * + * @return @c true if @a set contains the given @a character + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_ubool i18n_uset_contains (const i18n_uset_h set, i18n_uchar32 character); + +/** + * @brief Returns true if the given #i18n_uset_h contains all characters c + * where start <= c && c <= end. + * + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * + * @since_tizen 2.3.1 + * @param[in] set The set. Must not be @c NULL. + * @param[in] start The first character of the range to test, inclusive + * @param[in] end The last character of the range to test, inclusive + * @return true if set contains the range + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_ubool i18n_uset_contains_range (const i18n_uset_h set, i18n_uchar32 start, i18n_uchar32 end); + +/** + * @brief Returns true if the given #i18n_uset_h contains the given string. + * @since_tizen 2.3.1 + * + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * + * @param[in] set The set. Must not be @c NULL. + * @param[in] str The string. + * @param[in] str_len The length of the string, >= 0, or -1 if NULL terminated + * @return true if set contains str + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_ubool i18n_uset_contains_string (const i18n_uset_h set, const i18n_uchar *str, int32_t str_len); + +/** + * @brief Returns the index of the given @a character within this @a set, where + * the @a set is ordered by ascending code point. + * @details If the @a character is not in this @a set, return @c -1. + * The inverse of this function is i18n_uset_char_at(). + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] set the set. Must not be @c NULL. + * @param[in] character the character to obtain the index for + * + * @return An index from 0..size()-1, or @c -1 + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_uset_index_of (const i18n_uset_h set, i18n_uchar32 character); + +/** + * @brief Returns the character at the given index within this set, where + * the set is ordered by ascending code point. + * @details If the index is out of range, return (i18n_uchar32)-1. The inverse of this function is + * i18n_uset_index_of(). + * + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * + * @since_tizen 2.3.1 + * @param[in] set The set. Must not be @c NULL. + * @param[in] char_index An index from 0..size()-1 to obtain the char for + * @return The character at the given index, or (i18n_uchar32)-1. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_uchar32 i18n_uset_char_at (const i18n_uset_h set, int32_t char_index); + +/** + * @brief Returns the number of characters and strings contained in the given #i18n_uset_h. + * + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * + * @since_tizen 2.3.1 + * @param[in] set The set. Must not be @c NULL. + * @return A non-negative integer counting the characters and strings + * contained in set. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_uset_size (const i18n_uset_h set); + +/** + * @brief Returns the number of items in this set. + * @details An item is either a range of characters or a single multicharacter string. + * + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * + * @since_tizen 2.3.1 + * @param[in] set The set. Must not be @c NULL. + * @return A non-negative integer counting the character ranges + * and/or strings contained in set. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_uset_get_item_count (const i18n_uset_h set); + +/** + * @brief Returns an item of this set. + * @details An item is either a range of characters or a single multicharacter string. + * + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * + * @since_tizen 2.3.1 + * @param[in] set The set. Must not be @c NULL. + * @param[in] item_index A non-negative integer in the range [0; i18n_uset_get_item_count(set)-1]. + * @param[in] start Pointer to variable to receive first character + * in range, inclusive + * @param[in] end Pointer to variable to receive last character in range, + * inclusive + * @param[out] str Buffer to receive the string, may be NULL + * @param[in] str_capacity Capacity of @a str, or 0 if str is NULL + * @return The length of the string (>= 2), or 0 if the item is a + * range, in which case it is the range *start..*end, or -1 if + * item_index is out of range + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_uset_get_item (const i18n_uset_h set, int32_t item_index, i18n_uchar32 *start, i18n_uchar32 *end, i18n_uchar *str, int32_t str_capacity); + +/** + * @brief Returns true if set1 contains all the characters and strings of set2. It answers the question, 'Is set1 a superset of set2?' + * + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * + * @since_tizen 2.3.1 + * @param[in] set1 Set to be checked for containment. Must not be @c NULL. + * @param[in] set2 Set to be checked for containment. Must not be @c NULL. + * @return true if the test condition is met + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_ubool i18n_uset_contains_all (const i18n_uset_h set1, const i18n_uset_h set2); + +/** + * @brief Returns true if this set contains all the characters of the given string. + * @details This is does not check containment of grapheme + * clusters, like i18n_uset_contains_string(). + * + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * + * @since_tizen 2.3.1 + * @param[in] set Set of characters to be checked for containment. Must not be @c NULL. + * @param[in] str String containing codepoints to be checked for containment + * @param[in] str_len The length of the string, >= 0, or -1 if NULL terminated. + * @return true if the test condition is met. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_ubool i18n_uset_contains_all_code_points (const i18n_uset_h set, const i18n_uchar *str, int32_t str_len); + +/** + * @brief Returns true if set1 contains none of the characters and strings of set2. + * @details It answers the question, 'Is set1 a disjoint set of set2?' + * + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * + * @since_tizen 2.3.1 + * @param[in] set1 Set to be checked for containment. Must not be @c NULL. + * @param[in] set2 Set to be checked for containment. Must not be @c NULL. + * @return true if the test condition is met + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_ubool i18n_uset_contains_none (const i18n_uset_h set1, const i18n_uset_h set2); + +/** + * @brief Returns true if set1 contains some of the characters and strings of set2. + * @details It answers the question, 'Does set1 and set2 have an intersection?' + * + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * + * @since_tizen 2.3.1 + * @param[in] set1 Set to be checked for containment. Must not be @c NULL. + * @param[in] set2 Set to be checked for containment. Must not be @c NULL. + * @return true if the test condition is met + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_ubool i18n_uset_contains_some (const i18n_uset_h set1, const i18n_uset_h set2); + +/** + * @brief Returns the length of the initial substring of the input string which + * consists only of characters and strings that are contained in this set + * (#I18N_USET_SPAN_CONTAINED, #I18N_USET_SPAN_SIMPLE), + * or only of characters and strings that are not contained + * in this set (#I18N_USET_SPAN_NOT_CONTAINED). + * @details See #i18n_uset_span_condition_e for details. + * Similar to the strspn() C library function. + * Unpaired surrogates are treated according to contains() of their surrogate code points. + * This function works faster with a frozen set and with a non-negative string length argument. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] set the set. Must not be @c NULL. + * @param[in] str start of the input string. + * @param[in] length length of the @a string; >= 0, can be @c -1 for NULL-terminated + * @param[in] span_condition specifies the containment condition + * + * @return The length of the initial substring according to the @a span_condition; + * @c 0 if the start of the string does not fit the @a span_condition + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see #i18n_uset_span_condition_e + */ +int32_t i18n_uset_span (const i18n_uset_h set, const i18n_uchar *str, int32_t length, i18n_uset_span_condition_e span_condition); + +/** + * @brief Returns the start of the trailing substring of the input string which + * consists only of characters and strings that are contained in this set + * (#I18N_USET_SPAN_CONTAINED, #I18N_USET_SPAN_SIMPLE), + * or only of characters and strings that are not contained + * in this set (#I18N_USET_SPAN_NOT_CONTAINED). + * @details See #i18n_uset_span_condition_e for details. + * Unpaired surrogates are treated according to contains() of their surrogate code points. + * This function works faster with a frozen set and with a non-negative string length argument. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] set the set. Must not be @c NULL. + * @param[in] str start of the input string + * @param[in] length length of the @ string; >= 0, can be @c -1 for NULL-terminated + * @param[in] span_condition specifies the containment condition + * + * @return the start of the trailing substring according to the @a span_condition; + * the string length if the end of the string does not fit the @a span_condition + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see #i18n_uset_span_condition_e + */ +int32_t i18n_uset_span_back (const i18n_uset_h set, const i18n_uchar *str, int32_t length, i18n_uset_span_condition_e span_condition); + +/** + * @brief Returns the length of the initial substring of the input string which + * consists only of characters and strings that are contained in this set + * (#I18N_USET_SPAN_CONTAINED, #I18N_USET_SPAN_SIMPLE), + * or only of characters and strings that are not contained + * in this set (#I18N_USET_SPAN_NOT_CONTAINED). + * @details See #i18n_uset_span_condition_e for details. + * Similar to the strspn() C library function. + * Malformed byte sequences are treated according to contains(0xfffd). + * This function works faster with a frozen set and with a non-negative string length argument. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] set the set. Must not be @c NULL. + * @param[in] str start of the string (UTF-8) + * @param[in] length length of the string; >= 0, can be @c -1 for NULL-terminated + * @param[in] span_condition specifies the containment condition + * + * @return the length of the initial substring according to the @a span_condition; + * @c 0 if the start of the string does not fit the @a span_condition + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see #i18n_uset_span_condition_e + */ +int32_t i18n_uset_span_utf8 (const i18n_uset_h set, const char *str, int32_t length, i18n_uset_span_condition_e span_condition); + +/** + * @brief Returns the start of the trailing substring of the input string which + * consists only of characters and strings that are contained in this set + * (#I18N_USET_SPAN_CONTAINED, #I18N_USET_SPAN_SIMPLE), + * or only of characters and strings that are not contained + * in this set (#I18N_USET_SPAN_NOT_CONTAINED). + * @details See #i18n_uset_span_condition_e for details. + * Malformed byte sequences are treated according to contains(0xfffd). + * This function works faster with a frozen set and with a non-negative string length argument. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] set the set. Must not be @c NULL. + * @param[in] str start of the string (UTF-8) + * @param[in] length length of the string; >= 0, can be @c -1 for NULL-terminated + * @param[in] span_condition specifies the containment condition + * + * @return the start of the trailing substring according to the @a span_condition; + * the string length if the end of the string does not fit the @a span_condition + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see #i18n_uset_span_condition_e + */ +int32_t i18n_uset_span_back_utf8 (const i18n_uset_h set, const char *str, int32_t length, i18n_uset_span_condition_e span_condition); + +/** + * @brief Returns true if set1 contains all of the characters and strings + * of set2, and vice versa. It answers the question, 'Is set1 equal to set2?' + * + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * + * @since_tizen 2.3.1 + * @param[in] set1 Set to be checked for containment. Must not be @c NULL. + * @param[in] set2 Set to be checked for containment. Must not be @c NULL. + * @return true if the test condition is met + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_ubool i18n_uset_equals (const i18n_uset_h set1, const i18n_uset_h set2); + +/********************************************************************* + * Serialized set API + *********************************************************************/ + +/** + * @brief Serializes this @a set into an array of 16-bit integers. + * @details Serialization (currently) only records the characters in the set; + * multicharacter strings are ignored. + * + * The array has following format (each line is one 16-bit integer): + * + * length = (n+2*m) | (m!=0?0x8000:0) + * bmpLength = n; + * present if m!=0 + * bmp[0] + * bmp[1] + * ... + * bmp[n-1] + * supp-high[0] + * supp-low[0] + * supp-high[1] + * supp-low[1] + * ... + * supp-high[m-1] + * supp-low[m-1] + * + * The array starts with a header. After the header are n bmp + * code points, then m supplementary code points. Either n or m + * or both may be zero. n+2*m is always <= 0x7FFF. + * + * If there are no supplementary characters (if m==0) then the + * header is one 16-bit integer, 'length', with value n. + * + * If there are supplementary characters (if m!=0) then the header + * is two 16-bit integers. The first, 'length', has value + * (n+2*m)|0x8000. The second, 'bmpLength', has value n. + * + * After the header the code points are stored in ascending order. + * Supplementary code points are stored as most significant 16 + * bits followed by least significant 16 bits. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and in #i18n_error_code_e description. + * @since_tizen 2.3.1 + * + * @param[in] set the set. Must not be @c NULL. + * @param[out] dest pointer to buffer of @a dest_capacity 16-bit integers + * May be NULL only if @a dest_capacity is zero. + * @param[in] dest_capacity size of @a dest, or zero + * Must not be negative. + * + * @return the total length of the serialized format, including + * the header, that is, n+2*m+(m != 0 ? 2 : 1), + * or @c 0 on error other than #I18N_ERROR_BUFFER_OVERFLOW. + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @exception #I18N_ERROR_INDEX_OUTOFBOUNDS If n+2*m > 0x7FFF + * @exception #I18N_ERROR_BUFFER_OVERFLOW If n+2*m+(m != 0 ? 2 : 1) > dest_capacity. + */ +int32_t i18n_uset_serialize (const i18n_uset_h set, uint16_t *dest, int32_t dest_capacity); + +/** + * @brief Given a serialized array, fill in the given serialized set object. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] src pointer to start of array. Must not be @c NULL. + * @param[in] src_length length of @a src array, >= 0. + * @param[out] fill_set the serialized set to be filled + * + * @return @c true if the given array is valid, otherwise @c false + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see #i18n_userialized_set_s + */ +i18n_ubool i18n_uset_get_serialized_set (const uint16_t *src, int32_t src_length, i18n_userialized_set_s* fill_set); + +/** + * @brief Sets the #i18n_userialized_set_s to contain the given @a character (and nothing else). + * @since_tizen 2.3.1 + * + * @param[in] character the code point to set + * @param[out] fill_set the serialized set to be filled + * + * @return Error code. + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see #i18n_userialized_set_s + */ +int i18n_uset_set_serialized_to_one (i18n_uchar32 character, i18n_userialized_set_s* fill_set); + +/** + * @brief Returns @c true if the given #i18n_userialized_set_s contains the given @a character. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen 2.3.1 + * + * @param[in] set the serialized set. Must not be @c NULL. + * @param[in] character the code point to check for within the @a set + * + * @return @c true if @a set contains @a character + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see #i18n_userialized_set_s + */ +i18n_ubool i18n_uset_serialized_contains (const i18n_userialized_set_s* set, i18n_uchar32 character); + +/** + * @brief Returns the number of disjoint ranges of characters contained in + * the given serialized set. + * @details Ignores any strings contained in the set. + * + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * + * @since_tizen 2.3.1 + * @param[in] set The serialized set. Must not be @c NULL. + * @return A non-negative integer counting the character ranges contained in set + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see #i18n_userialized_set_s + */ +int32_t i18n_uset_get_serialized_range_count (const i18n_userialized_set_s* set); + +/** + * @brief Returns a range of characters contained in the given serialized set. + * + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * + * @since_tizen 2.3.1 + * @param[in] set The serialized set. Must not be @c NULL. + * @param[in] range_index A non-negative integer in the range 0.. + * i18n_uset_get_serialized_range_count(set)-1 + * @param[out] p_start Pointer to variable to receive first character + * in range, inclusive + * @param[out] p_end Pointer to variable to receive last character in range, + * inclusive + * @return true if range_index is valid, otherwise false + * + * @exception #I18N_ERROR_NONE Successful + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see #i18n_userialized_set_s + */ +i18n_ubool i18n_uset_get_serialized_range (const i18n_userialized_set_s* set, int32_t range_index, i18n_uchar32 *p_start, i18n_uchar32 *p_end); + +/** + * @} + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/include/wearable/utils_i18n_ustring.h b/src/include/wearable/utils_i18n_ustring.h new file mode 100755 index 0000000..247969d --- /dev/null +++ b/src/include/wearable/utils_i18n_ustring.h @@ -0,0 +1,1339 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + * + * Copyright (C) 1998-2012, International Business Machines + * Corporation and others. All Rights Reserved. + */ + +#ifndef __UTILS_I18N_USTRING_H__ +#define __UTILS_I18N_USTRING_H__ + +#include + +/** + * @file utils_i18n_ustring.h + * @version 0.1 + * @brief utils_i18n_ustring + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @ingroup CAPI_BASE_UTILS_I18N_MODULE + * @defgroup CAPI_BASE_UTILS_I18N_USTRING_MODULE Ustring + * @brief The Ustring module provides general unicode string handling information. + * + * @section CAPI_BASE_UTILS_I18N_USTRING_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_BASE_UTILS_I18N_USTRING_MODULE_OVERVIEW Overview + * @details The Ustring module provides general unicode string handling information. + * + * @section CAPI_BASE_UTILS_I18N_USTIRING_MODULE_SAMPLE_CODE_1 Sample Code 1 + * @brief It converts a byte string to a unicode string and then to uppercase letters. + * @code + char str_1[64] = {0,}; + i18n_uchar uchar_str_1[64] = {0,}; + i18n_uchar uchar_str_2[64] = {0,}; + int uchar_len = 0; + i18n_uerror_code_e err_code = I18N_ERROR_NONE; + + strcpy(str_1, "tizen"); + dlog_print(DLOG_INFO, LOG_TAG, "str_1 is %s\n", str_1); // str_1 is tizen + + // converts a byte string to a unicode string + i18n_ustring_copy_ua_n(uchar_str_1, str_1, strlen(str_1)); + + // converts to uppercase letters + i18n_ustring_to_upper(uchar_str_2, 64, uchar_str_1, i18n_ustring_get_length( uchar_str_1 ), "en_US", &err_code); + + i18n_ustring_copy_au(str_1, uchar_str_2); + dlog_print(DLOG_INFO, LOG_TAG, "str_1 is %s\n", str_1); // str_1 is TIZEN + * @endcode + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_USTRING_MODULE + * @{ + */ + +/** + * @brief Determines the length of an array of #i18n_uchar. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s The array of #i18n_uchar characters, @c NULL (U+0000) terminated. + * + * @return The number of #i18n_uchar characters in @c chars, minus the terminator + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ustring_get_length ( const i18n_uchar *s ); + +/** + * @brief Counts Unicode code points in the length #i18n_uchar code units of the string. + * @details A code point may occupy either one or two #i18n_uchar code units. + * Counting code points involves reading all code units. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s The input string. + * @param[in] length The number of #i18n_uchar code units to be checked, or @c -1 to count + * all code points before the first NULL (U+0000). + * + * @return The number of code points in the specified code units. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ustring_count_char32 ( const i18n_uchar *s, int32_t length ); + +/** + * @brief Checks if the string contains more Unicode code points than a certain number. + * @details This is more efficient than counting all code points in the entire string and comparing that number with a threshold. + * This function may not need to scan the string at all if the length is known (not @c -1 for NULL-termination) and falls within a certain range, + * and never needs to count more than 'number+1' code points. + * Logically equivalent to ( i18n_ustring_count_char32 (s, length, &number_of_code_points); number_of_code_points > number ). + * A Unicode code point may occupy either one or two #i18n_uchar code units. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s The input string. + * @param[in] length The length of the string, or @c -1 if it is NULL-terminated. + * @param[in] number The number of code points in the string is compared against the @a number parameter. + * + * @return Boolean value for whether the string contains more Unicode code points than @a number. Same as ( i18n_ustring_count_char32 (s, length, &number_of_code_points); number_of_code_points > number). + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_ubool i18n_ustring_has_more_char32_than ( const i18n_uchar *s, int32_t length, int32_t number ); + +/** + * @brief Concatenates two ustrings. + * @details Appends a copy of @a src, including the NULL terminator, to @a dest. + * The initial copied character from @a src overwrites the NULL terminator in @a dest. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest The destination string. + * @param[in] src The source string. + * + * @return A pointer to @a dest. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_uchar* i18n_ustring_cat ( i18n_uchar *dest, const i18n_uchar *src ); + +/** + * @brief Concatenate two ustrings. + * @details Appends a copy of @a src, including the NULL terminator, to @a dest. + * The initial copied character from @a src overwrites the NULL terminator in @a dest. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest The destination string. + * @param[in] src The source string. + * @param[in] n The maximum number of characters to append; no-op if <=0. + * + * @return A pointer to @a dest. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_uchar* i18n_ustring_cat_n ( i18n_uchar *dest, const i18n_uchar *src, int32_t n ); + +/** + * @brief Finds the first occurrence of a substring in a string. + * @details The substring is found at code point boundaries. That means that if the substring begins with a trail surrogate + * or ends with a lead surrogate, then it is found only if these surrogates stand alone in the text. + * Otherwise, the substring edge units would be matched against halves of surrogate pairs. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s The string to search (NULL-terminated). + * @param[in] sub_string The substring to find (NULL-terminated). + * + * @return A pointer to the first occurrence of @a sub_string in @a s, + * or @a s itself if the @a sub_string is empty, + * or @c NULL if @a sub_string is not in @a s. + * + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_ustring_r_string() + * @see i18n_ustring_find_first() + * @see i18n_ustring_find_last() + */ +i18n_uchar* i18n_ustring_string ( const i18n_uchar *s, const i18n_uchar *sub_string ); + +/** + * @brief Finds the first occurrence of a substring in a string. + * @details The substring is found at code point boundaries. That means that if the substring begins with a trail surrogate + * or ends with a lead surrogate, then it is found only if these surrogates stand alone in the text. + * Otherwise, the substring edge units would be matched against halves of surrogate pairs. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s The string to search (NULL-terminated). + * @param[in] length The length of @a s (number of #i18n_uchar characters), or @c -1 if it is NULL-terminated. + * @param[in] sub_string The substring to find (NULL-terminated). + * @param[in] sub_length The length of substring (number of #i18n_uchar characters), or @c -1 if it is NULL-terminated. + * + * @return A pointer to the first occurrence of @a sub_string in @a s, + * or @a s itself if the @a sub_string is empty, + * or @c NULL if @a sub_string is not in @a s. + * + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * + * @see i18n_ustring_string() + * @see i18n_ustring_find_last() + */ +i18n_uchar* i18n_ustring_find_first ( const i18n_uchar *s, int32_t length, const i18n_uchar *sub_string, int32_t sub_length ); + +/** + * @brief Finds the first occurrence of a BMP code point in a string. + * @details A surrogate code point is found only if its match in the text is not part of a surrogate pair. A NULL character is found at the string terminator. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s The string to search (NULL-terminated). + * @param[in] c The BMP code point to find. + * + * @return A pointer to the first occurrence of @a c in @a s + * or @c NULL if @a c is not in @a s. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ustring_char32() + * @see i18n_ustring_mem_char() + * @see i18n_ustring_string() + * @see i18n_ustring_find_first() + */ +i18n_uchar* i18n_ustring_char ( const i18n_uchar *s, i18n_uchar c ); + +/** + * @brief Finds the first occurrence of a code point in a string. + * @details A surrogate code point is found only if its match in the text is not part of a surrogate pair. A NULL character is found at the string terminator. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s The string to search (NULL-terminated). + * @param[in] c The code point to find. + * + * @return A pointer to the first occurrence of @a c in @a s + * or @c NULL if @a c is not in @a s. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ustring_char() + * @see i18n_ustring_mem_char32() + * @see i18n_ustring_string() + * @see i18n_ustring_find_first() + */ +i18n_uchar* i18n_ustring_char32 ( const i18n_uchar *s, i18n_uchar32 c ); + +/** + * @brief Finds the last occurrence of a substring in a string. + * @details The substring is found at code point boundaries. That means that if the substring begins with a trail surrogate + * or ends with a lead surrogate, then it is found only if these surrogates stand alone in the text. + * Otherwise, the substring edge units would be matched against halves of surrogate pairs. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s The string to search (NULL-terminated). + * @param[in] sub_string The substring to find (NULL-terminated). + * + * @return A pointer to the last occurrence of @a substring in @a s, + * or @a s itself if the @a sub_string is empty, + * or @c NULL if @a sub_string is not in @a s. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ustring_string() + * @see i18n_ustring_find_first() + * @see i18n_ustring_find_last() + */ +i18n_uchar* i18n_ustring_r_string ( const i18n_uchar *s, const i18n_uchar *sub_string ); + +/** + * @brief Finds the last occurrence of a substring in a string. + * @details The substring is found at code point boundaries. That means that if the substring begins with a trail surrogate + * or ends with a lead surrogate, then it is found only if these surrogates stand alone in the text. + * Otherwise, the substring edge units would be matched against halves of surrogate pairs. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s The string to search. + * @param[in] length The length of s (number of #i18n_uchar), or @c -1 if it is NULL-terminated. + * @param[in] sub_string The sub_string to find (NULL-terminated). + * @param[in] sub_length The length of sub_string (number of #i18n_uchar), or @c -1 if it is NULL-terminated. + * + * @return A pointer to the last occurrence of @a sub_string in @a s, + * or @a s itself if the @a substring is empty, + * or @c NULL if @a sub_string is not in @a s. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ustring_string() + * @see i18n_ustring_find_first() + */ +i18n_uchar* i18n_ustring_find_last( const i18n_uchar *s, int32_t length, const i18n_uchar *sub_string, int32_t sub_length ); + +/** + * @brief Finds the last occurrence of a BMP code point in a string. + * @details A surrogate code point is found only if its match in the text is not part of a surrogate pair. A NULL character is found at the string terminator. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s The string to search (NULL-terminated). + * @param[in] c The BMP code point to find. + * + * @return A pointer to the last occurrence of @a c in @a s + * or @c NULL if @a c is not in @a s. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ustring_char32() + * @see i18n_ustring_mem_char() + * @see i18n_ustring_string() + * @see i18n_ustring_find_first() + */ +i18n_uchar* i18n_ustring_r_char ( const i18n_uchar *s, i18n_uchar c ); + +/** + * @brief Finds the last occurrence of a code point in a string. + * @details A surrogate code point is found only if its match in the text is not part of a surrogate pair. A NULL character is found at the string terminator. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s The string to search (NULL-terminated). + * @param[in] c The code point to find. + * + * @return A pointer to the last occurrence of @a c in @a s + * or @c NULL if @a c is not in @a s. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ustring_char() + * @see i18n_ustring_mem_char32() + * @see i18n_ustring_string() + * @see i18n_ustring_find_first() + */ +i18n_uchar* i18n_ustring_r_char32 ( const i18n_uchar *s, i18n_uchar32 c ); + +/** + * @brief Locates the first occurrence in the string of any of the characters in the string matchSet. + * @details Works just like C's strpbrk but with Unicode. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] string The string in which to search, NULL-terminated. + * @param[in] match_set A NULL-terminated string defining a set of code points for which to search in the text string. + * + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @return A pointer to the character in @a string that matches one of the + * characters in @a match_set, or NULL if no such character is found. + */ +i18n_uchar* i18n_ustring_pbrk ( const i18n_uchar *string, const i18n_uchar *match_set ); + +/** + * @brief Returns the number of consecutive characters in string, beginning with the first, that do not occur somewhere in match_set. + * @details Works just like C's strcspn but with Unicode. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] string The string in which to search, NULL-terminated. + * @param[in] match_set A NULL-terminated string defining a set of code points for which to search in the text string. + * + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @return The number of initial characters in @a string that do not + * occur in @a match_set. + */ +int32_t i18n_ustring_cspn ( const i18n_uchar *string, const i18n_uchar *match_set ); + +/** + * @brief Returns the number of consecutive characters in string, beginning with the first, that occur somewhere in match_set. + * @details Works just like C's strspn but with Unicode. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] string The string in which to search, NULL-terminated. + * @param[in] match_set A NULL-terminated string defining a set of code points for which to search in the text string. + * @return The number of initial characters in @a string that do + * occur in @a match_set. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ustring_spn() + */ +int32_t i18n_ustring_spn ( const i18n_uchar *string, const i18n_uchar *match_set ); + +/** + * @brief The string tokenizer API allows an application to break a string into tokens. + * @details Works just like C's strspn but with Unicode. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] src String containing token(s). This string will be modified. After the first call to #i18n_ustring_tokenizer_r(), this argument must be NULL to get to the next token. + * @param[in] delim Set of delimiter characters (Unicode code points). + * @param[out] save_state The current pointer within the original string, which is set by this function. + * The save_state parameter should the address of a local variable of type #i18n_uchar *. + * @return A pointer to the next token found in src, or NULL + * when there are no more tokens. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_uchar* i18n_ustring_tokenizer_r ( i18n_uchar *src, const i18n_uchar *delim, i18n_uchar **save_state ); + +/** + * @brief Compares two Unicode strings for bitwise equality (code unit order). + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s1 A string to compare. + * @param[in] s2 A string to compare. + * @return 0 if @a s1 and @a s2 are bitwise equal; a negative + * value if @a s1 is bitwise less than @a s2; a positive + * value if @a s1 is bitwise greater than @a s2. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ustring_compare ( const i18n_uchar *s1, const i18n_uchar *s2 ); + +/** + * @brief Compare two Unicode strings in code point order. + * @details See #i18n_ustring_compare() for details. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s1 A string to compare. + * @param[in] s2 A string to compare. + * @return a negative/zero/positive integer corresponding to whether + * the first string is less than/equal to/greater than the second one + * in code point order + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ustring_compare_code_point_order( const i18n_uchar *s1, const i18n_uchar *s2 ); + +/** + * @brief Compare two Unicode strings (binary order). + * @details The comparison can be done in code unit order or in code point order. They differ only in UTF-16 when comparing supplementary code points + * (U+10000..U+10ffff) to BMP code points near the end of the BMP (i.e., U+e000..U+ffff). In code unit order, high BMP code points sort after + * supplementary code points because they are stored as pairs of surrogates which are at U+d800..U+dfff.\n + * This functions works with strings of different explicitly specified lengths unlike the ANSI C-like #i18n_ustring_compare() and #i18n_ustring_mem_compare() etc. + * NULL-terminated strings are possible with length arguments of -1. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s1 First source string. + * @param[in] length1 Length of first source string, or @c -1 if NULL-terminated. + * @param[in] s2 Second source string. + * @param[in] length2 Length of second source string, or @c -1 if NULL-terminated. + * @param[in] code_point_order Choose between code unit order (false) and code point order (true). + * @return < 0, 0 or > 0 as usual for string comparisons + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ustring_compare_binary_order( const i18n_uchar *s1, int32_t length1, const i18n_uchar *s2, int32_t length2, i18n_ubool code_point_order ); + +/** + * @brief Compare two strings case-insensitively using full case folding. + * @details The comparison can be done in UTF-16 code unit order or in code point order. They differ only when comparing + * supplementary code points (U+10000..U+10ffff) to BMP code points near the end of the BMP (i.e., U+e000..U+ffff). + * In code unit order, high BMP code points sort after supplementary code points because they are stored as pairs of surrogates which are at U+d800..U+dfff.\n + * This functions works with strings of different explicitly specified lengths unlike the ANSI C-like #i18n_ustring_compare() and i18n_ustring_mem_compare() etc. + * NULL-terminated strings are possible with length arguments of -1. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s1 First source string. + * @param[in] length1 Length of first source string, or @c -1 if NULL-terminated. + * @param[in] s2 Second source string. + * @param[in] length2 Length of second source string, or @c -1 if NULL-terminated. + * @param[in] options A bit set of options:\n + * - #I18N_USTRING_U_FOLD_CASE_DEFAULT or 0 is used for default options: Comparison in code unit order with default case folding.\n + * - #I18N_USTRING_U_COMPARE_CODE_POINT_ORDER Set to choose code point order instead of code unit order (see i18n_ustring_compare_code_pointer_order() for details).\n + * - #I18N_USTRING_U_FOLD_CASE_EXCLUDE_SPECIAL_I + * @param[out] error_code Must be a valid pointer to an error code value, + * which must not indicate a failure before the function call. + * @return <0 or 0 or >0 as usual for string comparisons + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ustring_case_compare_with_length( const i18n_uchar *s1, int32_t length1, const i18n_uchar *s2, int32_t length2, uint32_t options, i18n_error_code_e *error_code ); + +/** + * @brief Compare two ustrings for bitwise equality. + * @details Compares at most n characters. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s1 A string to compare (can be NULL/invalid if n<=0). + * @param[in] s2 A string to compare (can be NULL/invalid if n<=0). + * @param[in] n The maximum number of characters to compare; always returns 0 if n<=0. + * @return 0 if @a s1 and @a s2 are bitwise equal; a negative + * value if @a s1 is bitwise less than @a s2; a positive + * value if @a s1 is bitwise greater than @a s2. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ustring_compare_n( const i18n_uchar *s1, const i18n_uchar *s2, int32_t n ); + +/** + * @brief Compare two Unicode strings in code point order. + * @details This is different in UTF-16 from #i18n_ustring_compare_n() if supplementary characters are present. For details, see #i18n_ustring_compare_binary_order(). + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s1 A string to compare. + * @param[in] s2 A string to compare. + * @param[in] n The maximum number of characters to compare. + * @return a negative/zero/positive integer corresponding to whether + * the first string is less than/equal to/greater than the second one + * in code point order + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ustring_compare_n_code_point_order( const i18n_uchar *s1, const i18n_uchar *s2, int32_t n ); + +/** + * @brief Compare two strings case-insensitively using full case folding. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s1 A string to compare. + * @param[in] s2 A string to compare. + * @param[in] options bit set of options:\n + * - #I18N_USTRING_U_FOLD_CASE_DEFAULT or 0 is used for default options: Comparison in code unit order with default case folding. + * - #I18N_USTRING_U_COMPARE_CODE_POINT_ORDER Set to choose code point order instead of code unit order (see u_strCompare for details). + * - #I18N_USTRING_U_FOLD_CASE_EXCLUDE_SPECIAL_I + * @return A negative, zero, or positive integer indicating the comparison result. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ustring_case_compare( const i18n_uchar *s1, const i18n_uchar *s2, uint32_t options ); + +/** + * @brief Compare two strings case-insensitively using full case folding. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s1 A string to compare. + * @param[in] s2 A string to compare. + * @param[in] n The maximum number of characters each string to case-fold and then compare. + * @param[in] options A bit set of options:\n + * - #I18N_USTRING_U_FOLD_CASE_DEFAULT or 0 is used for default options: Comparison in code unit order with default case folding. + * - #I18N_USTRING_U_COMPARE_CODE_POINT_ORDER Set to choose code point order instead of code unit order (see u_strCompare for details). + * - #I18N_USTRING_U_FOLD_CASE_EXCLUDE_SPECIAL_I + * @return A negative, zero, or positive integer indicating the comparison result. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ustring_case_compare_n( const i18n_uchar *s1, const i18n_uchar *s2, int32_t n, uint32_t options ); + +/** + * @brief Compare two strings case-insensitively using full case folding. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s1 A string to compare. + * @param[in] s2 A string to compare. + * @param[in] length The number of characters in each string to case-fold and then compare. + * @param[in] options A bit set of options:\n + * - #I18N_USTRING_U_FOLD_CASE_DEFAULT or 0 is used for default options: Comparison in code unit order with default case folding. + * - #I18N_USTRING_U_COMPARE_CODE_POINT_ORDER Set to choose code point order instead of code unit order (see u_strCompare for details). + * - #I18N_USTRING_U_FOLD_CASE_EXCLUDE_SPECIAL_I + * @return A negative, zero, or positive integer indicating the comparison result. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ustring_mem_case_compare( const i18n_uchar *s1, const i18n_uchar *s2, int32_t length, uint32_t options ); + +/** + * @brief Copies a ustring. Adds a NULL terminator. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest The destination string + * @param[in] src The source string + * + * @return A pointer to @a dest. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_uchar* i18n_ustring_copy ( i18n_uchar *dest, const i18n_uchar *src ); + +/** + * @brief Copies a ustring. + * @details Copies at most @a n characters. The result will be NULL terminated + * if the length of @a src is less than @a n. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest The destination string + * @param[in] src The source string + * @param[in] n The maximum number of characters to copy + * + * @return A pointer to @a dest. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_uchar* i18n_ustring_copy_n ( i18n_uchar *dest, const i18n_uchar *src, int32_t n ); + +/** + * @brief Copies a byte string encoded in the default codepage to a ustring. + * @details Adds a NULL terminator. Performs a host byte to #i18n_uchar conversion. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest The destination string + * @param[in] src The source string + * + * @return A pointer to @a dest. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_uchar* i18n_ustring_copy_ua ( i18n_uchar *dest, const char *src ); + +/** + * @brief Copies a byte string encoded in the default codepage to a ustring. + * @details Copies at most @a n characters. The result will be NULL terminated + * if the length of @a src is less than @a n. + * Performs a host byte to #i18n_uchar conversion. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest The destination string + * @param[in] src The source string + * @param[in] n The maximum number of characters to copy + * + * @return A pointer to @a dest. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_uchar* i18n_ustring_copy_ua_n ( i18n_uchar *dest, const char *src, int32_t n ); + +/** + * @brief Copies a ustring to a byte string encoded in the default codepage. + * @details Adds a NULL terminator. Performs an #i18n_uchar to host byte conversion. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest The destination string + * @param[in] src The source string + * + * @return A pointer to @a dest. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +char* i18n_ustring_copy_au ( char *dest, const i18n_uchar *src ); + +/** + * @brief Copies a ustring to a byte string encoded in the default codepage. + * @details Copies at most @a n characters. The result will be NULL terminated + * if the length of @a src is less than @a n. + * Performs an #i18n_uchar to host byte conversion. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest The destination string + * @param[in] src The source string + * @param[in] n The maximum number of characters to copy + * + * @return A pointer to @a dest. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +char* i18n_ustring_copy_au_n ( char *dest, const i18n_uchar *src, int32_t n ); + +/** + * @brief Synonym for memcpy(), but with #i18n_uchar characters only. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest The destination string + * @param[in] src The source string (can be NULL/invalid if count<=0) + * @param[in] count The number of characters to copy; no-op if <=0 + * + * @return A pointer to @a dest + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_uchar* i18n_ustring_mem_copy ( i18n_uchar *dest, const i18n_uchar *src, int32_t count ); + +/** + * @brief Synonym for memmove(), but with #i18n_uchar characters only. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest The destination string + * @param[in] src The source string (can be NULL/invalid if count<=0) + * @param[in] count The number of characters to copy; no-op if <=0 + * + * @return A pointer to @a dest + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_uchar* i18n_ustring_mem_move ( i18n_uchar *dest, const i18n_uchar *src, int32_t count ); + +/** + * @brief Initialize count characters of dest to c. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest The destination string + * @param[in] c The character to initialize the string. + * @param[in] count The maximum number of characters to set. + * + * @return A pointer to @a dest. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_uchar* i18n_ustring_mem_set ( i18n_uchar *dest, const i18n_uchar c, int32_t count ); + +/** + * @brief Compare the first count #i18n_uchar characters of each buffer. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] buf1 The first string to compare. + * @param[in] buf2 The second string to compare. + * @param[in] count The maximum number of #i18n_uchar characters to compare. + * @return When buf1 < buf2, a negative number is returned. + * When buf1 == buf2, 0 is returned. + * When buf1 > buf2, a positive number is returned. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ustring_mem_compare ( const i18n_uchar *buf1, const i18n_uchar *buf2, int32_t count ); + +/** + * @brief Compare two Unicode strings in code point order. + * @details This is different in UTF-16 from #i18n_ustring_mem_compare() if supplementary characters are present. For details, see #i18n_ustring_compare_binary_order(). + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s1 A string to compare. + * @param[in] s2 A string to compare. + * @param[in] count The maximum number of characters to compare. + * @return a negative/zero/positive integer corresponding to whether + * the first string is less than/equal to/greater than the second one + * in code point order + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ustring_mem_compare_code_point_order ( const i18n_uchar *s1, const i18n_uchar *s2, int32_t count ); + +/** + * @brief Finds the first occurrence of a BMP code point in a string. + * @details A surrogate code point is found only if its match in the text is not part of a surrogate pair. A NULL character is found at the string terminator. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s The string to search (contains count #i18n_uchar characters). + * @param[in] c The BMP code point to find. + * @param[in] count The length of the string. + * @return A pointer to the first occurrence of @a c in @a s + * or @c NULL if @a c is not in @a s. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ustring_char() + * @see i18n_ustring_mem_char32() + * @see i18n_ustring_find_first() + */ +i18n_uchar* i18n_ustring_mem_char ( const i18n_uchar *s, i18n_uchar c, int32_t count ); + +/** + * @brief Finds the first occurrence of a code point in a string. + * @details A surrogate code point is found only if its match in the text is not part of a surrogate pair. A NULL character is found at the string terminator. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s The string to search (contains count #i18n_uchar characters). + * @param[in] c The code point to find. + * @param[in] count The length of the string. + * @return A pointer to the first occurrence of @a c in @a s + * or @c NULL if @a c is not in @a s. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_uchar* i18n_ustring_mem_char32 ( const i18n_uchar *s, i18n_uchar32 c, int32_t count ); + +/** + * @brief Finds the last occurrence of a BMP code point in a string. + * @details A surrogate code point is found only if its match in the text is not part of a surrogate pair. A NULL character is found at the string terminator. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s The string to search (contains count #i18n_uchar characters). + * @param[in] c The BMP code point to find. + * @param[in] count The length of the string. + * @return A pointer to the last occurrence of @a c in @a s + * or @c NULL if @a c is not in @a s. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see #i18n_ustring_r_char + * @see #i18n_ustring_mem_r_char32 + * @see #i18n_ustring_find_last + */ +i18n_uchar* i18n_ustring_mem_r_char ( const i18n_uchar *s, i18n_uchar c, int32_t count ); + +/** + * @brief Finds the last occurrence of a code point in a string. + * @details A surrogate code point is found only if its match in the text is not part of a surrogate pair. A NULL character is found at the string terminator. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] s The string to search (contains count #i18n_uchar characters). + * @param[in] c The code point to find. + * @param[in] count The length of the string. + * @return A pointer to the last occurrence of @a c in @a s + * or @c NULL if @a c is not in @a s. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see #i18n_ustring_r_char32 + * @see #i18n_ustring_mem_r_char + * @see #i18n_ustring_find_last + */ +i18n_uchar* i18n_ustring_mem_r_char32 ( const i18n_uchar *s, i18n_uchar32 c, int32_t count ); + +/** + * @brief Unescape a string of characters and write the resulting Unicode characters to the destination buffer. + * @details The following escape sequences are recognized:\n + * \\uhhhh 4 hex digits; h in [0-9A-Fa-f] \\Uhhhhhhhh 8 hex digits \\xhh 1-2 hex digits \\x{h...} 1-8 hex digits \\ooo 1-3 octal digits; o in [0-7] \\cX control-X; X is masked with 0x1F\n + * as well as the standard ANSI C escapes:\n + * \\a => U+0007, \\b => U+0008, \\t => U+0009, \\n => U+000A, \\v => U+000B, \\f => U+000C, \\r => U+000D, \\e => U+001B, \\" => U+0022, \\' => U+0027, \\? => U+003F, \\\\ => U+005C\n + * Anything else following a backslash is generically escaped. For example, "[a\-z]" returns "[a-z]".\n + * If an escape sequence is ill-formed, this method returns an empty string. An example of an ill-formed sequence is "\\u" followed by fewer than 4 hex digits. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] src a zero-terminated string of invariant characters + * @param[in] dest pointer to buffer to receive converted and unescaped text and, if there is room, a zero terminator. May be NULL for preflighting, in which case no #i18n_uchar characters will be written, + * but the return value will still be valid. On error, an empty string is stored here (if possible). + * @param[in] dest_capacity the number of #i18n_uchar characters that may be written at dest. Ignored if dest == NULL. + * @return the length of unescaped string. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ustring_unescape_at() + */ +int32_t i18n_ustring_unescape ( const char *src, i18n_uchar *dest, int32_t dest_capacity ); + +/** + * @brief Unescape a single sequence. + * @details The character at offset-1 is assumed (without checking) to be a backslash. This method takes a callback pointer to a function that returns the #i18n_uchar at a given offset. + * By varying this callback, I18N functions are able to unescape char* strings, and UnicodeString objects.\n + * If offset is out of range, or if the escape sequence is ill-formed, (i18n_uchar32)0xFFFFFFFF is returned. + * See documentation of #i18n_ustring_unescape() for a list of recognized sequences. + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[in] char_at callback function that returns a #i18n_uchar of the source text given an offset and a context pointer. + * @param[in] offset pointer to the offset that will be passed to char_at. The offset value will be updated upon return to point after the last parsed character of the escape sequence. + * On error the offset is unchanged. + * @param[in] length the number of #i18n_uchar characters that may be written at dest. Ignored if dest == NULL. + * @param[in] context an opaque pointer passed directly into char_at. + * + * @return the character represented by the escape sequence at + * offset, or (i18n_uchar32)0xFFFFFFFF on error. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ustring_unescape() + */ +i18n_uchar32 i18n_ustring_unescape_at ( i18n_ustring_unescape_char_at_cb char_at, int32_t *offset, int32_t length, void *context ); + +/** + * @brief Uppercases the characters in a string. + * @details Casing is locale-dependent and context-sensitive. + * The result may be longer or shorter than the original. + * The source string and the destination buffer are allowed to overlap. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest A buffer for the result string\n The result will be zero-terminated if + * the buffer is large enough. + * @param[in] dest_capacity The size of the buffer (number of #i18n_uchar characters)\n + * If it is @c 0, then @a dest may be @c NULL and the function will only return the length of the result + * without writing any of the result string. + * @param[in] src The original string + * @param[in] src_len The length of the original string\n + * If @c -1, then @a src must be zero-terminated. + * @param[in] locale The locale to consider, or "" for the root locale or @c NULL for the default locale. + * @param[out] error_code Must be a valid pointer to an error code value, + * which must not indicate a failure before the function call. + * @return The length of the result string. It may be greater than destCapacity. In that case, + * only some of the result was written to the destination buffer. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ustring_to_upper ( i18n_uchar *dest, int32_t dest_capacity, const i18n_uchar *src, int32_t src_len, const char *locale, i18n_error_code_e *error_code ); + +/** + * @brief Lowercase the characters in a string. + * @details Casing is locale-dependent and context-sensitive. The result may be longer or shorter than the original. The source string and the destination buffer are allowed to overlap. + * The result may be longer or shorter than the original. + * The source string and the destination buffer are allowed to overlap. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest A buffer for the result string. The result will be zero-terminated if the buffer is large enough. + * @param[in] dest_capacity The size of the buffer (number of #i18n_uchar characters)\n + * If it is 0, then dest may be NULL and the function will only return the length of the result without writing any of the result string. + * @param[in] src The original string + * @param[in] src_len The length of the original string.\n + * If @c -1, then @a src must be zero-terminated. + * @param[in] locale The locale to consider, or "" for the root locale or @c NULL for the default locale. + * @param[out] error_code Must be a valid pointer to an error code value, + * which must not indicate a failure before the function call. + * @return The length of the result string. It may be greater than destCapacity. In that case, + * only some of the result was written to the destination buffer. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ustring_to_lower ( i18n_uchar *dest, int32_t dest_capacity, const i18n_uchar *src, int32_t src_len, const char *locale, i18n_error_code_e *error_code ); + +/** + * @brief Titlecases a string. + * @details Casing is locale-dependent and context-sensitive. + * Titlecasing uses a break iterator to find the first characters of words + * that are to be titlecased. It titlecases those characters and lowercases + * all others. + * + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exceptions section and in #i18n_error_code_e description. + * + * The titlecase break iterator can be provided to customize arbitrary + * styles, using rules and dictionaries beyond the standard iterators. + * It may be more efficient to always provide an iterator to avoid + * opening and closing one for each string. + * The standard titlecase iterator for the root locale implements the + * algorithm of Unicode TR 21.\n + * The result may be longer or shorter than the original. + * The source string and the destination buffer are allowed to overlap. + * @since_tizen 2.3.1 + * + * @param[out] dest A buffer for the result string.\n + * The result will be zero-terminated if the buffer is large enough. + * @param[in] dest_capacity The size of the buffer (number of #i18n_uchar characters.\n + * If it is @c 0, then @a dest may be @c NULL and the function will only return the length of the result + * without writing any of the result string. + * @param[in] src The original string + * @param[in] src_len The length of the original string.\n If @c -1, then @a src must be zero-terminated. + * @param[in] title_iter A break iterator to find the first characters of words + * that are to be titlecased.\n + * If none are provided (@c NULL), then a standard titlecase + * break iterator is opened. + * @param[in] locale The locale to consider, or "" for the root locale or @c NULL for the default locale. + * @return The length of the result string. It may be greater than dest_capacity. In that case, + * only some of the result were written to the destination buffer. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ustring_to_title_new ( i18n_uchar *dest, int32_t dest_capacity, const i18n_uchar *src, int32_t src_len, i18n_ubreak_iterator_h title_iter, const char *locale); + +/** + * @brief Case-folds the characters in a string. + * @details Case-folding is locale-independent and not context-sensitive, + * but there is an option for whether to include or exclude mappings for dotted I and dotless i.\n + * The result may be longer or shorter than the original. + * The source string and the destination buffer are allowed to overlap. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest A buffer for the result string\n + * The result will be zero-terminated if the buffer is large enough. + * @param[in] dest_capacity The size of the buffer (number of #i18n_uchar characters)\n + * If it is @c 0, then @a dest may be @c NULL and the function will only return the length of the result + * without writing any of the result string. + * @param[in] src The original string + * @param[in] src_len The length of the original string.\n If @c -1, then @a src must be zero-terminated. + * @param[in] options Either #I18N_USTRING_U_FOLD_CASE_DEFAULT or #I18N_USTRING_U_FOLD_CASE_EXCLUDE_SPECIAL_I + * @param[out] error_code Must be a valid pointer to an error code value, + * which must not indicate a failure before the function call. + * @return The length of the result string. It may be greater than destCapacity. In that case, + * only some of the result was written to the destination buffer. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ustring_fold_case ( i18n_uchar *dest, int32_t dest_capacity, const i18n_uchar *src, int32_t src_len, uint32_t options, i18n_error_code_e *error_code ); + +/** + * @brief Convert a UTF-16 string to a wchar_t string. + * @details If it is known at compile time that wchar_t strings are in UTF-16 or UTF-32, then this function simply calls the fast, dedicated function for that. + * Otherwise, two conversions UTF-16 -> default charset -> wchar_t* are performed. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest A buffer for the result string. The result will be zero-terminated if the buffer is large enough. + * @param[in] dest_capacity The size of the buffer (number of wchar_t's).\n + * If it is @c 0, then @a dest may be @c NULL and the function will only return the length of the result + * without writing any of the result string (pre-flighting). + * @param[out] dest_len A pointer to receive the number of units written to the destination.\n + * If dest_len!=NULL then *dest_len is always set to the number of output units corresponding to the transformation of all the input units, even in case of a buffer overflow. + * @param[in] src The original source string. + * @param[in] src_len The length of the original string.\n If @c -1, then @a src must be zero-terminated. + * @param[out] error_code Must be a valid pointer to an error code value, + * which must not indicate a failure before the function call. + * @return The pointer to destination buffer. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +wchar_t* i18n_ustring_to_WCS ( wchar_t *dest, int32_t dest_capacity, int32_t *dest_len, const i18n_uchar *src, int32_t src_len, i18n_error_code_e *error_code ); + +/** + * @brief Convert a wchar_t string to UTF-16. + * @details If it is known at compile time that wchar_t strings are in UTF-16 or UTF-32, then this function simply calls the fast, dedicated function for that. + * Otherwise, two conversions wchar_t* -> default charset -> UTF-16 are performed. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest A buffer for the result string. The result will be zero-terminated if the buffer is large enough. + * @param[in] dest_capacity The size of the buffer (number of #i18n_uchar characters).\n + * If it is @c 0, then @a dest may be @c NULL and the function will only return the length of the result + * without writing any of the result string (pre-flighting). + * @param[out] dest_len A pointer to receive the number of units written to the destination.\n + * If dest_len!=NULL then *dest_len is always set to the number of output units corresponding to the transformation of all the input units, even in case of a buffer overflow. + * @param[in] src The original source string. + * @param[in] src_len The length of the original string.\n If @c -1, then @a src must be zero-terminated. + * @param[out] error_code Must be a valid pointer to an error code value, + * which must not indicate a failure before the function call. + * @return The pointer to destination buffer. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_uchar* i18n_ustring_from_WCS ( i18n_uchar *dest, int32_t dest_capacity, int32_t *dest_len, const wchar_t *src, int32_t src_len, i18n_error_code_e *error_code ); + +/** + * @brief Converts a UTF-16 string to UTF-8. + * @details If the input string is not well-formed, then the #I18N_ERROR_INVALID_CHAR_FOUND error code is set. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest A buffer for the result string.\n + * The result will be zero-terminated if the buffer is large enough. + * @param[in] dest_capacity The size of the buffer (number of chars)\n + * If it is @c 0, then @a dest may be @c NULL and the function will only return the length of the + * result without writing any of the result string (pre-flighting). + * @param[out] dest_len A pointer to receive the number of units written to the destination.\n + * If dest_len!=NULL then *dest_len is always set to the + * number of output units corresponding to the transformation of + * all the input units, even in case of a buffer overflow. + * @param[in] src The original source string + * @param[in] src_len The length of the original string.\n + * If @c -1, then @a src must be zero-terminated. + * @param[out] error_code Must be a valid pointer to an error code value, + * which must not indicate a failure before the function call. + * @return The pointer to destination buffer. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ustring_from_UTF8() + */ +char* i18n_ustring_to_UTF8 ( char *dest, int32_t dest_capacity, int32_t *dest_len, const i18n_uchar *src, int32_t src_len, i18n_error_code_e *error_code ); + +/** + * @brief Converts a UTF-8 string to UTF-16. + * @details If the input string is not well-formed, then the #I18N_ERROR_INVALID_CHAR_FOUND error code is set. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest A buffer for the result string.\n + * The result will be zero-terminated if the buffer is large enough. + * @param[in] dest_capacity The size of the buffer (number of #i18n_uchar characters)\n + * If it is @c 0, then @a dest may be @c NULL and the function will only return the length of the + * result without writing any of the result string (pre-flighting). + * @param[out] dest_len A pointer to receive the number of units written to the destination.\n + * If dest_len!=NULL then *dest_len is always set to the + * number of output units corresponding to the transformation of + * all the input units, even in case of a buffer overflow. + * @param[in] src The original source string + * @param[in] src_len The length of the original string.\n + * If @c -1, then @a src must be zero-terminated. + * @param[out] error_code Must be a valid pointer to an error code value, + * which must not indicate a failure before the function call. + * @return The pointer to destination buffer. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +i18n_uchar* i18n_ustring_from_UTF8 ( i18n_uchar *dest, int32_t dest_capacity, int32_t *dest_len, const char *src, int32_t src_len, i18n_error_code_e *error_code ); + +/** + * @brief Convert a UTF-16 string to UTF-8. + * @details If the input string is not well-formed, then the #I18N_ERROR_INVALID_CHAR_FOUND error code is set. + * Same as #i18n_ustring_to_UTF8() except for the additional sub_char which is output for illegal input sequences, instead of stopping with the #I18N_ERROR_INVALID_CHAR_FOUND error code. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest A buffer for the result string.\n + * The result will be zero-terminated if the buffer is large enough. + * @param[in] dest_capacity The size of the buffer (number of chars)\n + * If it is @c 0, then @a dest may be @c NULL and the function will only return the length of the + * result without writing any of the result string (pre-flighting). + * @param[out] dest_len A pointer to receive the number of units written to the destination.\n + * If dest_len!=NULL then *dest_len is always set to the + * number of output units corresponding to the transformation of + * all the input units, even in case of a buffer overflow. + * @param[in] src The original source string + * @param[in] src_len The length of the original string.\n + * If @c -1, then @a src must be zero-terminated. + * @param[in] sub_char The substitution character to use in place of an illegal input sequence, or U_SENTINEL if the function is to return with #I18N_ERROR_INVALID_CHAR_FOUND instead. + * A substitution character can be any valid Unicode code point (up to U+10FFFF) except for surrogate code points (U+D800..U+DFFF). + * The recommended value is U+FFFD "REPLACEMENT CHARACTER". + * @param[out] num_substitutions Output parameter receiving the number of substitutions if sub_char>=0. Set to 0 if no substitutions occur or sub_char<0. num_substitutions can be NULL. + * @param[out] error_code Pointer to a standard ICU error code. Its input value must + * pass the U_SUCCESS() test, or else the function returns + * immediately. Check for U_FAILURE() on output or use with + * function chaining. (See User Guide for details.) + * @return The pointer to destination buffer. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ustring_to_UTF8() + * @see i18n_ustring_from_UTF8_with_sub() + */ +char* i18n_ustring_to_UTF8_with_sub ( char *dest, int32_t dest_capacity, int32_t *dest_len, const i18n_uchar *src, int32_t src_len, i18n_uchar32 sub_char, int32_t *num_substitutions, i18n_error_code_e *error_code ); + +/** + * @brief Convert a UTF-8 string to UTF-16. + * @details Same as #i18n_ustring_from_UTF8() except for the additional sub_char which is output for illegal input sequences, instead of stopping with the #I18N_ERROR_INVALID_CHAR_FOUND error code. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest A buffer for the result string.\n + * The result will be zero-terminated if the buffer is large enough. + * @param[in] dest_capacity The size of the buffer (number of #i18n_uchar characters)\n + * If it is @c 0, then @a dest may be @c NULL and the function will only return the length of the + * result without writing any of the result string (pre-flighting). + * @param[out] dest_len A pointer to receive the number of units written to the destination.\n + * If dest_len!=NULL then *dest_len is always set to the + * number of output units corresponding to the transformation of + * all the input units, even in case of a buffer overflow. + * @param[in] src The original source string + * @param[in] src_len The length of the original string.\n + * If @c -1, then @a src must be zero-terminated. + * @param[in] sub_char The substitution character to use in place of an illegal input sequence, or U_SENTINEL if the function is to return with #I18N_ERROR_INVALID_CHAR_FOUND instead. + * A substitution character can be any valid Unicode code point (up to U+10FFFF) except for surrogate code points (U+D800..U+DFFF). + * The recommended value is U+FFFD "REPLACEMENT CHARACTER". + * @param[out] num_substitutions Output parameter receiving the number of substitutions if sub_char>=0. Set to 0 if no substitutions occur or sub_char<0. num_substitutions can be NULL. + * @param[out] error_code Pointer to a standard ICU error code. Its input value must + * pass the U_SUCCESS() test, or else the function returns + * immediately. Check for U_FAILURE() on output or use with + * function chaining. (See User Guide for details.) + * @return The pointer to destination buffer. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ustring_from_UTF8() + * @see i18n_ustring_from_UTF8_lenient() + * @see i18n_ustring_to_UTF8_with_sub() + */ +i18n_uchar* i18n_ustring_from_UTF8_with_sub ( i18n_uchar *dest, int32_t dest_capacity, int32_t *dest_len, const char *src, int32_t src_len, i18n_uchar32 sub_char, + int32_t *num_substitutions, i18n_error_code_e *error_code ); + +/** + * @brief Convert a UTF-8 string to UTF-16. + * @details Same as i18n_ustring_from_UTF8() except that this function is designed to be very fast, which it achieves by being lenient about malformed UTF-8 sequences. + * This function is intended for use in environments where UTF-8 text is expected to be well-formed.\n + * Its semantics are: + * - Well-formed UTF-8 text is correctly converted to well-formed UTF-16 text.\n + * - The function will not read beyond the input string, nor write beyond the dest_capacity.\n + * - Malformed UTF-8 results in "garbage" 16-bit Unicode strings which may not be well-formed UTF-16. The function will resynchronize to valid code point boundaries within a small number of code points after an illegal sequence.\n + * - Non-shortest forms are not detected and will result in "spoofing" output.\n + * For further performance improvement, if src_len is given (>=0), then it must be dest_capacity>=src_len.\n + * There is no inverse i18n_ustring_to_UTF8_lenient() function because there is practically no performance gain from not checking that a UTF-16 string is well-formed. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest A buffer for the result string.\n + * The result will be zero-terminated if the buffer is large enough. + * @param[in] dest_capacity The size of the buffer (number of #i18n_uchar characters)\n + * If it is @c 0, then @a dest may be @c NULL and the function will only return the length of the + * result without writing any of the result string (pre-flighting). + * Unlike for other I18N functions, if src_len>=0 then it must be dest_capacity>=src_len. + * @param[out] dest_len A pointer to receive the number of units written to the destination.\n + * If dest_len!=NULL then *dest_len is always set to the number of output units corresponding + * to the transformation of all the input units, even in case of a buffer overflow. + * Unlike for other I18N functions, if src_len>=0 but dest_capacity=0. Set to 0 if no substitutions occur or sub_char<0. num_substitutions can be NULL. + * @param[out] error_code Pointer to a standard ICU error code. Its input value must + * pass the U_SUCCESS() test, or else the function returns + * immediately. Check for U_FAILURE() on output or use with + * function chaining. (See User Guide for details.) + * @return The pointer to destination buffer. + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ustring_to_UTF32() + * @see i18n_ustring_from_UTF32_with_sub() + */ +i18n_uchar32* i18n_ustring_to_UTF32_with_sub ( i18n_uchar32 *dest, int32_t dest_capacity, int32_t *dest_len, const i18n_uchar *src, int32_t src_len, + i18n_uchar32 sub_char, int32_t *num_substitutions, i18n_error_code_e *error_code ); + +/** + * @brief Convert a UTF-32 string to UTF-16. + * @details If the input string is not well-formed, then the #I18N_ERROR_INVALID_CHAR_FOUND error code is set. + * Same as #i18n_ustring_from_UTF32() except for the additional sub_char which is output for illegal input sequences, instead of stopping with the #I18N_ERROR_INVALID_CHAR_FOUND error code. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * + * @param[out] dest A buffer for the result string.\n + * The result will be zero-terminated if the buffer is large enough. + * @param[in] dest_capacity The size of the buffer (number of i18n_chars)\n + * If it is @c 0, then @a dest may be @c NULL and the function will only return the length of the + * result without writing any of the result string (pre-flighting). + * @param[out] dest_len A pointer to receive the number of units written to the destination.\n + * If dest_len!=NULL then *dest_len is always set to the number of output units corresponding + * to the transformation of all the input units, even in case of a buffer overflow. + * @param[in] src The original source string + * @param[in] src_len The length of the original string.\n + * If @c -1, then @a src must be zero-terminated. + * @param[in] sub_char The substitution character to use in place of an illegal input sequence, or U_SENTINEL if the function is to return with #I18N_ERROR_INVALID_CHAR_FOUND instead. + * A substitution character can be any valid Unicode code point (up to U+10FFFF) except for surrogate code points (U+D800..U+DFFF). + * The recommended value is U+FFFD "REPLACEMENT CHARACTER". + * @param[out] num_substitutions Output parameter receiving the number of substitutions if sub_char>=0. Set to 0 if no substitutions occur or sub_char<0. num_substitutions can be NULL. + * @param[out] error_code Pointer to a standard ICU error code. Its input value must + * pass the U_SUCCESS() test, or else the function returns + * immediately. Check for U_FAILURE() on output or use with + * function chaining. (See User Guide for details.) + * @return[out] The pointer to destination buffer. + * + * @exception #I18N_ERROR_NONE Success + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @see i18n_ustring_from_UTF32() + * @see i18n_ustring_to_UTF32_with_sub() + */ +i18n_uchar* i18n_ustring_from_UTF32_with_sub ( i18n_uchar *dest, int32_t dest_capacity, int32_t *dest_len, const i18n_uchar32 *src, int32_t src_len, i18n_uchar32 sub_char, int32_t *num_substitutions, i18n_error_code_e *error_code ); + +#ifdef __cplusplus +} +#endif + +/** + * @} + * @} + */ +#endif /* __UTILS_I18N_USTRING_H__*/ diff --git a/src/utils_i18n_private.c b/src/utils_i18n_private.c new file mode 100755 index 0000000..b7331f6 --- /dev/null +++ b/src/utils_i18n_private.c @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + +int _i18n_error_mapping ( int err ) +{ + if(err == U_STRING_NOT_TERMINATED_WARNING) return I18N_WARNING_STRING_NOT_TERMINATED; + else if(err == U_SORT_KEY_TOO_SHORT_WARNING) return I18N_WARNING_SORT_KEY_TOO_SHORT; + else if(err <= U_ZERO_ERROR) return I18N_ERROR_NONE; + + switch (err) { + case U_ILLEGAL_ARGUMENT_ERROR : return I18N_ERROR_INVALID_PARAMETER; + case U_MISSING_RESOURCE_ERROR : return I18N_ERROR_MISSING_RESOURCE; + case U_INVALID_FORMAT_ERROR : return I18N_ERROR_INVALID_FORMAT; + case U_FILE_ACCESS_ERROR : return I18N_ERROR_FILE_ACCESS; + case U_INTERNAL_PROGRAM_ERROR : return I18N_ERROR_INTERNAL_PROGRAM; + case U_MESSAGE_PARSE_ERROR : return I18N_ERROR_MESSAGE_PARSE; + case U_MEMORY_ALLOCATION_ERROR : return I18N_ERROR_OUT_OF_MEMORY; + case U_INDEX_OUTOFBOUNDS_ERROR : return I18N_ERROR_INDEX_OUTOFBOUNDS; + case U_PARSE_ERROR : return I18N_ERROR_PARSE; + case U_INVALID_CHAR_FOUND : return I18N_ERROR_INVALID_CHAR_FOUND; + case U_TRUNCATED_CHAR_FOUND : return I18N_ERROR_TRUNCATED_CHAR_FOUND; + case U_ILLEGAL_CHAR_FOUND : return I18N_ERROR_ILLEGAL_CHAR_FOUND; + case U_INVALID_TABLE_FORMAT : return I18N_ERROR_INVALID_TABLE_FORMAT; + case U_INVALID_TABLE_FILE : return I18N_ERROR_INVALID_TABLE_FILE; + case U_BUFFER_OVERFLOW_ERROR : return I18N_ERROR_BUFFER_OVERFLOW; + case U_UNSUPPORTED_ERROR : return I18N_ERROR_NOT_SUPPORTED; + case U_RESOURCE_TYPE_MISMATCH : return I18N_ERROR_RESOURCE_TYPE_MISMATCH; + case U_ILLEGAL_ESCAPE_SEQUENCE : return I18N_ERROR_ILLECAL_ESCAPE_SEQUENCE; + case U_UNSUPPORTED_ESCAPE_SEQUENCE : return I18N_ERROR_UNSUPPORTED_ESCAPE_SEQUENCE; + case U_NO_SPACE_AVAILABLE : return I18N_ERROR_NO_SPACE_AVAILABLE; + case U_CE_NOT_FOUND_ERROR : return I18N_ERROR_CE_NOT_FOUND; + case U_PRIMARY_TOO_LONG_ERROR : return I18N_ERROR_PRIMARY_TOO_LONG; + case U_STATE_TOO_OLD_ERROR : return I18N_ERROR_STATE_TOO_OLD; + case U_TOO_MANY_ALIASES_ERROR : return I18N_ERROR_TOO_MANY_ALIASES; + case U_ENUM_OUT_OF_SYNC_ERROR : return I18N_ERROR_ENUM_OUT_OF_SYNC; + case U_INVARIANT_CONVERSION_ERROR : return I18N_ERROR_INVARIANT_CONVERSION; + case U_INVALID_STATE_ERROR : return I18N_ERROR_INVALID_STATE; + case U_COLLATOR_VERSION_MISMATCH : return I18N_ERROR_COLLATOR_VERSION_MISMATCH; + case U_USELESS_COLLATOR_ERROR : return I18N_ERROR_USELESS_COLLATOR; + case U_NO_WRITE_PERMISSION : return I18N_ERROR_NO_WRITE_PERMISSION; + case U_MALFORMED_SET : return I18N_ERROR_MALFORMED_SET; + case U_IDNA_STD3_ASCII_RULES_ERROR : return I18N_ERROR_STD3_ASCII_RULES; + case U_IDNA_UNASSIGNED_ERROR : return I18N_ERROR_UNASSIGNED; + default : return I18N_ERROR_UNKNOWN; + } +} + +int _i18n_error_mapping_reverse ( int err ) +{ + switch (err) { + case I18N_ERROR_NONE : return U_ZERO_ERROR; + case I18N_ERROR_INVALID_PARAMETER : return U_ILLEGAL_ARGUMENT_ERROR; + case I18N_ERROR_MISSING_RESOURCE : return U_MISSING_RESOURCE_ERROR; + case I18N_ERROR_INVALID_FORMAT : return U_INVALID_FORMAT_ERROR; + case I18N_ERROR_FILE_ACCESS : return U_FILE_ACCESS_ERROR; + case I18N_ERROR_INTERNAL_PROGRAM : return U_INTERNAL_PROGRAM_ERROR; + case I18N_ERROR_MESSAGE_PARSE : return U_MESSAGE_PARSE_ERROR; + case I18N_ERROR_OUT_OF_MEMORY : return U_MEMORY_ALLOCATION_ERROR; + case I18N_ERROR_INDEX_OUTOFBOUNDS : return U_INDEX_OUTOFBOUNDS_ERROR; + case I18N_ERROR_PARSE : return U_PARSE_ERROR; + case I18N_ERROR_INVALID_CHAR_FOUND : return U_INVALID_CHAR_FOUND; + case I18N_ERROR_TRUNCATED_CHAR_FOUND : return U_TRUNCATED_CHAR_FOUND; + case I18N_ERROR_ILLEGAL_CHAR_FOUND : return U_ILLEGAL_CHAR_FOUND; + case I18N_ERROR_INVALID_TABLE_FORMAT : return U_INVALID_TABLE_FORMAT; + case I18N_ERROR_INVALID_TABLE_FILE : return U_INVALID_TABLE_FILE; + case I18N_ERROR_BUFFER_OVERFLOW : return U_BUFFER_OVERFLOW_ERROR; + case I18N_ERROR_NOT_SUPPORTED : return U_UNSUPPORTED_ERROR; + case I18N_ERROR_RESOURCE_TYPE_MISMATCH : return U_RESOURCE_TYPE_MISMATCH; + case I18N_ERROR_ILLECAL_ESCAPE_SEQUENCE : return U_ILLEGAL_ESCAPE_SEQUENCE; + case I18N_ERROR_UNSUPPORTED_ESCAPE_SEQUENCE : return U_UNSUPPORTED_ESCAPE_SEQUENCE; + case I18N_ERROR_NO_SPACE_AVAILABLE : return U_NO_SPACE_AVAILABLE; + case I18N_ERROR_CE_NOT_FOUND : return U_CE_NOT_FOUND_ERROR; + case I18N_ERROR_PRIMARY_TOO_LONG : return U_PRIMARY_TOO_LONG_ERROR; + case I18N_ERROR_STATE_TOO_OLD : return U_STATE_TOO_OLD_ERROR; + case I18N_ERROR_TOO_MANY_ALIASES : return U_TOO_MANY_ALIASES_ERROR; + case I18N_ERROR_ENUM_OUT_OF_SYNC : return U_ENUM_OUT_OF_SYNC_ERROR; + case I18N_ERROR_INVARIANT_CONVERSION : return U_INVARIANT_CONVERSION_ERROR; + case I18N_ERROR_INVALID_STATE : return U_INVALID_STATE_ERROR; + case I18N_ERROR_COLLATOR_VERSION_MISMATCH : return U_COLLATOR_VERSION_MISMATCH; + case I18N_ERROR_USELESS_COLLATOR : return U_USELESS_COLLATOR_ERROR; + case I18N_ERROR_NO_WRITE_PERMISSION : return U_NO_WRITE_PERMISSION; + case I18N_ERROR_MALFORMED_SET : return U_MALFORMED_SET; + case I18N_ERROR_STD3_ASCII_RULES : return U_IDNA_STD3_ASCII_RULES_ERROR; + case I18N_WARNING_STRING_NOT_TERMINATED : return U_STRING_NOT_TERMINATED_WARNING; + case I18N_ERROR_UNASSIGNED : return U_IDNA_UNASSIGNED_ERROR; + case I18N_WARNING_SORT_KEY_TOO_SHORT : return U_SORT_KEY_TOO_SHORT_WARNING; + default : return U_STANDARD_ERROR_LIMIT; + } +} diff --git a/src/utils_i18n_timezone.cpp b/src/utils_i18n_timezone.cpp new file mode 100755 index 0000000..ad5de02 --- /dev/null +++ b/src/utils_i18n_timezone.cpp @@ -0,0 +1,426 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +#define __STDC_LIMIT_MACROS +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +int i18n_timezone_create_unknown ( i18n_timezone_h *timezone ) +{ + retv_if(timezone == NULL, I18N_ERROR_INVALID_PARAMETER); + + *timezone = (TimeZone::getUnknown()).clone(); + retv_if(timezone == NULL, I18N_ERROR_OUT_OF_MEMORY); + + return I18N_ERROR_NONE; +} + +int i18n_timezone_create_gmt ( i18n_timezone_h *timezone ) +{ + retv_if(timezone == NULL, I18N_ERROR_INVALID_PARAMETER); + + const TimeZone* gmt = TimeZone::getGMT(); + retv_if(gmt == NULL, I18N_ERROR_OUT_OF_MEMORY); + + *timezone = gmt->clone(); + if(gmt != NULL) { + delete gmt; + } + retv_if(timezone == NULL, I18N_ERROR_OUT_OF_MEMORY); + + return I18N_ERROR_NONE; +} + +int i18n_timezone_create ( i18n_timezone_h *timezone, const char *timezone_id ) +{ + retv_if(timezone == NULL, I18N_ERROR_INVALID_PARAMETER); + + const UnicodeString id(timezone_id); + *timezone = TimeZone::createTimeZone(id); + retv_if(*timezone == NULL, I18N_ERROR_OUT_OF_MEMORY); + + return I18N_ERROR_NONE; +} + +int i18n_timezone_destroy(i18n_timezone_h timezone) +{ + retv_if(timezone == NULL, I18N_ERROR_INVALID_PARAMETER); + + delete((TimeZone*)timezone); + + return I18N_ERROR_NONE; +} + +int i18n_timezone_foreach_timezone_id_by_region(i18n_system_timezone_type_e timezone_type, const char *region, const int32_t *raw_offset, + i18n_timezone_id_cb cb, void* user_data) +{ + retv_if(cb == NULL, I18N_ERROR_INVALID_PARAMETER); + UErrorCode err = U_ZERO_ERROR; + + StringEnumeration *s = TimeZone::createTimeZoneIDEnumeration((USystemTimeZoneType)timezone_type, region, raw_offset, err); + + UErrorCode status=U_ZERO_ERROR; + int32_t count = s->count(status); + for (int i = 0; i < count; i++) { + int32_t resultLength = 0; + if( cb(s->next(&resultLength, status), user_data) == false ) { + break; + } + } + + delete s; + return _i18n_error_mapping(err); +} + +int i18n_timezone_foreach_timezone_id(i18n_timezone_id_cb cb, void* user_data) +{ + retv_if(cb == NULL, I18N_ERROR_INVALID_PARAMETER); + StringEnumeration *s = TimeZone::createEnumeration(); + + UErrorCode status = U_ZERO_ERROR; + int32_t count = s->count(status); + for (int i = 0; i < count; i++) { + int32_t resultLength = 0; + if( cb(s->next(&resultLength, status), user_data) == false ) { + break; + } + } + + delete s; + return I18N_ERROR_NONE; +} + +int i18n_timezone_foreach_timezone_id_with_offset(int32_t raw_offset, i18n_timezone_id_cb cb, void* user_data) +{ + retv_if(cb == NULL, I18N_ERROR_INVALID_PARAMETER); + StringEnumeration *s = TimeZone::createEnumeration(raw_offset); + + UErrorCode status = U_ZERO_ERROR; + int32_t count = s->count(status); + for (int i = 0; i < count; i++) { + int32_t resultLength = 0; + if( cb(s->next(&resultLength, status), user_data) == false ) { + break; + } + } + + delete s; + return I18N_ERROR_NONE; +} + +int i18n_timezone_foreach_timezone_id_by_country(const char *country, i18n_timezone_id_cb cb, void* user_data) +{ + retv_if(cb == NULL, I18N_ERROR_INVALID_PARAMETER); + StringEnumeration *s = TimeZone::createEnumeration(country); + + UErrorCode status = U_ZERO_ERROR; + int32_t count = s->count(status); + for (int i = 0; i < count; i++) { + int32_t resultLength = 0; + if( cb(s->next(&resultLength, status), user_data) == false ) { + break; + } + } + + delete s; + return I18N_ERROR_NONE; +} + +int i18n_timezone_count_equivalent_ids(const char *timezone_id, int32_t *count) +{ + retv_if(timezone_id == NULL || count == NULL, I18N_ERROR_INVALID_PARAMETER); + const UnicodeString id(timezone_id); + *count = TimeZone::countEquivalentIDs(id); + + return I18N_ERROR_NONE; +} + +int i18n_timezone_get_equivalent_id(const char *timezone_id, int32_t index, char **equivalent_timezone_id) +{ + retv_if(timezone_id == NULL || equivalent_timezone_id == NULL, I18N_ERROR_INVALID_PARAMETER); + + *equivalent_timezone_id = NULL; + const UnicodeString id(timezone_id); + + UnicodeString equivalentTimezoneId = TimeZone::getEquivalentID(id, index); + const UChar * equivalent_tid = equivalentTimezoneId.getTerminatedBuffer(); + + retv_if(equivalent_tid == NULL, I18N_ERROR_INVALID_PARAMETER); + int32_t ulen = u_strlen(equivalent_tid); + + retv_if(ulen <= 0, I18N_ERROR_INVALID_PARAMETER); + *equivalent_timezone_id = (char*)malloc(ulen + 1); + + retv_if(*equivalent_timezone_id == NULL, I18N_ERROR_OUT_OF_MEMORY); + + u_austrcpy(*equivalent_timezone_id, equivalent_tid); + + return I18N_ERROR_NONE; +} + +int i18n_timezone_create_default ( i18n_timezone_h *timezone ) +{ + retv_if(timezone == NULL, I18N_ERROR_INVALID_PARAMETER); + *timezone = TimeZone::createDefault(); + + return I18N_ERROR_NONE; +} + +int i18n_timezone_set_default( i18n_timezone_h timezone ) +{ + retv_if(timezone == NULL, I18N_ERROR_INVALID_PARAMETER); + + TimeZone::setDefault(*(TimeZone*)timezone); + + return I18N_ERROR_NONE; +} + +const char* i18n_timezone_get_tzdata_version(void) +{ + UErrorCode status = U_ZERO_ERROR; + const char* tzver = TimeZone::getTZDataVersion(status); + + set_last_result(_i18n_error_mapping(status)); + + return tzver; +} + +int i18n_timezone_get_region(const char *timezone_id, char *region, int32_t *region_len, int32_t region_capacity) +{ + retv_if(timezone_id == NULL || region == NULL || region_len == NULL, I18N_ERROR_INVALID_PARAMETER); + + UErrorCode status = U_ZERO_ERROR; + const UnicodeString id(timezone_id); + *region_len = TimeZone::getRegion(id, region, region_capacity, status); + + return _i18n_error_mapping(status); + +} + +int i18n_timezone_get_offset_with_date(i18n_timezone_h timezone, i18n_udate date, i18n_ubool local, int32_t *raw_offset, int32_t *dst_offset) +{ + retv_if(timezone == NULL || raw_offset == NULL || dst_offset == NULL, I18N_ERROR_INVALID_PARAMETER); + + UErrorCode status = U_ZERO_ERROR; + ((TimeZone*)timezone)->getOffset( date, local, *raw_offset, *dst_offset, status ); + + return _i18n_error_mapping(status); + +} + +int i18n_timezone_set_raw_offset(i18n_timezone_h timezone, int32_t offset_milliseconds) +{ + retv_if(timezone == NULL, I18N_ERROR_INVALID_PARAMETER); + ((TimeZone*)timezone)->setRawOffset(offset_milliseconds); + + return I18N_ERROR_NONE; +} + +int i18n_timezone_get_raw_offset(i18n_timezone_h timezone, int32_t *offset_milliseconds) +{ + retv_if(timezone == NULL || offset_milliseconds == NULL, I18N_ERROR_INVALID_PARAMETER); + + *offset_milliseconds = ((TimeZone*)timezone)->getRawOffset(); + + return I18N_ERROR_NONE; +} + +int i18n_timezone_get_id(i18n_timezone_h timezone, char **timezone_id) +{ + retv_if(timezone == NULL || timezone_id == NULL, I18N_ERROR_INVALID_PARAMETER); + + *timezone_id = NULL; + UnicodeString TimezoneID; + + ((TimeZone*)timezone)->getID(TimezoneID); + const UChar * tid = TimezoneID.getTerminatedBuffer(); + + retv_if(tid == NULL, I18N_ERROR_INVALID_PARAMETER); + int32_t ulen = u_strlen(tid); + + retv_if(ulen <= 0, I18N_ERROR_INVALID_PARAMETER); + *timezone_id = (char*)malloc(ulen+1); + + retv_if(*timezone_id == NULL, I18N_ERROR_OUT_OF_MEMORY); + u_austrcpy(*timezone_id, tid); + + return I18N_ERROR_NONE; +} + +int i18n_timezone_set_id(i18n_timezone_h timezone, const char *timezone_id) +{ + retv_if(timezone == NULL || timezone_id == NULL, I18N_ERROR_INVALID_PARAMETER); + const UnicodeString id(timezone_id); + ((TimeZone*)timezone)->setID(id); + + return I18N_ERROR_NONE; +} + +int i18n_timezone_get_display_name(i18n_timezone_h timezone, char **display_name) +{ + retv_if(timezone == NULL || display_name == NULL, I18N_ERROR_INVALID_PARAMETER); + + *display_name = NULL; + UnicodeString displayName; + + ((TimeZone*)timezone)->getDisplayName(displayName); + const UChar * dn = displayName.getTerminatedBuffer(); + + retv_if(dn == NULL, I18N_ERROR_INVALID_PARAMETER); + int32_t ulen = u_strlen(dn); + + retv_if(ulen <= 0, I18N_ERROR_INVALID_PARAMETER); + *display_name = (char*)malloc(ulen + 1); + + retv_if(*display_name == NULL, I18N_ERROR_OUT_OF_MEMORY); + + u_austrcpy(*display_name, dn); + + return I18N_ERROR_NONE; +} + +int i18n_timezone_get_display_name_with_locale(i18n_timezone_h timezone, const char *language, const char *country , char **display_name) +{ + retv_if(timezone == NULL || display_name == NULL, I18N_ERROR_INVALID_PARAMETER); + + Locale locale(language, country, 0, 0); + *display_name = NULL; + UnicodeString displayName; + + ((TimeZone*)timezone)->getDisplayName(locale, displayName); + const UChar * dn = displayName.getTerminatedBuffer(); + + retv_if(dn == NULL, I18N_ERROR_INVALID_PARAMETER); + int32_t ulen = u_strlen(dn); + + retv_if(ulen <= 0, I18N_ERROR_INVALID_PARAMETER); + *display_name = (char*)malloc(ulen + 1); + + retv_if(*display_name == NULL, I18N_ERROR_OUT_OF_MEMORY); + + u_austrcpy(*display_name, dn); + + return I18N_ERROR_NONE; +} + +int i18n_timezone_get_display_name_with_type(i18n_timezone_h timezone, i18n_ubool daylight, i18n_timezone_display_type_e style, + char **display_name) +{ + retv_if(timezone == NULL || display_name == NULL, I18N_ERROR_INVALID_PARAMETER); + + *display_name = NULL; + UnicodeString displayName; + + ((TimeZone*)timezone)->getDisplayName((UBool)daylight, (TimeZone::EDisplayType)style, displayName); + const UChar * dn = displayName.getTerminatedBuffer(); + + retv_if(dn == NULL, I18N_ERROR_INVALID_PARAMETER); + int32_t ulen = u_strlen(dn); + + retv_if(ulen <= 0, I18N_ERROR_INVALID_PARAMETER); + *display_name = (char*)malloc(ulen + 1); + + retv_if(*display_name == NULL, I18N_ERROR_OUT_OF_MEMORY); + + u_austrcpy(*display_name, dn); + + return I18N_ERROR_NONE; +} + +int i18n_timezone_get_display_name_with_type_locale(i18n_timezone_h timezone, i18n_ubool daylight, i18n_timezone_display_type_e style, + const char *language, const char *country, char **display_name) +{ + retv_if(timezone == NULL || display_name == NULL, I18N_ERROR_INVALID_PARAMETER); + + const Locale locale(language, country, 0, 0); + *display_name = NULL; + UnicodeString displayName; + + ((TimeZone*)timezone)->getDisplayName((UBool)daylight, (TimeZone::EDisplayType)style, locale, displayName); + const UChar * dn = displayName.getTerminatedBuffer(); + + retv_if(dn == NULL, I18N_ERROR_INVALID_PARAMETER); + int32_t ulen = u_strlen(dn); + + retv_if(ulen <= 0, I18N_ERROR_INVALID_PARAMETER); + *display_name = (char*)malloc(ulen + 1); + + retv_if(*display_name == NULL, I18N_ERROR_OUT_OF_MEMORY); + + u_austrcpy(*display_name, dn); + + return I18N_ERROR_NONE; +} + +int i18n_timezone_use_daylight_time(i18n_timezone_h timezone, i18n_ubool *daylight_time) +{ + retv_if(timezone == NULL || daylight_time == NULL, I18N_ERROR_INVALID_PARAMETER); + + *daylight_time = ((TimeZone*)timezone)->useDaylightTime(); + + return I18N_ERROR_NONE; +} + +int i18n_timezone_in_daylight_time(i18n_timezone_h timezone, i18n_udate date, i18n_ubool *daylight_time) +{ + retv_if(timezone == NULL || daylight_time == NULL, I18N_ERROR_INVALID_PARAMETER); + + UErrorCode status; + + *daylight_time = ((TimeZone*)timezone)->inDaylightTime(date, status); + + return _i18n_error_mapping(status); + +} + +int i18n_timezone_has_same_rule(i18n_timezone_h timezone, i18n_timezone_h other, i18n_ubool *same_rule) +{ + retv_if(timezone == NULL || same_rule == NULL, I18N_ERROR_INVALID_PARAMETER); + + *same_rule = ((TimeZone*)timezone)->hasSameRules(*(TimeZone*)other); + + return I18N_ERROR_NONE; +} + +int i18n_timezone_clone(i18n_timezone_h timezone, i18n_timezone_h *clone) +{ + retv_if(timezone == NULL || clone == NULL, I18N_ERROR_INVALID_PARAMETER); + + *clone = ((TimeZone*)timezone)->clone(); + + return I18N_ERROR_NONE; +} + +int i18n_timezone_get_dst_savings(i18n_timezone_h timezone, int32_t *dst_savings) +{ + retv_if(timezone == NULL || dst_savings == NULL, I18N_ERROR_INVALID_PARAMETER); + + *dst_savings = ((TimeZone*)timezone)->getDSTSavings(); + + return I18N_ERROR_NONE; +} diff --git a/src/utils_i18n_ubrk.c b/src/utils_i18n_ubrk.c new file mode 100644 index 0000000..7f222d2 --- /dev/null +++ b/src/utils_i18n_ubrk.c @@ -0,0 +1,240 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + + +int i18n_ubrk_create (i18n_ubreak_iterator_type_e type, const char *locale, const i18n_uchar *text, int32_t text_length, i18n_ubreak_iterator_h *break_iter) +{ + if (type < I18N_UBRK_CHARACTER || type > I18N_UBRK_SENTENCE || NULL == break_iter) { + return I18N_ERROR_INVALID_PARAMETER; + } + if (text_length < -1) { + return I18N_ERROR_INVALID_PARAMETER; + } + UErrorCode icu_error = U_ZERO_ERROR; + *break_iter = (i18n_ubreak_iterator_h) ubrk_open((UBreakIteratorType)type, locale, text, text_length, &icu_error); + ERR("ErrorCode : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int i18n_ubrk_create_rules (const i18n_uchar *rules, int32_t rules_length, const i18n_uchar *text, int32_t text_length, i18n_ubreak_iterator_h *break_iter, i18n_uparse_error_s *parse_err) +{ + if (rules == NULL || rules_length < -1 || text_length < -1 || break_iter == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + + UErrorCode icu_error = U_ZERO_ERROR; + *break_iter = (i18n_ubreak_iterator_h) ubrk_openRules (rules, rules_length, text, text_length, (UParseError*)parse_err, &icu_error); + ERR("ErrorCode : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int i18n_ubrk_safe_clone (const i18n_ubreak_iterator_h break_iter, void *stack_buffer, int32_t *p_buffer_size, i18n_ubreak_iterator_h *break_iter_clone) +{ + if (break_iter == NULL || break_iter_clone == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + UErrorCode icu_error = U_ZERO_ERROR; + *break_iter_clone = (i18n_ubreak_iterator_h) ubrk_safeClone((const UBreakIterator*)break_iter, stack_buffer, p_buffer_size, &icu_error); + ERR("ErrorCode : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int i18n_ubrk_destroy (i18n_ubreak_iterator_h break_iter) +{ + if (break_iter == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + + ubrk_close((UBreakIterator*)break_iter); + return I18N_ERROR_NONE; +} + +int i18n_ubrk_set_text (i18n_ubreak_iterator_h break_iter, const i18n_uchar *text, int32_t text_length) +{ + if(text == NULL || break_iter == NULL || text_length < 0){ + return I18N_ERROR_INVALID_PARAMETER; + } + + UErrorCode icu_error = U_ZERO_ERROR; + ubrk_setText((UBreakIterator*)break_iter, text, text_length, &icu_error); + ERR("ErrorCode : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int32_t i18n_ubrk_current (const i18n_ubreak_iterator_h break_iter) +{ + if (break_iter == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return -1; + } + set_last_result(I18N_ERROR_NONE); + return ubrk_current ((const UBreakIterator*)break_iter); +} + +int32_t i18n_ubrk_next (i18n_ubreak_iterator_h break_iter) +{ + if (break_iter == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return -1; + } + + set_last_result(I18N_ERROR_NONE); + return ubrk_next((UBreakIterator*)break_iter); +} + +int32_t i18n_ubrk_previous (i18n_ubreak_iterator_h break_iter) +{ + if (break_iter == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return -1; + } + + set_last_result(I18N_ERROR_NONE); + return ubrk_previous ((UBreakIterator*)break_iter); +} + +int32_t i18n_ubrk_first (i18n_ubreak_iterator_h break_iter) +{ + if (break_iter == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return -1; + } + + set_last_result(I18N_ERROR_NONE); + return ubrk_first ((UBreakIterator*)break_iter); +} + +int32_t i18n_ubrk_last (i18n_ubreak_iterator_h break_iter) +{ + if( break_iter == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return -1; + } + + set_last_result(I18N_ERROR_NONE); + return ubrk_last ((UBreakIterator*)break_iter); +} + +int32_t i18n_ubrk_preceding (i18n_ubreak_iterator_h break_iter, int32_t offset) +{ + if (break_iter == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return -1; + } + + set_last_result(I18N_ERROR_NONE); + return ubrk_preceding((UBreakIterator*)break_iter, offset); +} + +int32_t i18n_ubrk_following (i18n_ubreak_iterator_h break_iter, int32_t offset) +{ + if (break_iter == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return -1; + } + + set_last_result(I18N_ERROR_NONE); + return ubrk_following((UBreakIterator*)break_iter, offset); +} + +const char *i18n_ubrk_get_available (int32_t index) +{ + if(index < 0) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + + set_last_result(I18N_ERROR_NONE); + return ubrk_getAvailable(index); +} + +int32_t i18n_ubrk_count_available (void) +{ + set_last_result(I18N_ERROR_NONE); + return ubrk_countAvailable(); +} + +i18n_ubool i18n_ubrk_is_boundary (i18n_ubreak_iterator_h break_iter, int32_t offset) +{ + if (break_iter == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return false; + } + + set_last_result(I18N_ERROR_NONE); + return ubrk_isBoundary((UBreakIterator*)break_iter, offset); +} + +int32_t i18n_ubrk_get_rule_status (i18n_ubreak_iterator_h break_iter) +{ + if (break_iter == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + set_last_result(I18N_ERROR_NONE); + return ubrk_getRuleStatus((UBreakIterator*)break_iter); +} + +int32_t i18n_ubrk_get_rule_status_vec (i18n_ubreak_iterator_h break_iter, int32_t *fill_in_vec, int32_t capacity) +{ + if (break_iter == NULL || capacity < 0) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + UErrorCode icu_error = U_ZERO_ERROR; + int32_t result_ubrk_getRuleStatusVec = ubrk_getRuleStatusVec((UBreakIterator*)break_iter, fill_in_vec, capacity, &icu_error); + ERR("ErrorCode : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return result_ubrk_getRuleStatusVec; +} + +const char *i18n_ubrk_get_locale_by_type (const i18n_ubreak_iterator_h break_iter, i18n_ulocale_data_locale_type_e type) +{ + if (type < I18N_ULOCALE_DATA_LOCALE_TYPE_ACTUAL_LOCALE || + type > I18N_ULOCALE_DATA_LOCALE_TYPE_LIMIT) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + UErrorCode icu_error = U_ZERO_ERROR; + const char * result_ubrk_getLocaleByType = ubrk_getLocaleByType((const UBreakIterator*)break_iter, type, &icu_error); + ERR("ErrorCode : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return result_ubrk_getLocaleByType; +} diff --git a/src/utils_i18n_ucalendar.c b/src/utils_i18n_ucalendar.c new file mode 100644 index 0000000..34fce8e --- /dev/null +++ b/src/utils_i18n_ucalendar.c @@ -0,0 +1,550 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + +int i18n_ucalendar_create ( const i18n_uchar *zone_id, int32_t len, const char *locale, i18n_ucalendar_type_e type, i18n_ucalendar_h *calendar ) +{ + retv_if(calendar == NULL, I18N_ERROR_INVALID_PARAMETER); + + i18n_error_code_e i18n_error; + UErrorCode icu_error = U_ZERO_ERROR; + *calendar = ucal_open(zone_id, len, locale, type, &icu_error); + ERR("Error code: %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int i18n_ucalendar_destroy ( i18n_ucalendar_h calendar ) +{ + retv_if(calendar == NULL, I18N_ERROR_INVALID_PARAMETER); + + ucal_close(calendar); + return I18N_ERROR_NONE; +} + +int i18n_ucalendar_clone ( const i18n_ucalendar_h cal, i18n_ucalendar_h *identical_to_cal ) +{ + retv_if(cal == NULL || identical_to_cal == NULL, I18N_ERROR_INVALID_PARAMETER); + + i18n_error_code_e i18n_error; + UErrorCode icu_error = U_ZERO_ERROR; + *identical_to_cal = ucal_clone(cal, &icu_error); + ERR("Error code: %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int i18n_ucalendar_add ( i18n_ucalendar_h calendar, i18n_ucalendar_date_fields_e field, int32_t amount ) +{ + retv_if(calendar == NULL, I18N_ERROR_INVALID_PARAMETER); + + i18n_error_code_e i18n_error; + UErrorCode icu_error = U_ZERO_ERROR; + ucal_add(calendar, field, amount, &icu_error); + ERR("Error code: %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int i18n_ucalendar_is_equivalent_to ( const i18n_ucalendar_h calendar1, const i18n_ucalendar_h calendar2, i18n_ubool *equiv ) +{ + retv_if(equiv == NULL || calendar1 == NULL || calendar2 == NULL, I18N_ERROR_INVALID_PARAMETER); + + *equiv = ucal_equivalentTo(calendar1, calendar2); + return I18N_ERROR_NONE; +} + +int i18n_ucalendar_get_milliseconds ( const i18n_ucalendar_h calendar, i18n_udate *date ) +{ + retv_if(calendar == NULL || date == NULL, I18N_ERROR_INVALID_PARAMETER); + + i18n_error_code_e i18n_error; + UErrorCode icu_error = U_ZERO_ERROR; + *date = ucal_getMillis(calendar, &icu_error); + ERR("Error code: %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int i18n_ucalendar_get ( const i18n_ucalendar_h calendar, i18n_ucalendar_date_fields_e field, int32_t *val ) +{ + retv_if(calendar == NULL || val == NULL, I18N_ERROR_INVALID_PARAMETER); + + i18n_error_code_e i18n_error; + UErrorCode icu_error = U_ZERO_ERROR; + *val = ucal_get(calendar, field, &icu_error); + ERR("Error code: %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int i18n_ucalendar_get_attribute ( i18n_ucalendar_h calendar, i18n_ucalendar_attribute_e attr, int32_t *val) +{ + retv_if(calendar == NULL || val == NULL, I18N_ERROR_INVALID_PARAMETER); + + *val = ucal_getAttribute(calendar, attr); + return I18N_ERROR_NONE; +} + +int i18n_ucalendar_get_timezone_displayname ( const i18n_ucalendar_h calendar, i18n_ucalendar_displayname_type_e type, const char *locale, + i18n_uchar *result, int32_t result_len, int32_t *buf_size_needed ) +{ + retv_if(calendar == NULL || result == NULL || buf_size_needed == NULL, I18N_ERROR_INVALID_PARAMETER); + + i18n_error_code_e i18n_error; + UErrorCode icu_error = U_ZERO_ERROR; + *buf_size_needed = ucal_getTimeZoneDisplayName(calendar, type, locale, result, result_len, &icu_error); + ERR("Error code: %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int i18n_ucalendar_is_in_daylight_time ( const i18n_ucalendar_h calendar, i18n_ubool *is_in ) +{ + retv_if(calendar == NULL || is_in == NULL, I18N_ERROR_INVALID_PARAMETER); + + i18n_error_code_e i18n_error; + UErrorCode icu_error = U_ZERO_ERROR; + *is_in = ucal_inDaylightTime(calendar, &icu_error); + ERR("Error code: %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int i18n_ucalendar_set ( i18n_ucalendar_h cal, i18n_ucalendar_date_fields_e field, int32_t val ) +{ + retv_if(cal == NULL, I18N_ERROR_INVALID_PARAMETER); + + ucal_set(cal, field, val); + return I18N_ERROR_NONE; +} + +int i18n_ucalendar_set_attribute ( i18n_ucalendar_h calendar, i18n_ucalendar_attribute_e attr, int32_t val ) +{ + retv_if(calendar == NULL, I18N_ERROR_INVALID_PARAMETER); + + ucal_setAttribute(calendar, attr, val); + return I18N_ERROR_NONE; +} + +int i18n_ucalendar_set_date_time ( i18n_ucalendar_h calendar, int32_t year, int32_t month, int32_t date, int32_t hour, int32_t min, int32_t sec ) +{ + retv_if(calendar == NULL, I18N_ERROR_INVALID_PARAMETER); + + i18n_error_code_e i18n_error; + UErrorCode icu_error = U_ZERO_ERROR; + ucal_setDateTime(calendar, year, month, date, hour, min, sec, &icu_error); + ERR("Error code: %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int i18n_ucalendar_set_milliseconds ( i18n_ucalendar_h calendar, i18n_udate milliseconds ) +{ + retv_if(calendar == NULL, I18N_ERROR_INVALID_PARAMETER); + + i18n_error_code_e i18n_error; + UErrorCode icu_error = U_ZERO_ERROR; + ucal_setMillis(calendar, milliseconds, &icu_error); + ERR("Error code: %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int i18n_ucalendar_set_default_timezone ( const i18n_uchar *zone_id ) +{ + retv_if(zone_id == NULL, I18N_ERROR_INVALID_PARAMETER); + + i18n_error_code_e i18n_error; + UErrorCode icu_error = U_ZERO_ERROR; + ucal_setDefaultTimeZone(zone_id, &icu_error); + ERR("Error code: %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int32_t i18n_ucalendar_get_field_difference ( i18n_ucalendar_h calendar, i18n_udate target, i18n_ucalendar_date_fields_e field, i18n_error_code_e *status ) +{ + if(calendar == NULL) + { + if(NULL != status) { + *status = I18N_ERROR_INVALID_PARAMETER; + } + return 0; + } + + UErrorCode icu_error = U_ZERO_ERROR; + int32_t result = ucal_getFieldDifference(calendar, target, field, &icu_error); + ERR("Error code: %d", icu_error); + + if(NULL != status) { + ERR_MAPPING(icu_error, *status); + } + + return result; +} + +int i18n_ucalendar_get_now ( i18n_udate *date ) +{ + retv_if(date == NULL, I18N_ERROR_INVALID_PARAMETER); + + *date = ucal_getNow(); + return I18N_ERROR_NONE; +} + +// Newly Added APIs +int i18n_ucalendar_timezone_id_enumeration_create ( i18n_system_timezone_type_e zone_type, const char *region, const int32_t *raw_offset, i18n_uenumeration_h *enumeration ) +{ + if(region == NULL || enumeration == NULL){ + return I18N_ERROR_INVALID_PARAMETER; + } + i18n_error_code_e i18n_error; + UErrorCode icu_error = U_ZERO_ERROR; + *enumeration = (i18n_uenumeration_h)ucal_openTimeZoneIDEnumeration (zone_type, region, raw_offset, &icu_error); + ERR("Error code: %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int i18n_ucalendar_timezones_create (i18n_uenumeration_h *enumeration) +{ + if(enumeration == NULL){ + return I18N_ERROR_INVALID_PARAMETER; + } + i18n_error_code_e i18n_error; + UErrorCode icu_error = U_ZERO_ERROR; + *enumeration = (i18n_uenumeration_h)ucal_openTimeZones(&icu_error); + ERR("ErrorCode : %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int i18n_ucalendar_country_timezones_create (const char *country, i18n_uenumeration_h *enumeration) +{ + if (country == NULL || enumeration == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + i18n_error_code_e i18n_error; + UErrorCode icu_error = U_ZERO_ERROR; + *enumeration = (i18n_uenumeration_h)ucal_openCountryTimeZones(country, &icu_error); + ERR("ErrorCode : %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int32_t i18n_ucalendar_get_default_timezone (i18n_uchar *result, int32_t result_capacity) +{ + i18n_error_code_e i18n_error; + UErrorCode icu_error = U_ZERO_ERROR; + int32_t result_ucal_getDefaultTimeZone = ucal_getDefaultTimeZone(result, result_capacity, &icu_error); + ERR("ErrorCode : %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return result_ucal_getDefaultTimeZone; +} + +int i18n_ucalendar_set_timezone ( i18n_ucalendar_h calendar, const i18n_uchar *zone_id, int32_t length) +{ + if (calendar == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + i18n_error_code_e i18n_error; + UErrorCode icu_error = U_ZERO_ERROR; + ucal_setTimeZone(calendar, zone_id, length, &icu_error); + ERR("ErrorCode : %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int32_t i18n_ucalendar_get_timezone_id (const i18n_ucalendar_h calendar, i18n_uchar *result, int32_t result_length) +{ + if (calendar == NULL || result == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + i18n_error_code_e i18n_error; + UErrorCode icu_error = U_ZERO_ERROR; + int32_t result_ucal_getTimeZoneID = ucal_getTimeZoneID(calendar, result, result_length, &icu_error); + ERR("ErrorCode : %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return result_ucal_getTimeZoneID; +} + +int i18n_ucalendar_set_gregorian_change ( i18n_ucalendar_h calendar, i18n_udate date) +{ + if (calendar == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + i18n_error_code_e i18n_error; + UErrorCode icu_error = U_ZERO_ERROR; + ucal_setGregorianChange(calendar, date, &icu_error); + ERR("ErrorCode : %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; + +} + +int i18n_ucalendar_get_gregorian_change ( const i18n_ucalendar_h calendar, i18n_udate *date) +{ + if (calendar == NULL || date == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + i18n_error_code_e i18n_error; + UErrorCode icu_error = U_ZERO_ERROR; + *date = ucal_getGregorianChange(calendar, &icu_error); + ERR("ErrorCode : %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +const char * i18n_ucalendar_get_available ( int32_t locale_index ) +{ + if (locale_index < 0) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + + set_last_result(I18N_ERROR_NONE); + return ucal_getAvailable(locale_index); +} + +int32_t i18n_ucalendar_count_available ( void ) +{ + set_last_result(I18N_ERROR_NONE); + return ucal_countAvailable(); +} + +int i18n_ucalendar_set_date ( i18n_ucalendar_h calendar, int32_t year, int32_t month, int32_t date) +{ + if (calendar == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + i18n_error_code_e i18n_error; + UErrorCode icu_error = U_ZERO_ERROR; + ucal_setDate(calendar, year, month, date, &icu_error); + ERR("ErrorCode : %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int i18n_ucalendar_roll ( i18n_ucalendar_h calendar, i18n_ucalendar_date_fields_e field, int32_t amount) +{ + if (calendar == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + i18n_error_code_e i18n_error; + UErrorCode icu_error = U_ZERO_ERROR; + ucal_roll(calendar, field, amount, &icu_error); + ERR("ErrorCode : %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +i18n_ubool i18n_ucalendar_is_set ( const i18n_ucalendar_h calendar, i18n_ucalendar_date_fields_e field ) +{ + if (calendar == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return false; + } + + set_last_result(I18N_ERROR_NONE); + return ucal_isSet (calendar, field); +} +int i18n_ucalendar_clear_field ( i18n_ucalendar_h calendar, i18n_ucalendar_date_fields_e field ) +{ + if (calendar == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + ucal_clearField (calendar, field); + return I18N_ERROR_NONE; +} + +int i18n_ucalendar_clear ( i18n_ucalendar_h calendar ) +{ + if (calendar == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + ucal_clear(calendar); + return I18N_ERROR_NONE; +} + +int32_t i18n_ucalendar_get_limit ( const i18n_ucalendar_h calendar, i18n_ucalendar_date_fields_e field, i18n_ucalendar_limit_type_e type) +{ + if (calendar == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + int32_t result_ucal_getLimit = 0; + switch (field) { + case I18N_UCALENDAR_YEAR_WOY: + case I18N_UCALENDAR_DOW_LOCAL: + case I18N_UCALENDAR_EXTENDED_YEAR: + case I18N_UCALENDAR_JULIAN_DAY: + case I18N_UCALENDAR_MILLISECONDS_IN_DAY: + case I18N_UCALENDAR_IS_LEAP_MONTH: + case I18N_UCALENDAR_FIELD_COUNT: + { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + ERR("Unsupported filed"); + break; + } + default: + { + i18n_error_code_e i18n_error = I18N_ERROR_NONE; + UErrorCode icu_error = U_ZERO_ERROR; + int32_t limit = ucal_getLimit(calendar, field, type, &icu_error); + ERR("ErrorCode : %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + if(i18n_error == I18N_ERROR_NONE) + result_ucal_getLimit = limit; + } + } + + return result_ucal_getLimit; +} + +const char *i18n_ucalendar_get_locale_by_type ( const i18n_ucalendar_h calendar, i18n_ulocale_data_locale_type_e type ) +{ + if (calendar == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + i18n_error_code_e i18n_error; + UErrorCode icu_error = U_ZERO_ERROR; + const char *result_ucal_getLocaleByType = ucal_getLocaleByType(calendar, type, &icu_error); + ERR("ErrorCode : %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return result_ucal_getLocaleByType; +} + +const char *i18n_ucalendar_get_tz_data_version (void) +{ + i18n_error_code_e i18n_error; + UErrorCode icu_error = U_ZERO_ERROR; + const char *result_ucal_getTZDataVersion = ucal_getTZDataVersion(&icu_error); + ERR("ErrorCode : %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return result_ucal_getTZDataVersion; +} + +int32_t i18n_ucalendar_get_canonical_timezone_id ( const i18n_uchar *id, int32_t length, i18n_uchar *result, int32_t result_capacity, i18n_ubool *is_system_id ) +{ + if (id == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + i18n_error_code_e i18n_error; + UErrorCode icu_error = U_ZERO_ERROR; + int32_t result_ucal_getCanonicalTimeZoneID = ucal_getCanonicalTimeZoneID(id, length, result, result_capacity, is_system_id, &icu_error); + ERR("ErrorCode : %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return result_ucal_getCanonicalTimeZoneID ; +} + +const char *i18n_ucalendar_get_type ( const i18n_ucalendar_h calendar ) +{ + if (calendar == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + i18n_error_code_e i18n_error; + UErrorCode icu_error = U_ZERO_ERROR; + const char *result_ucal_getType = ucal_getType(calendar, &icu_error); + ERR("ErrorCode : %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return result_ucal_getType; +} + +int i18n_ucalendar_get_keyword_values_for_locale ( const char *key, const char *locale, i18n_ubool commonly_used, i18n_uenumeration_h * enumeration ) +{ + if (key == NULL || enumeration == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + i18n_error_code_e i18n_error; + UErrorCode icu_error = U_ZERO_ERROR; + *enumeration = (i18n_uenumeration_h )ucal_getKeywordValuesForLocale(key, locale, commonly_used, &icu_error); + ERR("ErrorCode : %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int i18n_ucalendar_get_day_of_week_type ( const i18n_ucalendar_h calendar, i18n_ucalendar_days_of_week_e day_of_week, i18n_ucalendar_weekday_type_e *weekday_type ) +{ + if (calendar == NULL || weekday_type == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + i18n_error_code_e i18n_error; + UErrorCode icu_error = U_ZERO_ERROR; + *weekday_type = ucal_getDayOfWeekType(calendar, day_of_week, &icu_error); + ERR("ErrorCode : %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int32_t i18n_ucalendar_get_weekend_transition ( const i18n_ucalendar_h calendar, i18n_ucalendar_days_of_week_e day_of_week ) +{ + if (calendar == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + i18n_error_code_e i18n_error; + UErrorCode icu_error = U_ZERO_ERROR; + int32_t result_ucal_getWeekendTransition = ucal_getWeekendTransition(calendar, day_of_week, &icu_error); + ERR("ErrorCode : %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return result_ucal_getWeekendTransition; +} + +i18n_ubool i18n_ucalendar_is_weekend ( i18n_ucalendar_h calendar, i18n_udate date ) +{ + if (calendar == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + i18n_error_code_e i18n_error; + UErrorCode icu_error = U_ZERO_ERROR; + i18n_ubool result_ucal_isWeekend = ucal_isWeekend(calendar, date, &icu_error); + ERR("ErrorCode : %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return result_ucal_isWeekend; +} + +i18n_ubool i18n_ucalendar_get_timezone_transition_date ( const i18n_ucalendar_h calendar, i18n_utimezone_transition_type_e type, i18n_udate *transition) +{ + if (calendar == NULL || transition == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + i18n_error_code_e i18n_error; + UErrorCode icu_error = U_ZERO_ERROR; + i18n_ubool result_ucal_getTimeZoneTransitionDate = ucal_getTimeZoneTransitionDate(calendar, type, transition, &icu_error); + ERR("ErrorCode : %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return result_ucal_getTimeZoneTransitionDate; +} diff --git a/src/utils_i18n_uchar.c b/src/utils_i18n_uchar.c new file mode 100755 index 0000000..eedb1c8 --- /dev/null +++ b/src/utils_i18n_uchar.c @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + +int i18n_uchar_get_int_property_value ( i18n_uchar32 c, i18n_uchar_uproperty_e which, int32_t *property_val ) +{ + retv_if (property_val == NULL, I18N_ERROR_INVALID_PARAMETER); + *property_val = u_getIntPropertyValue(c, which); + + return I18N_ERROR_NONE; +} + +int i18n_uchar_get_ublock_code ( i18n_uchar32 c, i18n_uchar_ublock_code_e *block_val ) +{ + retv_if (block_val == NULL, I18N_ERROR_INVALID_PARAMETER); + *block_val = ublock_getCode(c); + + return I18N_ERROR_NONE; +} diff --git a/src/utils_i18n_ucollator.c b/src/utils_i18n_ucollator.c new file mode 100755 index 0000000..7cf1b01 --- /dev/null +++ b/src/utils_i18n_ucollator.c @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + +int i18n_ucollator_destroy ( i18n_ucollator_h collator ) +{ + retv_if(collator == NULL, I18N_ERROR_INVALID_PARAMETER); + + ucol_close(collator); + + return I18N_ERROR_NONE; +} + +int i18n_ucollator_equal ( const i18n_ucollator_h collator, const i18n_uchar *src, int32_t src_len, const i18n_uchar *target, int32_t target_len, i18n_ubool *equal ) +{ + retv_if(collator == NULL, I18N_ERROR_INVALID_PARAMETER); + + *equal = ucol_equal(collator, src, src_len, target, target_len); + + return I18N_ERROR_NONE; +} + +int i18n_ucollator_create ( const char *locale, i18n_ucollator_h *collator ) +{ + retv_if (collator == NULL, I18N_ERROR_INVALID_PARAMETER); + + i18n_error_code_e err = I18N_ERROR_NONE; + *collator = ucol_open(locale, (UErrorCode*)&err); + int result = _i18n_error_mapping(err); + + return result; +} + +int i18n_ucollator_set_attribute( i18n_ucollator_h collator, i18n_ucollator_attribute_e attr, i18n_ucollator_attribute_value_e val ) +{ + retv_if(collator == NULL, I18N_ERROR_INVALID_PARAMETER); + + i18n_error_code_e err = I18N_ERROR_NONE; + ucol_setAttribute(collator, attr, val, (UErrorCode*)&err); + int result = _i18n_error_mapping(err); + + return result; +} + +int i18n_ucollator_set_strength ( i18n_ucollator_h collator, i18n_ucollator_strength_e strength ) +{ + retv_if(collator == NULL, I18N_ERROR_INVALID_PARAMETER); + + ucol_setStrength(collator, strength); + + return I18N_ERROR_NONE; +} + +int i18n_ucollator_str_collator ( const i18n_ucollator_h collator, const i18n_uchar *src, int32_t src_len, const i18n_uchar *target, int32_t target_len, i18n_ucollator_result_e *result ) +{ + retv_if(collator == NULL, I18N_ERROR_INVALID_PARAMETER); + + *result = ucol_strcoll(collator, src, src_len, target, target_len); + + return I18N_ERROR_NONE; +} diff --git a/src/utils_i18n_udate.c b/src/utils_i18n_udate.c new file mode 100644 index 0000000..afdbf48 --- /dev/null +++ b/src/utils_i18n_udate.c @@ -0,0 +1,343 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + +int i18n_udate_create ( i18n_udate_format_style_e time_style, i18n_udate_format_style_e date_style, const char *locale, const i18n_uchar *tz_id, int32_t tz_id_len, const i18n_uchar *pattern, int32_t pattern_len, i18n_udate_format_h *format ) +{ + retv_if( format == NULL, I18N_ERROR_INVALID_PARAMETER ); + + UErrorCode icu_error = U_ZERO_ERROR; + *format = udat_open(time_style, date_style, locale, tz_id, tz_id_len, pattern, pattern_len, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int i18n_udate_destroy ( i18n_udate_format_h format ) +{ + retv_if( format == NULL, I18N_ERROR_INVALID_PARAMETER ); + + udat_close(format); + return I18N_ERROR_NONE; +} + +int i18n_udate_format_date ( const i18n_udate_format_h format, i18n_udate date_to_format, i18n_uchar *result, int32_t result_len, i18n_ufield_position_h pos, int32_t *buf_size_needed ) +{ + retv_if( format == NULL || buf_size_needed == NULL, I18N_ERROR_INVALID_PARAMETER ); + + UErrorCode icu_error = U_ZERO_ERROR; + *buf_size_needed = udat_format(format, date_to_format, result, result_len, (UFieldPosition*)pos, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +// Newly Added APIs +int i18n_udate_to_calendar_date_field ( i18n_udate_format_field_e field, i18n_ucalendar_date_fields_e *date_field_type ) +{ + if (date_field_type == NULL) + { + return I18N_ERROR_INVALID_PARAMETER; + } + + switch (field) { + case I18N_UDATE_FORMAT_TIMEZONE_LOCALIZED_GMT_OFFSET_FIELD: + case I18N_UDATE_FORMAT_TIMEZONE_ISO_FIELD: + case I18N_UDATE_FORMAT_TIMEZONE_ISO_LOCAL_FIELD: + case I18N_UDATE_FORMAT_FIELD_COUNT: + ERR("Unsupported field"); + return I18N_ERROR_INVALID_PARAMETER; + default: + *date_field_type = (i18n_ucalendar_date_fields_e)udat_toCalendarDateField(field); + } + + return I18N_ERROR_NONE; +} + +int i18n_udate_clone ( const i18n_udate_format_h format, i18n_udate_format_h *format_clone ) +{ + if (format == NULL || format_clone == NULL) + { + return I18N_ERROR_INVALID_PARAMETER; + } + + UErrorCode icu_error = U_ZERO_ERROR; + *format_clone = (i18n_udate_format_h)udat_clone((const UDateFormat *)format, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int i18n_udate_parse ( const i18n_udate_format_h format, const i18n_uchar *text, int32_t text_length, int32_t *parse_pos, i18n_udate *parsed_date ) +{ + if (format == NULL || text == NULL || parsed_date == NULL) + { + return I18N_ERROR_INVALID_PARAMETER; + } + + UErrorCode icu_error = U_ZERO_ERROR; + *parsed_date = udat_parse((const UDateFormat *)format, text, text_length, parse_pos, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int i18n_udate_parse_calendar (const i18n_udate_format_h format, i18n_ucalendar_h * calendar, const i18n_uchar *text, int32_t text_length, int32_t *parse_pos ) +{ + if (format == NULL || calendar == NULL || text == NULL || text_length < -1) + { + return I18N_ERROR_INVALID_PARAMETER; + } + + UErrorCode icu_error = U_ZERO_ERROR; + udat_parseCalendar((const UDateFormat *)format, calendar, text, text_length, parse_pos, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +i18n_ubool i18n_udate_is_lenient ( const i18n_udate_format_h format ) +{ + if (format == NULL) + { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return false; + } + + set_last_result(I18N_ERROR_NONE); + return udat_isLenient((const UDateFormat *)format); +} + +int i18n_udate_set_lenient ( i18n_udate_format_h format, i18n_ubool is_lenient ) +{ + if (format == NULL) + { + return I18N_ERROR_INVALID_PARAMETER; + } + udat_setLenient((UDateFormat *)format, is_lenient); + return I18N_ERROR_NONE; +} + +int i18n_udate_get_calendar ( const i18n_udate_format_h format, i18n_ucalendar_h *calendar) +{ + if (format == NULL || calendar == NULL) + { + return I18N_ERROR_INVALID_PARAMETER; + } + *calendar = (i18n_ucalendar_h)udat_getCalendar((const UDateFormat *)format); + + return I18N_ERROR_NONE; +} + +int i18n_udate_set_calendar ( i18n_udate_format_h format, const i18n_ucalendar_h calendar_to_set ) +{ + if (format == NULL || calendar_to_set == NULL) + { + return I18N_ERROR_INVALID_PARAMETER; + } + udat_setCalendar((UDateFormat *)format, (const UCalendar *)calendar_to_set); + return I18N_ERROR_NONE; +} + +int i18n_udate_get_number_format ( const i18n_udate_format_h format, i18n_unumber_format_h *number_format ) +{ + if (format == NULL || number_format == NULL) + { + return I18N_ERROR_INVALID_PARAMETER; + } + set_last_result(I18N_ERROR_NONE); + *number_format = (i18n_unumber_format_h)udat_getNumberFormat((const UDateFormat *)format); + return I18N_ERROR_NONE; +} + +int i18n_udate_set_number_format ( i18n_udate_format_h format, const i18n_unumber_format_h number_format_to_set ) +{ + if (format == NULL || number_format_to_set == NULL) + { + return I18N_ERROR_INVALID_PARAMETER; + } + udat_setNumberFormat((UDateFormat *)format, (const UNumberFormat *)number_format_to_set); + return I18N_ERROR_NONE; +} + +const char *i18n_udate_get_available ( int32_t locale_index ) +{ + if(locale_index < 0) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + set_last_result(I18N_ERROR_NONE); + return udat_getAvailable(locale_index); +} + +int32_t i18n_udate_count_available ( void ) +{ + set_last_result(I18N_ERROR_NONE); + return udat_countAvailable(); +} + +int i18n_udate_get_2digit_year_start ( const i18n_udate_format_h format, i18n_udate *year ) +{ + if (format == NULL || year == NULL) + { + return I18N_ERROR_INVALID_PARAMETER; + } + + UErrorCode icu_error = U_ZERO_ERROR; + *year = (i18n_udate)udat_get2DigitYearStart((const UDateFormat *)format, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int i18n_udate_set_2digit_year_start ( i18n_udate_format_h format, i18n_udate date ) +{ + if (format == NULL) + { + return I18N_ERROR_INVALID_PARAMETER; + } + + UErrorCode icu_error = U_ZERO_ERROR; + udat_set2DigitYearStart((UDateFormat *)format, date, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int32_t i18n_udate_to_pattern ( const i18n_udate_format_h format, i18n_ubool localized, i18n_uchar *result, int32_t result_length ) +{ + if (format == NULL) + { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return -1; + } + + UErrorCode icu_error = U_ZERO_ERROR; + int32_t needed_buffer_size = udat_toPattern((const UDateFormat *)format, localized, result, result_length, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return needed_buffer_size; +} + +int i18n_udate_apply_pattern ( i18n_udate_format_h format, i18n_ubool localized, const i18n_uchar *pattern, int32_t pattern_length ) +{ + if (format == NULL) + { + return I18N_ERROR_INVALID_PARAMETER; + } + udat_applyPattern((UDateFormat *)format, localized, pattern, pattern_length); + return I18N_ERROR_NONE; +} + +int32_t i18n_udate_get_symbols ( const i18n_udate_format_h format, i18n_udate_format_symbol_type_e type, int32_t symbol_index, i18n_uchar *result, int32_t result_length ) +{ + if (format == NULL) + { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return -1; + } + + UErrorCode icu_error = U_ZERO_ERROR; + int32_t needed_buffer_size = udat_getSymbols((const UDateFormat *)format, type, symbol_index, result, result_length, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return needed_buffer_size; +} + +int32_t i18n_udate_count_symbols ( const i18n_udate_format_h format, i18n_udate_format_symbol_type_e type ) +{ + if (format == NULL) + { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + set_last_result(I18N_ERROR_NONE); + return udat_countSymbols((const UDateFormat *)format, type); +} + +int i18n_udate_set_symbols ( i18n_udate_format_h format, i18n_udate_format_symbol_type_e type, int32_t symbol_index, i18n_uchar *value, int32_t value_length ) +{ + if (format == NULL || symbol_index < 0) + { + return I18N_ERROR_INVALID_PARAMETER; + } + + UErrorCode icu_error = U_ZERO_ERROR; + udat_setSymbols((UDateFormat *)format, type, symbol_index, value, value_length, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +const char *i18n_udate_get_locale_by_type ( const i18n_udate_format_h format, i18n_ulocale_data_locale_type_e type ) +{ + if (format == NULL) + { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + + UErrorCode icu_error = U_ZERO_ERROR; + const char *locale_name = udat_getLocaleByType((const UDateFormat *)format, type, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return locale_name; +} + +int i18n_udate_set_context ( i18n_udate_format_h format, i18n_udisplay_context_e value ) +{ + if (format == NULL) + { + return I18N_ERROR_INVALID_PARAMETER; + } + + UErrorCode icu_error = U_ZERO_ERROR; + udat_setContext((UDateFormat *)format, value, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} diff --git a/src/utils_i18n_udatepg.c b/src/utils_i18n_udatepg.c new file mode 100755 index 0000000..87a242e --- /dev/null +++ b/src/utils_i18n_udatepg.c @@ -0,0 +1,345 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + +int i18n_udatepg_create ( const char *locale, i18n_udatepg_h *dtpg ) +{ + retv_if(dtpg == NULL, I18N_ERROR_INVALID_PARAMETER); + + UErrorCode icu_error = U_ZERO_ERROR; + *dtpg = udatpg_open(locale, &icu_error); + + return _i18n_error_mapping(icu_error); +} + +int i18n_udatepg_destroy ( i18n_udatepg_h dtpg ) +{ + retv_if(dtpg == NULL, I18N_ERROR_INVALID_PARAMETER); + + udatpg_close(dtpg); + + return I18N_ERROR_NONE; +} + +int i18n_udatepg_get_best_pattern ( i18n_udatepg_h dtpg, const i18n_uchar *skeleton, int32_t len, i18n_uchar *best_pattern, int32_t capacity, int32_t *best_pattern_len ) +{ + retv_if(dtpg == NULL, I18N_ERROR_INVALID_PARAMETER); + retv_if(skeleton == NULL, I18N_ERROR_INVALID_PARAMETER); + retv_if(len < 0, I18N_ERROR_INVALID_PARAMETER); + retv_if(capacity < 0, I18N_ERROR_INVALID_PARAMETER); + + UErrorCode icu_error = U_ZERO_ERROR; + *best_pattern_len = udatpg_getBestPattern(dtpg, skeleton, len, best_pattern, capacity, &icu_error); + + return _i18n_error_mapping(icu_error); +} + +// Newly Added APIs + +int i18n_udatepg_create_empty (i18n_udatepg_h *dtpg) +{ + if (dtpg == NULL) + { + return I18N_ERROR_INVALID_PARAMETER; + } + UErrorCode icu_error = U_ZERO_ERROR; + *dtpg = (i18n_udatepg_h)udatpg_openEmpty(&icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int i18n_udatepg_clone ( const i18n_udatepg_h dtpg, i18n_udatepg_h *dtpg_clone ) +{ + if (dtpg == NULL || NULL == dtpg_clone) + { + return I18N_ERROR_INVALID_PARAMETER; + } + + UErrorCode icu_error = U_ZERO_ERROR; + *dtpg_clone = (i18n_udatepg_h)udatpg_clone((UDateTimePatternGenerator *)dtpg, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int32_t i18n_udatepg_get_best_pattern_with_options ( i18n_udatepg_h dtpg, const i18n_uchar *skeleton, int32_t length, + i18n_udatepg_date_time_pattern_match_options_e options, i18n_uchar *best_pattern, int32_t capacity ) +{ + if (dtpg == NULL || skeleton == NULL || length < 0 || capacity < 0) + { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + UErrorCode icu_error = U_ZERO_ERROR; + int32_t length_of_best_pattern = udatpg_getBestPatternWithOptions((UDateTimePatternGenerator *)dtpg, skeleton, length, options, best_pattern, capacity, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return length_of_best_pattern; +} + +int32_t i18n_udatepg_get_skeleton ( i18n_udatepg_h dtpg, const i18n_uchar *pattern, int32_t length, + i18n_uchar *skeleton, int32_t capacity ) +{ + if (dtpg == NULL || pattern == NULL || length < 0 || capacity < 0) + { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + UErrorCode icu_error = U_ZERO_ERROR; + int32_t length_of_skeleton = udatpg_getSkeleton((UDateTimePatternGenerator *)dtpg, pattern, length, skeleton, capacity, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return length_of_skeleton; +} + +int32_t i18n_udatepg_get_base_skeleton ( i18n_udatepg_h dtpg, const i18n_uchar *pattern, int32_t length, + i18n_uchar *base_skeleton, int32_t capacity ) +{ + if (dtpg == NULL || pattern == NULL || capacity < 0) + { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + UErrorCode icu_error = U_ZERO_ERROR; + int32_t length_of_skeleton = udatpg_getBaseSkeleton((UDateTimePatternGenerator *)dtpg, pattern, length, base_skeleton, capacity, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return length_of_skeleton; +} + +int32_t i18n_udatepg_add_pattern ( i18n_udatepg_h dtpg, const i18n_uchar *pattern, int32_t pattern_length, + i18n_ubool override, i18n_uchar *conflicting_pattern, int32_t capacity, i18n_udatepg_date_time_pattern_conflict_e *conflict_status ) +{ + if (dtpg == NULL || pattern == NULL || pattern_length < 0 || capacity < 0) + { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return -1; + } + int32_t confliction_pattern_length; + UErrorCode icu_error = U_ZERO_ERROR; + *conflict_status = udatpg_addPattern((UDateTimePatternGenerator *)dtpg, pattern, pattern_length, override, conflicting_pattern, capacity, &confliction_pattern_length, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return confliction_pattern_length; +} + +int i18n_udatepg_set_append_item_format ( i18n_udatepg_h dtpg, i18n_udatepg_date_time_pattern_field_e field, + const i18n_uchar *value, int32_t length ) +{ + if (dtpg == NULL || field < I18N_UDATEPG_ERA_FIELD || field >= I18N_UDATEPG_FIELD_COUNT + || value == NULL || length < 0) + { + return I18N_ERROR_INVALID_PARAMETER; + } + + udatpg_setAppendItemFormat((UDateTimePatternGenerator *)dtpg, field, value, length); + return I18N_ERROR_NONE; +} + +const i18n_uchar *i18n_udatepg_get_append_item_format ( const i18n_udatepg_h dtpg, i18n_udatepg_date_time_pattern_field_e field, + int32_t *pattern_length ) +{ + if (dtpg == NULL || field < I18N_UDATEPG_ERA_FIELD || field >= I18N_UDATEPG_FIELD_COUNT) + { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + + set_last_result(I18N_ERROR_NONE); + return udatpg_getAppendItemFormat((UDateTimePatternGenerator *)dtpg, field, pattern_length); +} + +int i18n_udatepg_set_append_item_name ( i18n_udatepg_h dtpg, i18n_udatepg_date_time_pattern_field_e field, + const i18n_uchar *value, int32_t length ) +{ + if (dtpg == NULL || field < I18N_UDATEPG_ERA_FIELD || field >= I18N_UDATEPG_FIELD_COUNT + || value == NULL || length < 0) + { + return I18N_ERROR_INVALID_PARAMETER; + } + + udatpg_setAppendItemName((UDateTimePatternGenerator *)dtpg, field, value, length); + return I18N_ERROR_NONE; +} + +const i18n_uchar *i18n_udatepg_get_append_item_name ( const i18n_udatepg_h dtpg, + i18n_udatepg_date_time_pattern_field_e field, int32_t *pattern_length ) +{ + if (dtpg == NULL || field < I18N_UDATEPG_ERA_FIELD || field >= I18N_UDATEPG_FIELD_COUNT) + { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + + set_last_result(I18N_ERROR_NONE); + return udatpg_getAppendItemName((UDateTimePatternGenerator *)dtpg, field, pattern_length); +} + +int i18n_udatepg_set_date_time_format ( const i18n_udatepg_h dtpg, const i18n_uchar *date_time_format, int32_t length ) +{ + if (dtpg == NULL || date_time_format == NULL || length < 0) + { + return I18N_ERROR_INVALID_PARAMETER; + } + + udatpg_setDateTimeFormat((UDateTimePatternGenerator *)dtpg, date_time_format, length); + return I18N_ERROR_NONE; +} + +const i18n_uchar *i18n_udatepg_get_date_time_format ( const i18n_udatepg_h dtpg, int32_t *pattern_length ) +{ + if (dtpg == NULL) + { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + + set_last_result(I18N_ERROR_NONE); + return udatpg_getDateTimeFormat((UDateTimePatternGenerator *)dtpg, pattern_length); +} + +int i18n_udatepg_set_decimal ( i18n_udatepg_h dtpg, const i18n_uchar *decimal, int32_t length ) +{ + if (dtpg == NULL || decimal == NULL || length < 0) + { + return I18N_ERROR_INVALID_PARAMETER; + } + + udatpg_setDecimal((UDateTimePatternGenerator *)dtpg, decimal, length); + return I18N_ERROR_NONE; +} + +const i18n_uchar *i18n_udatepg_get_decimal ( const i18n_udatepg_h dtpg, int32_t *pattern_length ) +{ + if (dtpg == NULL) + { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + + set_last_result(I18N_ERROR_NONE); + return udatpg_getDecimal((UDateTimePatternGenerator *)dtpg, pattern_length); +} + +int32_t i18n_udatepg_replace_field_types ( i18n_udatepg_h dtpg, const i18n_uchar *pattern, int32_t pattern_length, + const i18n_uchar *skeleton, int32_t skeleton_length, i18n_uchar *dest, + int32_t dest_capacity ) +{ + if (dtpg == NULL || pattern == NULL || pattern_length < 0 || skeleton == NULL + || skeleton_length < 0 || dest_capacity < 0) + { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + UErrorCode icu_error = U_ZERO_ERROR; + int32_t length_of_dest = udatpg_replaceFieldTypes((UDateTimePatternGenerator *)dtpg, pattern, pattern_length, skeleton, skeleton_length, dest, dest_capacity, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return length_of_dest; +} + +int32_t i18n_udatepg_replace_field_types_with_options ( i18n_udatepg_h dtpg, const i18n_uchar *pattern, int32_t pattern_length, + const i18n_uchar *skeleton, int32_t skeleton_length, i18n_udatepg_date_time_pattern_match_options_e options, + i18n_uchar *dest, int32_t dest_capacity ) +{ + if (dtpg == NULL || pattern == NULL || pattern_length < 0 || skeleton == NULL + || skeleton_length < 0 || dest_capacity < 0) + { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + UErrorCode icu_error = U_ZERO_ERROR; + int32_t length_of_dest = udatpg_replaceFieldTypesWithOptions((UDateTimePatternGenerator *)dtpg, pattern, pattern_length, skeleton, skeleton_length, options, dest, dest_capacity, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return length_of_dest; +} + +int i18n_udatepg_skeletons_create ( const i18n_udatepg_h dtpg, i18n_uenumeration_h *enumeration ) +{ + if (dtpg == NULL || NULL == enumeration) + { + return I18N_ERROR_INVALID_PARAMETER; + } + + UErrorCode icu_error = U_ZERO_ERROR; + *enumeration = udatpg_openSkeletons((const UDateTimePatternGenerator *)dtpg, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int i18n_udatepg_base_skeletons_create ( const i18n_udatepg_h dtpg, i18n_uenumeration_h *enumeration ) +{ + if (dtpg == NULL || NULL == enumeration) + { + return I18N_ERROR_INVALID_PARAMETER; + } + + UErrorCode icu_error = U_ZERO_ERROR; + *enumeration = udatpg_openBaseSkeletons((const UDateTimePatternGenerator *)dtpg, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +const i18n_uchar *i18n_udatepg_get_pattern_for_skeleton ( const i18n_udatepg_h dtpg, const i18n_uchar *skeleton, + int32_t skeleton_length, int32_t *pattern_length ) +{ + if (dtpg == NULL || skeleton == NULL || skeleton_length < 0) + { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + + set_last_result(I18N_ERROR_NONE); + return udatpg_getPatternForSkeleton((const UDateTimePatternGenerator *)dtpg, skeleton, skeleton_length, pattern_length); +} diff --git a/src/utils_i18n_uenumeration.c b/src/utils_i18n_uenumeration.c new file mode 100755 index 0000000..20ebd11 --- /dev/null +++ b/src/utils_i18n_uenumeration.c @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + +int i18n_uenumeration_destroy ( i18n_uenumeration_h enumeration ) +{ + if (enumeration == NULL) + { + return I18N_ERROR_INVALID_PARAMETER; + } + + uenum_close((UEnumeration *)enumeration); + return I18N_ERROR_NONE; +} + +int32_t i18n_uenumeration_count ( i18n_uenumeration_h enumeration ) +{ + if (enumeration == NULL) + { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return -1; + } + + UErrorCode icu_error = U_ZERO_ERROR; + int32_t number_of_elements = uenum_count((UEnumeration *)enumeration, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return number_of_elements; +} + +const i18n_uchar *i18n_uenumeration_unext ( i18n_uenumeration_h enumeration, int32_t *result_length ) +{ + if (enumeration == NULL) + { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + + UErrorCode icu_error = U_ZERO_ERROR; + const UChar *ustring = uenum_unext((UEnumeration *)enumeration, result_length, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return ustring; +} + +const char *i18n_uenumeration_next ( i18n_uenumeration_h enumeration, int32_t *result_length ) +{ + if (enumeration == NULL) + { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + + UErrorCode icu_error = U_ZERO_ERROR; + const char *string = uenum_next((UEnumeration *)enumeration, result_length, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return string; +} + +int i18n_uenumeration_reset ( i18n_uenumeration_h enumeration ) +{ + if (enumeration == NULL) + { + return I18N_ERROR_INVALID_PARAMETER; + } + + UErrorCode icu_error = U_ZERO_ERROR; + uenum_reset((UEnumeration *)enumeration, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int i18n_uenumeration_uchar_strings_enumeration_create ( const i18n_uchar *const strings[], int32_t count, i18n_uenumeration_h *enumeration ) +{ + if (count < 0 || NULL == enumeration) + { + return I18N_ERROR_INVALID_PARAMETER; + } + + UErrorCode icu_error = U_ZERO_ERROR; + *enumeration = uenum_openUCharStringsEnumeration(strings, count, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int i18n_uenumeration_char_strings_enumeration_create ( const char *const strings[], int32_t count, i18n_uenumeration_h *enumeration ) +{ + if (count < 0 || NULL == enumeration) + { + return I18N_ERROR_INVALID_PARAMETER; + } + + UErrorCode icu_error = U_ZERO_ERROR; + *enumeration = (i18n_uenumeration_h)uenum_openCharStringsEnumeration(strings, count, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} diff --git a/src/utils_i18n_ulocale.c b/src/utils_i18n_ulocale.c new file mode 100755 index 0000000..d77f8e6 --- /dev/null +++ b/src/utils_i18n_ulocale.c @@ -0,0 +1,443 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + +int i18n_ulocale_get_default (const char **locale) +{ + retv_if (locale == NULL, I18N_ERROR_INVALID_PARAMETER); + + *locale = uloc_getDefault(); + + return I18N_ERROR_NONE; +} + +int i18n_ulocale_set_default (const char *locale_id) +{ + UErrorCode icu_error = U_ZERO_ERROR; + uloc_setDefault(locale_id, &icu_error); + + return _i18n_error_mapping(icu_error); +} + +int i18n_ulocale_get_language (const char *locale_id, char *language, int32_t language_capacity, int32_t *buf_size_language) +{ + retv_if(buf_size_language == NULL || language == NULL, I18N_ERROR_INVALID_PARAMETER); + + UErrorCode icu_error = U_ZERO_ERROR; + *buf_size_language = uloc_getLanguage(locale_id, language, language_capacity, &icu_error); + + return _i18n_error_mapping(icu_error); +} + +int32_t i18n_ulocale_get_country (const char *locale_id, char *country, int32_t country_capacity, int *error) +{ + if(NULL == country) { + if(NULL != error) { + *error = I18N_ERROR_INVALID_PARAMETER; + } + return 0; + } + + UErrorCode icu_error = U_ZERO_ERROR; + int32_t result = uloc_getCountry(locale_id, country, country_capacity, &icu_error); + if(NULL != error) { + *error = _i18n_error_mapping(icu_error); + } + + return result; +} + +int i18n_ulocale_get_display_name (const char *locale_id, const char *in_locale_id, i18n_uchar *result_w, int32_t max_result_size, int32_t *buf_size_display_name) +{ + retv_if(buf_size_display_name == NULL, I18N_ERROR_INVALID_PARAMETER); + + UErrorCode icu_error = U_ZERO_ERROR; + *buf_size_display_name = uloc_getDisplayName(locale_id, in_locale_id, result_w, max_result_size, &icu_error); + + return _i18n_error_mapping(icu_error); +} + +const char* i18n_ulocale_get_available (int32_t n) +{ + if(n < 0){ + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + set_last_result(I18N_ERROR_NONE); + return uloc_getAvailable(n); +} + +int32_t i18n_ulocale_count_available (void) +{ + set_last_result(I18N_ERROR_NONE); + return uloc_countAvailable(); +} + +// Newly Added APIs + +int32_t i18n_ulocale_get_script (const char *locale_id, char *script, int32_t script_capacity) +{ + if(NULL == script || script_capacity < 0){ + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return -1; + } + + UErrorCode icu_error = U_ZERO_ERROR; + int32_t needed_buffer_size = uloc_getScript(locale_id, script, script_capacity, &icu_error); + ERR("Error Code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return needed_buffer_size; +} + +int32_t i18n_ulocale_get_variant (const char *locale_id, char *variant, int32_t variant_capacity) +{ + if(NULL == variant || variant_capacity < 0){ + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return -1; + } + + UErrorCode icu_error = U_ZERO_ERROR; + int32_t needed_buffer_size = uloc_getVariant(locale_id, variant, variant_capacity, &icu_error); + ERR("Error Code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return needed_buffer_size; +} + +int32_t i18n_ulocale_get_name (const char *locale_id, char *name, int32_t name_capacity) +{ + UErrorCode icu_error = U_ZERO_ERROR; + int32_t needed_buffer_size = uloc_getName(locale_id, name, name_capacity, &icu_error); + ERR("Error Code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return needed_buffer_size; +} + +int32_t i18n_ulocale_canonicalize (const char *locale_id, char *name, int32_t name_capacity) +{ + UErrorCode icu_error = U_ZERO_ERROR; + int32_t needed_buffer_size = uloc_canonicalize(locale_id, name, name_capacity, &icu_error); + ERR("Error Code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return needed_buffer_size; +} + +const char *i18n_ulocale_get_iso3_language (const char *locale_id) +{ + set_last_result(I18N_ERROR_NONE); + return uloc_getISO3Language(locale_id); +} + +const char *i18n_ulocale_get_iso3_country (const char *locale_id) +{ + set_last_result(I18N_ERROR_NONE); + return uloc_getISO3Country(locale_id); +} + +uint32_t i18n_ulocale_get_lcid (const char *locale_id) +{ + set_last_result(I18N_ERROR_NONE); + return uloc_getLCID(locale_id); +} + +int32_t i18n_ulocale_get_display_language (const char *locale, const char *display_locale, i18n_uchar *language, + int32_t language_capacity) +{ + UErrorCode icu_error = U_ZERO_ERROR; + int32_t needed_buffer_size = uloc_getDisplayLanguage(locale, display_locale, language, language_capacity, &icu_error); + ERR("Error Code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return needed_buffer_size; +} + +int32_t i18n_ulocale_get_display_script (const char *locale, const char *display_locale, i18n_uchar *script, + int32_t script_capacity) +{ + UErrorCode icu_error = U_ZERO_ERROR; + int32_t needed_buffer_size = uloc_getDisplayScript(locale, display_locale, script, script_capacity, &icu_error); + ERR("Error Code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return needed_buffer_size; +} + +int32_t i18n_ulocale_get_display_country (const char *locale, const char *display_locale, i18n_uchar *country, + int32_t country_capacity) +{ + UErrorCode icu_error = U_ZERO_ERROR; + int32_t needed_buffer_size = uloc_getDisplayCountry(locale, display_locale, country, country_capacity, &icu_error); + ERR("Error Code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return needed_buffer_size; +} + +int32_t i18n_ulocale_get_display_variant (const char *locale, const char *display_locale, i18n_uchar *variant, + int32_t variant_capacity) +{ + UErrorCode icu_error = U_ZERO_ERROR; + int32_t needed_buffer_size = uloc_getDisplayVariant(locale, display_locale, variant, variant_capacity, &icu_error); + ERR("Error Code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return needed_buffer_size; +} + +int32_t i18n_ulocale_get_display_keyword (const char *keyword, const char *display_locale, i18n_uchar *dest, + int32_t dest_capacity) +{ + UErrorCode icu_error = U_ZERO_ERROR; + int32_t needed_buffer_size = uloc_getDisplayKeyword(keyword, display_locale, dest, dest_capacity, &icu_error); + ERR("Error Code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return needed_buffer_size; +} + +int32_t i18n_ulocale_get_display_keyword_value (const char *locale, const char *keyword, const char *display_locale, + i18n_uchar *dest, int32_t dest_capacity) +{ + UErrorCode icu_error = U_ZERO_ERROR; + int32_t needed_buffer_size = uloc_getDisplayKeywordValue(locale, keyword, display_locale, dest, dest_capacity, &icu_error); + ERR("Error Code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return needed_buffer_size; +} + +const char * const *i18n_ulocale_get_iso_languages (void) +{ + set_last_result(I18N_ERROR_NONE); + return uloc_getISOLanguages(); +} + +const char * const *i18n_ulocale_get_iso_countries (void) +{ + set_last_result(I18N_ERROR_NONE); + return uloc_getISOCountries(); +} + +int32_t i18n_ulocale_get_parent (const char *locale_id, char *parent, int32_t parent_capacity) +{ + if(NULL == parent || parent_capacity < 0){ + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return -1; + } + + UErrorCode icu_error = U_ZERO_ERROR; + int32_t len_of_loc = uloc_getParent(locale_id, parent, parent_capacity, &icu_error); + ERR("Error Code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return len_of_loc; +} + +int32_t i18n_ulocale_get_base_name (const char *locale_id, char *name, int32_t name_capacity) +{ + UErrorCode icu_error = U_ZERO_ERROR; + int32_t needed_buffer_size = uloc_getBaseName(locale_id, name, name_capacity, &icu_error); + ERR("Error Code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return needed_buffer_size; +} + +int i18n_ulocale_keywords_create (const char *locale_id, i18n_uenumeration_h *enumeration ) +{ + if (NULL == enumeration){ + return I18N_ERROR_INVALID_PARAMETER; + } + UErrorCode icu_error = U_ZERO_ERROR; + *enumeration = (i18n_uenumeration_h)uloc_openKeywords(locale_id, &icu_error); + ERR("Error Code : %d", icu_error); + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int32_t i18n_ulocale_get_keyword_value (const char *locale_id, const char *keyword_name, char *buffer, + int32_t buffer_capacity) +{ + if(NULL == locale_id || NULL == keyword_name || NULL == buffer || buffer_capacity < 0){ + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return -1; + } + + UErrorCode icu_error = U_ZERO_ERROR; + int32_t len_of_keyword = uloc_getKeywordValue(locale_id, keyword_name, buffer, buffer_capacity, &icu_error); + ERR("Error Code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return len_of_keyword; +} + +int32_t i18n_ulocale_set_keyword_value (const char *keyword_name, const char *keyword_value, char *buffer, + int32_t buffer_capacity) +{ + if(NULL == keyword_name || NULL == buffer || buffer_capacity < 0){ + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return -1; + } + + UErrorCode icu_error = U_ZERO_ERROR; + int32_t needed_buffer_size = uloc_setKeywordValue(keyword_name, keyword_value, buffer, buffer_capacity, &icu_error); + ERR("Error Code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return needed_buffer_size; +} + +int i18n_ulocale_get_character_orientation (const char *locale_id, i18n_ulocale_layout_type_e *layout_type) +{ + if (NULL == layout_type){ + return I18N_ERROR_INVALID_PARAMETER; + } + UErrorCode icu_error = U_ZERO_ERROR; + *layout_type = uloc_getCharacterOrientation(locale_id, &icu_error); + ERR("Error Code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int i18n_ulocale_get_line_orientation (const char *locale_id, i18n_ulocale_layout_type_e *layout_type) +{ + if (NULL == layout_type){ + return I18N_ERROR_INVALID_PARAMETER; + } + UErrorCode icu_error = U_ZERO_ERROR; + *layout_type = uloc_getLineOrientation(locale_id, &icu_error); + ERR("Error Code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int32_t i18n_ulocale_get_locale_for_lcid (uint32_t host_id, char *locale, int32_t locale_capacity) +{ + if(NULL == locale || locale_capacity < 0){ + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return -1; + } + + UErrorCode icu_error = U_ZERO_ERROR; + int32_t needed_buffer_size = uloc_getLocaleForLCID(host_id, locale, locale_capacity, &icu_error); + ERR("Error Code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return needed_buffer_size; +} + +int32_t i18n_ulocale_add_likely_subtags (const char *locale_id, char *maximized_locale_id, + int32_t maximized_locale_id_capacity) +{ + UErrorCode icu_error = U_ZERO_ERROR; + int32_t needed_buffer_size = uloc_addLikelySubtags(locale_id, maximized_locale_id, maximized_locale_id_capacity, &icu_error); + ERR("Error Code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return needed_buffer_size; +} + +int32_t i18n_ulocale_minimize_subtags (const char *locale_id, char *minimized_locale_id, + int32_t minimized_locale_id_capacity) +{ + UErrorCode icu_error = U_ZERO_ERROR; + int32_t needed_buffer_size = uloc_minimizeSubtags(locale_id, minimized_locale_id, minimized_locale_id_capacity, &icu_error); + ERR("Error Code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return needed_buffer_size; +} + +int32_t i18n_ulocale_for_language_tag (const char *langtag, char *locale_id, int32_t locale_id_capacity, + int32_t *parsed_length) +{ + if(NULL == langtag || NULL == locale_id || locale_id_capacity < 0){ + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return -1; + } + + UErrorCode icu_error = U_ZERO_ERROR; + int32_t len_of_loc = uloc_forLanguageTag(langtag, locale_id, locale_id_capacity, parsed_length, &icu_error); + ERR("Error Code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return len_of_loc; +} + +int32_t i18n_ulocale_to_language_tag (const char *locale_id, char *langtag, int32_t langtag_capacity, + i18n_ubool strict) +{ + if(NULL == locale_id || NULL == langtag || langtag_capacity < 0){ + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return -1; + } + + UErrorCode icu_error = U_ZERO_ERROR; + int32_t len_of_loc = uloc_toLanguageTag(locale_id, langtag, langtag_capacity, strict, &icu_error); + ERR("Error Code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return len_of_loc; +} diff --git a/src/utils_i18n_unormalization.c b/src/utils_i18n_unormalization.c new file mode 100755 index 0000000..92fe656 --- /dev/null +++ b/src/utils_i18n_unormalization.c @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + +int i18n_unormalization_get_instance ( const char *package_name, const char *name, i18n_unormalization_mode_e mode, + i18n_unormalizer_h *normalizer ) +{ + i18n_error_code_e err = I18N_ERROR_NONE; + *normalizer = unorm2_getInstance(package_name, name, mode, (UErrorCode*)&err); + int result = _i18n_error_mapping(err); + + return result; +} + +int i18n_unormalization_normalize ( i18n_unormalizer_h normalizer, const i18n_uchar *src, int32_t len, i18n_uchar *dest, int32_t capacity, int32_t *len_deststr ) +{ + retv_if( normalizer == NULL, I18N_ERROR_INVALID_PARAMETER); + + i18n_error_code_e err = I18N_ERROR_NONE; + *len_deststr = unorm2_normalize((UNormalizer2*)normalizer, src, len, dest, capacity, (UErrorCode*)&err); + int result = _i18n_error_mapping(err); + + return result; +} diff --git a/src/utils_i18n_unumber.c b/src/utils_i18n_unumber.c new file mode 100755 index 0000000..159fc17 --- /dev/null +++ b/src/utils_i18n_unumber.c @@ -0,0 +1,392 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + +int i18n_unumber_create (i18n_unumber_format_style_e style, const i18n_uchar *pattern, int32_t pattern_len, const char *locale, i18n_uparse_error_s *parse_err, i18n_unumber_format_h *num_format) +{ + retv_if (num_format == NULL, I18N_ERROR_INVALID_PARAMETER); + + UErrorCode icu_error = U_ZERO_ERROR; + *num_format = unum_open(style, pattern, pattern_len, locale, (UParseError*)parse_err, &icu_error); + + return _i18n_error_mapping(icu_error); +} + +int i18n_unumber_destroy (i18n_unumber_format_h fmt) +{ + retv_if(fmt == NULL, I18N_ERROR_INVALID_PARAMETER); + + unum_close(fmt); + + return I18N_ERROR_NONE; +} + +int i18n_unumber_get_symbol (const i18n_unumber_format_h fmt, i18n_unumber_format_symbol_e symbol, i18n_uchar *buffer, int32_t size, int32_t *len_symbol) +{ + retv_if(fmt == NULL || len_symbol == NULL, I18N_ERROR_INVALID_PARAMETER); + + UErrorCode icu_error = U_ZERO_ERROR; + *len_symbol = unum_getSymbol(fmt, symbol, buffer, size, &icu_error); + + return _i18n_error_mapping(icu_error); +} + +// Newly Added APIs + +int i18n_unumber_clone(const i18n_unumber_format_h fmt, i18n_unumber_format_h *fmt_clone) +{ + if(fmt == NULL || NULL == fmt_clone) { + return I18N_ERROR_INVALID_PARAMETER; + } + + UErrorCode icu_error = U_ZERO_ERROR; + *fmt_clone = (i18n_unumber_format_h)unum_clone(fmt, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int32_t i18n_unumber_format (const i18n_unumber_format_h fmt, int32_t number, i18n_uchar *result, int32_t result_length, i18n_ufield_position_s *pos, i18n_error_code_e *status) +{ + if(NULL == fmt) { + if(NULL != status) { + *status = I18N_ERROR_INVALID_PARAMETER; + } + return 0; + } + UErrorCode err; + ERR_MAPPING_REVERSE(*status, err); + int32_t result_unum_format= unum_format (fmt, number, (UChar*)result, result_length, (UFieldPosition*)pos, &err); + ERR("pErrorCode : %d", err); + if(NULL != status) { + ERR_MAPPING(err, *status); + } + return result_unum_format; +} + +int32_t i18n_unumber_format_int64 (const i18n_unumber_format_h fmt, int64_t number, i18n_uchar *result, int32_t result_length, i18n_ufield_position_h pos) +{ + if(fmt == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + UErrorCode icu_error = U_ZERO_ERROR; + int32_t result_unum_formatInt64 = unum_formatInt64 (fmt, number, result, result_length, (UFieldPosition*)pos, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return result_unum_formatInt64; +} + +int32_t i18n_unumber_format_double (const i18n_unumber_format_h fmt, double number, i18n_uchar *result, int32_t result_length, i18n_ufield_position_h pos) +{ + if(fmt == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + UErrorCode icu_error = U_ZERO_ERROR; + int32_t result_unum_formatDouble = unum_formatDouble(fmt, number, result, result_length, (UFieldPosition*)pos, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return result_unum_formatDouble; +} + +int32_t i18n_unumber_format_decimal (const i18n_unumber_format_h fmt, const char *number, int32_t length, i18n_uchar *result, int32_t result_length, i18n_ufield_position_h pos) +{ + if(fmt == NULL || number == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + UErrorCode icu_error = U_ZERO_ERROR; + int32_t result_unum_formatDecimal = unum_formatDecimal (fmt, number, length, result, result_length, (UFieldPosition*)pos, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return result_unum_formatDecimal; +} + +int32_t i18n_unumber_format_double_currency (const i18n_unumber_format_h fmt, double number, i18n_uchar *currency, i18n_uchar *result, int32_t result_length, i18n_ufield_position_h pos) +{ + if(fmt == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + UErrorCode icu_error = U_ZERO_ERROR; + int32_t result_unum_formatDoubleCurrency = unum_formatDoubleCurrency (fmt, number, currency, result, result_length, (UFieldPosition*)pos, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return result_unum_formatDoubleCurrency; +} + +int32_t i18n_unumber_parse (const i18n_unumber_format_h fmt, const i18n_uchar *text, int32_t text_length, int32_t *parse_pos) +{ + if(fmt == NULL || text == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + UErrorCode icu_error = U_ZERO_ERROR; + int32_t result_unum_parse = unum_parse (fmt, text, text_length, parse_pos, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return result_unum_parse; +} + +int64_t i18n_unumber_parse_int64 (const i18n_unumber_format_h fmt, const i18n_uchar *text, int32_t text_length, int32_t *parse_pos) +{ + if(fmt == NULL || text == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + UErrorCode icu_error = U_ZERO_ERROR; + int64_t result_unum_parseInt64 = unum_parseInt64 (fmt, text, text_length, parse_pos, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return result_unum_parseInt64; +} + +double i18n_unumber_parse_double (const i18n_unumber_format_h fmt, const i18n_uchar *text, int32_t text_length, int32_t *parse_pos) +{ + if(fmt == NULL || text == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + UErrorCode icu_error = U_ZERO_ERROR; + double result_unum_parseDouble = unum_parseDouble (fmt, text, text_length, parse_pos, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return result_unum_parseDouble; +} + +int32_t i18n_unumber_parse_decimal (const i18n_unumber_format_h fmt, const i18n_uchar *text, int32_t text_length, int32_t *parse_pos, char *out_buf, int32_t out_buf_length) +{ + if(fmt == NULL || text == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + UErrorCode icu_error = U_ZERO_ERROR; + int32_t result_unum_parseDecimal = unum_parseDecimal (fmt, text, text_length, parse_pos, out_buf, out_buf_length, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return result_unum_parseDecimal; +} + +double i18n_unumber_parse_double_currency (const i18n_unumber_format_h fmt, const i18n_uchar *text, int32_t text_length, int32_t *parse_pos, i18n_uchar *currency) +{ + if(fmt == NULL || text == NULL || currency == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + UErrorCode icu_error = U_ZERO_ERROR; + int32_t result_unum_parseDoubleCurrency = unum_parseDoubleCurrency (fmt, text, text_length, parse_pos, currency, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return result_unum_parseDoubleCurrency; +} + +int i18n_unumber_apply_pattern (i18n_unumber_format_h format, i18n_ubool localized, const i18n_uchar *pattern, int32_t pattern_length, i18n_uparse_error_s* parse_error) +{ + if(format == NULL || pattern == NULL || pattern_length < -1) { + return I18N_ERROR_INVALID_PARAMETER; + } + + UErrorCode icu_error = U_ZERO_ERROR; + unum_applyPattern (format, localized, pattern, pattern_length, (UParseError*)parse_error, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +const char *i18n_unumber_get_available (int32_t locale_index) +{ + if(locale_index < 0) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + + set_last_result(I18N_ERROR_NONE); + return unum_getAvailable(locale_index); +} + +int32_t i18n_unumber_count_available (void) +{ + set_last_result(I18N_ERROR_NONE); + return unum_countAvailable(); +} + +int32_t i18n_unumber_get_attribute (const i18n_unumber_format_h fmt, i18n_unumber_format_attribute_e attr) +{ + if(fmt == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + set_last_result(I18N_ERROR_NONE); + return unum_getAttribute(fmt, attr); +} + +int i18n_unumber_set_attribute (i18n_unumber_format_h fmt, i18n_unumber_format_attribute_e attr, int32_t new_value) +{ + if(fmt == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + + unum_setAttribute(fmt, attr, new_value); + return I18N_ERROR_NONE; +} + +double i18n_unumber_get_double_attribute (const i18n_unumber_format_h fmt, i18n_unumber_format_attribute_e attr) +{ + if(fmt == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + set_last_result(I18N_ERROR_NONE); + return unum_getDoubleAttribute (fmt, attr); +} + +int i18n_unumber_set_double_attribute (i18n_unumber_format_h fmt, i18n_unumber_format_attribute_e attr, double new_value) +{ + if(fmt == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + + unum_setDoubleAttribute(fmt, attr, new_value); + return I18N_ERROR_NONE; +} + +int32_t i18n_unumber_get_text_attribute (const i18n_unumber_format_h fmt, i18n_unumber_format_text_attribute_e tag, i18n_uchar *result, int32_t result_length) +{ + if(fmt == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + UErrorCode icu_error = U_ZERO_ERROR; + int32_t result_unum_getTextAttribute = unum_getTextAttribute (fmt, tag, result, result_length, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return result_unum_getTextAttribute; +} + +int i18n_unumber_set_text_attribute (const i18n_unumber_format_h fmt, i18n_unumber_format_text_attribute_e tag, const i18n_uchar *new_value, int32_t new_value_length) +{ + if(fmt == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + + UErrorCode icu_error = U_ZERO_ERROR; + unum_setTextAttribute((UNumberFormat*)fmt, tag, new_value, new_value_length, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int32_t i18n_unumber_to_pattern (const i18n_unumber_format_h fmt, i18n_ubool is_pattern_localized, i18n_uchar *result, int32_t result_length) +{ + if(fmt == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + UErrorCode icu_error = U_ZERO_ERROR; + int32_t result_unum_toPattern = unum_toPattern(fmt, is_pattern_localized, result, result_length, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return result_unum_toPattern; +} + +int i18n_unumber_set_symbol (i18n_unumber_format_h fmt, i18n_unumber_format_symbol_e symbol, const i18n_uchar *value, int32_t length) +{ + if(fmt == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + + UErrorCode icu_error = U_ZERO_ERROR; + unum_setSymbol(fmt, symbol, value, length, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +const char *i18n_unumber_get_locale_by_type (const i18n_unumber_format_h fmt, i18n_ulocale_data_locale_type_e type) +{ + if(fmt == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + UErrorCode icu_error = U_ZERO_ERROR; + const char *result_unum_getLocaleByType = unum_getLocaleByType (fmt, type, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + set_last_result(i18n_error); + return result_unum_getLocaleByType; +} diff --git a/src/utils_i18n_usearch.c b/src/utils_i18n_usearch.c new file mode 100755 index 0000000..2a2a761 --- /dev/null +++ b/src/utils_i18n_usearch.c @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + +int i18n_usearch_destroy ( i18n_usearch_h searchiter ) +{ + retv_if ( searchiter == NULL, I18N_ERROR_INVALID_PARAMETER ); + + usearch_close ( searchiter ); + + return I18N_ERROR_NONE; +} + +int i18n_usearch_first ( i18n_usearch_h strsrch, int32_t *index_first ) +{ + retv_if ( strsrch == NULL || index_first == NULL, I18N_ERROR_INVALID_PARAMETER ); + i18n_error_code_e err = I18N_ERROR_NONE; + *index_first = usearch_first ( strsrch, (UErrorCode*)&err ); + + return I18N_ERROR_NONE; +} + +int i18n_usearch_get_collator ( const i18n_usearch_h strsrch, i18n_ucollator_h *collator ) +{ + retv_if ( strsrch == NULL || collator == NULL, I18N_ERROR_INVALID_PARAMETER ); + *collator = usearch_getCollator ( strsrch ); + + return I18N_ERROR_NONE; +} + +int i18n_usearch_get_matched_text ( const i18n_usearch_h strsrch, i18n_uchar *result_w, int32_t result_capacity, int32_t *len_matched_text ) +{ + i18n_error_code_e err = I18N_ERROR_NONE; + *len_matched_text = usearch_getMatchedText ( strsrch, result_w, result_capacity, (UErrorCode*)&err ); + int result = _i18n_error_mapping ( err ); + + return result; +} + +int i18n_usearch_create ( const i18n_uchar *pattern, int32_t pattern_len, const i18n_uchar *text, + int32_t text_len, const char *locale, i18n_ubreak_iterator_s *break_iter, i18n_usearch_h *search_iter ) +{ + retv_if ( search_iter == NULL, I18N_ERROR_INVALID_PARAMETER ); + i18n_error_code_e err = I18N_ERROR_NONE; + *search_iter = usearch_open ( pattern, pattern_len, text, text_len, locale, (UBreakIterator*)break_iter, (UErrorCode*)&err ); + int result = _i18n_error_mapping ( err ); + + return result; +} + +int i18n_usearch_create_new ( const i18n_uchar *pattern, int32_t pattern_len, const i18n_uchar *text, + int32_t text_len, const char *locale, i18n_ubreak_iterator_h break_iter, i18n_usearch_h *search_iter ) +{ + retv_if ( search_iter == NULL, I18N_ERROR_INVALID_PARAMETER ); + UErrorCode icu_error = U_ZERO_ERROR; + *search_iter = (i18n_usearch_h)usearch_open(pattern, pattern_len, text, text_len, locale, (UBreakIterator*)break_iter, &icu_error); + ERR("Error code : %d", icu_error); + + i18n_error_code_e i18n_error; + ERR_MAPPING(icu_error, i18n_error); + + return i18n_error; +} diff --git a/src/utils_i18n_uset.c b/src/utils_i18n_uset.c new file mode 100644 index 0000000..2f5e45c --- /dev/null +++ b/src/utils_i18n_uset.c @@ -0,0 +1,699 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + +int i18n_uset_create_empty ( i18n_uset_h* set ) +{ + if(set == NULL) + { + return I18N_ERROR_INVALID_PARAMETER; + } + *set = (i18n_uset_h)uset_openEmpty(); + return I18N_ERROR_NONE; +} + +int i18n_uset_create ( i18n_uchar32 start, i18n_uchar32 end, i18n_uset_h *set) +{ + if(set == NULL) + { + return I18N_ERROR_INVALID_PARAMETER; + } + *set = (i18n_uset_h)uset_open(start, end); + return I18N_ERROR_NONE; +} + +int i18n_uset_create_pattern ( const i18n_uchar *pattern, int32_t pattern_length, i18n_uset_h *set ) +{ + UErrorCode icu_error = U_ZERO_ERROR; + i18n_error_code_e i18n_error; + + if (pattern == NULL || pattern_length < -1 || set == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + + *set = (i18n_uset_h)uset_openPattern(pattern, pattern_length, &icu_error); + ERR("Error code: %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int i18n_uset_create_pattern_options ( const i18n_uchar *pattern, int32_t pattern_length, uint32_t options, i18n_uset_h *set ) +{ + UErrorCode icu_error = U_ZERO_ERROR; + i18n_error_code_e i18n_error; + + if (pattern == NULL || pattern_length < -1 || set == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + if ((options != I18N_USET_IGNORE_SPACE) && (options != I18N_USET_CASE_INSENSITIVE)) { + return I18N_ERROR_INVALID_PARAMETER; + } + + *set = (i18n_uset_h)uset_openPatternOptions(pattern, pattern_length, options, &icu_error); + ERR("Error code: %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + return i18n_error; +} + +int i18n_uset_destroy ( i18n_uset_h set ) +{ + if (set == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + uset_close((USet*)set); + return I18N_ERROR_NONE; +} + +int i18n_uset_clone ( const i18n_uset_h set, i18n_uset_h *set_clone ) +{ + if (set == NULL || set_clone == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + *set_clone = (i18n_uset_h)uset_clone((const USet*)set); + return I18N_ERROR_NONE; +} + +i18n_ubool i18n_uset_is_frozen ( const i18n_uset_h set ) +{ + set_last_result(I18N_ERROR_NONE); + if (set == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return false; + } + return uset_isFrozen((const USet*)set); +} + +int i18n_uset_freeze ( i18n_uset_h set ) +{ + if (set == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + uset_freeze((USet*)set); + return I18N_ERROR_NONE; +} + +int i18n_uset_clone_as_thawed ( const i18n_uset_h set, i18n_uset_h *set_copy ) +{ + if (set == NULL || set_copy == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + *set_copy = (i18n_uset_h)uset_cloneAsThawed((const USet*)set); + return I18N_ERROR_NONE; +} + +int i18n_uset_set ( i18n_uset_h set, i18n_uchar32 start, i18n_uchar32 end ) +{ + if (set == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + uset_set((USet*)set, start, end); + return I18N_ERROR_NONE; +} + +int32_t i18n_uset_apply_pattern ( i18n_uset_h set, const i18n_uchar *pattern, int32_t pattern_length, uint32_t options ) +{ + if (set == NULL ) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + if (pattern == NULL || pattern_length < -1) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + if (options != I18N_USET_IGNORE_SPACE && options != I18N_USET_CASE_INSENSITIVE) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + UErrorCode icu_error = U_ZERO_ERROR; + i18n_error_code_e i18n_error; + + int32_t result_uset_applyPattern = uset_applyPattern ((USet*)set, pattern, pattern_length, options, &icu_error); + ERR("Error code: %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + + set_last_result(i18n_error); + return result_uset_applyPattern; +} + +int i18n_uset_apply_int_property_value ( i18n_uset_h set, i18n_uchar_uproperty_e prop, int32_t value ) +{ + if (set == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + if ((prop < I18N_UCHAR_INT_START || prop > I18N_UCHAR_INT_LIMIT-1) && + (prop < I18N_UCHAR_MASK_START || prop > I18N_UCHAR_MASK_LIMIT-1)) { + return I18N_ERROR_INVALID_PARAMETER; + } + if (prop != I18N_UCHAR_GENERAL_CATEGORY_MASK && + (value <= I18N_UCHAR_INVALID_CODE || + value >= I18N_UCHAR_OTHER_PROPERTY_LIMIT)) { + return I18N_ERROR_INVALID_PARAMETER; + } + + UErrorCode icu_error = U_ZERO_ERROR; + i18n_error_code_e i18n_error; + + uset_applyIntPropertyValue((USet *)set, prop, value, &icu_error); + ERR("Error code: %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + + return i18n_error; +} + +int i18n_uset_apply_property_alias ( i18n_uset_h set, const i18n_uchar *prop, int32_t prop_length, const i18n_uchar *value, int32_t value_length ) +{ + if (set == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + if (prop == NULL || prop_length < -1) { + return I18N_ERROR_INVALID_PARAMETER; + } + if (value == NULL || value_length < -1) { + return I18N_ERROR_INVALID_PARAMETER; + } + + UErrorCode icu_error = U_ZERO_ERROR; + i18n_error_code_e i18n_error; + + uset_applyPropertyAlias ((USet*)set, prop, prop_length, value, value_length, &icu_error); + ERR("Error code: %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + + return i18n_error; + +} + +i18n_ubool i18n_uset_resembles_pattern ( const i18n_uchar *pattern, int32_t pattern_length, int32_t pos ) +{ + if (pattern == NULL || pattern_length < -1 || pos < 0) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return false; + } + set_last_result(I18N_ERROR_NONE); + return uset_resemblesPattern(pattern, pattern_length, pos); +} + +int32_t i18n_uset_to_pattern ( const i18n_uset_h set, i18n_uchar *result, int32_t result_capacity, i18n_ubool escape_unprintable ) +{ + if (set == NULL || result_capacity < 0) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + UErrorCode icu_error = U_ZERO_ERROR; + i18n_error_code_e i18n_error; + + int32_t result_uset_toPattern = uset_toPattern((const USet*)set, result, result_capacity, escape_unprintable, &icu_error); + ERR("Error code: %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + + set_last_result(i18n_error); + return result_uset_toPattern; +} + +int i18n_uset_add ( i18n_uset_h set, i18n_uchar32 character ) +{ + if (set == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + uset_add ((USet*)set, character); + return I18N_ERROR_NONE; +} + +int i18n_uset_add_all ( i18n_uset_h set, const i18n_uset_h additional_set ) +{ + if (set == NULL || additional_set == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + uset_addAll((USet *)set, (const USet*)additional_set); + return I18N_ERROR_NONE; +} + +int i18n_uset_add_range ( i18n_uset_h set, i18n_uchar32 start, i18n_uchar32 end ) +{ + if (set == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + uset_addRange((USet*)set, start, end); + return I18N_ERROR_NONE; +} + +int i18n_uset_add_string ( i18n_uset_h set, const i18n_uchar *str, int32_t str_len ) +{ + if (set == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + if (str == NULL || str_len < -1) { + return I18N_ERROR_INVALID_PARAMETER; + } + uset_addString((USet*)set, str, str_len); + return I18N_ERROR_NONE; +} + +int i18n_uset_add_all_code_points ( i18n_uset_h set, const i18n_uchar *str, int32_t str_len ) +{ + if(set == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + if (str == NULL || str_len < -1) { + return I18N_ERROR_INVALID_PARAMETER; + } + uset_addAllCodePoints((USet*)set, str, str_len); + return I18N_ERROR_NONE; +} + +int i18n_uset_remove ( i18n_uset_h set, i18n_uchar32 character ) +{ + if (set == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + uset_remove ((USet*)set, character); + return I18N_ERROR_NONE; +} + +int i18n_uset_remove_range ( i18n_uset_h set, i18n_uchar32 start, i18n_uchar32 end ) +{ + if (set == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + uset_removeRange ((USet*)set, start, end); + return I18N_ERROR_NONE; +} + +int i18n_uset_remove_string ( i18n_uset_h set, const i18n_uchar *str, int32_t str_len ) +{ + if (set == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + if (str == NULL || str_len < -1) { + return I18N_ERROR_INVALID_PARAMETER; + } + uset_removeString((USet*)set, str, str_len); + return I18N_ERROR_NONE; +} + +int i18n_uset_remove_all ( i18n_uset_h set, const i18n_uset_h remove_set ) +{ + if (set == NULL || remove_set == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + uset_removeAll((USet*)set, (const USet*)remove_set); + return I18N_ERROR_NONE; +} + +int i18n_uset_retain ( i18n_uset_h set, i18n_uchar32 start, i18n_uchar32 end ) +{ + if (set == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + uset_retain((USet*)set, start, end); + return I18N_ERROR_NONE; +} + +int i18n_uset_retain_all ( i18n_uset_h set, const i18n_uset_h retain ) +{ + if (set == NULL || retain == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + uset_retainAll ((USet*)set, (const USet*)retain); + return I18N_ERROR_NONE; +} + +int i18n_uset_compact ( i18n_uset_h set ) +{ + if (set == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + uset_compact((USet*)set); + return I18N_ERROR_NONE; +} + +int i18n_uset_complement ( i18n_uset_h set ) +{ + if (set == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + uset_complement((USet*)set); + return I18N_ERROR_NONE; +} + +int i18n_uset_complement_all ( i18n_uset_h set, const i18n_uset_h complement ) +{ + if (set == NULL || set == complement || complement == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + uset_complementAll((USet*)set, (const USet*)complement); + return I18N_ERROR_NONE; +} + +int i18n_uset_clear ( i18n_uset_h set ) +{ + if (set == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + uset_clear((USet*)set); + return I18N_ERROR_NONE; +} + +int i18n_uset_destroy_over ( i18n_uset_h set, int32_t attributes ) +{ + if (set == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + uset_closeOver((USet*)set, attributes); + return I18N_ERROR_NONE; +} + +int i18n_uset_remove_all_strings ( i18n_uset_h set ) +{ + if (set == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + uset_removeAllStrings((USet*)set); + return I18N_ERROR_NONE; +} + +i18n_ubool i18n_uset_is_empty ( const i18n_uset_h set ) +{ + if (set == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return false; + } + set_last_result(I18N_ERROR_NONE); + return uset_isEmpty((const USet*)set); +} + +i18n_ubool i18n_uset_contains ( const i18n_uset_h set, i18n_uchar32 character ) +{ + if (set == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return false; + } + set_last_result(I18N_ERROR_NONE); + return uset_contains((const USet*)set, character); +} + +i18n_ubool i18n_uset_contains_range ( const i18n_uset_h set, i18n_uchar32 start, i18n_uchar32 end ) +{ + if (set == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return false; + } + set_last_result(I18N_ERROR_NONE); + return uset_containsRange((const USet*)set, start, end); +} + +i18n_ubool i18n_uset_contains_string ( const i18n_uset_h set, const i18n_uchar *str, int32_t str_len ) +{ + if (set == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return false; + } + if (str == NULL || str_len < -1) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return false; + } + set_last_result(I18N_ERROR_NONE); + return uset_containsString((const USet*)set, str, str_len); +} + +int32_t i18n_uset_index_of ( const i18n_uset_h set, i18n_uchar32 character ) +{ + if (set == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + set_last_result(I18N_ERROR_NONE); + return uset_indexOf((const USet*)set, character); +} + +i18n_uchar32 i18n_uset_char_at ( const i18n_uset_h set, int32_t char_index ) +{ + if (set == NULL || (char_index < 0 || char_index > uset_size((const USet*)set)-1)) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0x0; + } + set_last_result(I18N_ERROR_NONE); + return uset_charAt((const USet*)set, char_index); +} + +int32_t i18n_uset_size ( const i18n_uset_h set ) +{ + if (set == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + set_last_result(I18N_ERROR_NONE); + return uset_size((const USet*)set); +} + +int32_t i18n_uset_get_item_count ( const i18n_uset_h set ) +{ + if (set == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + set_last_result(I18N_ERROR_NONE); + return uset_getItemCount((const USet*)set); +} + +int32_t i18n_uset_get_item ( const i18n_uset_h set, int32_t item_index, i18n_uchar32 *start, i18n_uchar32 *end, + i18n_uchar *str, int32_t str_capacity ) +{ + if (set == NULL || (item_index < 0 || item_index > uset_getItemCount((const USet*)set)-1) || start == NULL || end == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + if ((str == NULL && str_capacity != 0) || (str != NULL && str_capacity < 0)) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + UErrorCode icu_error = U_ZERO_ERROR; + i18n_error_code_e i18n_error; + + int32_t result_uset_getItem = uset_getItem((const USet*)set, item_index, start, end, str, str_capacity, &icu_error); + ERR("Error code: %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + + set_last_result(i18n_error); + return result_uset_getItem; +} + +i18n_ubool i18n_uset_contains_all ( const i18n_uset_h set1, const i18n_uset_h set2 ) +{ + if (set1 == NULL || set2 == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return false; + } + set_last_result(I18N_ERROR_NONE); + return uset_containsAll((const USet*)set1, (const USet*)set2); +} + +i18n_ubool i18n_uset_contains_all_code_points ( const i18n_uset_h set, const i18n_uchar *str, int32_t str_len ) +{ + if (set == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return false; + } + if (str == NULL || str_len < -1) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return false; + } + set_last_result(I18N_ERROR_NONE); + return uset_containsAllCodePoints((const USet*)set, str, str_len); +} + +i18n_ubool i18n_uset_contains_none ( const i18n_uset_h set1, const i18n_uset_h set2 ) +{ + if (set1 == NULL || set2 == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return false; + } + set_last_result(I18N_ERROR_NONE); + return uset_containsNone((const USet*)set1, (const USet*)set2); +} + +i18n_ubool i18n_uset_contains_some ( const i18n_uset_h set1, const i18n_uset_h set2 ) +{ + if (set1 == NULL || set2 == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return false; + } + set_last_result(I18N_ERROR_NONE); + return uset_containsSome((const USet*)set1, (const USet*)set2); +} + +int32_t i18n_uset_span ( const i18n_uset_h set, const i18n_uchar *str, int32_t length, i18n_uset_span_condition_e span_condition ) +{ + if (set == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + if (str == NULL || length < -1) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + set_last_result(I18N_ERROR_NONE); + return uset_span((const USet*)set, str, length, (USetSpanCondition) span_condition); +} + +int32_t i18n_uset_span_back ( const i18n_uset_h set, const i18n_uchar *str, int32_t length, i18n_uset_span_condition_e span_condition ) +{ + if (set == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + if (str == NULL || length < -1) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + if (span_condition < I18N_USET_SPAN_NOT_CONTAINED || + span_condition > I18N_USET_SPAN_CONDITION_COUNT) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + set_last_result(I18N_ERROR_NONE); + return uset_spanBack((const USet*)set, str, length, (USetSpanCondition) span_condition); +} + +int32_t i18n_uset_span_utf8 ( const i18n_uset_h set, const char *str, int32_t length, i18n_uset_span_condition_e span_condition ) +{ + if (set == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + if (str == NULL || length < -1) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + if (span_condition < I18N_USET_SPAN_NOT_CONTAINED || + span_condition > I18N_USET_SPAN_CONDITION_COUNT) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + set_last_result(I18N_ERROR_NONE); + return uset_spanUTF8((const USet*)set, str, length, (USetSpanCondition) span_condition); +} + +int32_t i18n_uset_span_back_utf8 ( const i18n_uset_h set, const char *str, int32_t length, i18n_uset_span_condition_e span_condition ) +{ + if(set == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + if (str == NULL || length < -1) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + if (span_condition < I18N_USET_SPAN_NOT_CONTAINED || + span_condition > I18N_USET_SPAN_CONDITION_COUNT) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + set_last_result(I18N_ERROR_NONE); + return uset_spanBackUTF8((const USet*)set, str, length, (USetSpanCondition) span_condition); +} + +i18n_ubool i18n_uset_equals ( const i18n_uset_h set1, const i18n_uset_h set2 ) +{ + if (set1 == NULL || set2 == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return false; + } + set_last_result(I18N_ERROR_NONE); + return uset_equals((const USet*)set1, (const USet*)set2); +} + +int32_t i18n_uset_serialize ( const i18n_uset_h set, uint16_t *dest, int32_t dest_capacity ) +{ + i18n_error_code_e i18n_error; + + if (set == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + if (dest == NULL || dest_capacity < 0) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + UErrorCode icu_error = U_ZERO_ERROR; + int32_t result_uset_serialize = uset_serialize((const USet*)set, dest, dest_capacity, &icu_error); + ERR("Error code: %d", icu_error); + ERR_MAPPING(icu_error, i18n_error); + + set_last_result(i18n_error); + return result_uset_serialize; +} + +i18n_ubool i18n_uset_get_serialized_set ( const uint16_t *src, int32_t src_length, i18n_userialized_set_s *fill_set ) +{ + if (src == NULL || src_length < 0) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + set_last_result(I18N_ERROR_NONE); + return uset_getSerializedSet((USerializedSet*)fill_set, src, src_length); +} + +int i18n_uset_set_serialized_to_one ( i18n_uchar32 character, i18n_userialized_set_s *fill_set ) +{ + if (fill_set == NULL) { + return I18N_ERROR_INVALID_PARAMETER; + } + uset_setSerializedToOne((USerializedSet*)fill_set, character); + return I18N_ERROR_NONE; +} + +i18n_ubool i18n_uset_serialized_contains ( const i18n_userialized_set_s *set, i18n_uchar32 character ) +{ + if (set == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + set_last_result(I18N_ERROR_NONE); + return uset_serializedContains((const USerializedSet*)set, character); +} + +int32_t i18n_uset_get_serialized_range_count ( const i18n_userialized_set_s *set ) +{ + if (set == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + set_last_result(I18N_ERROR_NONE); + return uset_getSerializedRangeCount((const USerializedSet*)set); +} + +i18n_ubool i18n_uset_get_serialized_range ( const i18n_userialized_set_s *set, int32_t range_index, i18n_uchar32 *p_start, i18n_uchar32 *p_end ) +{ + if (set == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return false; + } + if (range_index < 0 || range_index > uset_getSerializedRangeCount((const USerializedSet*)set)-1) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return false; + } + set_last_result(I18N_ERROR_NONE); + return uset_getSerializedRange((const USerializedSet*)set, range_index, p_start, p_end); +} diff --git a/src/utils_i18n_ustring.c b/src/utils_i18n_ustring.c new file mode 100644 index 0000000..1ba6126 --- /dev/null +++ b/src/utils_i18n_ustring.c @@ -0,0 +1,733 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + +int32_t i18n_ustring_get_length ( const i18n_uchar *s ) +{ + if(s == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + set_last_result(I18N_ERROR_NONE); + return u_strlen (s); +} + +int32_t i18n_ustring_count_char32 ( const i18n_uchar *s, int32_t length ) +{ + if(s == NULL || length < -1) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + set_last_result(I18N_ERROR_NONE); + return u_countChar32(s, length); +} + +i18n_ubool i18n_ustring_has_more_char32_than ( const i18n_uchar *s, int32_t length, int32_t number ) +{ + if(s == NULL || length < -1) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return false; + } + + set_last_result(I18N_ERROR_NONE); + return u_strHasMoreChar32Than(s, length, number); +} + +i18n_uchar* i18n_ustring_cat ( i18n_uchar *dest, const i18n_uchar *src ) +{ + if(dest == NULL || src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + + set_last_result(I18N_ERROR_NONE); + return u_strcat(dest, src); +} + +i18n_uchar * i18n_ustring_cat_n ( i18n_uchar *dest, const i18n_uchar *src, int32_t n ) +{ + if(dest == NULL || src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + + set_last_result(I18N_ERROR_NONE); + return u_strncat(dest, src, n); +} + +i18n_uchar* i18n_ustring_string ( const i18n_uchar *s, const i18n_uchar *sub_string ) +{ + if(s == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + + set_last_result(I18N_ERROR_NONE); + return (i18n_uchar*)u_strstr(s, sub_string); +} + +i18n_uchar* i18n_ustring_find_first ( const i18n_uchar *s, int32_t length, const i18n_uchar *sub_string, int32_t sub_length ) +{ + if(s == NULL || length < -1) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + + set_last_result(I18N_ERROR_NONE); + return u_strFindFirst(s, length, sub_string, sub_length); +} + +i18n_uchar* i18n_ustring_char ( const i18n_uchar *s, i18n_uchar c ) +{ + if(s == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + + set_last_result(I18N_ERROR_NONE); + return (i18n_uchar*)u_strchr(s, c); +} + +i18n_uchar* i18n_ustring_char32 ( const i18n_uchar *s, i18n_uchar32 c ) +{ + if(s == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + + set_last_result(I18N_ERROR_NONE); + return (i18n_uchar*)u_strchr32(s, c); +} + +i18n_uchar* i18n_ustring_r_string ( const i18n_uchar *s, const i18n_uchar *sub_string ) +{ + if(s == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + + set_last_result(I18N_ERROR_NONE); + return (i18n_uchar*)u_strrstr(s, sub_string); +} + +i18n_uchar* i18n_ustring_find_last( const i18n_uchar *s, int32_t length, const i18n_uchar *sub_string, int32_t sub_length ) +{ + if(s == NULL || length < -1) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + + set_last_result(I18N_ERROR_NONE); + return (i18n_uchar*)u_strFindLast(s, length, sub_string, sub_length); +} + +i18n_uchar* i18n_ustring_r_char ( const i18n_uchar *s, i18n_uchar c ) +{ + if(s == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + + set_last_result(I18N_ERROR_NONE); + return (i18n_uchar*)u_strrchr(s, c); +} + +i18n_uchar* i18n_ustring_r_char32 ( const i18n_uchar *s, i18n_uchar32 c ) +{ + if(s == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + + set_last_result(I18N_ERROR_NONE); + return (i18n_uchar*)u_strrchr32(s, c); +} + +i18n_uchar* i18n_ustring_pbrk ( const i18n_uchar *string, const i18n_uchar *match_set ) +{ + if(string == NULL || match_set == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + + set_last_result(I18N_ERROR_NONE); + return (i18n_uchar*)u_strpbrk(string, match_set); +} + +int32_t i18n_ustring_cspn ( const i18n_uchar *string, const i18n_uchar *match_set ) +{ + if(string == NULL || match_set == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + set_last_result(I18N_ERROR_NONE); + return u_strcspn(string, match_set); +} + +int32_t i18n_ustring_spn ( const i18n_uchar *string, const i18n_uchar *match_set ) +{ + if(string == NULL || match_set == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + set_last_result(I18N_ERROR_NONE); + return u_strspn(string, match_set); +} + +i18n_uchar* i18n_ustring_tokenizer_r ( i18n_uchar *src, const i18n_uchar *delim, i18n_uchar **save_state ) +{ + if((src == NULL && save_state == NULL) || delim == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + + set_last_result(I18N_ERROR_NONE); + return u_strtok_r(src, delim, save_state); +} + +int32_t i18n_ustring_compare ( const i18n_uchar *s1, const i18n_uchar *s2 ) +{ + if(s1 == NULL || s2 == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + set_last_result(I18N_ERROR_NONE); + return u_strcmp (s1, s2); +} + +int32_t i18n_ustring_compare_code_point_order( const i18n_uchar *s1, const i18n_uchar *s2 ) +{ + if(s1 == NULL || s2 == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + set_last_result(I18N_ERROR_NONE); + return u_strcmpCodePointOrder(s1, s2); +} + +int32_t i18n_ustring_compare_binary_order( const i18n_uchar *s1, int32_t length1, const i18n_uchar *s2, int32_t length2, i18n_ubool code_point_order ) +{ + if(s1 == NULL || s2 == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + set_last_result(I18N_ERROR_NONE); + return u_strCompare(s1, length1, s2, length2, code_point_order); +} + +int32_t i18n_ustring_case_compare_with_length( const i18n_uchar *s1, int32_t length1, const i18n_uchar *s2, int32_t length2, uint32_t options, i18n_error_code_e *i18n_error ) +{ + UErrorCode icu_error = U_ZERO_ERROR; + int32_t result = u_strCaseCompare(s1, length1, s2, length2, options, &icu_error); + *i18n_error = _i18n_error_mapping(icu_error); + set_last_result(*i18n_error); + + return result; +} + +int32_t i18n_ustring_compare_n( const i18n_uchar *s1, const i18n_uchar *s2, int32_t n ) +{ + if(s1 == NULL || s2 == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + set_last_result(I18N_ERROR_NONE); + return u_strncmp(s1, s2, n); +} + +int32_t i18n_ustring_compare_n_code_point_order( const i18n_uchar *s1, const i18n_uchar *s2, int32_t n ) +{ + if(s1 == NULL || s2 == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + set_last_result(I18N_ERROR_NONE); + return u_strncmpCodePointOrder(s1, s2, n); +} + +int32_t i18n_ustring_case_compare( const i18n_uchar *s1, const i18n_uchar *s2, uint32_t options ) +{ + if(s1 == NULL || s2 == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + set_last_result(I18N_ERROR_NONE); + return u_strcasecmp(s1, s2, options); +} + +int32_t i18n_ustring_case_compare_n( const i18n_uchar *s1, const i18n_uchar *s2, int32_t n, uint32_t options ) +{ + if(s1 == NULL || s2 == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + set_last_result(I18N_ERROR_NONE); + return u_strncasecmp(s1, s2, n, options); +} + +int32_t i18n_ustring_mem_case_compare( const i18n_uchar *s1, const i18n_uchar *s2, int32_t length, uint32_t options ) +{ + if(s1 == NULL || s2 == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + set_last_result(I18N_ERROR_NONE); + return u_memcasecmp(s1, s2, length, options); +} + +i18n_uchar* i18n_ustring_copy ( i18n_uchar *dest, const i18n_uchar *src ) +{ + if(dest == NULL || src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + + set_last_result(I18N_ERROR_NONE); + return u_strcpy(dest, src); +} + +i18n_uchar* i18n_ustring_copy_n ( i18n_uchar *dest, const i18n_uchar *src, int32_t n ) +{ + if(dest == NULL || src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + + set_last_result(I18N_ERROR_NONE); + return u_strncpy(dest, src, n); +} + +i18n_uchar* i18n_ustring_copy_ua ( i18n_uchar *dest, const char *src ) +{ + if(dest == NULL || src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + + set_last_result(I18N_ERROR_NONE); + return u_uastrcpy(dest, src); +} + +i18n_uchar* i18n_ustring_copy_ua_n ( i18n_uchar *dest, const char *src, int32_t n ) +{ + if(dest == NULL || src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + + set_last_result(I18N_ERROR_NONE); + return u_uastrncpy(dest, src, n); +} + +char* i18n_ustring_copy_au ( char *dest, const i18n_uchar *src ) +{ + if(dest == NULL || src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + + set_last_result(I18N_ERROR_NONE); + return u_austrcpy(dest, src); +} + +char* i18n_ustring_copy_au_n ( char *dest, const i18n_uchar *src, int32_t n ) +{ + if(dest == NULL || src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + + set_last_result(I18N_ERROR_NONE); + return u_austrncpy(dest, src, n); +} + +i18n_uchar* i18n_ustring_mem_copy ( i18n_uchar *dest, const i18n_uchar *src, int32_t count ) +{ + if(dest == NULL || src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + + set_last_result(I18N_ERROR_NONE); + return u_memcpy(dest, src, count); +} + +i18n_uchar* i18n_ustring_mem_move ( i18n_uchar *dest, const i18n_uchar *src, int32_t count ) +{ + if(dest == NULL || src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + + set_last_result(I18N_ERROR_NONE); + return u_memmove(dest, src, count); +} + +i18n_uchar* i18n_ustring_mem_set ( i18n_uchar *dest, const i18n_uchar c, int32_t count ) +{ + if(dest == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + + set_last_result(I18N_ERROR_NONE); + return u_memset(dest, c, count); +} + +int32_t i18n_ustring_mem_compare ( const i18n_uchar *buf1, const i18n_uchar *buf2, int32_t count ) +{ + if(buf1 == NULL || buf2 == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + set_last_result(I18N_ERROR_NONE); + return u_memcmp(buf1, buf2, count); +} + +int32_t i18n_ustring_mem_compare_code_point_order ( const i18n_uchar *s1, const i18n_uchar *s2, int32_t count ) +{ + if(s1 == NULL || s2 == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + set_last_result(I18N_ERROR_NONE); + return u_memcmpCodePointOrder(s1, s2, count); +} + +i18n_uchar* i18n_ustring_mem_char ( const i18n_uchar *s, i18n_uchar c, int32_t count ) +{ + if(s == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + + set_last_result(I18N_ERROR_NONE); + return (i18n_uchar*)u_memchr(s, c, count); +} + +i18n_uchar* i18n_ustring_mem_char32 ( const i18n_uchar *s, i18n_uchar32 c, int32_t count ) +{ + if(s == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + + set_last_result(I18N_ERROR_NONE); + return (i18n_uchar*)u_memchr32(s, c, count); +} + +i18n_uchar* i18n_ustring_mem_r_char ( const i18n_uchar *s, i18n_uchar c, int32_t count ) +{ + if(s == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + + set_last_result(I18N_ERROR_NONE); + return (i18n_uchar*)u_memrchr(s, c, count); +} + +i18n_uchar* i18n_ustring_mem_r_char32 ( const i18n_uchar *s, i18n_uchar32 c, int32_t count ) +{ + if(s == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + + set_last_result(I18N_ERROR_NONE); + return (i18n_uchar*)u_memrchr32(s, c, count); +} + +int32_t i18n_ustring_unescape ( const char *src, i18n_uchar *dest, int32_t dest_capacity ) +{ + if(dest == NULL || src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + set_last_result(I18N_ERROR_NONE); + return u_unescape(src, dest, dest_capacity); +} + +i18n_uchar32 i18n_ustring_unescape_at ( i18n_ustring_unescape_char_at_cb char_at, int32_t *offset, int32_t length, void *context ) +{ + if(char_at == NULL || offset == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + set_last_result(I18N_ERROR_NONE); + return u_unescapeAt(char_at, offset, length, context); +} + +int32_t i18n_ustring_to_upper ( i18n_uchar *dest, int32_t dest_capacity, const i18n_uchar *src, int32_t src_len, const char *locale, i18n_error_code_e *i18n_error ) +{ + UErrorCode icu_error = U_ZERO_ERROR; + int32_t result = u_strToUpper (dest, dest_capacity, src, src_len, locale, &icu_error); + *i18n_error = _i18n_error_mapping(icu_error); + set_last_result(*i18n_error); + + return result; +} + +int32_t i18n_ustring_to_lower ( i18n_uchar *dest, int32_t dest_capacity, const i18n_uchar *src, int32_t src_len, const char *locale, i18n_error_code_e *i18n_error ) +{ + UErrorCode icu_error = U_ZERO_ERROR; + int32_t result = u_strToLower (dest, dest_capacity, src, src_len, locale, &icu_error); + *i18n_error = _i18n_error_mapping(icu_error); + set_last_result(*i18n_error); + + return result; +} + +int32_t i18n_ustring_to_title ( i18n_uchar *dest, int32_t dest_capacity, const i18n_uchar *src, int32_t src_len, i18n_ubreak_iterator_s *title_iter, + const char *locale, i18n_error_code_e *i18n_error ) +{ + if(src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + *i18n_error = I18N_ERROR_INVALID_PARAMETER; + return 0; + } + + UErrorCode icu_error = U_ZERO_ERROR; + int32_t result = u_strToTitle (dest, dest_capacity, src, src_len, (UBreakIterator*)title_iter, locale, &icu_error); + *i18n_error = _i18n_error_mapping(icu_error); + set_last_result(*i18n_error); + + return result; +} + +int32_t i18n_ustring_to_title_new ( i18n_uchar *dest, int32_t dest_capacity, const i18n_uchar *src, + int32_t src_len, i18n_ubreak_iterator_h title_iter, const char *locale) +{ + UErrorCode err = U_ZERO_ERROR; + int32_t result = u_strToTitle (dest, dest_capacity, src, src_len, (UBreakIterator*)title_iter, locale, &err); + set_last_result(_i18n_error_mapping(err)); + + return result; +} + +int32_t i18n_ustring_fold_case ( i18n_uchar *dest, int32_t dest_capacity, const i18n_uchar *src, int32_t src_len, uint32_t options, i18n_error_code_e *i18n_error ) +{ + if(src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + *i18n_error = I18N_ERROR_INVALID_PARAMETER; + return 0; + } + + UErrorCode icu_error = U_ZERO_ERROR; + int32_t result =u_strFoldCase (dest, dest_capacity, src, src_len, options, &icu_error); + *i18n_error = _i18n_error_mapping(icu_error); + set_last_result(*i18n_error); + + return result; +} + +wchar_t* i18n_ustring_to_WCS ( wchar_t *dest, int32_t dest_capacity, int32_t *dest_len, const i18n_uchar *src, int32_t src_len, i18n_error_code_e *i18n_error ) +{ + if(src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + *i18n_error = I18N_ERROR_INVALID_PARAMETER; + return NULL; + } + + UErrorCode icu_error = U_ZERO_ERROR; + wchar_t* result = u_strToWCS (dest, dest_capacity, dest_len, src, src_len, &icu_error); + *i18n_error = _i18n_error_mapping(icu_error); + set_last_result(*i18n_error); + + return result; +} + +i18n_uchar* i18n_ustring_from_WCS ( i18n_uchar *dest, int32_t dest_capacity, int32_t *dest_len, const wchar_t *src, int32_t src_len, i18n_error_code_e *i18n_error ) +{ + if(src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + *i18n_error = I18N_ERROR_INVALID_PARAMETER; + return NULL; + } + + UErrorCode icu_error = U_ZERO_ERROR; + i18n_uchar* result = u_strFromWCS (dest, dest_capacity, dest_len, src, src_len, &icu_error); + *i18n_error = _i18n_error_mapping(icu_error); + set_last_result(*i18n_error); + + return result; +} + +char* i18n_ustring_to_UTF8 ( char *dest, int32_t dest_capacity, int32_t *dest_len, const i18n_uchar *src, int32_t src_len, i18n_error_code_e *i18n_error ) +{ + if(src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + *i18n_error = I18N_ERROR_INVALID_PARAMETER; + return NULL; + } + + UErrorCode icu_error = U_ZERO_ERROR; + char* result = u_strToUTF8 (dest, dest_capacity, dest_len, src, src_len, &icu_error); + *i18n_error = _i18n_error_mapping(icu_error); + set_last_result(*i18n_error); + + return result; +} + +i18n_uchar* i18n_ustring_from_UTF8 ( i18n_uchar *dest, int32_t dest_capacity, int32_t *dest_len, const char *src, int32_t src_len, i18n_error_code_e *i18n_error ) +{ + if(src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + *i18n_error = I18N_ERROR_INVALID_PARAMETER; + return NULL; + } + + UErrorCode icu_error = U_ZERO_ERROR; + i18n_uchar* result = u_strFromUTF8 (dest, dest_capacity, dest_len, src, src_len, &icu_error); + *i18n_error = _i18n_error_mapping(icu_error); + set_last_result(*i18n_error); + + return result; +} + +char* i18n_ustring_to_UTF8_with_sub ( char *dest, int32_t dest_capacity, int32_t *dest_len, const i18n_uchar *src, int32_t src_len, i18n_uchar32 sub_char, int32_t *num_substitutions, i18n_error_code_e *i18n_error ) +{ + if(src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + *i18n_error = I18N_ERROR_INVALID_PARAMETER; + return NULL; + } + + UErrorCode icu_error = U_ZERO_ERROR; + char* result = u_strToUTF8WithSub (dest, dest_capacity, dest_len, src, src_len, sub_char, num_substitutions, &icu_error); + *i18n_error = _i18n_error_mapping(icu_error); + set_last_result(*i18n_error); + + return result; +} + +i18n_uchar* i18n_ustring_from_UTF8_with_sub ( i18n_uchar *dest, int32_t dest_capacity, int32_t *dest_len, const char *src, int32_t src_len, i18n_uchar32 sub_char, + int32_t *num_substitutions, i18n_error_code_e *i18n_error ) +{ + if(src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + *i18n_error = I18N_ERROR_INVALID_PARAMETER; + return NULL; + } + + UErrorCode icu_error = U_ZERO_ERROR; + i18n_uchar* result = u_strFromUTF8WithSub (dest, dest_capacity, dest_len, src, src_len, sub_char, num_substitutions, &icu_error); + *i18n_error = _i18n_error_mapping(icu_error); + set_last_result(*i18n_error); + + return result; +} + +i18n_uchar* i18n_ustring_from_UTF8_lenient ( i18n_uchar *dest, int32_t dest_capacity, int32_t *dest_len, const char *src, int32_t src_len, i18n_error_code_e *i18n_error ) +{ + if(src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + *i18n_error = I18N_ERROR_INVALID_PARAMETER; + return NULL; + } + + UErrorCode icu_error = U_ZERO_ERROR; + i18n_uchar* result = u_strFromUTF8Lenient (dest, dest_capacity, dest_len, src, src_len, &icu_error); + *i18n_error = _i18n_error_mapping(icu_error); + set_last_result(*i18n_error); + + return result; +} + +i18n_uchar32* i18n_ustring_to_UTF32 ( i18n_uchar32 *dest, int32_t dest_capacity, int32_t *dest_len, const i18n_uchar *src, int32_t src_len, i18n_error_code_e *i18n_error ) +{ + if(src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + *i18n_error = I18N_ERROR_INVALID_PARAMETER; + return NULL; + } + + UErrorCode icu_error = U_ZERO_ERROR; + i18n_uchar32* result = u_strToUTF32 (dest, dest_capacity, dest_len, src, src_len, &icu_error); + *i18n_error = _i18n_error_mapping(icu_error); + set_last_result(*i18n_error); + + return result; +} + +i18n_uchar* i18n_ustring_from_UTF32 ( i18n_uchar *dest, int32_t dest_capacity, int32_t *dest_len, const i18n_uchar32 *src, int32_t src_len, i18n_error_code_e *i18n_error ) +{ + if(src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + *i18n_error = I18N_ERROR_INVALID_PARAMETER; + return NULL; + } + + UErrorCode icu_error = U_ZERO_ERROR; + i18n_uchar* result = u_strFromUTF32 (dest, dest_capacity, dest_len, src, src_len, &icu_error); + *i18n_error = _i18n_error_mapping(icu_error); + set_last_result(*i18n_error); + + return result; +} + +i18n_uchar32* i18n_ustring_to_UTF32_with_sub ( i18n_uchar32 *dest, int32_t dest_capacity, int32_t *dest_len, const i18n_uchar *src, int32_t src_len, + i18n_uchar32 sub_char, int32_t *num_substitutions, i18n_error_code_e *i18n_error ) +{ + if(src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + *i18n_error = I18N_ERROR_INVALID_PARAMETER; + return NULL; + } + + UErrorCode icu_error = U_ZERO_ERROR; + i18n_uchar32* result = u_strToUTF32WithSub (dest, dest_capacity, dest_len, src, src_len, sub_char, num_substitutions, &icu_error); + *i18n_error = _i18n_error_mapping(icu_error); + set_last_result(*i18n_error); + + return result; +} + +i18n_uchar* i18n_ustring_from_UTF32_with_sub ( i18n_uchar *dest, int32_t dest_capacity, int32_t *dest_len, const i18n_uchar32 *src, int32_t src_len, i18n_uchar32 sub_char, int32_t *num_substitutions, i18n_error_code_e *i18n_error ) +{ + if(src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + *i18n_error = I18N_ERROR_INVALID_PARAMETER; + return NULL; + } + + UErrorCode icu_error = U_ZERO_ERROR; + i18n_uchar* result = u_strFromUTF32WithSub (dest, dest_capacity, dest_len, src, src_len, sub_char, num_substitutions, (UErrorCode*)&icu_error); + *i18n_error = _i18n_error_mapping(icu_error); + set_last_result(*i18n_error); + + return result; +} + -- 2.7.4