summaryrefslogtreecommitdiffstats
path: root/src/xplist.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/xplist.c')
-rw-r--r--src/xplist.c27
1 files changed, 3 insertions, 24 deletions
diff --git a/src/xplist.c b/src/xplist.c
index 2bee7c7..38cc4fe 100644
--- a/src/xplist.c
+++ b/src/xplist.c
@@ -126,12 +126,6 @@ static void node_to_xml(GNode * node, gpointer xml_struct)
126 //for base64 126 //for base64
127 gchar *valtmp = NULL; 127 gchar *valtmp = NULL;
128 128
129 //for unicode
130 glong len = 0;
131 glong items_read = 0;
132 glong items_written = 0;
133 GError *error = NULL;
134
135 uint32_t i = 0; 129 uint32_t i = 0;
136 130
137 if (!node) 131 if (!node)
@@ -165,12 +159,6 @@ static void node_to_xml(GNode * node, gpointer xml_struct)
165 val = g_strdup(node_data->strval); 159 val = g_strdup(node_data->strval);
166 break; 160 break;
167 161
168 case PLIST_UNICODE:
169 tag = XPLIST_STRING;
170 len = node_data->length;
171 val = g_utf16_to_utf8(node_data->unicodeval, len, &items_read, &items_written, &error);
172 break;
173
174 case PLIST_KEY: 162 case PLIST_KEY:
175 tag = XPLIST_KEY; 163 tag = XPLIST_KEY;
176 val = g_strdup((gchar *) node_data->strval); 164 val = g_strdup((gchar *) node_data->strval);
@@ -233,11 +221,7 @@ static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node)
233 plist_t subnode = NULL; 221 plist_t subnode = NULL;
234 222
235 //for string 223 //for string
236 unsigned char *tmp = NULL;
237 glong len = 0; 224 glong len = 0;
238 glong items_read = 0;
239 glong items_written = 0;
240 GError *error = NULL;
241 int type = 0; 225 int type = 0;
242 226
243 if (!xml_node) 227 if (!xml_node)
@@ -301,16 +285,11 @@ static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node)
301 if (!xmlStrcmp(node->name, XPLIST_STRING)) { 285 if (!xmlStrcmp(node->name, XPLIST_STRING)) {
302 xmlChar *strval = xmlNodeGetContent(node); 286 xmlChar *strval = xmlNodeGetContent(node);
303 len = strlen((char *) strval); 287 len = strlen((char *) strval);
304 items_read = 0;
305 items_written = 0;
306 error = NULL;
307 type = xmlDetectCharEncoding(strval, len); 288 type = xmlDetectCharEncoding(strval, len);
308 289
309 if (XML_CHAR_ENCODING_UTF8 == type) { 290 if (XML_CHAR_ENCODING_UTF8 == type ||
310 data->unicodeval = g_utf8_to_utf16((char *) strval, len, &items_read, &items_written, &error); 291 XML_CHAR_ENCODING_ASCII == type ||
311 data->type = PLIST_UNICODE; 292 XML_CHAR_ENCODING_NONE == type) {
312 data->length = items_written;
313 } else if (XML_CHAR_ENCODING_ASCII == type || XML_CHAR_ENCODING_NONE == type) {
314 data->strval = strdup((char *) strval); 293 data->strval = strdup((char *) strval);
315 data->type = PLIST_STRING; 294 data->type = PLIST_STRING;
316 data->length = strlen(data->strval); 295 data->length = strlen(data->strval);