Exemple #1
0
 /**
  * Convert tabs to spaces on each line using a 4-space tab stop
  * @param string $string
  *
  * @return string
  */
 protected static function detabLine($string)
 {
     if (strpos($string, "\t") === false) {
         return $string;
     }
     // Split into different parts
     $parts = explode("\t", $string);
     // Add each part to the resulting line
     // The first one is done here; others are prefixed
     // with the necessary spaces inside the loop below
     $line = $parts[0];
     unset($parts[0]);
     foreach ($parts as $part) {
         // Calculate number of spaces; insert them followed by the non-tab contents
         $amount = 4 - Typecho_Common::strLen($line, 'UTF-8') % 4;
         $line .= str_repeat(' ', $amount) . $part;
     }
     return $line;
 }
Exemple #2
0
 /**
  * Max Length
  *
  * @access public
  * @param string
  * @return boolean
  */
 public function maxLength($str, $length)
 {
     return Typecho_Common::strLen($str) < $length;
 }