comparison lib/protocols.c @ 582:5df46f79d9c1

2004-10-4 Brian Masney <masneyb@gftp.org> * lib/protocols.c (gftp_string_from_utf8,gftp_string_to_utf8) - added more printf() functions whenever there is a problem converting a string * src/gtk/gtkui_transfer.c (gftpui_ask_transfer) - make sure the filename that is to be displayed to the user is encoded in UTF8
author masneyb
date Tue, 05 Oct 2004 00:13:09 +0000
parents 5dc685bf403e
children fa0838b22b14
comparison
equal deleted inserted replaced
581:abcb6713b6b8 582:5df46f79d9c1
449 return (NULL); 449 return (NULL);
450 450
451 if (g_utf8_validate (str, -1, NULL)) 451 if (g_utf8_validate (str, -1, NULL))
452 return (NULL); 452 return (NULL);
453 else if (request->iconv_initialized) 453 else if (request->iconv_initialized)
454 return (g_convert_with_iconv (str, -1, request->iconv, &bread, &bwrite, 454 {
455 &error)); 455 ret = g_convert_with_iconv (str, -1, request->iconv, &bread, &bwrite,
456 &error);
457 if (ret == NULL)
458 printf (_("Error converting string '%s' from character set %s to character set %s: %s\n"),
459 str, _("<unknown>"), "UTF-8", error->message);
460
461 return (ret);
462 }
456 463
457 gftp_lookup_request_option (request, "remote_charsets", &tempstr); 464 gftp_lookup_request_option (request, "remote_charsets", &tempstr);
458 if (*tempstr == '\0') 465 if (*tempstr == '\0')
459 { 466 {
460 error = NULL; 467 error = NULL;
478 485
479 error = NULL; 486 error = NULL;
480 if ((ret = g_convert_with_iconv (str, -1, request->iconv, &bread, &bwrite, 487 if ((ret = g_convert_with_iconv (str, -1, request->iconv, &bread, &bwrite,
481 &error)) == NULL) 488 &error)) == NULL)
482 { 489 {
490 printf (_("Error converting string '%s' from character set %s to character set %s: %s\n"),
491 str, cur_charset, "UTF-8", error->message);
492
483 g_iconv_close (request->iconv); 493 g_iconv_close (request->iconv);
484 request->iconv = NULL; 494 request->iconv = NULL;
485 continue; 495 continue;
486 } 496 }
487 else 497 else
505 GError * error; 515 GError * error;
506 516
507 if (request == NULL) 517 if (request == NULL)
508 return (NULL); 518 return (NULL);
509 519
510 if (request->iconv_initialized) 520 /* If the string isn't in UTF-8 format, assume it is already in the current
511 return (g_convert_with_iconv (str, -1, request->iconv, &bread, &bwrite, 521 locale... */
512 &error)); 522 if (!g_utf8_validate (str, -1, NULL))
523 return (NULL);
524 else if (request->iconv_initialized)
525 {
526 ret = g_convert_with_iconv (str, -1, request->iconv, &bread, &bwrite,
527 &error);
528 if (ret == NULL)
529 printf (_("Error converting string '%s' from character set %s to character set %s: %s\n"),
530 str, "UTF-8", _("<unknown>"), error->message);
531
532 return (ret);
533 }
513 534
514 gftp_lookup_request_option (request, "remote_charsets", &tempstr); 535 gftp_lookup_request_option (request, "remote_charsets", &tempstr);
515 if (*tempstr == '\0') 536 if (*tempstr == '\0')
516 { 537 {
517 error = NULL; 538 error = NULL;
535 556
536 error = NULL; 557 error = NULL;
537 if ((ret = g_convert_with_iconv (str, -1, request->iconv, &bread, &bwrite, 558 if ((ret = g_convert_with_iconv (str, -1, request->iconv, &bread, &bwrite,
538 &error)) == NULL) 559 &error)) == NULL)
539 { 560 {
561 printf (_("Error converting string '%s' from character set %s to character set %s: %s\n"),
562 str, "UTF-8", cur_charset, error->message);
563
540 g_iconv_close (request->iconv); 564 g_iconv_close (request->iconv);
541 request->iconv = NULL; 565 request->iconv = NULL;
542 continue; 566 continue;
543 } 567 }
544 else 568 else