1 From 344872231b95ce7c2808288101cc563dcd011940 Mon Sep 17 00:00:00 2001
2 From: Hillwood Yang <hillwoodroc@gmail.com>
3 Date: Thu, 26 Feb 2015 11:04:29 +0800
4 Subject: [PATCH] Update SimpTradConverter.cc
8 src/SimpTradConverter.cc | 42 +++++++++++++---------------------------
9 1 file changed, 13 insertions(+), 29 deletions(-)
11 diff --git a/src/SimpTradConverter.cc b/src/SimpTradConverter.cc
12 index 6fe9123..7be0749 100644
13 --- a/src/SimpTradConverter.cc
14 +++ b/src/SimpTradConverter.cc
15 @@ -40,7 +41,6 @@ namespace PyZy {
19 - static const int BUFFER_SIZE = 64;
23 @@ -55,29 +55,13 @@ class opencc {
25 void convert (const char *in, String &out)
28 - unichar *in_ucs4 = g_utf8_to_ucs4_fast (in, -1, &n_char);
30 - ucs4_t *pinbuf = (ucs4_t *)in_ucs4;
31 - size_t inbuf_left = n_char;
32 - while (inbuf_left != 0) {
33 - ucs4_t *poutbuf = (ucs4_t *)m_buffer;
34 - size_t outbuf_left = BUFFER_SIZE;
35 - size_t retval = opencc_convert(m_od, &pinbuf, &inbuf_left, &poutbuf, &outbuf_left);
36 - if (retval == (size_t) -1) {
37 - /* append left chars in pinbuf */
38 - g_warning ("opencc_convert return failed");
39 - out << (unichar *) pinbuf;
46 + char * converted = opencc_convert_utf8 (m_od, in, -1);
47 + g_assert (converted != NULL);
49 + opencc_convert_utf8_free (converted);
53 - unichar m_buffer[BUFFER_SIZE + 1];