Exemplo n.º 1
0
 function readUTF8Bytes($len)
 {
     $string = $this->read($len);
     $pos = 0;
     $pass = 1;
     while ($pass <= $len) {
         $charCode = ord($string[$pos]);
         if ($charCode < 0x80) {
             $pos++;
         } elseif (($charCode & 0xe0) == 0xc0) {
             $pos += 2;
             $string .= $this->read(1);
         } elseif (($charCode & 0xf0) == 0xe0) {
             $pos += 3;
             $string .= $this->read(2);
         }
         $pass++;
     }
     if (HessianUtils::isInternalUTF8()) {
         return $string;
     }
     return utf8_decode($string);
     /*$string = '';
     		for($i=0;$i<$len;$i++){
     			$ch = $this->read(1);
     			$charCode = ord($ch);
     			if($charCode < 0x80)
     				$string .= $ch;
     			elseif(($charCode & 0xe0) == 0xc0) {
     				$string .= $ch.$this->read(1);
     			} elseif (($charCode & 0xf0) == 0xe0) {
     				$string .= $ch.$this->read(2);
     			} else {
     				throw new HessianParsingException("Bad utf-8 encoding at pos ".$this->stream->pos);
     			}
     		}
     		if(HessianUtils::isInternalUTF8())
     			return $string;
     		return utf8_decode($string);*/
 }
Exemplo n.º 2
0
 function parseString($code, $num)
 {
     $end = false;
     $string = '';
     while (!$end) {
         $tempLen = unpack('n', $this->read(2));
         $len = $tempLen[1];
         if ($code == 's' || $code == 'x') {
             $code = $this->read(1);
         } else {
             $end = true;
         }
         $string .= $this->readUTF8Bytes($len);
         //$end = true;
     }
     if (HessianUtils::isInternalUTF8()) {
         return $string;
     }
     return utf8_decode($string);
 }