Skip to content

Commit 6b8a26f

Browse files
committed
Add iconv_open function for codepage.
修改: ChangeLog 修改: include/cppp/reiconv.hpp.in 修改: lang/en_US.langmap 修改: lang/zh_CN.langmap 修改: lib/iconv.cpp 修改: lib/iconv_open1.h 修改: lib/iconv_open2.h 删除: lib/loop_wchar.h 修改: lib/loops.h
1 parent 6d1a756 commit 6b8a26f

File tree

9 files changed

+695
-1156
lines changed

9 files changed

+695
-1156
lines changed

ChangeLog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
2023-08-29 ChenPi11 <wushengwuxi-msctinoulk@outlook.com>
22

33
Fix type-conflict warning when in clang.
4+
Fully remove wchar support.
5+
Add function 'extern iconv_t iconv_open (int tocode_cp, int fromcode_cp, bool strict=true)'.
46

57
2023-08-27 ChenPi11 <wushengwuxi-msctinoulk@outlook.com>
68

include/cppp/reiconv.hpp.in

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ extern "C++"
6767

6868
/**
6969
* @brief Allocates descriptor for code conversion from encoding 'fromcode' to encoding 'tocode'.
70-
* @param tocodepage Target codepage.
71-
* @param fromcodepage From codepage.
70+
* @param tocode_cp Target codepage.
71+
* @param fromcode_cp From codepage.
7272
* @return Allocated iconv conversation buffer's pointer.
7373
*/
74-
extern @DLL_VARIABLE@ iconv_t iconv_open (int tocodepage, int fromcodepage);
74+
extern @DLL_VARIABLE@ iconv_t iconv_open (int tocode_cp, int fromcode_cp, bool strict=true);
7575

7676
#undef iconv
7777
/**
@@ -109,18 +109,13 @@ extern "C++"
109109
* @brief Hook performed after every successful conversion of a Unicode character.
110110
*/
111111
typedef void (*iconv_unicode_char_hook) (unsigned int uc, void* data);
112-
/**
113-
* @typedef void (*) (wchar_t, void*)
114-
* @brief Hook performed after every successful conversion of a wide character.
115-
*/
116-
typedef void (*iconv_wide_char_hook) (wchar_t wc, void* data);
112+
117113
/**
118114
* @brief Set of hooks.
119115
*/
120116
struct iconv_hooks
121117
{
122118
iconv_unicode_char_hook uc_hook;
123-
iconv_wide_char_hook wc_hook;
124119
void* data;
125120
};
126121

@@ -150,41 +145,13 @@ extern "C++"
150145
void* callback_arg,
151146
void* data);
152147

153-
/**
154-
* @brief Fallback function. Invoked when a number of bytes could not be converted to
155-
* a wide character. This function should process all bytes from inbuf and may
156-
* produce replacement wide characters by calling the write_replacement
157-
* callback repeatedly.
158-
*/
159-
typedef void (*iconv_wchar_mb_to_wc_fallback)
160-
(const char* inbuf, size_t inbufsize,
161-
void (*write_replacement) (const wchar_t *buf, size_t buflen,
162-
void* callback_arg),
163-
void* callback_arg,
164-
void* data);
165-
166-
/**
167-
* @brief Fallback function. Invoked when a wide character could not be converted to
168-
* the target encoding. This function should process the character and may
169-
* produce replacement bytes (in the target encoding) by calling the
170-
* write_replacement callback repeatedly.
171-
*/
172-
typedef void (*iconv_wchar_wc_to_mb_fallback)
173-
(wchar_t code,
174-
void (*write_replacement) (const char *buf, size_t buflen,
175-
void* callback_arg),
176-
void* callback_arg,
177-
void* data);
178-
179148
/**
180149
* @brief Set of fallbacks.
181150
*/
182151
struct iconv_fallbacks
183152
{
184153
iconv_unicode_mb_to_uc_fallback mb_to_uc_fallback;
185154
iconv_unicode_uc_to_mb_fallback uc_to_mb_fallback;
186-
iconv_wchar_mb_to_wc_fallback mb_to_wc_fallback;
187-
iconv_wchar_wc_to_mb_fallback wc_to_mb_fallback;
188155
void* data;
189156
};
190157

lang/en_US.langmap

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -157,18 +157,6 @@
157157
*/
158158
'''
159159

160-
'''
161-
/**
162-
* @typedef void (*) (wchar_t, void*)
163-
* @brief Hook performed after every successful conversion of a wide character.
164-
*/
165-
'''
166-
/**
167-
* @typedef void (*) (wchar_t, void*)
168-
* @brief Hook performed after every successful conversion of a wide character.
169-
*/
170-
'''
171-
172160
'''
173161
/**
174162
* @brief Set of hooks.
@@ -211,38 +199,6 @@
211199
*/
212200
'''
213201

214-
'''
215-
/**
216-
* @brief Fallback function. Invoked when a number of bytes could not be converted to
217-
* a wide character. This function should process all bytes from inbuf and may
218-
* produce replacement wide characters by calling the write_replacement
219-
* callback repeatedly.
220-
*/
221-
'''
222-
/**
223-
* @brief Fallback function. Invoked when a number of bytes could not be converted to
224-
* a wide character. This function should process all bytes from inbuf and may
225-
* produce replacement wide characters by calling the write_replacement
226-
* callback repeatedly.
227-
*/
228-
'''
229-
230-
'''
231-
/**
232-
* @brief Fallback function. Invoked when a wide character could not be converted to
233-
* the target encoding. This function should process the character and may
234-
* produce replacement bytes (in the target encoding) by calling the
235-
* write_replacement callback repeatedly.
236-
*/
237-
'''
238-
/**
239-
* @brief Fallback function. Invoked when a wide character could not be converted to
240-
* the target encoding. This function should process the character and may
241-
* produce replacement bytes (in the target encoding) by calling the
242-
* write_replacement callback repeatedly.
243-
*/
244-
'''
245-
246202
'''
247203
/**
248204
* @brief Set of fallbacks.

lang/zh_CN.langmap

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -153,18 +153,6 @@
153153
*/
154154
'''
155155

156-
'''
157-
/**
158-
* @typedef void (*) (wchar_t, void*)
159-
* @brief Hook performed after every successful conversion of a wide character.
160-
*/
161-
'''
162-
/**
163-
* @typedef void (*) (wchar_t, void*)
164-
* @brief 在每次成功转换宽字符之后执行的钩子函数。
165-
*/
166-
'''
167-
168156
'''
169157
/**
170158
* @brief Set of hooks.
@@ -205,34 +193,6 @@
205193

206194
'''
207195

208-
'''
209-
/**
210-
* @brief Fallback function. Invoked when a number of bytes could not be converted to
211-
* a wide character. This function should process all bytes from inbuf and may
212-
* produce replacement wide characters by calling the write_replacement
213-
* callback repeatedly.
214-
*/
215-
'''
216-
/**
217-
* @brief 回调函数。在无法将一些字节转换为宽字符时调用。
218-
* 此函数应处理来自 “inbuf” 的所有字节,并可以通过重复调用 “write_replacement” 回调来生成替代的宽字符。
219-
*/
220-
'''
221-
222-
'''
223-
/**
224-
* @brief Fallback function. Invoked when a wide character could not be converted to
225-
* the target encoding. This function should process the character and may
226-
* produce replacement bytes (in the target encoding) by calling the
227-
* write_replacement callback repeatedly.
228-
*/
229-
'''
230-
/**
231-
* @brief 回调函数。在无法将宽字符转换为目标编码时调用。
232-
* 此函数应处理字符,并可通过重复调用 “write_replacement” 回调来生成替代字节(使用目标编码)。
233-
*/
234-
'''
235-
236196
'''
237197
/**
238198
* @brief Set of fallbacks.

0 commit comments

Comments
 (0)