From: Christian G. <phi...@us...> - 2003-02-27 18:33:04
|
Update of /cvsroot/perl-xml/XML-LibXML-Common In directory sc8-pr-cvs1:/tmp/cvs-serv22148 Modified Files: Changes Common.pm Common.xs test.pl Log Message: Modified Files: Changes Common.pm + version updates Common.xs + fixed the UTF16 decoding bug. now the entire string is copied to the SV* test.pl + utf16 tests Index: Changes =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-Common/Changes,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Changes 12 Nov 2002 10:41:29 -0000 1.5 +++ Changes 27 Feb 2003 18:32:59 -0000 1.6 @@ -1,4 +1,10 @@ Revision history for Perl extension XML::LibXML::Common. +0.13 + - fixed the UTF16 decoding bug (now the entire string is available) + +0.12_1 Sat Nov 16 11:30:00 2002 + - removed japanese test from default tests. + (solaris cannot handle it by default) 0.12 Tue Nov 12 12:00:00 2002 - Encoding fix provided by Daisuke Maki Index: Common.pm =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-Common/Common.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Common.pm 15 Nov 2002 20:10:13 -0000 1.4 +++ Common.pm 27 Feb 2003 18:32:59 -0000 1.5 @@ -14,7 +14,7 @@ @ISA = qw(DynaLoader Exporter); -$VERSION = '0.12'; +$VERSION = '0.13'; bootstrap XML::LibXML::Common $VERSION; Index: Common.xs =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-Common/Common.xs,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Common.xs 12 Nov 2002 10:41:29 -0000 1.4 +++ Common.xs 27 Feb 2003 18:32:59 -0000 1.5 @@ -121,7 +121,7 @@ croak( "return value missing!" ); } - len = xmlStrlen( tstr ); + len = xmlStrlen( tstr ); RETVAL = newSVpvn( (const char *)tstr, len ); #ifdef HAVE_UTF8 SvUTF8_on(RETVAL); @@ -191,7 +191,8 @@ out = xmlBufferCreate(); xmlBufferCCat( in, realstring ); if ( xmlCharEncOutFunc( coder, out, in ) >= 0 ) { - tstr = xmlStrdup(out->content); + len = xmlBufferLength(out); + tstr = (xmlChar*)xmlBufferContent(out); } xmlBufferFree( in ); @@ -207,7 +208,7 @@ } } - len = xmlStrlen( tstr ); + /* len = xmlStrlen( tstr ); */ RETVAL = newSVpvn( (const char *)tstr, len ); #ifdef HAVE_UTF8 if ( enc == XML_CHAR_ENCODING_UTF8 ) { Index: test.pl =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-Common/test.pl,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- test.pl 2 Sep 2002 09:15:16 -0000 1.1.1.1 +++ test.pl 27 Feb 2003 18:32:59 -0000 1.2 @@ -6,12 +6,14 @@ # change 'tests => 1' to 'tests => last_test_to_print'; use Test; -BEGIN { plan tests => 5 }; +BEGIN { plan tests => 8 }; use XML::LibXML::Common qw( :libxml :encoding ); use constant TEST_STRING_GER => "Hänsel und Gretel"; use constant TEST_STRING_GER2 => "täst"; use constant TEST_STRING_UTF => 'test'; +use constant TEST_STRING_JP => 'À¸ÇþÀ¸ÊÆÀ¸Íñ'; + ok(1); # If we made it this far, we're ok. ######################### @@ -35,8 +37,32 @@ TEST_STRING_UTF ); +my $u16 = decodeFromUTF8( 'UTF-16', + encodeToUTF8('UTF-8', TEST_STRING_UTF ) ); +ok( length($u16), 2*length(TEST_STRING_UTF)); + +my $u16be = decodeFromUTF8( 'UTF-16BE', + encodeToUTF8('UTF-8', TEST_STRING_UTF ) ); +ok( length($u16be), 2*length(TEST_STRING_UTF)); + +my $u16le = decodeFromUTF8( 'UTF-16LE', + encodeToUTF8('UTF-8', TEST_STRING_UTF ) ); +ok( length($u16le), 2*length(TEST_STRING_UTF)); +#bad encoding name test. eval { - my $str = encodeToUTF8( "EUC-JP" ,"Föö" ); + my $str = encodeToUTF8( "foo" , TEST_STRING_GER2 ); }; ok( length( $@ ) ); + +# here should be a test to test badly encoded strings. but for some +# reasons i am unable to create an apropriate test :( + + + +# uncomment these lines if your system is capable to handel not only i +# so latin 1 +#ok( decodeFromUTF8('EUC-JP', +# encodeToUTF8('EUC-JP', +# TEST_STRING_JP ) ), +# TEST_STRING_JP ); |