|
From: Christian G. <phi...@us...> - 2002-11-12 10:41:32
|
Update of /cvsroot/perl-xml/XML-LibXML-Common
In directory usw-pr-cvs1:/tmp/cvs-serv10650
Modified Files:
Common.xs Changes
Log Message:
Modified Files:
Common.xs Changes
added daisukes encoding patch
Index: Common.xs
===================================================================
RCS file: /cvsroot/perl-xml/XML-LibXML-Common/Common.xs,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- Common.xs 21 Oct 2002 16:43:16 -0000 1.3
+++ Common.xs 12 Nov 2002 10:41:29 -0000 1.4
@@ -58,55 +58,64 @@
realstring = SvPV(string, len);
if ( realstring != NULL ) {
/* warn("encode %s", realstring ); */
- enc = xmlParseCharEncoding( encoding );
-
- if ( enc == 0 ) {
- /* this happens if the encoding is "" or NULL */
- enc = XML_CHAR_ENCODING_UTF8;
- }
-
- if ( enc == XML_CHAR_ENCODING_UTF8 ) {
- /* copy the string */
- /* warn( "simply copy the string" ); */
- tstr = xmlStrdup( realstring );
- }
- else {
- LibXML_COMMON_error = NEWSV(0, 512);
- xmlSetGenericErrorFunc(PerlIO_stderr(),
- (xmlGenericErrorFunc)LIBXML_COMMON_error_handler);
-
-
- if ( enc > 1 ) {
- coder= xmlGetCharEncodingHandler( enc );
+#ifdef HAVE_UTF8
+ if ( !DO_UTF8(string) && encoding != NULL ) {
+#else
+ if ( encoding != NULL ) {
+#endif
+ enc = xmlParseCharEncoding( encoding );
+
+ if ( enc == 0 ) {
+ /* this happens if the encoding is "" or NULL */
+ enc = XML_CHAR_ENCODING_UTF8;
}
- else if ( enc == XML_CHAR_ENCODING_ERROR ){
- coder =xmlFindCharEncodingHandler( encoding );
+
+ if ( enc == XML_CHAR_ENCODING_UTF8 ) {
+ /* copy the string */
+ /* warn( "simply copy the string" ); */
+ tstr = xmlStrdup( realstring );
}
else {
- croak("no encoder found\n");
- }
+ LibXML_COMMON_error = NEWSV(0, 512);
+ xmlSetGenericErrorFunc(PerlIO_stderr(),
+ (xmlGenericErrorFunc)LIBXML_COMMON_error_handler);
- if ( coder == NULL ) {
- croak( "cannot encode string" );
- }
+
+ if ( enc > 1 ) {
+ coder= xmlGetCharEncodingHandler( enc );
+ }
+ else if ( enc == XML_CHAR_ENCODING_ERROR ){
+ coder =xmlFindCharEncodingHandler( encoding );
+ }
+ else {
+ croak("no encoder found\n");
+ }
+
+ if ( coder == NULL ) {
+ croak( "cannot encode string" );
+ }
- in = xmlBufferCreate();
- out = xmlBufferCreate();
- xmlBufferCCat( in, realstring );
- if ( xmlCharEncInFunc( coder, out, in ) >= 0 ) {
- tstr = xmlStrdup( out->content );
- }
+ in = xmlBufferCreate();
+ out = xmlBufferCreate();
+ xmlBufferCCat( in, realstring );
+ if ( xmlCharEncInFunc( coder, out, in ) >= 0 ) {
+ tstr = xmlStrdup( out->content );
+ }
- xmlBufferFree( in );
- xmlBufferFree( out );
- xmlCharEncCloseFunc( coder );
+ xmlBufferFree( in );
+ xmlBufferFree( out );
+ xmlCharEncCloseFunc( coder );
- sv_2mortal(LibXML_COMMON_error);
+ sv_2mortal(LibXML_COMMON_error);
- if ( SvCUR( LibXML_COMMON_error ) > 0 ) {
- croak(SvPV(LibXML_COMMON_error, len));
+ if ( SvCUR( LibXML_COMMON_error ) > 0 ) {
+ croak(SvPV(LibXML_COMMON_error, len));
+ }
}
}
+ else {
+ tstr = xmlStrdup( realstring );
+ }
if ( !tstr ) {
croak( "return value missing!" );
@@ -162,11 +171,13 @@
xmlSetGenericErrorFunc(PerlIO_stderr(),
(xmlGenericErrorFunc)LIBXML_COMMON_error_handler);
+ sv_2mortal(LibXML_COMMON_error);
+
if ( enc > 1 ) {
coder= xmlGetCharEncodingHandler( enc );
}
else if ( enc == XML_CHAR_ENCODING_ERROR ){
- coder =xmlFindCharEncodingHandler( encoding );
+ coder = xmlFindCharEncodingHandler( encoding );
}
else {
croak("no encoder found\n");
@@ -186,8 +197,6 @@
xmlBufferFree( in );
xmlBufferFree( out );
xmlCharEncCloseFunc( coder );
-
- sv_2mortal(LibXML_COMMON_error);
if ( SvCUR( LibXML_COMMON_error ) > 0 ) {
croak(SvPV(LibXML_COMMON_error, len));
Index: Changes
===================================================================
RCS file: /cvsroot/perl-xml/XML-LibXML-Common/Changes,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Changes 21 Oct 2002 16:43:16 -0000 1.4
+++ Changes 12 Nov 2002 10:41:29 -0000 1.5
@@ -1,12 +1,15 @@
Revision history for Perl extension XML::LibXML::Common.
+0.12 Tue Nov 12 12:00:00 2002
+ - Encoding fix provided by Daisuke Maki
+
0.11 Sat Okt 12 21:30:00 2002
- added a disclaimer note and the license statement
0.10 Sat Aug 31 20:00:00 2002
- - implemented encoding functions
- - libxml/ libgdome conform implementation
+ - implemented encoding functions
+ - libxml/ libgdome conform implementation
0.01 Sat Aug 31 18:29:05 2002
- - original version; created by h2xs 1.21 with options
+ - original version; created by h2xs 1.21 with options
|