From 59f26f62a8a73fa139e2553f47a3935e0512bd14 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Mon, 1 Nov 2010 19:44:22 +0800 Subject: fixes convert to utf8 in phrase lookup --- src/lookup/phrase_lookup.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/lookup') 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; -- cgit