_safe_substr

The Google Font Fix safe substr function.

Description

_safe_substr( $string, $start, $length ); 

Parameters (3)

0. $string
The string.
1. $start
The start.
2. $length
The length.

Usage

  1. if ( !function_exists( '_safe_substr' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'google-font-fix/geo/geoip.inc.php'; 
  3.  
  4. // The string. 
  5. $string = null; 
  6.  
  7. // The start. 
  8. $start = null; 
  9.  
  10. // The length. 
  11. $length = null; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = _safe_substr($string, $start, $length); 
  15.  

Defined (1)

The function is defined in the following location(s).

/geo/geoip.inc.php  
  1. function _safe_substr($string, $start, $length) 
  2. // workaround php's broken substr, strpos, etc handling with 
  3. // mbstring.func_overload and mbstring.internal_encoding 
  4. $mbExists = extension_loaded('mbstring'); 
  5.  
  6. if ($mbExists) { 
  7. $enc = mb_internal_encoding(); 
  8. mb_internal_encoding('ISO-8859-1'); 
  9.  
  10. $buf = substr($string, $start, $length); 
  11.  
  12. if ($mbExists) { 
  13. mb_internal_encoding($enc); 
  14.  
  15. return $buf;