#3 Some files can't be required by a function

<= 0.3
closed-fixed
5
2006-10-25
2006-10-01
No

<?php
public function singleRepresentation($str)
{
// dynamically requiring file of phputf8 library,
// as it is only required if this function is
// called
require_once 'utf8/utils/ascii.php';
return utf8_decode(utf8_accents_to_ascii($str));
}
?>
Problem is!

utf8/utils/ascii.php contains global variables
$UTF8_LOWER_ACCENTS & $UTF8_UPPER_ACCENTS which
when required by a function become local to that
function!

Resulting in problems for utf8_accents_to_ascii()
that can no longer locate the variables it needs.

The solution is to change:
<?php
$UTF8_LOWER_ACCENTS = array(...);
?>
to
<?php
$GLOBALS['UTF8_LOWER_ACCENTS'] = array(...);
?>
If the bug is still difficult to understand have a look
at http://forums.devnetwork.net/viewtopic.php?p=315239

Discussion

  • Harry Fuecks

    Harry Fuecks - 2006-10-04
    • labels: 823465 --> UTF-8 Utils (./utils)
    • milestone: --> <= 0.3
    • assigned_to: nobody --> harryf
    • status: open --> open-accepted
     
  • Harry Fuecks

    Harry Fuecks - 2006-10-16
    • status: open-accepted --> open-fixed
     
  • Harry Fuecks

    Harry Fuecks - 2006-10-16

    Logged In: YES
    user_id=569780

    OK - now fixed in CVS - release coming soon. In fact the
    utf8_accents_to_ascii() fn was badly broken - now works.

     
  • Harry Fuecks

    Harry Fuecks - 2006-10-25

    Logged In: YES
    user_id=569780

    OK - next release (0.4) containing this fix is out

     
  • Harry Fuecks

    Harry Fuecks - 2006-10-25
    • status: open-fixed --> closed-fixed
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks