Пример #1
0
function yk_d($a)
{
    if (!$a) {
        return '';
    }
    $f = strlen($a);
    $b = 0;
    $str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
    for ($c = ''; $b < $f;) {
        $e = charCodeAt($a, $b++) & 255;
        if ($b == $f) {
            $c .= charAt($str, $e >> 2);
            $c .= charAt($str, ($e & 3) << 4);
            $c .= '==';
            break;
        }
        $g = charCodeAt($a, $b++);
        if ($b == $f) {
            $c .= charAt($str, $e >> 2);
            $c .= charAt($str, ($e & 3) << 4 | ($g & 240) >> 4);
            $c .= charAt($str, ($g & 15) << 2);
            $c .= '=';
            break;
        }
        $h = charCodeAt($a, $b++);
        $c .= charAt($str, $e >> 2);
        $c .= charAt($str, ($e & 3) << 4 | ($g & 240) >> 4);
        $c .= charAt($str, ($g & 15) << 2 | ($h & 192) >> 6);
        $c .= charAt($str, $h & 63);
    }
    return $c;
}
Пример #2
0
 function matchString($s)
 {
     $i = 0;
     while ($i < strlen($s)) {
         if ($this->input->LA(1) != charAt($s, $i)) {
             if ($this->state->backtracking > 0) {
                 $this->state->failed = true;
                 return;
             }
             $mte = new MismatchedTokenException(charAt($s, $i), $this->input);
             $this->recover($mte);
             throw $mte;
         }
         $i++;
         $this->input->consume();
         $this->state->failed = false;
     }
 }
Пример #3
0
function yk_d($a)
{
    if (!$a) {
        return '';
    }
    $zm = "abcdefghijklmnopqrstuvwxyz";
    $f = strlen($a);
    $b = 0;
    $str = strtoupper($zm) . strtolower($zm) . '0123456789+/';
    for ($c = ''; $b < $f;) {
        $e = charCodeAt($a, $b++) & 255;
        if ($b == $f) {
            $c .= charAt($str, $e >> 2);
            $c .= charAt($str, ($e & 3) << 4);
            $c .= "==";
            break;
        }
        $g = charCodeAt($a, $b++);
        if ($b == f) {
            $c .= charAt($str, $e >> 2);
            $c .= charAt($str, ($e & 3) << 4 | ($g & 240) >> 4);
            $c .= charAt($str, ($g & 15) << 2);
            $c .= "=";
            break;
        }
        $h = charCodeAt($a, $b++);
        $c .= charAt($str, $e >> 2);
        $c .= charAt($str, ($e & 3) << 4 | ($g & 240) >> 4);
        $c .= charAt($str, ($g & 15) << 2 | ($h & 192) >> 6);
        $c .= charAt($str, $h & 63);
    }
    return $c;
}
Пример #4
0
 /** Given a String that has a run-length-encoding of some unsigned shorts
  *  like "\1\2\3\9", convert to short[] {2,9,9,9}.  We do this to avoid
  *  static short[] which generates so much init code that the class won't
  *  compile. :(
  */
 public static function unpackEncodedString($encodedString)
 {
     $data = array();
     $di = 0;
     for ($i = 0, $len = strlen($encodedString); $i < $len; $i += 2) {
         $n = charAt($encodedString, $i);
         $v = charAt($encodedString, $i + 1);
         // add v n times to data
         for ($j = 1; $j <= $n; $j++) {
             if ($v == 0xff) {
                 $v = -1;
             }
             $data[$di++] = $v;
         }
     }
     return $data;
 }
Пример #5
0
 /**
  * Returns the unwrapped string for the result value. An unwrapped string is
  * a string value without the quote characters that wrap the result value.
  * For a string to be returned, then the first character must be a quote
  * character and the last character must be a quote character. Otherwise, a
  * null value is returned.
  * 
  * @return String The normal string for the result value. Null will be returned if
  *         the result value is not of a string type.
  */
 public function getUnwrappedString()
 {
     if ($this->result != null && $this->result->length() >= 2) {
         if ($this->result->charAt(0) == $this->quoteCharacter && $this->result . charAt($this->result . length() - 1) == $this->quoteCharacter) {
             return $this->result->substring(1, $this->result->length() - 1);
         }
     }
     return null;
 }
Пример #6
0
function yk_d($a)
{
    if (!$a) {
        return '';
    }
    $f = strlen($a);
    $b = 0;
    $str = strtoupper(ZM) . strtolower(ZM) . '0123456789+/';
    for ($c = ''; $b < $f;) {
        $e = charCodeAt($a, $b++) & 255;
        if ($b == $f) {
            $c .= charAt($str, $e >> 2);
            $c .= charAt($str, ($e & 3) << 4);
            $c .= '==';
            break;
        }
        $g = charCodeAt($a, $b++);
        if ($b == f) {
            $c .= charAt($str, $e >> 2);
            $c .= charAt($str, ($e & 3) << 4 | ($g & 240) >> 4);
            $c .= charAt($str, ($g & 15) << 2);
            $c .= '=';
            break;
        }
        $h = charCodeAt($a, $b++);
        $c .= charAt($str, $e >> 2);
        $c .= charAt($str, ($e & 3) << 4 | ($g & 240) >> 4);
        $c .= charAt($str, ($g & 15) << 2 | ($h & 192) >> 6);
        $c .= charAt($str, $h & 63);
    }
    return $c;
}