Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Deprecated e modifier replacement by preg_replace_callback, encoding problem


raiwa

Recommended Posts

Trying to update the sloppy words cleaner add-on, I replaced the e modifier by preg_replace_callback.

 

Example:

   if ($all_uppercase) {
// capitalize acronymns and initialisms i.e. PO
       $str = preg_replace("/\\b($all_uppercase)\\b/e", 'mb_strtoupper("$1", CHARSET)', $str);
   }

Replaced by:

   if ($all_uppercase) {
   	 // capitalize acronymns and initialisms i.e. PO
       $str = preg_replace_callback(
           "/\\b($all_uppercase)\\b/",
           function ($m) {
             return mb_strtoupper($m[1], CHARSET);
           },
           $str
           );
   }

It all works correct except for the character encoding.

Adding "CHARSET" to the mb_strtoupper function worked in the old version, but doesn't work within the preg_replace_callback function.

I tried also with "utf-8" and 'utf-8' instead of CHARSET.

Any ideas??

 

Thanks

Rainer

Link to comment
Share on other sites

Link to comment
Share on other sites

Link to comment
Share on other sites

That's a really old bug in PHP. I thought it was fixed long ago, but apparently not. Good thing it worked, because I was running out of things to suggest.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...