00001 /* Part of the culibs project, <http://www.eideticdew.org/culibs/>. 00002 * Copyright (C) 2004--2007 Petter Urkedal <urkedal@nbi.dk> 00003 * 00004 * This program is free software: you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation, either version 3 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 00018 #ifndef CUTEXT_UCS4_H 00019 #define CUTEXT_UCS4_H 00020 00021 #include <cu/fwd.h> 00022 #include <cu/str.h> 00023 #include <cu/wchar.h> 00024 #include <stdint.h> 00025 00026 CU_BEGIN_DECLARATIONS 00027 00028 /* Convert 'src_size' UTF-8 bytes starting at 'src_arr' storing up to 00029 * 'dst_cap' UCS-4 characters starting at 'dst_arr', and set 00030 * '*dst_size' to the actual number stored. Return 0 on success and 00031 * the 'errno' returned from 'iconv' on failure. */ 00032 int cutext_iconv_char_to_wchar(char const **src_arr, size_t *src_cnt, 00033 cu_wchar_t **dst_arr, size_t *dst_cnt); 00034 00035 /* Convert 'src_size' UCS-4 characters starting at 'src_arr' storing 00036 * up to 'dst_cap' UTF-8 characters starting at 'dst_arr', and set 00037 * '*dst_size' to the actual numbers stored. Return 0 on success and 00038 * the 'errno' returned from 'iconv' on failure. */ 00039 int cutext_iconv_wchar_to_char(cu_wchar_t const **src_arr, size_t *src_size, 00040 char **dst_arr, size_t *dst_cap); 00041 00042 /* Convert a single UCS-4 character to an UTF-8 sequence. */ 00043 int cutext_wchar_to_charr(cu_wchar_t wc, char **dst_arr, size_t *dst_cnt); 00044 00045 cu_dsink_t cutext_dsink_open_iconv(char const *source_encoding, 00046 char const *target_encoding, 00047 cu_dsink_t target_sink); 00048 00049 CU_END_DECLARATIONS 00050 00051 #endif