comparison libpurple/protocols/msn/slpcall.c @ 28093:4362f871369c

Using g_convert instead of g_utf16_to_utf8 so that we can explicitly set the input byte order. It should always be little-endian and not depend on the host order.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Fri, 31 Jul 2009 04:04:24 +0000
parents 35b6fd563056
children a82fec14ac0f
comparison
equal deleted inserted replaced
28092:6c9c6123b942 28093:4362f871369c
204 204
205 if (slpmsg->session_id == 64) 205 if (slpmsg->session_id == 64)
206 { 206 {
207 /* This is for handwritten messages (Ink) */ 207 /* This is for handwritten messages (Ink) */
208 GError *error; 208 GError *error;
209 glong items_read, items_written; 209 gsize bytes_read, bytes_written;
210 210
211 body_str = g_utf16_to_utf8((gunichar2 *)body, body_len / 2, 211 body_str = g_convert(body, body_len / 2, "UTF16-LE", "UTF-8",
212 &items_read, &items_written, &error); 212 &bytes_read, &bytes_written, &error);
213 body_len -= items_read * 2 + 2; 213 body_len -= bytes_read + 2;
214 body += items_read * 2 + 2; 214 body += bytes_read + 2;
215 if (body_str == NULL 215 if (body_str == NULL
216 || body_len <= 0 216 || body_len <= 0
217 || strstr(body_str, "image/gif") == NULL) 217 || strstr(body_str, "image/gif") == NULL)
218 { 218 {
219 if (error != NULL) 219 if (error != NULL)
226 g_free(body_str); 226 g_free(body_str);
227 return NULL; 227 return NULL;
228 } 228 }
229 g_free(body_str); 229 g_free(body_str);
230 230
231 body_str = g_utf16_to_utf8((gunichar2 *)body, body_len / 2, 231 body_str = g_convert(body, body_len / 2, "UTF16-LE", "UTF-8",
232 &items_read, &items_written, &error); 232 &bytes_read, &bytes_written, &error);
233 if (!body_str) 233 if (!body_str)
234 { 234 {
235 purple_debug_error("msn", 235 purple_debug_error("msn",
236 "Unable to convert Ink body from UTF-16 to UTF-8: %s\n", 236 "Unable to convert Ink body from UTF-16 to UTF-8: %s\n",
237 error->message); 237 error->message);