summaryrefslogtreecommitdiffstats
path: root/src/lookup/phrase_lookup.cpp
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2010-11-01 19:44:22 +0800
committerPeng Wu <alexepico@gmail.com>2010-11-01 19:44:22 +0800
commit59f26f62a8a73fa139e2553f47a3935e0512bd14 (patch)
tree7718f9753cdff9315226f295208b6ede8e2507a5 /src/lookup/phrase_lookup.cpp
parentc622cd3d4aa44de57cb8e692dc5dba5832febccb (diff)
downloadlibpinyin-59f26f62a8a73fa139e2553f47a3935e0512bd14.tar.gz
libpinyin-59f26f62a8a73fa139e2553f47a3935e0512bd14.tar.xz
libpinyin-59f26f62a8a73fa139e2553f47a3935e0512bd14.zip
fixes convert to utf8 in phrase lookup
Diffstat (limited to 'src/lookup/phrase_lookup.cpp')
-rw-r--r--src/lookup/phrase_lookup.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/lookup/phrase_lookup.cpp b/src/lookup/phrase_lookup.cpp
index 1d72fee..e3bf2d9 100644
--- a/src/lookup/phrase_lookup.cpp
+++ b/src/lookup/phrase_lookup.cpp
@@ -262,7 +262,7 @@ bool PhraseLookup::convert_to_utf8(MatchResults results, /* in */ const char * d
//init variables
if ( NULL == delimiter )
delimiter = "";
- result_string = g_strdup("");
+ result_string = NULL;
for ( size_t i = 0; i < results->len; ++i ){
phrase_token_t * token = &g_array_index(results, phrase_token_t, i);
@@ -274,7 +274,10 @@ bool PhraseLookup::convert_to_utf8(MatchResults results, /* in */ const char * d
guint8 length = m_cache_phrase_item.get_phrase_length();
gchar * phrase = g_utf16_to_utf8(buffer, length, NULL, NULL, NULL);
char * tmp = result_string;
- result_string = g_strconcat(result_string, delimiter, phrase, NULL);
+ if ( NULL == result_string )
+ result_string = g_strdup(phrase);
+ else
+ result_string = g_strconcat(result_string, delimiter, phrase, NULL);
g_free(tmp); g_free(phrase);
}
return true;