original_string: public static function getLength($str)
      {
          $bytes = 0;
          $chars = 0;
          while ($bytes < strlen($str)) {
              $charBytes = 1;
              if ((ord($str[$bytes]) & 0xC0) == 0xC0) {
                  $charBytes++;
                  if (ord($str[$bytes]) & 0x20 ) {
                      $charBytes++;
                      if (ord($str[$bytes]) & 0x10 ) {
                          $charBytes++;
                      }
                  }
              }
  
              if ($bytes + $charBytes > strlen($str)) {
                  // wrong character
                  break;
              }
  
              $chars++;
              $bytes += $charBytes;
          }
  
          return $chars;
      }
code: public static function getLength($str)
      {
          $bytes = 0;
          $chars = 0;
          while ($bytes < strlen($str)) {
              $charBytes = 1;
              if ((ord($str[$bytes]) & 0xC0) == 0xC0) {
                  $charBytes++;
                  if (ord($str[$bytes]) & 0x20 ) {
                      $charBytes++;
                      if (ord($str[$bytes]) & 0x10 ) {
                          $charBytes++;
                      }
                  }
              }
  
              if ($bytes + $charBytes > strlen($str)) {
                  // wrong character
                  break;
              }
  
              $chars++;
              $bytes += $charBytes;
          }
  
          return $chars;
      }
code_tokens: public static function getLength ( $ str ) { $ bytes = 0 ; $ chars = 0 ; while ( $ bytes < strlen ( $ str ) ) { $ charBytes = 1 ; if ( ( ord ( $ str [ $ bytes ] ) & 0xC0 ) == 0xC0 ) { $ charBytes ++ ; if ( ord ( $ str [ $ bytes ] ) & 0x20 ) { $ charBytes ++ ; if ( ord ( $ str [ $ bytes ] ) & 0x10 ) { $ charBytes ++ ; } } } if ( $ bytes + $ charBytes > strlen ( $ str ) ) { // wrong character break ; } $ chars ++ ; $ bytes += $ charBytes ; } return $ chars ; }
docstring: Get UTF-8 string length
  
  @param  string $str
  @return string
docstring_tokens: Get UTF - 8 string length