Skip Menu |

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

Report information
The Basics
Id: 6449
Status: resolved
Worked: 3 min
Priority: 0/
Queue: XML-Smart

People
Owner: Nobody in particular
Requestors: oleo [...] trenger.ro
Cc:
AdminCc:

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



Subject: Will unicode check ever run?
I've been having problems with XML::Smart reading my xml-files, and always saving them as iso-8859-1 files. Then I read the source of XML/Smart/Data.pm and found the following pice of code: ############### # _IS_UNICODE # ############### sub _is_unicode { if ($] >= 5.8) { eval(q` if ( $data =~ /[\x{100}-\x{10FFFF}]/s) { return 1 ;}} `); } else { ## No Perl internal support for UTF-8! ;-/ ## Is better to handle as Latin1. return undef ; } return undef ; } ------------------------------ Now I'm not an expert but, I guess the $data variable should be shifted, since it's passed as a parameter, and the $] never returns 5.8 but 5.008xxx, so anyways the $data variable is never used, and therefor the unicode check is nevere run (ergo never fails). My suggestion to a fix is as follows: ------------------------------- sub _is_unicode { my $data = shift; if ($] >= 5.008) { ## If we're using >5.008, we got utf8 so we should be able ## to use the utf8::_is_utf8 function. use utf8; if ( utf8::is_utf8($data)) { return 1 ;} } else { ## No Perl internal support for UTF-8! ;-/ ## Is better to handle as Latin1. return undef ; } return undef ; } ------------------------------------ Ole Øyvind Hove <oleo@trenger.ro>
From: oleo [...] trenger.ro
[guest - Fri May 28 04:24:28 2004]: Show quoted text
> I've been having problems with XML::Smart reading my xml-files, and > always saving them as iso-8859-1 files. > Then I read the source of XML/Smart/Data.pm and found the following > pice of code: > ############### > # _IS_UNICODE # > ############### > > sub _is_unicode { > if ($] >= 5.8) { > eval(q` > if ( $data =~ /[\x{100}-\x{10FFFF}]/s) { return 1 ;}} > `); > } > else { > ## No Perl internal support for UTF-8! ;-/ > ## Is better to handle as Latin1. > return undef ; > } > > return undef ; > } > ------------------------------ > Now I'm not an expert but, I guess the $data variable should be > shifted, since it's passed as a parameter, and the $] never returns > 5.8 but 5.008xxx, so anyways the $data variable is never used, and > therefor the unicode check is nevere run (ergo never fails). > > My suggestion to a fix is as follows: > ------------------------------- > sub _is_unicode { > my $data = shift; > if ($] >= 5.008) { > ## If we're using >5.008, we got utf8 so we should be able > ## to use the utf8::_is_utf8 function.
Better remove the following use-clause: Show quoted text
> #use utf8; > if ( utf8::is_utf8($data)) { return 1 ;} > } > else { > ## No Perl internal support for UTF-8! ;-/ > ## Is better to handle as Latin1. > return undef ; > } > > return undef ; > } > ------------------------------------ > > Ole Øyvind Hove <oleo@trenger.ro>