diff options
42 files changed, 7768 insertions, 0 deletions
@@ -0,0 +1,4 @@ +Hobum Kwon <hobum.kwon@samsung.com> +Jinwoo Jeong <jinw.jeong@samsung.com> +Jonghoon Lim <j.h.lim@samsung.com> +Joonghyun Cho <jh5.cho@samsung.com> 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/) @@ -0,0 +1,25 @@ +COPYRIGHT AND PERMISSION NOTICE +Copyright (c) 1995-2014 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. 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 @@ +<manifest> + <request> + <domain name="_"/> + </request> +</manifest> diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..40dcfae --- /dev/null +++ b/debian/changelog @@ -0,0 +1,239 @@ +bundle (0.1.22) unstable; urgency=low + + * Checksum added to encode/decode to enhance stability and svace defects fixed. + * Git: 165.213.180.234:slp/pkgs/b/bundle + * Tag: bundle_0.1.22 + + -- Jaeho Lee <jaeho81.lee@samsung.com> Fri, 17 Feb 2012 16:45:12 +0900 + +bundle (0.1.21) unstable; urgency=low + + * Updated changelog + * Git: 165.213.180.234:slp/pkgs/b/bundle + * Tag: bundle_0.1.21 + + -- Sewook Park <sewook7.park@samsung.com> Mon, 05 Dec 2011 15:58:05 +0900 + +bundle (0.1.20) unstable; urgency=low + + * Changed Boilerplate as per the guideline + * Git: 165.213.180.234:slp/pkgs/b/bundle + * Tag: bundle_0.1.20 + + -- Jaeho Lee <jaeho81.lee@samsung.com> Mon, 07 Nov 2011 09:57:20 +0900 + +bundle (0.1.19) unstable; urgency=low + + * Support array + * Git: 165.213.180.234:slp/pkgs/b/bundle + * Tag: bundle_0.1.19 + + -- Jaeho Lee <jaeho81.lee@samsung.com> Thu, 06 Oct 2011 14:53:57 +0900 + +bundle (0.1.18) unstable; urgency=low + + * Modify TC Makefile + * Git: 165.213.180.234:slp/pkgs/b/bundle + * Tag: bundle_0.1.18 + + -- Jaeho Lee <jaeho81.lee@samsung.com> Tue, 16 Aug 2011 14:53:16 +0900 + +bundle (0.1.17) unstable; urgency=low + + * Fix Apply code cleanup + * Git: 165.213.180.234:slp/pkgs/b/bundle + * Tag: bundle_0.1.17 + + -- Sewook Park <sewook7.park@samsung.com> Tue, 02 Aug 2011 19:11:59 +0900 + +bundle (0.1.16) unstable; urgency=low + + * Fix Boilerplate module name + * Git: 165.213.180.234:slp/pkgs/b/bundle + * Tag: bundle_0.1.16 + + -- Sewook Park <sewook7.park@samsung.com> Sat, 16 Jul 2011 13:33:11 +0900 + +bundle (0.1.15) unstable; urgency=low + + * Apply Boilerplate + * Git: 165.213.180.234:slp/pkgs/b/bundle + * Tag: bundle_0.1.15 + + -- Sewook Park <sewook7.park@samsung.com> Wed, 13 Jul 2011 17:36:38 +0900 + +bundle (0.1.14) unstable; urgency=low + + * Rollback to bundle_0.1.12 + * Git: 165.213.180.234:slp/pkgs/b/bundle + * Tag: bundle_0.1.14 + + -- Sewook Park <sewook7.park@samsung.com> Thu, 07 Jul 2011 15:25:40 +0900 + +bundle (0.1.13) unstable; urgency=low + + * Check ENOMEM when adding a value in a bundle + * Git: 165.213.180.234:slp/pkgs/b/bundle + * Tag: bundle_0.1.13 + + -- Youmin Ha <youmin.ha@samsung.com> Thu, 21 Apr 2011 10:52:49 +0900 + +bundle (0.1.12) unstable; urgency=low + + * Add bundle_export_to_argv(), bundle_import_from-argv() + * Git: 165.213.180.234:slp/pkgs/b/bundle + * Tag: bundle_0.1.12 + + -- Youmin Ha <youmin.ha@samsung.com> Mon, 28 Feb 2011 09:33:57 +0900 + +bundle (0.1.11-3) unstable; urgency=low + + * reupload + * Git: 165.213.180.234:slp/pkgs/b/bundle + * Tag: bundle_0.1.11-3 + + -- Youmin Ha <youmin.ha@samsung.com> Wed, 19 Jan 2011 11:13:57 +0900 + +bundle (0.1.11-2) unstable; urgency=low + + * fix git path + * Git: 165.213.180.234:slp/pkgs/b/bundle + * Tag: bundle_0.1.11-2 + + -- Youmin Ha <youmin.ha@samsung.com> Wed, 19 Jan 2011 10:38:28 +0900 + +bundle (0.1.11-1) unstable; urgency=low + + * add {0, NULL} as last item to the tclist + * Git: 165.213.180.234:/git/slp/pkgs/bundle + * Tag: bundle_0.1.11-1 + + -- Youmin Ha <youmin.ha@samsung.com> Wed, 19 Jan 2011 08:36:04 +0900 + +bundle (0.1.11) unstable; urgency=low + + * remove garbages from src pkg + * Git: 165.213.180.234:/git/slp/pkgs/bundle + * Tag: bundle_0.1.11 + + -- Youmin Ha <youmin.ha@samsung.com> Wed, 24 Nov 2010 17:48:57 +0900 + +bundle (0.1.10-1) unstable; urgency=low + + * Add doxygen + * Git: 165.213.180.234:/git/slp/pkgs/bundle + * Tag: bundle_0.1.10-1 + + -- Youmin Ha <youmin.ha@samsung.com> Fri, 05 Nov 2010 14:13:58 +0900 + +bundle (0.1.10) unstable; urgency=low + + * Add doxygen + * Git: 165.213.180.234:/git/slp/pkgs/bundle + * Tag: bundle_0.1.10 + + -- Youmin Ha <youmin.ha@samsung.com> Tue, 02 Nov 2010 16:57:33 +0900 + +bundle (0.1.9) unstable; urgency=low + + * Apply SOVERSION + VERSION automatically + * Git: 165.213.180.234:/git/slp/pkgs/bundle + * Tag: bundle_0.1.9 + + -- Youmin Ha <youmin.ha@samsung.com> Wed, 20 Oct 2010 19:24:28 +0900 + +bundle (0.1.8-3) unstable; urgency=low + + * Fix doxygen + * Git: 165.213.180.234:/git/slp/pkgs/bundle + * Tag: bundle_0.1.8-3 + + -- Youmin Ha <youmin.ha@samsung.com> Mon, 18 Oct 2010 19:58:08 +0900 + +bundle (0.1.8-2) unstable; urgency=low + + * Fix doxygen + * Git: 165.213.180.234:/git/slp/pkgs/bundle + * Tag: bundle_0.1.8-2 + + -- Youmin Ha <youmin.ha@samsung.com> Mon, 18 Oct 2010 11:05:06 +0900 + +bundle (0.1.8-1) unstable; urgency=low + + * Add libglib2.0-dev to build-dep + * Git: 165.213.180.234:/git/slp/pkgs/bundle + * Tag: bundle_0.1.8-1 + + -- Youmin Ha <youmin.ha@samsung.com> Sat, 18 Sep 2010 17:16:52 +0900 + +bundle (0.1.8) unstable; urgency=low + + * Use base64 encoding/decoding with bundle_encode(), bundle_decode() + * Git: 165.213.180.234:/git/slp/pkgs/bundle + * Tag: bundle_0.1.8 + + -- Youmin Ha <youmin.ha@samsung.com> Sat, 18 Sep 2010 16:47:29 +0900 + +bundle (0.1.7) unstable; urgency=low + + * add TC + * Git: 165.213.180.234:/git/slp/pkgs/bundle + * Tag: bundle_0.1.7 + + -- Youmin Ha <youmin.ha@samsung.com> Wed, 08 Sep 2010 17:22:15 +0900 + +bundle (0.1.6) unstable; urgency=low + + * Include PG into dev package + * Git: 165.213.180.234:/git/slp/pkgs/bundle + * Tag: bundle_0.1.6 + + -- Youmin Ha <youmin.ha@samsung.com> Fri, 27 Aug 2010 15:26:31 +0900 + +bundle (0.1.5) unstable; urgency=low + + * add programming guide into doxygen + * Git: 165.213.180.234:/git/slp/pkgs/bundle + * Tag: bundle_0.1.5 + + -- Youmin Ha <youmin.ha@samsung.com> Tue, 24 Aug 2010 19:04:10 +0900 + +bundle (0.1.4) unstable; urgency=low + + * add bundle_dup() function + * Git: 165.213.180.234:/git/slp/pkgs/bundle + * Tag: bundle_0.1.4 + + -- Youmin Ha <youmin.ha@samsung.com> Tue, 27 Jul 2010 14:04:52 +0900 + +bundle (0.1.3) unstable; urgency=low + + * add bundle_del() function, and many tests for wrong uses + * Git: 165.213.180.234:/git/slp/pkgs/bundle + * Tag: bundle_0.1.3 + + -- Youmin Ha <youmin.ha@samsung.com> Fri, 23 Jul 2010 11:21:32 +0900 + +bundle (0.1.2) unstable; urgency=low + + * Create libbundle.so.0 and its symlink libbundle.so + * Git: 165.213.180.234:/git/slp/pkgs/bundle + * Tag: bundle_0.1.2 + + -- Youmin Ha <youmin.ha@samsung.com> Thu, 22 Jul 2010 11:22:13 +0900 + +bundle (0.1.1) unstable; urgency=low + + * Fix CMakeList.txt : add @ONLY option to the command generating pc file + * Git: 165.213.180.234:/git/slp/pkgs/bundle + * Tag: bundle_0.1.1 + + -- Youmin Ha <youmin.ha@samsung.com> Thu, 22 Jul 2010 09:49:54 +0900 + +bundle (0.1.0) unstable; urgency=low + + * Initial release. + * Git: 165.213.180.234:/git/slp/pkgs/bundle + * Tag: bundle_0.1.0 + + -- Youmin Ha <youmin.ha@samsung.com> Wed, 21 Jul 2010 17:04:19 +0900 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +5 diff --git a/debian/control b/debian/control new file mode 100755 index 0000000..9db2a05 --- /dev/null +++ b/debian/control @@ -0,0 +1,24 @@ +Source: bundle +Section: devel +Priority: extra +Maintainer: Garima <garima.s@samsung.com>, Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com> +Build-Depends: debhelper (>= 4.0.0), libglib2.0-dev, dlog-dev +Standards-Version: 0.1.0 + +Package: libbundle-0 +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Simple string key-val dictionary ADT + +Package: libbundle-dev +Architecture: any +Depends: libbundle-0 (= ${Source-Version}) +Description: Dev package for libbundle-0 +XB-Generate-Docs: yes + +Package: libbundle-dbg +Section: debug +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, libbundle-0 (= ${Source-Version}) +Description: Debug symbols for libbundle-0 + diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..a868b66 --- /dev/null +++ b/debian/rules @@ -0,0 +1,126 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + + +# These are used for cross-compiling and for saving the configure script +# from having to guess our platform (since we know it already) +DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) +DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) +DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH) +DEB_HOST_ARCH_OS ?= $(shell dpkg-architecture -qDEB_HOST_GNU_OS) + +CFLAGS ?= -Wall -g +LDFLAGS ?= +PREFIX ?= /usr +DATADIR ?= /opt + +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) + CFLAGS += -O0 +else + CFLAGS += -O2 +endif + +# architecture is not arm +ifneq (, $(findstring arm, $(DEB_HOST_ARCH))) + # do something here +else + # do something here for arm +endif + +CFLAGS += -fvisibility=hidden -fPIC +LDFLAGS += -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed + +CMAKE_TMP_DIR = $(CURDIR)/cmake_tmp + +config.status: + +configure: configure-stamp + +configure-stamp: + dh_testdir + mkdir -p $(CMAKE_TMP_DIR); + export LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(CMAKE_TMP_DIR) && cd $(CMAKE_TMP_DIR); CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" cmake .. -DCMAKE_INSTALL_PREFIX=$(PREFIX) + touch configure-stamp + +build: build-stamp + +build-stamp: configure-stamp + dh_testdir + # Add here commands to compile the package. + cd $(CMAKE_TMP_DIR) && $(MAKE) all + + for f in `find $(CURDIR)/debian/ -name "*.in"`; do \ + cat $$f > $${f%.in}; \ + sed -i -e "s#@PREFIX@#$(PREFIX)#g" $${f%.in}; \ + sed -i -e "s#@DATADIR@#$(DATADIR)#g" $${f%.in}; \ + done + + touch $@ + +clean: + dh_testdir + dh_testroot + rm -f *-stamp + + rm -rf $(CMAKE_TMP_DIR) + + for f in `find $(CURDIR)/debian/ -name "*.in"`; do \ + rm -f $${f%.in}; \ + done + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/ncurses. + cd $(CMAKE_TMP_DIR) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_installexamples + dh_install --list-missing --sourcedir=debian/tmp +# dh_installmenu +# dh_installdebconf +# dh_installlogrotate +# dh_installemacsen +# dh_installpam +# dh_installmime +# dh_python +# dh_installinit +# dh_installcron +# dh_installinfo + dh_installman + dh_link + dh_strip --dbg-package=libbundle-dbg + dh_compress + dh_fixperms +# dh_perl + dh_makeshlibs + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install diff --git a/doc/utils_doc.h b/doc/utils_doc.h new file mode 100755 index 0000000..876cbca --- /dev/null +++ b/doc/utils_doc.h @@ -0,0 +1,27 @@ +#ifndef __UTILS_DOC_H__ +#define __UTILS_DOC_H__ + +/** + * @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 + * <table> + * <tr> + * <th>Module</th> + * <th>Description</th> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_MODULE</td> + * <td>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 to format and parse dates/number for any locale.</td> + * </tr> + * </table> + */ + +#endif /* __UTILS_DOC_H__*/ diff --git a/image/SLP_bundle_PG_image01.png b/image/SLP_bundle_PG_image01.png Binary files differnew file mode 100755 index 0000000..3dd18de --- /dev/null +++ b/image/SLP_bundle_PG_image01.png diff --git a/image/SLP_bundle_PG_images_encode_decode.png b/image/SLP_bundle_PG_images_encode_decode.png Binary files differnew file mode 100644 index 0000000..96cc725 --- /dev/null +++ b/image/SLP_bundle_PG_images_encode_decode.png diff --git a/image/SLP_bundle_PG_images_export_import.png b/image/SLP_bundle_PG_images_export_import.png Binary files differnew file mode 100644 index 0000000..fd7202f --- /dev/null +++ b/image/SLP_bundle_PG_images_export_import.png diff --git a/image/SLP_bundle_PG_images_logical_view.png b/image/SLP_bundle_PG_images_logical_view.png Binary files differnew file mode 100644 index 0000000..b2bbaf7 --- /dev/null +++ b/image/SLP_bundle_PG_images_logical_view.png diff --git a/packaging/capi-base-utils.spec b/packaging/capi-base-utils.spec new file mode 100755 index 0000000..21c4529 --- /dev/null +++ b/packaging/capi-base-utils.spec @@ -0,0 +1,67 @@ +Name: capi-base-utils +Summary: capi-base-utils +Version: 0.0.8 +Release: 8 +Group: Development/Libraries +License: MIT LICENSE +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 + +%package devel +Summary: The Base Utils Library (Development) +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} + +%description devel +The Base Utils Library (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} + +make %{?jobs:-j%jobs} + +%install +rm -rf %{buildroot} +%make_install +mkdir -p %{buildroot}/usr/share/license +cp LICENSE %{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.h +%{_libdir}/pkgconfig/*.pc diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100755 index 0000000..42d027c --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,63 @@ +SET(target_name "base-utils-i18n") +SET(pc_name "capi-base-utils-i18n") + +#PKG_SEARCH_MODULE(baseutils REQUIRED capi-base-common icu-i18n) +#INCLUDE_DIRECTORIES( + #${CMAKE_CURRENT_SOURCE_DIR}/include +#) + +SET(dependents "icu-i18n") +PKG_CHECK_MODULES(baseutils REQUIRED ${dependents}) +INCLUDE_DIRECTORIES( + ${baseutils_INCLUDE_DIRS} + ${CMAKE_CURRENT_SOURCE_DIR}/include +) + + +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_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}/include/utils_i18n_types.h DESTINATION ${INCLUDE_INSTALL_DIR}/base) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/utils_i18n_uchar.h DESTINATION ${INCLUDE_INSTALL_DIR}/base) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/utils_i18n_ucollator.h DESTINATION ${INCLUDE_INSTALL_DIR}/base) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/utils_i18n_unormalization.h DESTINATION ${INCLUDE_INSTALL_DIR}/base) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/utils_i18n_usearch.h DESTINATION ${INCLUDE_INSTALL_DIR}/base) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/utils_i18n_ustring.h DESTINATION ${INCLUDE_INSTALL_DIR}/base) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/utils_i18n_types.h DESTINATION ${INCLUDE_INSTALL_DIR}/base) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/utils_i18n_ucalendar.h DESTINATION ${INCLUDE_INSTALL_DIR}/base) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/utils_i18n_udate.h DESTINATION ${INCLUDE_INSTALL_DIR}/base) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/utils_i18n_udatepg.h DESTINATION ${INCLUDE_INSTALL_DIR}/base) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/utils_i18n_ulocale.h DESTINATION ${INCLUDE_INSTALL_DIR}/base) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/utils_i18n_unumber.h DESTINATION ${INCLUDE_INSTALL_DIR}/base) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/utils_i18n_timezone.h DESTINATION ${INCLUDE_INSTALL_DIR}/base) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/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/utils_i18n.h b/src/include/utils_i18n.h new file mode 100755 index 0000000..1420f33 --- /dev/null +++ b/src/include/utils_i18n.h @@ -0,0 +1,788 @@ +/* + * icu + * + * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * + * 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 <utils_i18n_types.h> +#include <utils_i18n_uchar.h> +#include <utils_i18n_ustring.h> +#include <utils_i18n_ucollator.h> +#include <utils_i18n_unormalization.h> +#include <utils_i18n_usearch.h> +#include <utils_i18n_ucalendar.h> +#include <utils_i18n_udate.h> +#include <utils_i18n_udatepg.h> +#include <utils_i18n_ulocale.h> +#include <utils_i18n_unumber.h> +#include <utils_i18n_timezone.h> + +/** + * @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 <utils_i18n.h> + * @section CAPI_BASE_UTILS_I18N_MODULE_OVERVIEW Overview + * <table> + * <tr> + * <th>API</th> + * <th>Description</th> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td> + * <td>The Timezone module represents a time zone offset, and also figures out daylight savings.</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULE</td> + * <td>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.</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UCHAR_MODULE</td> + * <td>Uchar module provides low-level access to the Unicode Character Database.</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UNORMALIZATION_MODULE</td> + * <td>Unormalization module provides Unicode normalization functionality for standard unicode normalization.</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USEARCH_MODULE</td> + * <td>Usearch module provides language-sensitive text searching based on the comparison rules defined in a ucollator data struct.</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>Ustring module provides general unicode string handling.</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE</td> + * <td>Ucalendar 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.</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE</td> + * <td>Udate module consists of functions that convert dates and times from their + internal representations to textual form and back again in a language-independent manner.</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE</td> + * <td> Udatepg module provides flexible generation of date format patterns, like "yy-MM-dd". </td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE</td> + * <td>A ulocale represents a specific geographical, political, or cultural region. </td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE</td> + * <td>Unumber helps you format and parse numbers for any locale.</td> + * </tr> + * </table> + * + * @section CAPI_BASE_UTILS_I18N_MODULE_MAPPING_TABLE Mapping Table + * <table> + * <tr> + * <th>Module</th> + * <th>Native API</th> + * <th>ICU API</th> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td> + * <td>#i18n_timezone_create_unknown</td> + * <td>getUnknown</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td> + * <td>#i18n_timezone_create_gmt</td> + * <td>getGMT</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td> + * <td>#i18n_timezone_create</td> + * <td>createTimeZone</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td> + * <td>#i18n_timezone_destroy</td> + * <td></td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td> + * <td>#i18n_timezone_foreach_timezone_id_by_region</td> + * <td>createTimeZoneIDEnumeration</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td> + * <td>#i18n_timezone_foreach_timezone_id</td> + * <td>createEnumeration</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td> + * <td>#i18n_timezone_foreach_timezone_id_with_offset</td> + * <td>createEnumeration</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td> + * <td>#i18n_timezone_foreach_timezone_id_by_country</td> + * <td>createEnumeration</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td> + * <td>#i18n_timezone_count_equivalent_ids</td> + * <td>countEquivalentIDs</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td> + * <td>#i18n_timezone_get_equivalent_id</td> + * <td>getEquivalentID</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td> + * <td>#i18n_timezone_create_default</td> + * <td>createDefault</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td> + * <td>#i18n_timezone_set_default</td> + * <td>setDefault</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td> + * <td>#i18n_timezone_get_tzdata_version</td> + * <td>getTZDataVersion</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td> + * <td>#i18n_timezone_get_region</td> + * <td>getRegion</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td> + * <td>#i18n_timezone_get_offset_with_date</td> + * <td>getOffset</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td> + * <td>#i18n_timezone_set_raw_offset</td> + * <td>setRawOffset</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td> + * <td>#i18n_timezone_get_raw_offset</td> + * <td>getRawOffset</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td> + * <td>#i18n_timezone_get_id</td> + * <td>getID</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td> + * <td>#i18n_timezone_set_id</td> + * <td>setID</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td> + * <td>#i18n_timezone_get_display_name</td> + * <td>getDisplayName</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td> + * <td>#i18n_timezone_get_display_name_with_locale</td> + * <td>getDisplayName</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td> + * <td>#i18n_timezone_get_display_name_with_type</td> + * <td>getDisplayName</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td> + * <td>#i18n_timezone_get_display_name_with_type_locale</td> + * <td>getDisplayName</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td> + * <td>#i18n_timezone_use_daylight_time</td> + * <td>useDaylightTime</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td> + * <td>#i18n_timezone_in_daylight_time</td> + * <td>inDaylightTime</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td> + * <td>#i18n_timezone_has_same_rule</td> + * <td>hasSameRules</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td> + * <td>#i18n_timezone_clone</td> + * <td>clone</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td> + * <td>#i18n_timezone_get_dst_savings</td> + * <td>getDSTSavings</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE</td> + * <td>#i18n_ucalendar_set_default_timezone</td> + * <td>ucal_setDefaultTimeZone</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE</td> + * <td>#i18n_ucalendar_get_now</td> + * <td>ucal_getNow</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE</td> + * <td>#i18n_ucalendar_create</td> + * <td>ucal_open</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE</td> + * <td>#i18n_ucalendar_destroy</td> + * <td>ucal_close</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE</td> + * <td>#i18n_ucalendar_clone</td> + * <td>ucal_clone</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE</td> + * <td>#i18n_ucalendar_get_timezone_displayname</td> + * <td>ucal_getTimeZoneDisplayName</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE</td> + * <td>#i18n_ucalendar_is_in_daylight_time</td> + * <td>ucal_inDaylightTime</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE</td> + * <td>#i18n_ucalendar_set</td> + * <td>ucal_set</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE</td> + * <td>#i18n_ucalendar_set_attribute</td> + * <td>ucal_setAttribute</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE</td> + * <td>#i18n_ucalendar_get_attribute</td> + * <td>ucal_getAttribute</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE</td> + * <td>#i18n_ucalendar_get_milliseconds</td> + * <td>ucal_getMillis</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE</td> + * <td>#i18n_ucalendar_set_milliseconds</td> + * <td>ucal_setMillis</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE</td> + * <td>#i18n_ucalendar_set_date_time</td> + * <td>ucal_setDateTime</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE</td> + * <td>#i18n_ucalendar_is_equivalent_to</td> + * <td>ucal_equivalentTo</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE</td> + * <td>#i18n_ucalendar_add</td> + * <td>ucal_add</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE</td> + * <td>#i18n_ucalendar_get</td> + * <td>ucal_get</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UCHAR_MODULE</td> + * <td>#i18n_uchar_get_int_property_value</td> + * <td>u_getIntpropertyValue</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UCHAR_MODULE</td> + * <td>#i18n_uchar_get_ublock_code</td> + * <td>ublock_getCode</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULE</td> + * <td>#i18n_ucollator_create</td> + * <td>ucol_open</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULE</td> + * <td>#i18n_ucollator_destroy</td> + * <td>ucol_close</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULE</td> + * <td>#i18n_ucollator_str_collator</td> + * <td>ucol_strcoll</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULE</td> + * <td>#i18n_ucollator_equal</td> + * <td>ucol_equal</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULE</td> + * <td>#i18n_ucollator_set_strength</td> + * <td>ucol_setStrength</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UCOLLATOR_MODULE</td> + * <td>#i18n_ucollator_set_attribute</td> + * <td>ucol_setAttribute</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE</td> + * <td>#i18n_udate_create</td> + * <td>udat_open</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE</td> + * <td>#i18n_udate_destroy</td> + * <td>udat_close</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UDATE_MODULE</td> + * <td>#i18n_udate_format_date</td> + * <td>udat_format</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE</td> + * <td>#i18n_udatepg_create</td> + * <td>udatpg_open</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE</td> + * <td>#i18n_udatepg_destroy</td> + * <td>udatpg_close</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UDATEPG_MODULE</td> + * <td>#i18n_udatepg_get_best_pattern</td> + * <td>udatpg_getBestPattern</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE</td> + * <td>#i18n_ulocale_get_default</td> + * <td>uloc_getDefault</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE</td> + * <td>#i18n_ulocale_set_default</td> + * <td>uloc_setDefault</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE</td> + * <td>#i18n_ulocale_get_language</td> + * <td>uloc_getLanguage</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE</td> + * <td>#i18n_ulocale_get_country</td> + * <td>uloc_getCountry</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE</td> + * <td>#i18n_ulocale_get_display_name</td> + * <td>uloc_getDisplayName</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE</td> + * <td>#i18n_ulocale_get_available</td> + * <td>uloc_getAvailable</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_ULOCALE_MODULE</td> + * <td>#i18n_ulocale_count_available</td> + * <td>uloc_countAvailable</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UNORMALIZATION_MODULE</td> + * <td>#i18n_unormalization_get_instance</td> + * <td>unorm2_getInstance</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UNORMALIZATION_MODULE</td> + * <td>#i18n_unormalization_normalize</td> + * <td>unorm2_normalize</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE</td> + * <td>#i18n_unumber_create</td> + * <td>unum_open</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE</td> + * <td>#i18n_unumber_destroy</td> + * <td>unum_close</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_UNUMBER_MODULE</td> + * <td>#i18n_unumber_get_symbol</td> + * <td>unum_getSymbol</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USEARCH_MODULE</td> + * <td>#i18n_usearch_create</td> + * <td>usearch_open</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USEARCH_MODULE</td> + * <td>#i18n_usearch_destroy</td> + * <td>usearch_close</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USEARCH_MODULE</td> + * <td>#i18n_usearch_get_matched_text</td> + * <td>usearch_getMatchedText</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USEARCH_MODULE</td> + * <td>#i18n_usearch_get_collator</td> + * <td>usearch_getCollator</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USEARCH_MODULE</td> + * <td>#i18n_usearch_first</td> + * <td>usearch_first</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_get_length</td> + * <td>u_strlen</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_count_char32</td> + * <td>u_countChar32</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_has_more_char32_than</td> + * <td>u_strHasMoreChar32Than</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_cat</td> + * <td>u_strcat</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_cat_n</td> + * <td>u_strncat</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_string</td> + * <td>u_strstr</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_find_first</td> + * <td>u_strFindFirst</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_char</td> + * <td>u_strchr</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_char32</td> + * <td>u_strchr32</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_r_string</td> + * <td>u_strrstr</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_find_last</td> + * <td>u_strFindLast</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_r_char</td> + * <td>u_strrchr</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_r_char32</td> + * <td>u_strrchr32</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_pbrk</td> + * <td>u_strpbrk</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_cspn</td> + * <td>u_strcspn</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_spn</td> + * <td>u_strspn</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_tokenizer_r</td> + * <td>u_strtok_r</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_compare</td> + * <td>u_strcmp</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_compare_code_point_order</td> + * <td>u_strcmpCodePointOrder</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_compare_binary_order</td> + * <td>u_strCompare</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_case_compare_with_length</td> + * <td>u_strCaseCompare</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_compare_n</td> + * <td>u_strncmp</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_compare_n_code_point_order</td> + * <td>u_strncmpCodePointOrder</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_case_compare</td> + * <td>u_strcasecmp</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_case_compare_n</td> + * <td>u_strncasecmp</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_mem_case_compare</td> + * <td>u_memcasecmp</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_copy</td> + * <td>u_strcpy</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_copy_n</td> + * <td>u_strncpy</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_copy_ua</td> + * <td>u_uastrcpy</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_copy_ua_n</td> + * <td>u_uastrncpy</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_copy_au</td> + * <td>u_austrcpy</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_copy_au_n</td> + * <td>u_austrncpy</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_mem_copy</td> + * <td>u_memcpy</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_mem_move</td> + * <td>u_memmove</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_mem_set</td> + * <td>u_memset</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_mem_compare</td> + * <td>u_memcmp</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_mem_compare_code_point_order</td> + * <td>u_memcmpCodePointOrder</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_mem_char</td> + * <td>u_memchr</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_mem_char32</td> + * <td>u_memchr32</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_mem_r_char</td> + * <td>u_memrchr</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_mem_r_char32</td> + * <td>u_memrchr32</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_unescape</td> + * <td>u_unescape</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_unescape_at</td> + * <td>u_unescapeAt</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_to_upper</td> + * <td>u_strToUpper</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_to_lower</td> + * <td>u_strToLower</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_to_title</td> + * <td>u_strToTitle</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_fold_case</td> + * <td>u_strFoldCase</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_to_WCS</td> + * <td>u_strToWCS</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_from_WCS</td> + * <td>u_strFromWCS</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_to_UTF8</td> + * <td>u_strToUTF8</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_from_UTF8</td> + * <td>u_strFromUTF8</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_to_UTF8_with_sub</td> + * <td>u_strToUTF8WithSub</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_from_UTF8_with_sub</td> + * <td>u_strFromUTF8WithSub</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_from_UTF8_lenient</td> + * <td>u_strFromUTF8Lenient</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_to_UTF32</td> + * <td>u_strToUTF32</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_from_UTF32</td> + * <td>u_strFromUTF32</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_to_UTF32_with_sub</td> + * <td>u_strToUTF32WithSub</td> + * </tr> + * <tr> + * <td>@ref CAPI_BASE_UTILS_I18N_USTRING_MODULE</td> + * <td>#i18n_ustring_from_UTF32_with_sub</td> + * <td>u_strFromUTF32WithSub</td> + * </tr> + * </table> + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __UTILS_I18N_H__*/ diff --git a/src/include/utils_i18n_private.h b/src/include/utils_i18n_private.h new file mode 100755 index 0000000..caaf03e --- /dev/null +++ b/src/include/utils_i18n_private.h @@ -0,0 +1,79 @@ +#ifndef __UTILS_I18N_PRIVATE_H__ +#define __UTILS_I18N_PRIVATE_H__ + +#include <stdbool.h> +#include <dlog.h> +#include <utils_i18n_types.h> + +/** + * @file utils_i18n_private.h + * @version 0.1 + * @brief utils_i18n_private + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#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); + +typedef enum { + I18N_U_ZERO_ERROR = 0, + I18N_U_ILLEGAL_ARGUMENT_ERROR = 1, + I18N_U_MISSING_RESOURCE_ERROR = 2, + I18N_U_INVALID_FORMAT_ERROR = 3, + I18N_U_FILE_ACCESS_ERROR = 4, + I18N_U_INTERNAL_PROGRAM_ERROR = 5, + I18N_U_MEMORY_ALLOCATION_ERROR = 7, + I18N_U_INDEX_OUTOFBOUNDS_ERROR = 8, + I18N_U_INVALID_CHAR_FOUND = 10, + I18N_U_BUFFER_OVERFLOW_ERROR = 15, + I18N_U_UNSUPPORTED_ERROR = 16, + I18N_U_RESOURCE_TYPE_MISMATCH = 17, + I18N_U_TOO_MANY_ALIASES_ERROR = 24, + I18N_U_COLLATOR_VERSION_MISMATCH = 28, + I18N_U_USELESS_COLLATOR_ERROR = 29, + I18N_U_NO_WRITE_PERMISSION = 30 +} i18n_uerror_code_private_e; + +int _i18n_error_mapping ( i18n_uerror_code_private_e err ); + + +#ifdef __cplusplus +} +#endif + +#endif /* __UTILS_I18N_PRIVATE_H__*/ diff --git a/src/include/utils_i18n_timezone.h b/src/include/utils_i18n_timezone.h new file mode 100755 index 0000000..3c32870 --- /dev/null +++ b/src/include/utils_i18n_timezone.h @@ -0,0 +1,445 @@ +#ifndef __UTILS_I18N_TIMEZONE_H__ +#define __UTILS_I18N_TIMEZONE_H__ + +#include <utils_i18n_types.h> + +/** + * @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 <utils_i18n.h> + * + * @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 + * <code> + * i18n_timezone_h timezone;\n + * i18n_timezone_create(&timezone, "America/Los_Angeles");\n + * </code> + * 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 2.3 + * + * @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 2.3 + * + * @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 2.3 + * + * @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 2.3 + * + * @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 2.3 + * + * @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 2.3 + * + * @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 2.3 + * + * @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 2.3 + * + * @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 2.3 + * + * @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 2.3 + * + * @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 2.3 + * + * @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 2.3 + * @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. + * @since_tizen 2.3 + * + * @return the version string, such as "2007f" + */ +const char* i18n_timezone_get_tzdata_version(); + +/** + * @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 2.3 + * + * @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. + * + * @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 2.3 + * + * @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 2.3 + * + * @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 2.3 + * + * @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 2.3 + * + * @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<code> + * i18n_timezone_h timezone = NULL;\n + * i18n_timezone_create ( &timezone, "America/New_York" );\n + * i18n_timezone_set_id ( "America/Los_Angeles" );\n + * </code>\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 2.3 + * + * @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 2.3 + * + * @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 2.3 + * + * @param[in] timezone The i18n_timezone_h to get a display name. + * @param[in] language The language in which to supply the display name. + * @param[in] country The country in which to supply the 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_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 2.3 + * + * @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 2.3 + * + * @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. + * @param[in] country The country in which to supply the 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_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 2.3 + * + * @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 + * + * @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 2.3 + * + * @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 2.3 + * + * @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 2.3 + * + * @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/utils_i18n_types.h b/src/include/utils_i18n_types.h new file mode 100755 index 0000000..9591cb9 --- /dev/null +++ b/src/include/utils_i18n_types.h @@ -0,0 +1,1316 @@ +#ifndef __UTILS_I18N_TYPES_H__ +#define __UTILS_I18N_TYPES_H__ + +#include <inttypes.h> +#include <tizen.h> +#include <wchar.h> + +/** + * @file utils_i18n_types.h + * @version 0.1 + * @brief utils_i18n_types + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_UCHAR_MODULE + * @{ + */ + +#define I18N_U_MASK(x) ((uint32_t)1<<(x)) + +#define I18N_U_GC_CN_MASK I18N_U_MASK(I18N_UCHAR_U_GENERAL_OTHER_TYPES) +#define I18N_U_GC_LU_MASK I18N_U_MASK(I18N_UCHAR_U_UPPERCASE_LETTER) +#define I18N_U_GC_LL_MASK I18N_U_MASK(I18N_UCHAR_U_LOWERCASE_LETTER) +#define I18N_U_GC_LT_MASK I18N_U_MASK(I18N_UCHAR_U_TITLECASE_LETTER) +#define I18N_U_GC_LM_MASK I18N_U_MASK(I18N_UCHAR_U_MODIFIER_LETTER) +#define I18N_U_GC_LO_MASK I18N_U_MASK(I18N_UCHAR_U_OTHER_LETTER) +#define I18N_U_GC_MN_MASK I18N_U_MASK(I18N_UCHAR_U_NON_SPACING_MARK) +#define I18N_U_GC_ME_MASK I18N_U_MASK(I18N_UCHAR_U_ENCLOSING_MARK) +#define I18N_U_GC_MC_MASK I18N_U_MASK(I18N_UCHAR_U_COMBINING_SPACING_MARK) +#define I18N_U_GC_ND_MASK I18N_U_MASK(I18N_UCHAR_U_DECIMAL_DIGIT_NUMBER) +#define I18N_U_GC_NL_MASK I18N_U_MASK(I18N_UCHAR_U_LETTER_NUMBER) +#define I18N_U_GC_NO_MASK I18N_U_MASK(I18N_UCHAR_U_OTHER_NUMBER) +#define I18N_U_GC_ZS_MASK I18N_U_MASK(I18N_UCHAR_U_SPACE_SEPARATOR) +#define I18N_U_GC_ZL_MASK I18N_U_MASK(I18N_UCHAR_U_LINE_SEPARATOR) +#define I18N_U_GC_ZP_MASK I18N_U_MASK(I18N_UCHAR_U_PARAGRAPH_SEPARATOR) +#define I18N_U_GC_CC_MASK I18N_U_MASK(I18N_UCHAR_U_CONTROL_CHAR) +#define I18N_U_GC_CF_MASK I18N_U_MASK(I18N_UCHAR_U_FORMAT_CHAR) +#define I18N_U_GC_CO_MASK I18N_U_MASK(I18N_UCHAR_U_PRIVATE_USE_CHAR) +#define I18N_U_GC_CS_MASK I18N_U_MASK(I18N_UCHAR_U_SURROGATE) +#define I18N_U_GC_PD_MASK I18N_U_MASK(I18N_UCHAR_U_DASH_PUNCTUATION) +#define I18N_U_GC_PS_MASK I18N_U_MASK(I18N_UCHAR_U_START_PUNCTUATION) +#define I18N_U_GC_PE_MASK I18N_U_MASK(I18N_UCHAR_U_END_PUNCTUATION) +#define I18N_U_GC_PC_MASK I18N_U_MASK(I18N_UCHAR_U_CONNECTOR_PUNCTUATION) +#define I18N_U_GC_PO_MASK I18N_U_MASK(I18N_UCHAR_U_OTHER_PUNCTUATION) +#define I18N_U_GC_SM_MASK I18N_U_MASK(I18N_UCHAR_U_MATH_SYMBOL) +#define I18N_U_GC_SC_MASK I18N_U_MASK(I18N_UCHAR_U_CURRENCY_SYMBOL) +#define I18N_U_GC_SK_MASK I18N_U_MASK(I18N_UCHAR_U_MODIFIER_SYMBOL) +#define I18N_U_GC_SO_MASK I18N_U_MASK(I18N_UCHAR_U_OTHER_SYMBOL) +#define I18N_U_GC_PI_MASK I18N_U_MASK(I18N_UCHAR_U_INITIAL_PUNCTUATION) +#define I18N_U_GC_PF_MASK I18N_U_MASK(I18N_UCHAR_U_FINAL_PUNCTUATION) +#define I18N_U_GC_L_MASK (I18N_U_GC_LU_MASK|I18N_U_GC_LL_MASK|I18N_U_GC_LT_MASK|I18N_U_GC_LM_MASK|I18N_U_GC_LO_MASK) +#define I18N_U_GC_LC_MASK (I18N_U_GC_LU_MASK|I18N_U_GC_LL_MASK|I18N_U_GC_LT_MASK) +#define I18N_U_GC_M_MASK (I18N_U_GC_MN_MASK|I18N_U_GC_ME_MASK|I18N_U_GC_MC_MASK) +#define I18N_U_GC_N_MASK (I18N_U_GC_ND_MASK|I18N_U_GC_NL_MASK|I18N_U_GC_NO_MASK) +#define I18N_U_GC_Z_MASK (I18N_U_GC_ZS_MASK|I18N_U_GC_ZL_MASK|I18N_U_GC_ZP_MASK) +#define I18N_U_GC_C_MASK (I18N_U_GC_CN_MASK|I18N_U_GC_CC_MASK|I18N_U_GC_CF_MASK|I18N_U_GC_CO_MASK|I18N_U_GC_CS_MASK) +#define I18N_U_GC_P_MASK (I18N_U_GC_PD_MASK|I18N_U_GC_PS_MASK|I18N_U_GC_PE_MASK|I18N_U_GC_PC_MASK|I18N_U_GC_PO_MASK|I18N_U_GC_PI_MASK|I18N_U_GC_PF_MASK) +#define I18N_U_GC_S_MASK (I18N_U_GC_SM_MASK|I18N_U_GC_SC_MASK|I18N_U_GC_SK_MASK|I18N_U_GC_SO_MASK) + +#define I18N_U_NO_NUMERIC_VALUE ((double)-123456789.) + +#define I18N_U_GET_GC_MASK(c) I18N_U_MASK(u_charType(c)) + +#define I18N_U_FOLD_CASE_DEFAULT 0 +#define I18N_U_FOLD_CASE_EXCLUDE_SPECIAL_I 1 + +#define I18N_USEARCH_DONE -1 + + +#if !defined(U_WCHAR_IS_UTF16) && !defined(U_WCHAR_IS_UTF32) +# ifdef __STDC_ISO_10646__ +# if (U_SIZEOF_WCHAR_T==2) +# define U_WCHAR_IS_UTF16 +# elif (U_SIZEOF_WCHAR_T==4) +# define U_WCHAR_IS_UTF32 +# endif +# elif defined __UCS2__ +# if (U_PF_OS390 <= U_PLATFORM && U_PLATFORM <= U_PF_OS400) && (U_SIZEOF_WCHAR_T==2) +# define U_WCHAR_IS_UTF16 +# endif +# elif defined(__UCS4__) || (U_PLATFORM == U_PF_OS400 && defined(__UTF32__)) +# if (U_SIZEOF_WCHAR_T==4) +# define U_WCHAR_IS_UTF32 +# endif +# elif U_PLATFORM_IS_DARWIN_BASED || (U_SIZEOF_WCHAR_T==4 && U_PLATFORM_IS_LINUX_BASED) +# define U_WCHAR_IS_UTF32 +# elif U_PLATFORM_HAS_WIN32_API +# define U_WCHAR_IS_UTF16 +# endif +#endif +#define U_SIZEOF_UCHAR 2 +#if defined(UCHAR_TYPE) + typedef UCHAR_TYPE i18n_uchar; +/* Not #elif U_HAVE_CHAR16_T -- because that is type-incompatible with pre-C++11 callers + typedef char16_t i18n_uchar; */ +#elif U_SIZEOF_WCHAR_T==2 + typedef wchar_t i18n_uchar; +#elif defined(__CHAR16_TYPE__) + typedef __CHAR16_TYPE__ i18n_uchar; +#else + typedef uint16_t i18n_uchar; +#endif + +typedef int32_t i18n_uchar32; + +/** + * @brief Enumeration of constants for Unicode properties. + * The properties APIs are intended to reflect Unicode properties as defined in the Unicode Character Database (UCD) and Unicode Technical Reports (UTR). For details about the properties see http://www.unicode.org/ucd/ . For names of Unicode properties see the UCD file PropertyAliases.txt. + */ +typedef enum { + I18N_UCHAR_ALPHABETIC = 0, /**< */ + + I18N_UCHAR_BINARY_START = I18N_UCHAR_ALPHABETIC, /**< */ + I18N_UCHAR_ASCII_HEX_DIGIT, /**< */ + I18N_UCHAR_BIDI_CONTROL, /**< */ + I18N_UCHAR_BIDI_MIRRORED, /**< */ + I18N_UCHAR_DASH, /**< */ + I18N_UCHAR_DEFAULT_IGNORABLE_CODE_POINT, /**< */ + I18N_UCHAR_DEPRECATED, /**< */ + I18N_UCHAR_DIACRITIC, /**< */ + I18N_UCHAR_EXTENDER, /**< */ + I18N_UCHAR_FULL_COMPOSITION_EXCLUSION, /**< */ + I18N_UCHAR_GRAPHEME_BASE, /**< */ + I18N_UCHAR_GRAPHEME_EXTEND, /**< */ + I18N_UCHAR_GRAPHEME_LINK, /**< */ + I18N_UCHAR_HEX_DIGIT, /**< */ + I18N_UCHAR_HYPHEN, /**< */ + I18N_UCHAR_ID_CONTINUE, /**< */ + I18N_UCHAR_ID_START, /**< */ + I18N_UCHAR_IDEOGRAPHIC, /**< */ + I18N_UCHAR_IDS_BINARY_OPERATOR, /**< */ + I18N_UCHAR_IDS_TRINARY_OPERATOR, /**< */ + I18N_UCHAR_JOIN_CONTROL, /**< */ + I18N_UCHAR_LOGICAL_ORDER_EXCEPTION, /**< */ + I18N_UCHAR_LOWERCASE, /**< */ + I18N_UCHAR_MATH, /**< */ + I18N_UCHAR_NONCHARACTER_CODE_POINT, /**< */ + I18N_UCHAR_QUOTATION_MARK, /**< */ + I18N_UCHAR_RADICAL, /**< */ + I18N_UCHAR_SOFT_DOTTED, /**< */ + I18N_UCHAR_TERMINAL_PUNCTUATION, /**< */ + I18N_UCHAR_UNIFIED_IDEOGRAPH, /**< */ + I18N_UCHAR_UPPERCASE, /**< */ + I18N_UCHAR_WHITE_SPACE, /**< */ + I18N_UCHAR_XID_CONTINUE, /**< */ + I18N_UCHAR_XID_START, /**< */ + I18N_UCHAR_CASE_SENSITIVE, /**< */ + I18N_UCHAR_S_TERM, /**< */ + I18N_UCHAR_VARIATION_SELECTOR, /**< */ + I18N_UCHAR_NFD_INERT, /**< */ + I18N_UCHAR_NFKD_INERT, /**< */ + I18N_UCHAR_NFC_INERT, /**< */ + I18N_UCHAR_NFKC_INERT, /**< */ + I18N_UCHAR_SEGMENT_STARTER, /**< */ + I18N_UCHAR_PATTERN_SYNTAX, /**< */ + I18N_UCHAR_PATTERN_WHITE_SPACE, /**< */ + I18N_UCHAR_POSIX_ALNUM, /**< */ + I18N_UCHAR_POSIX_BLANK, /**< */ + I18N_UCHAR_POSIX_GRAPH, /**< */ + I18N_UCHAR_POSIX_PRINT, /**< */ + I18N_UCHAR_POSIX_XDIGIT, /**< */ + I18N_UCHAR_CASED, /**< */ + I18N_UCHAR_CASE_IGNORABLE, /**< */ + I18N_UCHAR_CHANGES_WHEN_LOWERCASED, /**< */ + I18N_UCHAR_CHANGES_WHEN_UPPERCASED, /**< */ + I18N_UCHAR_CHANGES_WHEN_TITLECASED, /**< */ + I18N_UCHAR_CHANGES_WHEN_CASEFOLDED, /**< */ + I18N_UCHAR_CHANGES_WHEN_CASEMAPPED, /**< */ + I18N_UCHAR_CHANGES_WHEN_NFKC_CASEFOLDED, /**< */ + I18N_UCHAR_BINARY_LIMIT, /**< */ + + I18N_UCHAR_BIDI_CLASS = 0x1000, /**< */ + + I18N_UCHAR_INT_START = I18N_UCHAR_BIDI_CLASS, /**< */ + I18N_UCHAR_BLOCK, /**< */ + I18N_UCHAR_CANONICAL_COMBINING_CLASS, /**< */ + I18N_UCHAR_DECOMPOSITION_TYPE, /**< */ + I18N_UCHAR_EAST_ASIAN_WIDTH, /**< */ + I18N_UCHAR_GENERAL_CATEGORY, /**< */ + I18N_UCHAR_JOINING_GROUP, /**< */ + I18N_UCHAR_JOINING_TYPE, /**< */ + I18N_UCHAR_LINE_BREAK, /**< */ + I18N_UCHAR_NUMERIC_TYPE, /**< */ + I18N_UCHAR_SCRIPT, /**< */ + I18N_UCHAR_HANGUL_SYLLABLE_TYPE, /**< */ + I18N_UCHAR_NFD_QUICK_CHECK, /**< */ + I18N_UCHAR_NFKD_QUICK_CHECK, /**< */ + I18N_UCHAR_NFC_QUICK_CHECK, /**< */ + I18N_UCHAR_NFKC_QUICK_CHECK, /**< */ + I18N_UCHAR_LEAD_CANONICAL_COMBINING_CLASS, /**< */ + I18N_UCHAR_TRAIL_CANONICAL_COMBINING_CLASS, /**< */ + I18N_UCHAR_GRAPHEME_CLUSTER_BREAK, /**< */ + I18N_UCHAR_SENTENCE_BREAK, /**< */ + I18N_UCHAR_WORD_BREAK, /**< */ + I18N_UCHAR_BIDI_PAIRED_BRACKET_TYPE, /**< */ + I18N_UCHAR_INT_LIMIT, /**< */ + + I18N_UCHAR_GENERAL_CATEGORY_MASK = 0x2000, /**< */ + + I18N_UCHAR_MASK_START = I18N_UCHAR_GENERAL_CATEGORY_MASK, /**< */ + I18N_UCHAR_MASK_LIMIT, /**< */ + + I18N_UCHAR_NUMERIC_VALUE = 0x3000, /**< */ + I18N_UCHAR_DOUBLE_START = I18N_UCHAR_NUMERIC_VALUE, /**< */ + I18N_UCHAR_DOUBLE_LIMIT, /**< */ + + I18N_UCHAR_AGE = 0x4000, /**< */ + I18N_UCHAR_STRING_START = I18N_UCHAR_AGE, /**< */ + I18N_UCHAR_BIDI_MIRRORING_GLYPH, /**< */ + I18N_UCHAR_CASE_FOLDING, /**< */ + + I18N_UCHAR_LOWERCASE_MAPPING = 0x4004, /**< */ + I18N_UCHAR_NAME, /**< */ + I18N_UCHAR_SIMPLE_CASE_FOLDING, /**< */ + I18N_UCHAR_SIMPLE_LOWERCASE_MAPPING, /**< */ + I18N_UCHAR_SIMPLE_TITLECASE_MAPPING, /**< */ + I18N_UCHAR_SIMPLE_UPPERCASE_MAPPING, /**< */ + I18N_UCHAR_TITLECASE_MAPPING, /**< */ + + I18N_UCHAR_UPPERCASE_MAPPING = 0x400C, /**< */ + I18N_UCHAR_BIDI_PAIRED_BRACKET, /**< */ + I18N_UCHAR_STRING_LIMIT, /**< */ + + I18N_UCHAR_SCRIPT_EXTENSIONS = 0x7000, /**< */ + I18N_UCHAR_OTHER_PROPERTY_START = I18N_UCHAR_SCRIPT_EXTENSIONS, /**< */ + I18N_UCHAR_OTHER_PROPERTY_LIMIT, /**< */ + I18N_UCHAR_INVALID_CODE = -1 /**< */ +} i18n_uchar_uproperty_e; + +/** + * @brief Constants for Unicode blocks, see the Unicode Data file Blocks.txt. + */ +typedef enum { + I18N_UCHAR_UBLOCK_NO_BLOCK, /**< */ + I18N_UCHAR_UBLOCK_BASIC_LATIN, /**< */ + I18N_UCHAR_UBLOCK_LATIN_1_SUPPLEMENT, /**< */ + I18N_UCHAR_UBLOCK_LATIN_EXTENDED_A, /**< */ + I18N_UCHAR_UBLOCK_LATIN_EXTENDED_B, /**< */ + I18N_UCHAR_UBLOCK_IPA_EXTENSIONS, /**< */ + I18N_UCHAR_UBLOCK_SPACING_MODIFIER_LETTERS, /**< */ + I18N_UCHAR_UBLOCK_COMBINING_DIACRITICAL_MARKS, /**< */ + I18N_UCHAR_UBLOCK_GREEK, /**< */ + I18N_UCHAR_UBLOCK_CYRILLIC, /**< */ + I18N_UCHAR_UBLOCK_ARMENIAN, /**< */ + I18N_UCHAR_UBLOCK_HEBREW, /**< */ + I18N_UCHAR_UBLOCK_ARABIC, /**< */ + I18N_UCHAR_UBLOCK_SYRIAC, /**< */ + I18N_UCHAR_UBLOCK_THAANA, /**< */ + I18N_UCHAR_UBLOCK_DEVANAGARI, /**< */ + I18N_UCHAR_UBLOCK_BENGALI, /**< */ + I18N_UCHAR_UBLOCK_GURMUKHI, /**< */ + I18N_UCHAR_UBLOCK_GUJARATI, /**< */ + I18N_UCHAR_UBLOCK_ORIYA, /**< */ + I18N_UCHAR_UBLOCK_TAMIL, /**< */ + I18N_UCHAR_UBLOCK_TELUGU, /**< */ + I18N_UCHAR_UBLOCK_KANNADA, /**< */ + I18N_UCHAR_UBLOCK_MALAYALAM, /**< */ + I18N_UCHAR_UBLOCK_SINHALA, /**< */ + I18N_UCHAR_UBLOCK_THAI, /**< */ + I18N_UCHAR_UBLOCK_LAO, /**< */ + I18N_UCHAR_UBLOCK_TIBETAN, /**< */ + I18N_UCHAR_UBLOCK_MYANMAR, /**< */ + I18N_UCHAR_UBLOCK_GEORGIAN, /**< */ + I18N_UCHAR_UBLOCK_HANGUL_JAMO, /**< */ + I18N_UCHAR_UBLOCK_ETHIOPIC, /**< */ + I18N_UCHAR_UBLOCK_CHEROKEE, /**< */ + I18N_UCHAR_UBLOCK_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS, /**< */ + I18N_UCHAR_UBLOCK_OGHAM, /**< */ + I18N_UCHAR_UBLOCK_RUNIC, /**< */ + I18N_UCHAR_UBLOCK_KHMER, /**< */ + I18N_UCHAR_UBLOCK_MONGOLIAN, /**< */ + I18N_UCHAR_UBLOCK_LATIN_EXTENDED_ADDITIONAL, /**< */ + I18N_UCHAR_UBLOCK_GREEK_EXTENDED, /**< */ + I18N_UCHAR_UBLOCK_GENERAL_PUNCTUATION, /**< */ + I18N_UCHAR_UBLOCK_SUPERSCRIPTS_AND_SUBSCRIPTS, /**< */ + I18N_UCHAR_UBLOCK_CURRENCY_SYMBOLS, /**< */ + I18N_UCHAR_UBLOCK_COMBINING_MARKS_FOR_SYMBOLS, /**< */ + I18N_UCHAR_UBLOCK_LETTERLIKE_SYMBOLS, /**< */ + I18N_UCHAR_UBLOCK_NUMBER_FORMS, /**< */ + I18N_UCHAR_UBLOCK_ARROWS, /**< */ + I18N_UCHAR_UBLOCK_MATHEMATICAL_OPERATORS, /**< */ + I18N_UCHAR_UBLOCK_MISCELLANEOUS_TECHNICAL, /**< */ + I18N_UCHAR_UBLOCK_CONTROL_PICTURES, /**< */ + I18N_UCHAR_UBLOCK_OPTICAL_CHARACTER_RECOGNITION, /**< */ + I18N_UCHAR_UBLOCK_ENCLOSED_ALPHANUMERICS, /**< */ + I18N_UCHAR_UBLOCK_BOX_DRAWING, /**< */ + I18N_UCHAR_UBLOCK_BLOCK_ELEMENTS, /**< */ + I18N_UCHAR_UBLOCK_GEOMETRIC_SHAPES, /**< */ + I18N_UCHAR_UBLOCK_MISCELLANEOUS_SYMBOLS, /**< */ + I18N_UCHAR_UBLOCK_DINGBATS, /**< */ + I18N_UCHAR_UBLOCK_BRAILLE_PATTERNS, /**< */ + I18N_UCHAR_UBLOCK_CJK_RADICALS_SUPPLEMENT, /**< */ + I18N_UCHAR_UBLOCK_KANGXI_RADICALS, /**< */ + I18N_UCHAR_UBLOCK_IDEOGRAPHIC_DESCRIPTION_CHARACTERS, /**< */ + I18N_UCHAR_UBLOCK_CJK_SYMBOLS_AND_PUNCTUATION, /**< */ + I18N_UCHAR_UBLOCK_HIRAGANA, /**< */ + I18N_UCHAR_UBLOCK_KATAKANA, /**< */ + I18N_UCHAR_UBLOCK_BOPOMOFO, /**< */ + I18N_UCHAR_UBLOCK_HANGUL_COMPATIBILITY_JAMO, /**< */ + I18N_UCHAR_UBLOCK_KANBUN, /**< */ + I18N_UCHAR_UBLOCK_BOPOMOFO_EXTENDED, /**< */ + I18N_UCHAR_UBLOCK_ENCLOSED_CJK_LETTERS_AND_MONTHS, /**< */ + I18N_UCHAR_UBLOCK_CJK_COMPATIBILITY, /**< */ + I18N_UCHAR_UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A, /**< */ + I18N_UCHAR_UBLOCK_CJK_UNIFIED_IDEOGRAPHS, /**< */ + I18N_UCHAR_UBLOCK_YI_SYLLABLES, /**< */ + I18N_UCHAR_UBLOCK_YI_RADICALS, /**< */ + I18N_UCHAR_UBLOCK_HANGUL_SYLLABLES, /**< */ + I18N_UCHAR_UBLOCK_HIGH_SURROGATES, /**< */ + I18N_UCHAR_UBLOCK_HIGH_PRIVATE_USE_SURROGATES, /**< */ + I18N_UCHAR_UBLOCK_LOW_SURROGATES, /**< */ + I18N_UCHAR_UBLOCK_PRIVATE_USE_AREA, /**< */ + I18N_UCHAR_UBLOCK_PRIVATE_USE, /**< */ + I18N_UCHAR_UBLOCK_CJK_COMPATIBILITY_IDEOGRAPHS, /**< */ + + I18N_UCHAR_UBLOCK_ALPHABETIC_PRESENTATION_FORMS, /**< */ + I18N_UCHAR_UBLOCK_ARABIC_PRESENTATION_FORMS_A, /**< */ + I18N_UCHAR_UBLOCK_COMBINING_HALF_MARKS, /**< */ + I18N_UCHAR_UBLOCK_CJK_COMPATIBILITY_FORMS, /**< */ + I18N_UCHAR_UBLOCK_SMALL_FORM_VARIANTS, /**< */ + I18N_UCHAR_UBLOCK_ARABIC_PRESENTATION_FORMS_B, /**< */ + I18N_UCHAR_UBLOCK_SPECIALS, /**< */ + I18N_UCHAR_UBLOCK_HALFWIDTH_AND_FULLWIDTH_FORMS, /**< */ + I18N_UCHAR_UBLOCK_OLD_ITALIC, /**< */ + I18N_UCHAR_UBLOCK_GOTHIC, /**< */ + I18N_UCHAR_UBLOCK_DESERET, /**< */ + I18N_UCHAR_UBLOCK_BYZANTINE_MUSICAL_SYMBOLS, /**< */ + I18N_UCHAR_UBLOCK_MUSICAL_SYMBOLS, /**< */ + I18N_UCHAR_UBLOCK_MATHEMATICAL_ALPHANUMERIC_SYMBOLS, /**< */ + I18N_UCHAR_UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B, /**< */ + I18N_UCHAR_UBLOCK_CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT, /**< */ + I18N_UCHAR_UBLOCK_TAGS, /**< */ + I18N_UCHAR_UBLOCK_CYRILLIC_SUPPLEMENT, /**< */ + I18N_UCHAR_UBLOCK_CYRILLIC_SUPPLEMENTARY, /**< */ + I18N_UCHAR_UBLOCK_TAGALOG, /**< */ + I18N_UCHAR_UBLOCK_HANUNOO, /**< */ + I18N_UCHAR_UBLOCK_BUHID, /**< */ + I18N_UCHAR_UBLOCK_TAGBANWA, /**< */ + I18N_UCHAR_UBLOCK_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A, /**< */ + I18N_UCHAR_UBLOCK_SUPPLEMENTAL_ARROWS_A, /**< */ + I18N_UCHAR_UBLOCK_SUPPLEMENTAL_ARROWS_B, /**< */ + I18N_UCHAR_UBLOCK_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B, /**< */ + I18N_UCHAR_UBLOCK_SUPPLEMENTAL_MATHEMATICAL_OPERATORS, /**< */ + I18N_UCHAR_UBLOCK_KATAKANA_PHONETIC_EXTENSIONS, /**< */ + I18N_UCHAR_UBLOCK_VARIATION_SELECTORS, /**< */ + I18N_UCHAR_UBLOCK_SUPPLEMENTARY_PRIVATE_USE_AREA_A, /**< */ + I18N_UCHAR_UBLOCK_SUPPLEMENTARY_PRIVATE_USE_AREA_B, /**< */ + I18N_UCHAR_UBLOCK_LIMBU, /**< */ + I18N_UCHAR_UBLOCK_TAI_LE, /**< */ + I18N_UCHAR_UBLOCK_KHMER_SYMBOLS, /**< */ + I18N_UCHAR_UBLOCK_PHONETIC_EXTENSIONS, /**< */ + I18N_UCHAR_UBLOCK_MISCELLANEOUS_SYMBOLS_AND_ARROWS, /**< */ + I18N_UCHAR_UBLOCK_YIJING_HEXAGRAM_SYMBOLS, /**< */ + I18N_UCHAR_UBLOCK_LINEAR_B_SYLLABARY, /**< */ + I18N_UCHAR_UBLOCK_LINEAR_B_IDEOGRAMS, /**< */ + I18N_UCHAR_UBLOCK_AEGEAN_NUMBERS, /**< */ + I18N_UCHAR_UBLOCK_UGARITIC, /**< */ + I18N_UCHAR_UBLOCK_SHAVIAN, /**< */ + I18N_UCHAR_UBLOCK_OSMANYA, /**< */ + I18N_UCHAR_UBLOCK_CYPRIOT_SYLLABARY, /**< */ + I18N_UCHAR_UBLOCK_TAI_XUAN_JING_SYMBOLS, /**< */ + I18N_UCHAR_UBLOCK_VARIATION_SELECTORS_SUPPLEMENT, /**< */ + I18N_UCHAR_UBLOCK_ANCIENT_GREEK_MUSICAL_NOTATION, /**< */ + I18N_UCHAR_UBLOCK_ANCIENT_GREEK_NUMBERS, /**< */ + I18N_UCHAR_UBLOCK_ARABIC_SUPPLEMENT, /**< */ + I18N_UCHAR_UBLOCK_BUGINESE, /**< */ + I18N_UCHAR_UBLOCK_CJK_STROKES, /**< */ + I18N_UCHAR_UBLOCK_COMBINING_DIACRITICAL_MARKS_SUPPLEMENT, /**< */ + I18N_UCHAR_UBLOCK_COPTIC, /**< */ + I18N_UCHAR_UBLOCK_ETHIOPIC_EXTENDED, /**< */ + I18N_UCHAR_UBLOCK_ETHIOPIC_SUPPLEMENT, /**< */ + I18N_UCHAR_UBLOCK_GEORGIAN_SUPPLEMENT, /**< */ + I18N_UCHAR_UBLOCK_GLAGOLITIC, /**< */ + I18N_UCHAR_UBLOCK_KHAROSHTHI, /**< */ + I18N_UCHAR_UBLOCK_MODIFIER_TONE_LETTERS, /**< */ + I18N_UCHAR_UBLOCK_NEW_TAI_LUE, /**< */ + I18N_UCHAR_UBLOCK_OLD_PERSIAN, /**< */ + I18N_UCHAR_UBLOCK_PHONETIC_EXTENSIONS_SUPPLEMENT, /**< */ + I18N_UCHAR_UBLOCK_SUPPLEMENTAL_PUNCTUATION, /**< */ + I18N_UCHAR_UBLOCK_SYLOTI_NAGRI, /**< */ + I18N_UCHAR_UBLOCK_TIFINAGH, /**< */ + I18N_UCHAR_UBLOCK_VERTICAL_FORMS, /**< */ + I18N_UCHAR_UBLOCK_NKO, /**< */ + I18N_UCHAR_UBLOCK_BALINESE, /**< */ + I18N_UCHAR_UBLOCK_LATIN_EXTENDED_C, /**< */ + I18N_UCHAR_UBLOCK_LATIN_EXTENDED_D, /**< */ + I18N_UCHAR_UBLOCK_PHAGS_PA, /**< */ + I18N_UCHAR_UBLOCK_PHOENICIAN, /**< */ + I18N_UCHAR_UBLOCK_CUNEIFORM, /**< */ + I18N_UCHAR_UBLOCK_CUNEIFORM_NUMBERS_AND_PUNCTUATION, /**< */ + I18N_UCHAR_UBLOCK_COUNTING_ROD_NUMERALS, /**< */ + I18N_UCHAR_UBLOCK_SUNDANESE, /**< */ + I18N_UCHAR_UBLOCK_LEPCHA, /**< */ + I18N_UCHAR_UBLOCK_OL_CHIKI, /**< */ + I18N_UCHAR_UBLOCK_CYRILLIC_EXTENDED_A, /**< */ + I18N_UCHAR_UBLOCK_VAI, /**< */ + I18N_UCHAR_UBLOCK_CYRILLIC_EXTENDED_B, /**< */ + I18N_UCHAR_UBLOCK_SAURASHTRA, /**< */ + I18N_UCHAR_UBLOCK_KAYAH_LI, /**< */ + I18N_UCHAR_UBLOCK_REJANG, /**< */ + I18N_UCHAR_UBLOCK_CHAM, /**< */ + I18N_UCHAR_UBLOCK_ANCIENT_SYMBOLS, /**< */ + I18N_UCHAR_UBLOCK_PHAISTOS_DISC, /**< */ + I18N_UCHAR_UBLOCK_LYCIAN, /**< */ + I18N_UCHAR_UBLOCK_CARIAN, /**< */ + I18N_UCHAR_UBLOCK_LYDIAN, /**< */ + I18N_UCHAR_UBLOCK_MAHJONG_TILES, /**< */ + I18N_UCHAR_UBLOCK_DOMINO_TILES, /**< */ + I18N_UCHAR_UBLOCK_SAMARITAN, /**< */ + I18N_UCHAR_UBLOCK_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS_EXTENDED, /**< */ + I18N_UCHAR_UBLOCK_TAI_THAM, /**< */ + I18N_UCHAR_UBLOCK_VEDIC_EXTENSIONS, /**< */ + I18N_UCHAR_UBLOCK_LISU, /**< */ + I18N_UCHAR_UBLOCK_BAMUM, /**< */ + I18N_UCHAR_UBLOCK_COMMON_INDIC_NUMBER_FORMS, /**< */ + I18N_UCHAR_UBLOCK_DEVANAGARI_EXTENDED, /**< */ + I18N_UCHAR_UBLOCK_HANGUL_JAMO_EXTENDED_A, /**< */ + I18N_UCHAR_UBLOCK_JAVANESE, /**< */ + I18N_UCHAR_UBLOCK_MYANMAR_EXTENDED_A, /**< */ + I18N_UCHAR_UBLOCK_TAI_VIET, /**< */ + I18N_UCHAR_UBLOCK_MEETEI_MAYEK, /**< */ + I18N_UCHAR_UBLOCK_HANGUL_JAMO_EXTENDED_B, /**< */ + I18N_UCHAR_UBLOCK_IMPERIAL_ARAMAIC, /**< */ + I18N_UCHAR_UBLOCK_OLD_SOUTH_ARABIAN, /**< */ + I18N_UCHAR_UBLOCK_AVESTAN, /**< */ + I18N_UCHAR_UBLOCK_INSCRIPTIONAL_PARTHIAN, /**< */ + I18N_UCHAR_UBLOCK_INSCRIPTIONAL_PAHLAVI, /**< */ + I18N_UCHAR_UBLOCK_OLD_TURKIC, /**< */ + I18N_UCHAR_UBLOCK_RUMI_NUMERAL_SYMBOLS, /**< */ + I18N_UCHAR_UBLOCK_KAITHI, /**< */ + I18N_UCHAR_UBLOCK_EGYPTIAN_HIEROGLYPHS, /**< */ + I18N_UCHAR_UBLOCK_ENCLOSED_ALPHANUMERIC_SUPPLEMENT, /**< */ + I18N_UCHAR_UBLOCK_ENCLOSED_IDEOGRAPHIC_SUPPLEMENT, /**< */ + I18N_UCHAR_UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_C, /**< */ + I18N_UCHAR_UBLOCK_MANDAIC, /**< */ + I18N_UCHAR_UBLOCK_BATAK, /**< */ + I18N_UCHAR_UBLOCK_ETHIOPIC_EXTENDED_A, /**< */ + I18N_UCHAR_UBLOCK_BRAHMI, /**< */ + I18N_UCHAR_UBLOCK_BAMUM_SUPPLEMENT, /**< */ + I18N_UCHAR_UBLOCK_KANA_SUPPLEMENT, /**< */ + I18N_UCHAR_UBLOCK_PLAYING_CARDS, /**< */ + I18N_UCHAR_UBLOCK_MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS, /**< */ + I18N_UCHAR_UBLOCK_EMOTICONS, /**< */ + I18N_UCHAR_UBLOCK_TRANSPORT_AND_MAP_SYMBOLS, /**< */ + I18N_UCHAR_UBLOCK_ALCHEMICAL_SYMBOLS, /**< */ + I18N_UCHAR_UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_D, /**< */ + I18N_UCHAR_UBLOCK_COUNT, /**< */ + I18N_UCHAR_UBLOCK_INVALID_CODE = -1 /**< */ +} i18n_uchar_ublock_code_e; + +/** + * @brief Enumeration for the language directional property of a character set. + */ +typedef enum { + /* + * Note: UCharDirection constants and their API comments are parsed by preparseucd.py. + * It matches pairs of lines like + * / ** <Unicode 1..3-letter Bidi_Class value> comment... * / + * U_<[A-Z_]+> = <integer>, + */ + 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. + */ +typedef enum { + /* + * Note: UDecompositionType constants are parsed by preparseucd.py. + * It matches lines like + * U_DT_<Unicode Decomposition_Type value name> + */ + 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. + */ +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. + */ +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. + */ +typedef enum { + /* + * Note: UJoiningGroup constants are parsed by preparseucd.py. + * It matches lines like + * U_JG_<Unicode Joining_Group value name> + */ + 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. + */ +typedef enum { + /* + * Note: UJoiningType constants are parsed by preparseucd.py. + * It matches lines like + * U_JT_<Unicode Joining_Type value name> + */ + 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. + */ +typedef enum { + /* + * Note: ULineBreak constants are parsed by preparseucd.py. + * It matches lines like + * U_LB_<Unicode Line_Break value name> + */ + 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. + */ +typedef enum { + /* + * Note: UNumericType constants are parsed by preparseucd.py. + * It matches lines like + * U_NT_<Unicode Numeric_Type value name> + */ + 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. + */ +typedef enum { + /* + * Note: UHangulSyllableType constants are parsed by preparseucd.py. + * It matches lines like + * U_HST_<Unicode Hangul_Syllable_Type value name> + */ + 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. + */ +typedef enum { + /* + * Note: USentenceBreak constants are parsed by preparseucd.py. + * It matches lines like + * U_SB_<Unicode Sentence_Break value name> + */ + 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. + */ +typedef enum { + /* + * Note: UWordBreakValues constants are parsed by preparseucd.py. + * It matches lines like + * U_WB_<Unicode Word_Break value name> + */ + 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. + */ + typedef enum { + /* + * Note: UGraphemeClusterBreak constants are parsed by preparseucd.py. + * It matches lines like + * U_GCB_<Unicode Grapheme_Cluster_Break value name> + */ + 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 + * @{ + */ + +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. + */ +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 UColAttribute constants */ +} i18n_ucollator_attribute_e; + +/** + * @brief Enumeration containing attribute values for controling 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. + */ +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 Ui18n_ucollator_hs. These values can now be found in the #i18n_ucollator_attribute_value_e enum. + */ +typedef i18n_ucollator_attribute_value_e i18n_ucollator_strength_e; + +/** + * @brief Enumeration for source and target string comparison result. #I18N_UCOLLATOR_EQUAL is returned if the source string is compared to be less than the target string in the {@link #i18n_ucollator_str_collator() } method. + * {@link #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. + */ +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 + * @{ + */ + +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/ + */ +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 + * @{ + */ + +typedef void* i18n_usearch_h; + +/** + * @} + * @} + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_UCALENDAR_MODULE + * @{ + */ + +typedef void* i18n_ucalendar_h; + +/** + * @brief Enumeration for possible fields in an i18n_ucalendar_h. + */ +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, /**< Field count */ + 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. + */ +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. + */ +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. + */ +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. + */ +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. + */ +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; + +/** + * @} + * @} + */ + +/** + * @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. + */ +typedef double i18n_udate; + +typedef void* i18n_udate_format_h; + + +typedef struct { + int32_t field; + int32_t beginIndex; + int32_t endIndex; +} i18n_ufield_position_s; + +typedef i18n_ufield_position_s* i18n_ufield_position_h; + +/** + * @brief Enumeration for the possible date/time format styles. + */ +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; + +/** + * @} + * @} + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_UDATEPG_MODULE + * @{ + */ + +typedef void* i18n_udatepg_h; + +/** + * @} + * @} + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_UNUMBER_MODULE + * @{ + */ + +typedef void* i18n_unumber_format_h; + + +enum { I18N_U_PARSE_CONTEXT_LEN = 16 }; + +typedef struct { + int32_t line; + int32_t offset; + i18n_uchar preContext[I18N_U_PARSE_CONTEXT_LEN]; + i18n_uchar postContext[I18N_U_PARSE_CONTEXT_LEN]; +} i18n_uparse_error_s; + +/** + * @brief Enumeration for the possible number format styles. + */ +typedef enum { + I18N_UNUMBER_PATTERN_DECIMAL = 0, /**< Decimal format defined by a pattern string */ + I18N_UNUMBER_DECIMAL = 1, /**< Decimal format ("normal" style) */ + I18N_UNUMBER_CURRENCY, /**< Currency format with a currency symbol, e.g., "$1.00" */ + I18N_UNUMBER_PERCENT, /**< Percent format */ + I18N_UNUMBER_SCIENTIFIC, /**< Scientific format */ + I18N_UNUMBER_SPELLOUT, /**< Spellout rule-based format */ + I18N_UNUMBER_ORDINAL, /**< Ordinal rule-based format */ + I18N_UNUMBER_DURATION, /**< Duration rule-based format */ + I18N_UNUMBER_NUMBERING_SYSTEM, /**< Numbering system rule-based format */ + I18N_UNUMBER_PATTERN_RULEBASED, /**< Rule-based format defined by a pattern string */ + I18N_UNUMBER_CURRENCY_ISO, /**< Currency format with an ISO currency code, e.g., "USD1.00" */ + I18N_UNUMBER_CURRENCY_PLURAL, /**< Currency format with a pluralized currency name, e.g., "1.00 US dollar" and "3.00 US dollars" */ + + I18N_UNUMBER_FORMAT_STYLE_COUNT = I18N_UNUMBER_CURRENCY_PLURAL + 2, /**< One more than the highest number format style constant */ + I18N_UNUMBER_DEFAULT = I18N_UNUMBER_DECIMAL, /**< Default format */ + I18N_UNUMBER_IGNORE = I18N_UNUMBER_PATTERN_DECIMAL /**< Alias for #I18N_UNUMBER_PATTERN_DECIMAL */ + } i18n_unumber_format_style_e; + +/** + * @brief Enumeration of constants for specifying a number format symbol. + */ +typedef enum { + I18N_UNUMBER_DECIMAL_SEPARATOR_SYMBOL = 0, /**< The decimal separator */ + I18N_UNUMBER_GROUPING_SEPARATOR_SYMBOL = 1, /**< The grouping separator */ + I18N_UNUMBER_PATTERN_SEPARATOR_SYMBOL = 2, /**< The pattern separator */ + I18N_UNUMBER_PERCENT_SYMBOL = 3, /**< The percent sign */ + I18N_UNUMBER_ZERO_DIGIT_SYMBOL = 4, /**< Zero */ + I18N_UNUMBER_DIGIT_SYMBOL = 5, /**< Character representing a digit in the pattern.*/ + I18N_UNUMBER_MINUS_SIGN_SYMBOL = 6, /**< The minus sign */ + I18N_UNUMBER_PLUS_SIGN_SYMBOL = 7, /**< The plus sign */ + I18N_UNUMBER_CURRENCY_SYMBOL = 8, /**< The currency symbol */ + I18N_UNUMBER_INTL_CURRENCY_SYMBOL = 9, /**< The international currency symbol */ + I18N_UNUMBER_MONETARY_SEPARATOR_SYMBOL = 10, /**< The monetary separator */ + I18N_UNUMBER_EXPONENTIAL_SYMBOL = 11, /**< The exponential symbol */ + I18N_UNUMBER_PERMILL_SYMBOL = 12, /**< Per mill symbol */ + I18N_UNUMBER_PAD_ESCAPE_SYMBOL = 13, /**< Escape padding character */ + I18N_UNUMBER_INFINITY_SYMBOL = 14, /**< Infinity symbol */ + I18N_UNUMBER_NAN_SYMBOL = 15, /**< Nan symbol */ + I18N_UNUMBER_SIGNIFICANT_DIGIT_SYMBOL = 16, /**< Significant digit symbol */ + I18N_UNUMBER_MONETARY_GROUPING_SEPARATOR_SYMBOL = 17, /**< The monetary grouping separator */ + I18N_UNUMBER_ONE_DIGIT_SYMBOL = 18, /**< One */ + I18N_UNUMBER_TWO_DIGIT_SYMBOL = 19, /**< Two */ + I18N_UNUMBER_THREE_DIGIT_SYMBOL = 20, /**< Three */ + I18N_UNUMBER_FOUR_DIGIT_SYMBOL = 21, /**< Four */ + I18N_UNUMBER_FIVE_DIGIT_SYMBOL = 22, /**< Five */ + I18N_UNUMBER_SIX_DIGIT_SYMBOL = 23, /**< Six */ + I18N_UNUMBER_SEVEN_DIGIT_SYMBOL = 24, /**< Seven */ + I18N_UNUMBER_EIGHT_DIGIT_SYMBOL = 25, /**< Eight */ + I18N_UNUMBER_NINE_DIGIT_SYMBOL = 26, /**< Nine */ + I18N_UNUMBER_FORMAT_SYMBOL_COUNT = 27 /**< count symbol constants */ + } i18n_unumber_format_symbol_e; + +/** + * @} + * @} + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_ULOCALE_MODULE + * @{ + */ + +#define I18N_ULOCALE_CHINESE "zh" /**< Useful constant for zh */ +#define I18N_ULOCALE_ENGLISH "en" /**< Useful constant for en */ +#define I18N_ULOCALE_FRENCH "fr" /**< Useful constant for fr */ +#define I18N_ULOCALE_GERMAN "de" /**< Useful constant for de */ +#define I18N_ULOCALE_ITALIAN "it" /**< Useful constant for it */ +#define I18N_ULOCALE_JAPANESE "ja" /**< Useful constant for ja */ +#define I18N_ULOCALE_KOREAN "ko" /**< Useful constant for ko */ +#define I18N_ULOCALE_SIMPLIFIED_CHINESE "zh_CN" /**< Useful constant for zh_CN */ +#define I18N_ULOCALE_TRADITIONAL_CHINESE "zh_TW" /**< Useful constant for zh_TW */ +#define I18N_ULOCALE_CANADA "en_CA" /**< Useful constant for en_CA */ +#define I18N_ULOCALE_CANADA_FRENCH "fr_CA" /**< Useful constant for fr_CA */ +#define I18N_ULOCALE_CHINA "zh_CN" /**< Useful constant for zh_CN */ +#define I18N_ULOCALE_PRC "zh_CN" /**< Useful constant for zh_CN */ +#define I18N_ULOCALE_FRANCE "fr_FR" /**< Useful constant for fr_FR */ +#define I18N_ULOCALE_GERMANY "de_DE" /**< Useful constant for de_DE */ +#define I18N_ULOCALE_ITALY "it_IT" /**< Useful constant for it_IT */ +#define I18N_ULOCALE_JAPAN "ja_JP" /**< Useful constant for ja_JP */ +#define I18N_ULOCALE_KOREA "ko_KR" /**< Useful constant for ko_KR */ +#define I18N_ULOCALE_TAIWAN "zh_TW" /**< Useful constant for zh_TW */ +#define I18N_ULOCALE_UK "en_GB" /**< Useful constant for en_GB */ +#define I18N_ULOCALE_US "en_US" /**< Useful constant for en_US */ + +/** + * @} + * @} + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_MODULE + * @{ + */ + +typedef void* i18n_ubreak_iterator_s; + +/** + * @brief Enumeration for error codes to replace exception handlings. + */ +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_code_e; + +/** + * @} + * @} + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_USTRING_MODULE + * @{ + */ + +/** + * @brief Callback function for #i18n_ustring_unescape_at() that returns a character of the source text given an offset and a context pointer.\n + * The context pointer will be whatever is passed into #i18n_ustring_unescape_at(). + * + * @param[in] offset pointer to the offset that will be passed to #i18n_ustring_unescape_at(). + * @param[in] context an opaque pointer passed directly into #i18n_ustring_unescape_at() + * + * @retval character the character represented by the escape sequence at offset + * + * @see #i18n_ustring_unescape_at() + */ +typedef i18n_uchar(* i18n_ustring_unescape_char_at_cb)(int32_t offset, void *context); + +/** + * @brief Option value for case folding: use default mappings defined in CaseFolding.txt. + */ +#define I18N_USTRING_U_FOLD_CASE_DEFAULT 0 + +/** + * @brief Option value for case folding: \n + * Use the modified set of mappings provided in CaseFolding.txt to handle dotted I and dotless i appropriately for Turkic languages (tr, az).\n + * Before Unicode 3.2, CaseFolding.txt contains mappings marked with 'I' that are to be included for default mappings and excluded for the Turkic-specific mappings.\n + * Unicode 3.2 CaseFolding.txt instead contains mappings marked with 'T' that are to be excluded for default mappings and included for the Turkic-specific mappings. + */ +#define I18N_USTRING_U_FOLD_CASE_EXCLUDE_SPECIAL_I 1 + +/** + * @brief Option bit #i18n_ustring_case_compare_with_length(), #i18n_ustring_case_compare(), etc: Compare strings in code point order instead of code unit order. + */ +#define I18N_USTRING_U_COMPARE_CODE_POINT_ORDER 0x8000 + +/** + * @} + * @} + */ + +/** + * @addtogroup CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE + * @{ + */ +typedef void* i18n_timezone_h; + +/** + * @brief Callback function for #i18n_timezone_foreach_timezone_id(), #i18n_timezone_foreach_timezone_id_with_offset(), and i18n_timezone_foreach_timezone_id_by_country() + * that returns an enumeration over all recognized time zone IDs. + * + * @param[in] timezone_id time zone ID + * @param[in] user_data The user data passed to the callback function. + * + * @return true to continue with the next iteration of the loop, otherwise false to break out of the loop. + * + * @see #i18n_ustring_unescape_at() + */ +typedef bool (*i18n_timezone_id_cb)(const char *timezone_id, void* user_data); +typedef int8_t i18n_ubool; + +/** + * @brief Enumeration for use with #i18n_timezone_get_display_name, #i18n_timezone_get_display_name_with_locale, and #i18n_timezone_get_display_name_with_type. + */ +typedef enum { + I18N_TIMEZONE_DISPLAY_TYPE_SHORT = 1, /**< Selector for short display name */ + I18N_TIMEZONE_DISPLAY_TYPE_LONG, /**< Selector for long display name */ + I18N_TIMEZONE_DISPLAY_TYPE_SHORT_GENERIC, /**< Selector for short generic display name */ + I18N_TIMEZONE_DISPLAY_TYPE_LONG_GENERIC, /**< Selector for long generic display name */ + I18N_TIMEZONE_DISPLAY_TYPE_SHORT_GMT, /**< Selector for short display name derived */ + I18N_TIMEZONE_DISPLAY_TYPE_LONG_GMT, /**< Selector for long display name derived from time zone offset */ + I18N_TIMEZONE_DISPLAY_TYPE_SHORT_COMMONLY_USED, /**< Selector for short display name derived from the time zone's fallback name */ + I18N_TIMEZONE_DISPLAY_TYPE_GENERIC_LOCATION /**< Selector for long display name derived from the time zone's fallback name */ +}i18n_timezone_display_type_e; + +/** + * @} + * @} + */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __UTILS_I18N_TYPES_H__*/ diff --git a/src/include/utils_i18n_ucalendar.h b/src/include/utils_i18n_ucalendar.h new file mode 100755 index 0000000..f54c1d4 --- /dev/null +++ b/src/include/utils_i18n_ucalendar.h @@ -0,0 +1,377 @@ +#ifndef __UTILS_I18N_UCALENDAR_H__ +#define __UTILS_I18N_UCALENDAR_H__ + +#include <utils_i18n_types.h> + +/** + * @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 <utils_i18n.h> + * @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 2.3 + * + * @param[in] zone_id null-terminated time zone ID + * + * @retval #I18N_ERROR_NONE Successful + */ +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 2.3 + * + * @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 2.3 + * @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 + * @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 + * + * @retval #I18N_ERROR_NONE Successful + * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +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 2.3 + * + * @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 Open a copy of a i18n_ucalendar. + * This function performs a deep copy. + * @since_tizen 2.3 + * + * @param[in] cal The i18n_ucalendar_h to copy + * @param[out] identical_to_cal A pointer to a i18n_ucalendar_h identical to 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 an i18n_ucalendar_h's TimeZone. + * @details A display name is suitable for presentation to a user. + * @since_tizen 2.3 + * + * @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 2.3 + * + * @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 2.3 + * + * @param[in] cal The i18n_ucalendar to set. + * @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 2.3 + * + * @param[in] calendar The i18n_ucalendar_h to set. + * @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 2.3 + * + * @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 an i18n_ucalendar_h's current time in milliseconds. + * @details The time is represented as milliseconds from the epoch. + * @since_tizen 2.3 + * + * @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 an i18n_ucalendar_h's current time in milliseconds. + * @details The time is represented as milliseconds from the epoch. + * @since_tizen 2.3 + * + * @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 an i18n_ucalendar_h's current date. + * @details The date is represented as a series of 32-bit integers. + * @since_tizen 2.3 + * + * @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_hs are equivalent. + * @details Equivalent i18n_ucalendar_hs will behave identically, but they may be set to + * different times. + * @since_tizen 2.3 + * + * @param[in] calendar1 The first of the i18n_ucalendar_hs to compare + * @param[in] calendar2 The second of the i18n_ucalendar_hs 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 2.3 + * + * @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, #I18N_UCALENDAR_ZONE_OFFSET, or #I18N_UCALENDAR_DST_OFFSET. + * @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 2.3 + * + * @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 ); + +/** + * @} + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __I18N_UCALENDAR_H__*/ diff --git a/src/include/utils_i18n_uchar.h b/src/include/utils_i18n_uchar.h new file mode 100755 index 0000000..29c15fd --- /dev/null +++ b/src/include/utils_i18n_uchar.h @@ -0,0 +1,159 @@ +#ifndef __UTILS_I18N_UCHAR_H__ +#define __UTILS_I18N_UCHAR_H__ + +#include <utils_i18n_types.h> + +/** + * @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 <utils_i18n.h> + * + * @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 + * <code> + * 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 + * </code> + * @since_tizen 2.3 + * + * @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 2.3 + * + * @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/utils_i18n_ucollator.h b/src/include/utils_i18n_ucollator.h new file mode 100755 index 0000000..a3f3fe5 --- /dev/null +++ b/src/include/utils_i18n_ucollator.h @@ -0,0 +1,214 @@ +#ifndef __UTILS_I18N_UCOLLATOR_H__ +#define __UTILS_I18N_UCOLLATOR_H__ + +#include <utils_i18n_types.h> + +/** + * @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 <utils_i18n.h> + * + * @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 2.3 + * @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 2.3 + * + * @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 stirngs. + * @details The strings will be compared using the options already specified. + * @since_tizen 2.3 + * + * @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 2.3 + * + * @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 2.3 + * + * @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 2.3 + * + * @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/utils_i18n_udate.h b/src/include/utils_i18n_udate.h new file mode 100755 index 0000000..cd92604 --- /dev/null +++ b/src/include/utils_i18n_udate.h @@ -0,0 +1,223 @@ +#ifndef __UTILS_I18N_UDATE_H__ +#define __UTILS_I18N_UDATE_H__ + +#include <utils_i18n_types.h> + +/** + * @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 <utils_i18n.h> + * + * @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) { + // open a pattern generator according to a given locale + i18n_udatepg_create(locale, &pattern_generator); + } + + if(!pattern_generator) { + dlog_print(DLOG_INFO, LOG_TAG, "udatpg_open 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 is 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 is 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 is 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 a 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 2.3 + * @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, 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 + * @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 + * + * @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 2.3 +* +* @param[in] format The formatter to close. +* +* @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 2.3 +* +* @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. +* +* @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 ); + +/** + * @} + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __UTILS_I18N_UDATE_H__*/ diff --git a/src/include/utils_i18n_udatepg.h b/src/include/utils_i18n_udatepg.h new file mode 100755 index 0000000..a458771 --- /dev/null +++ b/src/include/utils_i18n_udatepg.h @@ -0,0 +1,209 @@ +#ifndef __UTILS_I18N_UDATEPG_H__ +#define __UTILS_I18N_UDATEPG_H__ + +#include <utils_i18n_types.h> + +/** + * @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 <utils_i18n.h> + * + * @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. + * + * @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) { + // open a pattern generator according to a given locale + i18n_udatepg_create(locale, &pattern_generator); + } + + if(!pattern_generator) { + dlog_print(DLOG_INFO, LOG_TAG, "udatpg_open 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 is 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 is 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 is 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 a i18n_udate_format + 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. + * @since_tizen 2.3 + * @remarks Must release @a dtpg using i18n_udatepg_destroy(). + * + * @param[in] locale + * @param[out] dtpg A pointer to i18n_udatepg_h + * + * @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 Closes a generator. + * @since_tizen 2.3 + * + * @param[in] dtpg A pointer to i18n_udatepg_h + * + * @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. + * @since_tizen 2.3 + * + * @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. + * + * @param[in] dtpg A pointer to i18n_udatepg_h + * @param[in] skeleton The skeleton is a pattern containing only the variable fields\n + * For example, "MMMdd" and "mmhh" are skeletons. + * @param[in] len The length of the skeleton + * @param[out] best_pattern The best pattern found from the given skeleton + * @param[in] capacity The capacity of @a best_pattern + * @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 ); + +#ifdef __cplusplus +} +#endif + +/** + * @} + * @} + */ + +#endif /* __UTILS_I18N_UDATEPG_H__*/ diff --git a/src/include/utils_i18n_ulocale.h b/src/include/utils_i18n_ulocale.h new file mode 100755 index 0000000..5eb64de --- /dev/null +++ b/src/include/utils_i18n_ulocale.h @@ -0,0 +1,191 @@ +#ifndef __UTILS_I18N_ULOCALE_H__ +#define __UTILS_I18N_ULOCALE_H__ + +#include <utils_i18n_types.h> + +/** + * @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 ulocale represents a specific geographical, political, or cultural region. + * @section CAPI_BASE_UTILS_I18N_ULOCALE_MODULE_HEADER Required Header + * \#include <utils_i18n.h> + * + * @section CAPI_BASE_UTILS_I18N_ULOCALE_MODULE_OVERVIEW Overview + * @details A ulocale represents a specific geographical, political, or cultural region. + * An operation that requires a ulocale to perform its task is called locale-sensitive + * and uses the ulocale 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_INFO, LOG_TAG, "i18n_ulocale_get_default() is 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_INFO, LOG_TAG, "i18n_ulocale_get_language() is 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); + 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 the 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. + * @since_tizen 2.3 + * + * @param[out] locale The 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 the default locale. + * @since_tizen 2.3 + * + * @param[in] locale_id The new ICU default locale\n + * A value of @c NULL will try to get the system's default locale. + * + * @retval #I18N_ERROR_NONE Successful + */ +int i18n_ulocale_set_default ( const char *locale_id ); + +/** + * @brief Gets the language code for the specified locale. + * @since_tizen 2.3 + * + * @param[in] locale_id The locale to get the ISO language code with + * @param[out] language The language code for @a locale_id + * @param[in] language_capacity The size of the 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 2.3 + * + * @param[in] locale_id The locale to get the country code with + * @param[out] country the country code for locale_id + * @param[in] country_capacity The size of the country buffer to store the country code with + * @param[out] error error information if retrieving the country code is failed + * (It must not indicate a failure before the function call) + * + * @return 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. + */ +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 2.3 + * + * @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 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. + * @since_tizen 2.3 + * + * @param[in] n the specific locale name index of the available locale list + * + * @return A specified locale name of all available locales + */ +const char* i18n_ulocale_get_available ( int32_t n ); + +/** + * @brief Gets the size of the all available locale list. + * @since_tizen 2.3 + * + * @return the size of the locale list + */ +int32_t i18n_ulocale_count_available ( void ); + +#ifdef __cplusplus +} +#endif + +/** + * @} + * @} + */ + +#endif /* __UTILS_I18N_ULOCALE_H__*/ diff --git a/src/include/utils_i18n_unormalization.h b/src/include/utils_i18n_unormalization.h new file mode 100755 index 0000000..3e679d7 --- /dev/null +++ b/src/include/utils_i18n_unormalization.h @@ -0,0 +1,98 @@ +#ifndef __UTILS_I18N_UNORMALIZATION_H__ +#define __UTILS_I18N_UNORMALIZATION_H__ + +#include <utils_i18n_types.h> + +/** + * @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 <utils_i18n.h> + * + * @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 2.3 + * + * @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 2.3 + * + * @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/utils_i18n_unumber.h b/src/include/utils_i18n_unumber.h new file mode 100755 index 0000000..0eac12e --- /dev/null +++ b/src/include/utils_i18n_unumber.h @@ -0,0 +1,135 @@ +#ifndef __UTILS_I18N_UNUMBER_H__ +#define __UTILS_I18N_UNUMBER_H__ + +#include <utils_i18n_types.h> + +/** + * @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 <utils_i18n.h> + * + * @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 2.3 + * @remarks Must release @a num_format using i18n_unumber_destroy(). + * + * @param[in] style The type of number format to open: 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 opened 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 @c 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_unumber_uparse_error_h struct 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 occurrs. + * + * @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 2.3 +* +* @param[in] fmt The formatter to destroy +* +* @retval #I18N_ERROR_NONE Successful +*/ +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 2.3 +* +* @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 <code>length >= size</code> +* +* @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 ); + +#ifdef __cplusplus +} +#endif + +/** + * @} + * @} + */ + +#endif /* __UTILS_I18N_UNUMBER_H__*/ diff --git a/src/include/utils_i18n_usearch.h b/src/include/utils_i18n_usearch.h new file mode 100755 index 0000000..552a2e3 --- /dev/null +++ b/src/include/utils_i18n_usearch.h @@ -0,0 +1,165 @@ +#ifndef __UTILS_I18N_USEARCH_H__ +#define __UTILS_I18N_USEARCH_H__ + +#include <utils_i18n_types.h> + +/** + * @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 <utils_i18n.h> + * + * @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( 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 {@link #i18n_usearch_destroy()}. +* @since_tizen 2.3 +* @remarks Must release @a searchiter using i18n_usearch_destroy(). +* +* @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] breakiter A BreakIterator 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 @c i18n_ubreak_iterator_s, +* the match will be rejected and another will be searched If this parameter is @c NULL,\n +* no break detection is attempted. +* @param[out] searchiter 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 *breakiter, i18n_usearch_h *searchiter ); + +/** +* @brief Destroys and cleans up the i18n_usearch_h. +* @details If a collator is created in {@link #i18n_usearch_create() }, it will be destroyed here. +* @since_tizen 2.3 +* +* @param[in] searchiter 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 searchiter ); + +/** +* @brief Returns the text that matches by the most recent call to {@link #i18n_usearch_first()}, or so on. +* @details If the iterator is not pointing at a valid match (e.g. just after +* construction or after @c 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 2.3 +* +* @param[in] strsrch The search iterator data struct +* @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 strsrch, 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 +* {@link #i18n_usearch_destroy()} would cause the string search to fail. +* {@link #i18n_usearch_destroy()} will delete the collator if this search owns it. +* @since_tizen 2.3 +* +* @param[in] strsrch The search iterator data struct +* @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 strsrch, 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, @c I18N_USEARCH_DONE will be returned and +* the iterator will be adjusted to the index @c I18N_USEARCH_DONE. +* @since_tizen 2.3 +* +* @param[in] strsrch The search iterator data struct +* @param[out] index_first The character index of the first match, +* otherwise @c 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 strsrch, int32_t *index_first ); + +#ifdef __cplusplus +} +#endif + +/** + * @} + * @} + */ + +#endif /* __UTILS_I18N_USEARCH_H__*/ diff --git a/src/include/utils_i18n_ustring.h b/src/include/utils_i18n_ustring.h new file mode 100755 index 0000000..77c52a8 --- /dev/null +++ b/src/include/utils_i18n_ustring.h @@ -0,0 +1,1220 @@ +#ifndef __UTILS_I18N_USTRING_H__ +#define __UTILS_I18N_USTRING_H__ + +#include <utils_i18n_types.h> + +/** + * @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 <utils_i18n.h> + * + * @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. + * @since_tizen 2.3 + * + * @param[in] s The array of i18n_uchars, NULL (U+0000) terminated. + * + * @return The number of i18n_uchars in <code>chars</code>, minus the terminator + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ustring_get_length ( const i18n_uchar *s ); + +/** + * @brief Count 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. + * @since_tizen 2.3 + * + * @param[in] s The input string. + * @param[in] length The number of i18n_uchar code units to be checked, or -1 to count + * all code points before the first NUL (U+0000). + * + * @return The number of code points in the specified code units. + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + */ +int32_t i18n_ustring_count_char32 ( const i18n_uchar *s, int32_t length ); + +/** + * @brief Check 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 -1 for NUL-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. + * + * @since_tizen 2.3 + * + * @param[in] s The input string. + * @param[in] length The length of the string, or -1 if it is NUL-terminated. + * @param[in] number The number of code points in the string is compared against the 'number' parameter. + * + * @return Boolean value for whether the string contains more Unicode code points than 'number'. Same as ( #i18n_ustring_count_char32 (s, length, &number_of_code_points); number_of_code_points > number). + * @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 Concatenate two ustrings. + * @details Appends a copy of src, including the null terminator, to dest. The initial copied character from src overwrites the null terminator in dest. + * + * @since_tizen 2.3 + * + * @param[out] dest The destination string. + * @param[in] src The source string. + * + * @return A pointer to <code>dest</code>. + * @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 src, including the null terminator, to dest. The initial copied character from src overwrites the null terminator in dest. + * + * @since_tizen 2.3 + * + * @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 <code>dest</code>. + * @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 Find 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. + * + * @since_tizen 2.3 + * + * @param[in] s The string to search (NUL-terminated). + * @param[in] sub_string The substring to find (NUL-terminated). + * + * @return A pointer to the first occurrence of <code>sub_string</code> in <code>s</code>, + * or <code>s</code> itself if the <code>sub_string</code> is empty, + * or <code>NULL</code> if <code>sub_string</code> is not in <code>s</code>. + * @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 Find 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. + * + * @since_tizen 2.3 + * + * @param[in] s The string to search (NUL-terminated). + * @param[in] length The length of s (number of i18n_uchars), or -1 if it is NUL-terminated. + * @param[in] sub_string The substring to find (NUL-terminated). + * @param[in] sub_length TThe length of substring (number of i18n_uchars), or -1 if it is NUL-terminated. + * + * @return A pointer to the first occurrence of <code>sub_string</code> in <code>s</code>, + * or <code>s</code> itself if the <code>sub_string</code> is empty, + * or <code>NULL</code> if <code>sub_string</code> is not in <code>s</code>. + * @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 Find 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 NUL character is found at the string terminator. + * + * @since_tizen 2.3 + * + * @param[in] s The string to search (NUL-terminated). + * @param[in] c The BMP code point to find. + * + * @return A pointer to the first occurrence of <code>c</code> in <code>s</code> + * or <code>NULL</code> if <code>c</code> is not in <code>s</code>. + * @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 Find 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 NUL character is found at the string terminator. + * + * @since_tizen 2.3 + * + * @param[in] s The string to search (NUL-terminated). + * @param[in] c The code point to find. + * + * @return A pointer to the first occurrence of <code>c</code> in <code>s</code> + * or <code>NULL</code> if <code>c</code> is not in <code>s</code>. + * @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 Find 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. + * + * @since_tizen 2.3 + * + * @param[in] s The string to search (NUL-terminated). + * @param[in] sub_string The substring to find (NUL-terminated). + * + * @return A pointer to the last occurrence of <code>substring</code> in <code>s</code>, + * or <code>s</code> itself if the <code>sub_string</code> is empty, + * or <code>NULL</code> if <code>sub_string</code> is not in <code>s</code>. + * @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 Find 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. + * + * @since_tizen 2.3 + * + * @param[in] s The string to search. + * @param[in] length The length of s (number of i18n_uchar), or -1 if it is NUL-terminated. + * @param[in] sub_string The sub_string to find (NUL-terminated). + * @param[in] sub_length The length of sub_string (number of i18n_uchar), or -1 if it is NUL-terminated. + * + * @return A pointer to the last occurrence of <code>sub_string</code> in <code>s</code>, + * or <code>s</code> itself if the <code>substring</code> is empty, + * or <code>NULL</code> if <code>sub_string</code> is not in <code>s</code>. + * @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 Find 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 NUL character is found at the string terminator. + * + * @since_tizen 2.3 + * + * @param[in] s The string to search (NUL-terminated). + * @param[in] c The BMP code point to find. + * + * @return A pointer to the last occurrence of <code>c</code> in <code>s</code> + * or <code>NULL</code> if <code>c</code> is not in <code>s</code>. + * @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 Find 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 NUL character is found at the string terminator. + * + * @since_tizen 2.3 + * + * @param[in] s The string to search (NUL-terminated). + * @param[in] c The code point to find. + * + * @return A pointer to the last occurrence of <code>c</code> in <code>s</code> + * or <code>NULL</code> if <code>c</code> is not in <code>s</code>. + * @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. + * + * @since_tizen 2.3 + * + * @param[in] string The string in which to search, NUL-terminated. + * @param[in] match_set A NUL-terminated string defining a set of code points for which to search in the text string. + * + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @return A pointer to the character in <code>string</code> that matches one of the + * characters in <code>match_set</code>, 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. + * + * @since_tizen 2.3 + * + * @param[in] string The string in which to search, NUL-terminated. + * @param[in] match_set A NUL-terminated string defining a set of code points for which to search in the text string. + * + * @exception #I18N_ERROR_INVALID_PARAMETER Invalid function parameter + * @return The number of initial characters in <code>string</code> that do not + * occur in <code>matchSet</code>. + */ +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. + * + * @since_tizen 2.3 + * + * @param[in] string The string in which to search, NUL-terminated. + * @param[in] match_set A NUL-terminated string defining a set of code points for which to search in the text string. + * @return The number of initial characters in <code>string</code> that do + * occur in <code>match_set</code>. + * @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. + * + * @since_tizen 2.3 + * + * @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_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). + * @since_tizen 2.3 + * + * @param[in] s1 A string to compare. + * @param[in] s2 A string to compare. + * @return 0 if <code>s1</code> and <code>s2</code> are bitwise equal; a negative + * value if <code>s1</code> is bitwise less than <code>s2,</code>; a positive + * value if <code>s1</code> is bitwise greater than <code>s2</code>. + * @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. + * + * @since_tizen 2.3 + * + * @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_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. + * NUL-terminated strings are possible with length arguments of -1. + * + * @since_tizen 2.3 + * + * @param[in] s1 First source string. + * @param[in] length1 Length of first source string, or -1 if NUL-terminated. + * @param[in] s2 Second source string. + * @param[in] length2 Length of second source string, or -1 if NUL-terminated. + * @param[in] code_point_order Choose between code unit order (FALSE) and code point order (TRUE). + * @return <0 or 0 or >0 as usual for string comparisons + * @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. + * NUL-terminated strings are possible with length arguments of -1. + * + * @since_tizen 2.3 + * + * @param[in] s1 First source string. + * @param[in] length1 Length of first source string, or -1 if NUL-terminated. + * @param[in] s2 Second source string. + * @param[in] length2 Length of second source string, or -1 if NUL-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_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. + * + * @since_tizen 2.3 + * + * @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 <code>s1</code> and <code>s2</code> are bitwise equal; a negative + * value if <code>s1</code> is bitwise less than <code>s2</code>; a positive + * value if <code>s1</code> is bitwise greater than <code>s2</code>. + * @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(). + * + * @since_tizen 2.3 + * + * @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_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. + * + * @since_tizen 2.3 + * + * @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_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. + * + * @since_tizen 2.3 + * + * @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_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. + * + * @since_tizen 2.3 + * + * @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_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. + * @since_tizen 2.3 + * + * @param[out] dest The destination string + * @param[in] src The source string + * + * @return A pointer to <code>dest</code>. + * @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 <code>n</code> characters. The result will be null terminated + * if the length of <code>src</code> is less than <code>n</code>. + * @since_tizen 2.3 + * + * @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 <code>dest</code>. + * @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. + * @since_tizen 2.3 + * + * @param[out] dest The destination string + * @param[in] src The source string + * + * @return A pointer to <code>dest</code>. + * @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 <code>n</code> characters. The result will be null terminated + * if the length of <code>src</code> is less than <code>n</code>. + * Performs a host byte to i18n_uchar conversion. + * @since_tizen 2.3 + * + * @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 <code>dest</code>. + * @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. + * @since_tizen 2.3 + * + * @param[out] dest The destination string + * @param[in] src The source string + * + * @return A pointer to <code>dest</code>. + * @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 <code>n</code> characters. The result will be null terminated + * if the length of <code>src</code> is less than <code>n</code>. + * Performs an i18n_uchar to host byte conversion. + * @since_tizen 2.3 + * + * @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 <code>dest</code>. + * @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_uchars only. + * + * @since_tizen 2.3 + * + * @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 <code>dest</code> + * @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_uchars only. + * + * @since_tizen 2.3 + * + * @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 <code>dest</code> + * @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. + * + * @since_tizen 2.3 + * + * @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 <code>dest</code>. + * @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_uchars of each buffer. + * + * @since_tizen 2.3 + * + * @param[in] buf1 The first string to compare. + * @param[in] buf2 The second string to compare. + * @param[in] count The maximum number of i18n_uchars 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_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(). + * + * @since_tizen 2.3 + * + * @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_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 Find 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 NUL character is found at the string terminator. + * + * @since_tizen 2.3 + * + * @param[in] s The string to search (contains count i18n_uchars). + * @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 <code>c</code> in <code>s</code> + * or <code>NULL</code> if <code>c</code> is not in <code>s</code>. + * @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 Find 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 NUL character is found at the string terminator. + * + * @since_tizen 2.3 + * + * @param[in] s The string to search (contains count i18n_uchars). + * @param[in] c The code point to find. + * @param[in] count The length of the string. + * @return A pointer to the first occurrence of <code>c</code> in <code>s</code> + * or <code>NULL</code> if <code>c</code> is not in <code>s</code>. + * @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 Find 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 NUL character is found at the string terminator. + * + * @since_tizen 2.3 + * + * @param[in] s The string to search (contains count i18n_uchars). + * @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 <code>c</code> in <code>s</code> + * or <code>NULL</code> if <code>c</code> is not in <code>s</code>. + * @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 Find 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 NUL character is found at the string terminator. + * + * @since_tizen 2.3 + * + * @param[in] s The string to search (contains count i18n_uchars). + * @param[in] c The code point to find. + * @param[in] count The length of the string. + * @return A pointer to the last occurrence of <code>c</code> in <code>s</code> + * or <code>NULL</code> if <code>c</code> is not in <code>s</code>. + * @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. + * + * @since_tizen 2.3 + * + * @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_uchars 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_uchars that may be written at dest. Ignored if dest == NULL. + * @return the length of unescaped string. + * @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. + * + * @since_tizen 2.3 + * + * @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_uchars 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_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 2.3 + * + * @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_uchars)\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_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 2.3 + * + * @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_uchars)\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_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. + * + * @since_tizen 2.3 + * + * @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. + * + * @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_uchars)\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_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 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 2.3 + * + * @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_uchars)\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_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 2.3 + * + * @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_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 2.3 + * + * @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_uchars).\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_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 2.3 + * + * @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_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 2.3 + * + * @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_uchars)\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_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 2.3 + * + * @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_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 2.3 + * + * @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_uchars)\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_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 2.3 + * + * @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_uchars)\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<src_len, then *dest_len will be + * set to src_len (and I18N_U_BUFFER_OVERFLOW_ERROR will be set) regardless of the actual result length. + * @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 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_INVALID_PARAMETER Invalid function parameter + * @see i18n_ustring_from_UTF8() + * @see i18n_ustring_to_UTF8_with_sub() + * @see i18n_ustring_from_UTF8_with_sub() + */ +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 *error_code ); + +/** + * @brief Convert a UTF-16 string to UTF-32. + * @details If the input string is not well-formed, then the #I18N_ERROR_INVALID_CHAR_FOUND error code is set. + * + * @since_tizen 2.3 + * + * @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_uchar32s)\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_INVALID_PARAMETER Invalid function parameter + * @see i18n_ustring_to_UTF32_with_sub() + * @see i18n_ustring_from_UTF32() + */ +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 *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. + * + * @since_tizen 2.3 + * + * @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_uchars)\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_INVALID_PARAMETER Invalid function parameter + * @see i18n_ustring_from_UTF32_with_sub() + * @see i18n_ustring_to_UTF32() + */ +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 *error_code ); + +/** + * @brief Convert a UTF-16 string to UTF-32. + * @details Same as #i18n_ustring_to_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 2.3 + * + * @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_char32s)\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_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 2.3 + * + * @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_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..2781666 --- /dev/null +++ b/src/utils_i18n_private.c @@ -0,0 +1,41 @@ +#include <utils_i18n_private.h> + +int _i18n_error_mapping ( i18n_uerror_code_private_e err ) +{ + switch(err){ + case I18N_U_ZERO_ERROR: + return I18N_ERROR_NONE; + case I18N_U_MISSING_RESOURCE_ERROR: + return I18N_ERROR_MISSING_RESOURCE; + case I18N_U_INVALID_FORMAT_ERROR: + return I18N_ERROR_INVALID_FORMAT; + case I18N_U_FILE_ACCESS_ERROR: + return I18N_ERROR_FILE_ACCESS; + case I18N_U_INTERNAL_PROGRAM_ERROR: + return I18N_ERROR_INTERNAL_PROGRAM; + case I18N_U_MEMORY_ALLOCATION_ERROR: + return I18N_ERROR_OUT_OF_MEMORY; + case I18N_U_INDEX_OUTOFBOUNDS_ERROR: + return I18N_ERROR_INDEX_OUTOFBOUNDS; + case I18N_U_INVALID_CHAR_FOUND: + return I18N_ERROR_INVALID_CHAR_FOUND; + case I18N_U_BUFFER_OVERFLOW_ERROR: + return I18N_ERROR_BUFFER_OVERFLOW; + case I18N_U_UNSUPPORTED_ERROR: + return I18N_ERROR_NOT_SUPPORTED; + case I18N_U_RESOURCE_TYPE_MISMATCH: + return I18N_ERROR_RESOURCE_TYPE_MISMATCH; + case I18N_U_TOO_MANY_ALIASES_ERROR: + return I18N_ERROR_TOO_MANY_ALIASES; + case I18N_U_COLLATOR_VERSION_MISMATCH: + return I18N_ERROR_COLLATOR_VERSION_MISMATCH; + case I18N_U_USELESS_COLLATOR_ERROR: + return I18N_ERROR_USELESS_COLLATOR; + case I18N_U_NO_WRITE_PERMISSION: + return I18N_ERROR_NO_WRITE_PERMISSION; + case I18N_U_ILLEGAL_ARGUMENT_ERROR: + return I18N_ERROR_INVALID_PARAMETER; + default: + return I18N_ERROR_NONE; + } +} diff --git a/src/utils_i18n_timezone.cpp b/src/utils_i18n_timezone.cpp new file mode 100755 index 0000000..aa51901 --- /dev/null +++ b/src/utils_i18n_timezone.cpp @@ -0,0 +1,382 @@ +#include <stdio.h> +#include <stdlib.h> +#include <utils_i18n_timezone.h> +#include <utils_i18n_private.h> +#include <utils_i18n_ustring.h> + +#include <unicode/ustdio.h> +#include <unicode/ucal.h> +#include <unicode/timezone.h> +#include <unicode/strenum.h> +#include <unicode/ustring.h> +#include <unicode/uchar.h> +#include <unicode/locid.h> + +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; + int result = _i18n_error_mapping((i18n_uerror_code_private_e)err); + return result; +} + +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); + int32_t ulen = u_strlen(equivalentTimezoneId.getTerminatedBuffer()); + 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, equivalentTimezoneId.getTerminatedBuffer()); + + 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() +{ + UErrorCode status = U_ZERO_ERROR; + return TimeZone::getTZDataVersion(status); +} + +int i18n_timezone_get_region(const char *timezone_id, char *region, int32_t *region_len, int32_t region_capacity) +{ + retv_if(timezone_id == NULL, I18N_ERROR_INVALID_PARAMETER); + UErrorCode status = U_ZERO_ERROR; + const UnicodeString id(timezone_id); + *region_len = TimeZone::getRegion(id, region, region_capacity, status); + + int result = _i18n_error_mapping((i18n_uerror_code_private_e)status); + return result; +} + +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, I18N_ERROR_INVALID_PARAMETER); + UErrorCode status = U_ZERO_ERROR; + ((TimeZone*)timezone)->getOffset( date, local, *raw_offset, *dst_offset, status ); + + int result = _i18n_error_mapping((i18n_uerror_code_private_e)status); + return result; +} + +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, 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); + int32_t ulen = u_strlen(TimezoneID.getTerminatedBuffer()); + 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, TimezoneID.getTerminatedBuffer()); + + 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); + int32_t ulen = u_strlen(displayName.getTerminatedBuffer()); + 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, displayName.getTerminatedBuffer()); + + 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); + int32_t ulen = u_strlen(displayName.getTerminatedBuffer()); + 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, displayName.getTerminatedBuffer()); + + 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); + int32_t ulen = u_strlen(displayName.getTerminatedBuffer()); + 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, displayName.getTerminatedBuffer()); + + 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); + int32_t ulen = u_strlen(displayName.getTerminatedBuffer()); + 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, displayName.getTerminatedBuffer()); + + 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); + + int result = _i18n_error_mapping((i18n_uerror_code_private_e)status); + return result; +} + +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_ucalendar.c b/src/utils_i18n_ucalendar.c new file mode 100755 index 0000000..37770e2 --- /dev/null +++ b/src/utils_i18n_ucalendar.c @@ -0,0 +1,163 @@ +#include <unicode/ucal.h> +#include <utils_i18n_ucalendar.h> +#include <utils_i18n_private.h> + +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 err = I18N_ERROR_NONE; + *calendar = ucal_open(zone_id, len, locale, type, (UErrorCode*)&err); + int result = _i18n_error_mapping(err); + + return result; +} + +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 err = I18N_ERROR_NONE; + *identical_to_cal = ucal_clone(cal, (UErrorCode*)&err); + int result = _i18n_error_mapping(err); + + return result; +} + +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 err = I18N_ERROR_NONE; + ucal_add(calendar, field, amount, (UErrorCode*)&err); + int result = _i18n_error_mapping(err); + + return result; +} + +int i18n_ucalendar_is_equivalent_to ( const i18n_ucalendar_h calendar1, const i18n_ucalendar_h calendar2, i18n_ubool *equiv ) +{ + retv_if(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 err = I18N_ERROR_NONE; + *date = ucal_getMillis(calendar, (UErrorCode*)&err); + int result = _i18n_error_mapping(err); + + return result; +} + +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 err = I18N_ERROR_NONE; + *val = ucal_get(calendar, field, (UErrorCode*)&err); + int result = _i18n_error_mapping(err); + + return result; +} + +int i18n_ucalendar_get_attribute ( i18n_ucalendar_h calendar, i18n_ucalendar_attribute_e attr, int32_t *val) +{ + retv_if(calendar == 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, I18N_ERROR_INVALID_PARAMETER); + + i18n_error_code_e err = I18N_ERROR_NONE; + *buf_size_needed = ucal_getTimeZoneDisplayName(calendar, type, locale, result, result_len, (UErrorCode*)&err); + + return _i18n_error_mapping(err); +} + +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 err = I18N_ERROR_NONE; + *is_in = ucal_inDaylightTime(calendar, (UErrorCode*)&err); + int result = _i18n_error_mapping(err); + + return result; +} + +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 err = I18N_ERROR_NONE; + ucal_setDateTime(calendar, year, month, date, hour, min, sec, (UErrorCode*)&err); + int result = _i18n_error_mapping(err); + + return result; +} + +int i18n_ucalendar_set_milliseconds ( i18n_ucalendar_h calendar, i18n_udate milliseconds ) +{ + retv_if(calendar == NULL, I18N_ERROR_INVALID_PARAMETER); + + i18n_error_code_e err = I18N_ERROR_NONE; + ucal_setMillis(calendar, milliseconds, (UErrorCode*)&err); + int result = _i18n_error_mapping(err); + + return result; +} + +int i18n_ucalendar_set_default_timezone ( const i18n_uchar *zone_id ) +{ + i18n_error_code_e err = I18N_ERROR_NONE; + ucal_setDefaultTimeZone(zone_id, (UErrorCode*)&err); + int result = _i18n_error_mapping(err); + + 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; +} diff --git a/src/utils_i18n_uchar.c b/src/utils_i18n_uchar.c new file mode 100755 index 0000000..6663524 --- /dev/null +++ b/src/utils_i18n_uchar.c @@ -0,0 +1,19 @@ +#include <unicode/uchar.h> +#include <utils_i18n_uchar.h> +#include <utils_i18n_private.h> + +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..3110770 --- /dev/null +++ b/src/utils_i18n_ucollator.c @@ -0,0 +1,61 @@ +#include <unicode/ucol.h> +#include <utils_i18n_ucollator.h> +#include <utils_i18n_private.h> + +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 100755 index 0000000..b775d42 --- /dev/null +++ b/src/utils_i18n_udate.c @@ -0,0 +1,29 @@ +#include <unicode/udat.h> +#include <utils_i18n_udate.h> +#include <utils_i18n_private.h> + +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 ); + + i18n_error_code_e err = I18N_ERROR_NONE; + *format = udat_open(time_style, date_style, locale, tz_id, tz_id_len, pattern, pattern_len, (UErrorCode*)&err); + return err; +} + +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 ); + + i18n_error_code_e err = I18N_ERROR_NONE; + *buf_size_needed = udat_format(format, date_to_format, result, result_len, (UFieldPosition*)pos, (UErrorCode*)&err); + return _i18n_error_mapping(err); +} diff --git a/src/utils_i18n_udatepg.c b/src/utils_i18n_udatepg.c new file mode 100755 index 0000000..e608e19 --- /dev/null +++ b/src/utils_i18n_udatepg.c @@ -0,0 +1,36 @@ +#include <unicode/udatpg.h> +#include <utils_i18n_udatepg.h> +#include <utils_i18n_private.h> + +int i18n_udatepg_create ( const char *locale, i18n_udatepg_h *dtpg ) +{ + retv_if(dtpg == NULL, I18N_ERROR_INVALID_PARAMETER); + + i18n_error_code_e err = I18N_ERROR_NONE; + *dtpg = udatpg_open(locale, (UErrorCode*)&err); + int result = _i18n_error_mapping(err); + + return result; +} + +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(best_pattern == NULL && capacity > 0, I18N_ERROR_INVALID_PARAMETER); + + i18n_error_code_e err = I18N_ERROR_NONE; + *best_pattern_len = udatpg_getBestPattern(dtpg, skeleton, len, best_pattern, capacity, (UErrorCode*)&err); + int result = _i18n_error_mapping(err); + + return result; +} + diff --git a/src/utils_i18n_ulocale.c b/src/utils_i18n_ulocale.c new file mode 100755 index 0000000..a66f3a6 --- /dev/null +++ b/src/utils_i18n_ulocale.c @@ -0,0 +1,61 @@ +#include <unicode/uloc.h> +#include <utils_i18n_ulocale.h> +#include <utils_i18n_private.h> + +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 ) +{ + i18n_error_code_e err =I18N_ERROR_NONE; + uloc_setDefault(locale_id, (UErrorCode*)&err); + int result = _i18n_error_mapping(err); + + return result; +} + +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, I18N_ERROR_INVALID_PARAMETER); + + i18n_error_code_e err = I18N_ERROR_NONE; + *buf_size_language = uloc_getLanguage(locale_id, language, language_capacity, (UErrorCode*)&err); + int result = _i18n_error_mapping(err); + + return result; +} + +int32_t i18n_ulocale_get_country ( const char *locale_id, char *country, int32_t country_capacity, int *error ) +{ + int32_t result = uloc_getCountry(locale_id, country, country_capacity, error); + *error = _i18n_error_mapping(*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); + + i18n_error_code_e err = I18N_ERROR_NONE; + *buf_size_display_name = uloc_getDisplayName(locale_id, in_locale_id, result_w, max_result_size,(UErrorCode*)&err); + int result = _i18n_error_mapping(err); + + return result; +} + +const char* i18n_ulocale_get_available ( int32_t n ) +{ + return uloc_getAvailable(n); +} + +int32_t i18n_ulocale_count_available ( void ) +{ + return uloc_countAvailable(); +} diff --git a/src/utils_i18n_unormalization.c b/src/utils_i18n_unormalization.c new file mode 100755 index 0000000..90002f8 --- /dev/null +++ b/src/utils_i18n_unormalization.c @@ -0,0 +1,24 @@ +#include <unicode/unorm2.h> +#include <utils_i18n_unormalization.h> +#include <utils_i18n_private.h> + +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..9681341 --- /dev/null +++ b/src/utils_i18n_unumber.c @@ -0,0 +1,34 @@ +#include <stdio.h> +#include <unicode/unum.h> +#include <utils_i18n_unumber.h> +#include <utils_i18n_private.h> + +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); + i18n_error_code_e err = I18N_ERROR_NONE; + *num_format = unum_open(style, pattern, pattern_len, locale, (UParseError*)parse_err, (UErrorCode*)&err); + int result = _i18n_error_mapping(err); + + return result; +} + +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, I18N_ERROR_INVALID_PARAMETER); + + i18n_error_code_e err = I18N_ERROR_NONE; + *len_symbol = unum_getSymbol(fmt, symbol, buffer, size, (UErrorCode*)&err); + int result = _i18n_error_mapping(err); + + return result; +} diff --git a/src/utils_i18n_usearch.c b/src/utils_i18n_usearch.c new file mode 100755 index 0000000..3d6583d --- /dev/null +++ b/src/utils_i18n_usearch.c @@ -0,0 +1,50 @@ +#include <unicode/usearch.h> +#include <utils_i18n_usearch.h> +#include <utils_i18n_private.h> + +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 ) +{ + retv_if ( strsrch == NULL, I18N_ERROR_INVALID_PARAMETER ); + + 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 *breakiter, 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*)breakiter, (UErrorCode*)&err ); + int result = _i18n_error_mapping ( err ); + + return result; +} diff --git a/src/utils_i18n_ustring.c b/src/utils_i18n_ustring.c new file mode 100755 index 0000000..54ff675 --- /dev/null +++ b/src/utils_i18n_ustring.c @@ -0,0 +1,631 @@ +#include <unicode/ustring.h> +#include <utils_i18n_ustring.h> +#include <utils_i18n_private.h> + +int32_t i18n_ustring_get_length ( const i18n_uchar *s ) +{ + set_last_result(I18N_ERROR_NONE); + if(s == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + + return u_strlen (s); +} + +int32_t i18n_ustring_count_char32 ( const i18n_uchar *s, int32_t length ) +{ + set_last_result(I18N_ERROR_NONE); + if(s == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + return u_countChar32(s, length); +} + +i18n_ubool i18n_ustring_has_more_char32_than ( const i18n_uchar *s, int32_t length, int32_t number ) +{ + set_last_result(I18N_ERROR_NONE); + if(s == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + return u_strHasMoreChar32Than(s, length, number); +} + +i18n_uchar* i18n_ustring_cat ( i18n_uchar *dest, const i18n_uchar *src ) +{ + set_last_result(I18N_ERROR_NONE); + if(dest == NULL || src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + return u_strcat(dest, src); +} + +i18n_uchar * i18n_ustring_cat_n ( i18n_uchar *dest, const i18n_uchar *src, int32_t n ) +{ + set_last_result(I18N_ERROR_NONE); + if(dest == NULL || src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + return u_strncat(dest, src, n); +} + +i18n_uchar* i18n_ustring_string ( const i18n_uchar *s, const i18n_uchar *sub_string ) +{ + 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 ) +{ + 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 ) +{ + set_last_result(I18N_ERROR_NONE); + if(s == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + return (i18n_uchar*)u_strchr(s, c); +} + +i18n_uchar* i18n_ustring_char32 ( const i18n_uchar *s, i18n_uchar32 c ) +{ + set_last_result(I18N_ERROR_NONE); + if(s == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + return (i18n_uchar*)u_strchr32(s, c); +} + +i18n_uchar* i18n_ustring_r_string ( const i18n_uchar *s, const i18n_uchar *sub_string ) +{ + 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 ) +{ + 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 ) +{ + set_last_result(I18N_ERROR_NONE); + if(s == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + return (i18n_uchar*)u_strrchr(s, c); +} + +i18n_uchar* i18n_ustring_r_char32 ( const i18n_uchar *s, i18n_uchar32 c ) +{ + set_last_result(I18N_ERROR_NONE); + if(s == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + return (i18n_uchar*)u_strrchr32(s, c); +} + +i18n_uchar* i18n_ustring_pbrk ( const i18n_uchar *string, const i18n_uchar *match_set ) +{ + set_last_result(I18N_ERROR_NONE); + if(string == NULL || match_set == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + return (i18n_uchar*)u_strpbrk(string, match_set); +} + +int32_t i18n_ustring_cspn ( const i18n_uchar *string, const i18n_uchar *match_set ) +{ + set_last_result(I18N_ERROR_NONE); + if(string == NULL || match_set == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + return u_strcspn(string, match_set); +} + +int32_t i18n_ustring_spn ( const i18n_uchar *string, const i18n_uchar *match_set ) +{ + set_last_result(I18N_ERROR_NONE); + if(string == NULL || match_set == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + return u_strspn(string, match_set); +} + +i18n_uchar* i18n_ustring_tokenizer_r ( i18n_uchar *src, const i18n_uchar *delim, i18n_uchar **save_state ) +{ + 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 ) +{ + set_last_result(I18N_ERROR_NONE); + if(s1 == NULL || s2 == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + return u_strcmp (s1, s2); +} + +int32_t i18n_ustring_compare_code_point_order( const i18n_uchar *s1, const i18n_uchar *s2 ) +{ + set_last_result(I18N_ERROR_NONE); + if(s1 == NULL || s2 == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + 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 ) +{ + set_last_result(I18N_ERROR_NONE); + if(s1 == NULL || s2 == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + 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 *pErrorCode ) +{ + set_last_result(I18N_ERROR_NONE); + if(s1 == NULL || s2 == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + UErrorCode err = U_ZERO_ERROR; + int32_t result = u_strCaseCompare(s1, length1, s2, length2, options, &err); + *pErrorCode = _i18n_error_mapping(err); + + return result; +} + +int32_t i18n_ustring_compare_n( const i18n_uchar *s1, const i18n_uchar *s2, int32_t n ) +{ + set_last_result(I18N_ERROR_NONE); + if(s1 == NULL || s2 == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + 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 ) +{ + set_last_result(I18N_ERROR_NONE); + if(s1 == NULL || s2 == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + return u_strncmpCodePointOrder(s1, s2, n); +} + +int32_t i18n_ustring_case_compare( const i18n_uchar *s1, const i18n_uchar *s2, uint32_t options ) +{ + set_last_result(I18N_ERROR_NONE); + if(s1 == NULL || s2 == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + 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 ) +{ + set_last_result(I18N_ERROR_NONE); + if(s1 == NULL || s2 == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } 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 ) +{ + set_last_result(I18N_ERROR_NONE); + if(s1 == NULL || s2 == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + return u_memcasecmp(s1, s2, length, options); +} + +i18n_uchar* i18n_ustring_copy ( i18n_uchar *dest, const i18n_uchar *src ) +{ + set_last_result(I18N_ERROR_NONE); + if(dest == NULL || src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + return u_strcpy(dest, src); +} + +i18n_uchar* i18n_ustring_copy_n ( i18n_uchar *dest, const i18n_uchar *src, int32_t n ) +{ + set_last_result(I18N_ERROR_NONE); + if(dest == NULL || src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + return u_strncpy(dest, src, n); +} + +i18n_uchar* i18n_ustring_copy_ua ( i18n_uchar *dest, const char *src ) +{ + set_last_result(I18N_ERROR_NONE); + if(dest == NULL || src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + return u_uastrcpy(dest, src); +} + +i18n_uchar* i18n_ustring_copy_ua_n ( i18n_uchar *dest, const char *src, int32_t n ) +{ + set_last_result(I18N_ERROR_NONE); + if(dest == NULL || src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + return u_uastrncpy(dest, src, n); +} + +char* i18n_ustring_copy_au ( char *dest, const i18n_uchar *src ) +{ + set_last_result(I18N_ERROR_NONE); + if(dest == NULL || src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + return u_austrcpy(dest, src); +} + +char* i18n_ustring_copy_au_n ( char *dest, const i18n_uchar *src, int32_t n ) +{ + set_last_result(I18N_ERROR_NONE); + if(dest == NULL || src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + return u_austrncpy(dest, src, n); +} + +i18n_uchar* i18n_ustring_mem_copy ( i18n_uchar *dest, const i18n_uchar *src, int32_t count ) +{ + set_last_result(I18N_ERROR_NONE); + if(dest == NULL || src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + return u_memcpy(dest, src, count); +} + +i18n_uchar* i18n_ustring_mem_move ( i18n_uchar *dest, const i18n_uchar *src, int32_t count ) +{ + set_last_result(I18N_ERROR_NONE); + if(dest == NULL || src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + return u_memmove(dest, src, count); +} + +i18n_uchar* i18n_ustring_mem_set ( i18n_uchar *dest, const i18n_uchar c, int32_t count ) +{ + set_last_result(I18N_ERROR_NONE); + if(dest == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + return u_memset(dest, c, count); +} + +int32_t i18n_ustring_mem_compare ( const i18n_uchar *buf1, const i18n_uchar *buf2, int32_t count ) +{ + set_last_result(I18N_ERROR_NONE); + if(buf1 == NULL || buf2 == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + 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 ) +{ + set_last_result(I18N_ERROR_NONE); + if(s1 == NULL || s2 == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + return u_memcmpCodePointOrder(s1, s2, count); +} + +i18n_uchar* i18n_ustring_mem_char ( const i18n_uchar *s, i18n_uchar c, int32_t count ) +{ + set_last_result(I18N_ERROR_NONE); + if(s == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + return (i18n_uchar*)u_memchr(s, c, count); +} + +i18n_uchar* i18n_ustring_mem_char32 ( const i18n_uchar *s, i18n_uchar32 c, int32_t count ) +{ + set_last_result(I18N_ERROR_NONE); + if(s == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + 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 ) +{ + set_last_result(I18N_ERROR_NONE); + if(s == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + 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 ) +{ + set_last_result(I18N_ERROR_NONE); + if(s == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + return (i18n_uchar*)u_memrchr32(s, c, count); +} + +int32_t i18n_ustring_unescape ( const char *src, i18n_uchar *dest, int32_t dest_capacity ) +{ + set_last_result(I18N_ERROR_NONE); + if(dest == NULL || src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + 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 ) +{ + set_last_result(I18N_ERROR_NONE); + if(char_at == NULL || offset == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + 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 *pErrorCode ) +{ + set_last_result(I18N_ERROR_NONE); + if(src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + UErrorCode err = U_ZERO_ERROR; + int32_t result = u_strToUpper (dest, dest_capacity, src, src_len, locale, &err); + *pErrorCode = _i18n_error_mapping(err); + + 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 *pErrorCode ) +{ + set_last_result(I18N_ERROR_NONE); + if(src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + UErrorCode err = U_ZERO_ERROR; + int32_t result = u_strToLower (dest, dest_capacity, src, src_len, locale, &err); + *pErrorCode = _i18n_error_mapping(err); + + 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 *pErrorCode ) +{ + set_last_result(I18N_ERROR_NONE); + if(src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + UErrorCode err = U_ZERO_ERROR; + int32_t result = u_strToTitle (dest, dest_capacity, src, src_len, (UBreakIterator*)title_iter, locale, &err); + *pErrorCode = _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 *pErrorCode ) +{ + set_last_result(I18N_ERROR_NONE); + if(src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return 0; + } + UErrorCode err = U_ZERO_ERROR; + int32_t result =u_strFoldCase (dest, dest_capacity, src, src_len, options, &err); + *pErrorCode = _i18n_error_mapping(err); + + 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 *pErrorCode ) +{ + set_last_result(I18N_ERROR_NONE); + if(src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + UErrorCode err = U_ZERO_ERROR; + wchar_t* result = u_strToWCS (dest, dest_capacity, dest_len, src, src_len, &err); + *pErrorCode = _i18n_error_mapping(err); + + 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 *pErrorCode ) +{ + set_last_result(I18N_ERROR_NONE); + if(src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + UErrorCode err = U_ZERO_ERROR; + i18n_uchar* result = u_strFromWCS (dest, dest_capacity, dest_len, src, src_len, &err); + *pErrorCode = _i18n_error_mapping(err); + + 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 *pErrorCode ) +{ + set_last_result(I18N_ERROR_NONE); + if(src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + UErrorCode err = U_ZERO_ERROR; + char* result = u_strToUTF8 (dest, dest_capacity, dest_len, src, src_len, &err); + *pErrorCode = _i18n_error_mapping(err); + + 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 *pErrorCode ) +{ + set_last_result(I18N_ERROR_NONE); + if(src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + UErrorCode err = U_ZERO_ERROR; + i18n_uchar* result = u_strFromUTF8 (dest, dest_capacity, dest_len, src, src_len, &err); + *pErrorCode = _i18n_error_mapping(err); + + 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 *pErrorCode ) +{ + set_last_result(I18N_ERROR_NONE); + if(src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + UErrorCode err = U_ZERO_ERROR; + char* result = u_strToUTF8WithSub (dest, dest_capacity, dest_len, src, src_len, sub_char, num_substitutions, &err); + *pErrorCode = _i18n_error_mapping(err); + + 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 *pErrorCode ) +{ + set_last_result(I18N_ERROR_NONE); + if(src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + UErrorCode err = U_ZERO_ERROR; + i18n_uchar* result = u_strFromUTF8WithSub (dest, dest_capacity, dest_len, src, src_len, sub_char, num_substitutions, &err); + *pErrorCode = _i18n_error_mapping(err); + + 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 *pErrorCode ) +{ + set_last_result(I18N_ERROR_NONE); + if(src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + UErrorCode err = U_ZERO_ERROR; + i18n_uchar* result = u_strFromUTF8Lenient (dest, dest_capacity, dest_len, src, src_len, &err); + *pErrorCode = _i18n_error_mapping(err); + + 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 *pErrorCode ) +{ + set_last_result(I18N_ERROR_NONE); + if(src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + UErrorCode err = U_ZERO_ERROR; + i18n_uchar32* result = u_strToUTF32 (dest, dest_capacity, dest_len, src, src_len, &err); + *pErrorCode = _i18n_error_mapping(err); + + 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 *pErrorCode ) +{ + set_last_result(I18N_ERROR_NONE); + if(src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + UErrorCode err = U_ZERO_ERROR; + i18n_uchar* result = u_strFromUTF32 (dest, dest_capacity, dest_len, src, src_len, &err); + *pErrorCode = _i18n_error_mapping(err); + + 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 *pErrorCode ) +{ + set_last_result(I18N_ERROR_NONE); + if(src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + UErrorCode err = U_ZERO_ERROR; + i18n_uchar32* result = u_strToUTF32WithSub (dest, dest_capacity, dest_len, src, src_len, sub_char, num_substitutions, &err); + *pErrorCode = _i18n_error_mapping(err); + + 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 *pErrorCode ) +{ + set_last_result(I18N_ERROR_NONE); + if(src == NULL) { + set_last_result(I18N_ERROR_INVALID_PARAMETER); + return NULL; + } + UErrorCode err = U_ZERO_ERROR; + i18n_uchar* result = u_strFromUTF32WithSub (dest, dest_capacity, dest_len, src, src_len, sub_char, num_substitutions, (UErrorCode*)&err); + *pErrorCode = _i18n_error_mapping(err); + + return result; +} + |