2 * @brief definition of IConvert related classes.
5 /* ISF is based on SCIM 1.4.7 and extended for supporting more mobile fitable. */
8 * Smart Common Input Method
10 * Copyright (c) 2002-2005 James Su <suzhe@tsinghua.org.cn>
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Lesser General Public
15 * License as published by the Free Software Foundation; either
16 * version 2 of the License, or (at your option) any later version.
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License for more details.
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with this program; if not, write to the
25 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
26 * Boston, MA 02111-1307 USA
28 * $Id: scim_iconv.h,v 1.18 2005/08/15 12:45:46 suzhe Exp $
31 #ifndef __SCIM_ICONVERT_H
32 #define __SCIM_ICONVERT_H
37 * @addtogroup Accessories
38 * @ingroup InputServiceFramework
42 #define SCIM_MAX_BUFSIZE 4096
45 * @brief A class to convert strings between UCS-4 and local encodings.
51 IConvertImpl * m_impl;
56 * @param encoding the local encoding to be used.
58 IConvert (const String& encoding = String ());
61 * @brief Copy constructor
63 IConvert (const IConvert & iconvert);
68 * @brief Assign operator
70 const IConvert & operator = (const IConvert & iconvert);
73 * @brief Set the working local encoding.
74 * @param encoding the local encoding to be used.
75 * @return whether the encoding is ok or not.
77 bool set_encoding (const String& encoding);
80 * @brief Get the current working local encoding.
81 * @return The name of the local encoding, like "UTF-8", "GB2312" etc.
83 String get_encoding () const;
86 * @brief Convert a UCS-4 encoded WideString into a local encoded String.
87 * @param dest the result string will be stored here.
88 * @param src the WideString to be converted.
89 * @return true if success.
91 bool convert (String &dest, const WideString &src) const;
94 * @brief Convert a UCS-4 encoded WideString into a local encoded String.
95 * @param dest the result string will be stored here.
96 * @param src the ucs-4 encoded string to be converted.
97 * @param src_len the length of source string.
98 * @return true if success.
100 bool convert (String &dest, const ucs4_t *src, int src_len) const;
103 * @brief Convert a local encoded String into a UCS-4 encoded WideString.
104 * @param dest the result string will be stored here.
105 * @param src the local encoded string to be converted.
106 * @return ture if success.
108 bool convert (WideString &dest, const String &src) const;
111 * @brief Convert a local encoded String into a UCS-4 encoded WideString.
112 * @param dest the result string will be stored here.
113 * @param src the local encoded string to be converted.
114 * @param src_len the length of source string.
115 * @return ture if success.
117 bool convert (WideString &dest, const char *src, int src_len) const;
120 * @brief Test if a UCS-4 encoded WideString can be converted to a local encoded String.
121 * @param src the ucs-4 encoded string to be test.
122 * @return true if it can be converted without any problem.
124 bool test_convert (const WideString &src) const;
127 * @brief Test if a ucs-4 encoded string can be converted to a local encoded String.
128 * @param src the ucs-4 encoded string to be test.
129 * @param src_len the length of source string.
130 * @return true if it can be converted without any problem.
132 bool test_convert (const ucs4_t *src, int src_len) const;
135 * @brief Test if a local encoded string can be converted to a UCS-4 encoded WideString.
136 * @param src the local encoded string to be test.
137 * @return true if it can be converted without any problem.
139 bool test_convert (const String &src) const;
142 * @brief Test if a local encoded string can be converted to a UCS-4 encoded WideString.
143 * @param src the local encoded string to be test.
144 * @param src_len the length of source string.
145 * @return true if it can be converted without any problem.
147 bool test_convert (const char *src, int src_len) const;
154 #endif //__SCIM_ICONVERT_H
157 vi:ts=4:nowrap:ai:expandtab