[perl-Glib-Object-Introspection] Do not assume filenames are UTF8-encoded



commit f224fcc9a19ba940d8624d53ce9f6966154619f5
Author: Torsten SchÃnfeld <kaffeetisch gmx de>
Date:   Sat Feb 18 22:40:00 2012 +0100

    Do not assume filenames are UTF8-encoded
    
    Instead of automatically converting filenames to and from UTF8-encoded Perl
    strings, be agnostic about the encoding.  Before passing a filename on to
    something which expects UTF8 (like widgets), users now have to ensure manually
    that it is UTF8-encoded (via Glib::filename_to_unicode, for example).  Thus,
    this change might be an API break.

 NEWS                     |    8 ++++++++
 gperl-i11n-marshal-arg.c |    7 +++----
 t/00-basic-types.t       |    2 +-
 3 files changed, 12 insertions(+), 5 deletions(-)
---
diff --git a/NEWS b/NEWS
index 599a8d4..c7aace1 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,11 @@
+Overview of changes in Glib::Object::Introspection <next>
+========================================================
+
+* Do not assume filenames are UTF8-encoded; pass the strings on unaltered in
+  both directions, C to Perl and Perl to C.  Before passing a filename on to
+  something which expects UTF8 (like widgets), users now have to ensure that it
+  is UTF8-encoded.  Glib::filename_to_unicode provides one way to do this.
+
 Overview of changes in Glib::Object::Introspection 0.006
 ========================================================
 
diff --git a/gperl-i11n-marshal-arg.c b/gperl-i11n-marshal-arg.c
index 90c57a5..5de46bd 100644
--- a/gperl-i11n-marshal-arg.c
+++ b/gperl-i11n-marshal-arg.c
@@ -117,8 +117,8 @@ sv_to_arg (SV * sv,
 		break;
 
 	    case GI_TYPE_TAG_FILENAME:
-		/* FIXME: Is it correct to use gperl_filename_from_sv here? */
-		arg->v_string = gperl_sv_is_defined (sv) ? gperl_filename_from_sv (sv) : NULL;
+		/* FIXME: Should we use SvPVbyte_nolen here? */
+		arg->v_string = gperl_sv_is_defined (sv) ? SvPV_nolen (sv) : NULL;
 		if (transfer >= GI_TRANSFER_CONTAINER)
 			arg->v_string = g_strdup (arg->v_string);
 		break;
@@ -227,8 +227,7 @@ arg_to_sv (GIArgument * arg,
 
 	    case GI_TYPE_TAG_FILENAME:
 	    {
-		/* FIXME: Is it correct to use gperl_sv_from_filename here? */
-		SV *sv = gperl_sv_from_filename (arg->v_string);
+		SV *sv = newSVpv (arg->v_string, PL_na);
 		if (own)
 			g_free (arg->v_string);
 		return sv;
diff --git a/t/00-basic-types.t b/t/00-basic-types.t
index 00816c2..7f28e0d 100644
--- a/t/00-basic-types.t
+++ b/t/00-basic-types.t
@@ -48,7 +48,7 @@ is (Regress::test_utf8_null_out (), undef);
 
 my $filenames = Regress::test_filename_return ();
 is (scalar @$filenames, 2);
-is ($filenames->[0], 'ÃÃÃ');
+is (Glib::filename_to_unicode ($filenames->[0]), 'ÃÃÃ');
 is ($filenames->[1], '/etc/fstab');
 
 is (Regress::test_int_out_utf8 ('ÎÎÎè'), 4);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]