Skip Menu |

This queue is for tickets about the XML-Smart CPAN distribution.

Report information
The Basics
Id: 18119
Status: resolved
Priority: 0/
Queue: XML-Smart

People
Owner: TMHARISH [...] cpan.org
Requestors: jamguo [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Wide character in subroutine entry at Base64.pm line 27.
When use data() method after new(), the program report: Wide character in subroutine entry at C:/Perl/site/lib/XML/Smart/Base64.pm line 27. xml file is attached: ------ <?xml version="1.0" encoding="utf-8"?> <subject_list> <subject type="book"> <memo><![CDATA[本书可为政府决策部门制定相关决策使用。它详细介绍了科技 发达国家的宏观科技经费管理体制、监督机构设置及职责,经费管理法律制度要 求,监督操作方法,以及监督结果的使用等。]]></memo> </subject> </subject_list> ------
I encountered this problem while trying to rebuild (using data_pointer()) the XML that contained the right single quote character ("\x{2019}"). It worked fine for cyrillic letters and for some randomly picked hieroglyph, though (they must be recognized as "word" characters so XML::Smart decides they don't need to be binary-encoded). The attached file contains a quick fix patch for the problem. It's only suitable for recent Perl versions, though; the proper fix would probably need some version-specific logic similar to the _is_unicode function.
--- XML/Smart/Base64.pm.old 2004-06-06 16:48:46.000000000 +0700 +++ XML/Smart/Base64.pm 2009-06-01 19:27:41.000000000 +0700 @@ -16,7 +16,7 @@ no warnings ; my ($BASE64_PM) ; -eval("use MIME::Base64 ()") ; +eval("use MIME::Base64 (); use Encode;") ; if ( defined &MIME::Base64::encode_base64 ) { $BASE64_PM = 1 ;} ################# @@ -24,7 +24,9 @@ ################# sub encode_base64 { - if ( $BASE64_PM ) { return &MIME::Base64::encode_base64($_[0]) ;} + if ( $BASE64_PM ) { return &MIME::Base64::encode_base64( utf8::is_utf8($_[0]) + ? &Encode::encode_utf8($_[0]) + : $_[0] ) ;} else { return &_encode_base64_pure_perl($_[0]) ;} }
Fixed in 1.73 Please see details of additions to $XML->data in POD