Rev 2 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2 | Rev 131 | ||
---|---|---|---|
Line 430... | Line 430... | ||
430 | } |
430 | } |
431 | // Find last occurence of the delimiter |
431 | // Find last occurence of the delimiter |
432 | $delim_pos = strrpos($encoded, '-'); |
432 | $delim_pos = strrpos($encoded, '-'); |
433 | if ($delim_pos > self::byteLength($this->_punycode_prefix)) { |
433 | if ($delim_pos > self::byteLength($this->_punycode_prefix)) { |
434 | for ($k = self::byteLength($this->_punycode_prefix); $k < $delim_pos; ++$k) { |
434 | for ($k = self::byteLength($this->_punycode_prefix); $k < $delim_pos; ++$k) { |
435 | $decoded[] = ord($encoded{$k}); |
435 | $decoded[] = ord($encoded[$k]); |
436 | } |
436 | } |
437 | } |
437 | } |
438 | $deco_len = count($decoded); |
438 | $deco_len = count($decoded); |
439 | $enco_len = self::byteLength($encoded); |
439 | $enco_len = self::byteLength($encoded); |
440 | 440 | ||
Line 444... | Line 444... | ||
444 | $idx = 0; |
444 | $idx = 0; |
445 | $char = $this->_initial_n; |
445 | $char = $this->_initial_n; |
446 | 446 | ||
447 | for ($enco_idx = ($delim_pos) ? ($delim_pos + 1) : 0; $enco_idx < $enco_len; ++$deco_len) { |
447 | for ($enco_idx = ($delim_pos) ? ($delim_pos + 1) : 0; $enco_idx < $enco_len; ++$deco_len) { |
448 | for ($old_idx = $idx, $w = 1, $k = $this->_base; 1; $k += $this->_base) { |
448 | for ($old_idx = $idx, $w = 1, $k = $this->_base; 1; $k += $this->_base) { |
449 | $digit = $this->_decode_digit($encoded{$enco_idx++}); |
449 | $digit = $this->_decode_digit($encoded[$enco_idx++]); |
450 | $idx += $digit * $w; |
450 | $idx += $digit * $w; |
451 | $t = ($k <= $bias) ? $this->_tmin : |
451 | $t = ($k <= $bias) ? $this->_tmin : |
452 | (($k >= $bias + $this->_tmax) ? $this->_tmax : ($k - $bias)); |
452 | (($k >= $bias + $this->_tmax) ? $this->_tmax : ($k - $bias)); |
453 | if ($digit < $t) { |
453 | if ($digit < $t) { |
454 | break; |
454 | break; |
Line 871... | Line 871... | ||
871 | $out_len = 0; |
871 | $out_len = 0; |
872 | $inp_len = self::byteLength($input); |
872 | $inp_len = self::byteLength($input); |
873 | $mode = 'next'; |
873 | $mode = 'next'; |
874 | $test = 'none'; |
874 | $test = 'none'; |
875 | for ($k = 0; $k < $inp_len; ++$k) { |
875 | for ($k = 0; $k < $inp_len; ++$k) { |
876 | $v = ord($input{$k}); // Extract byte from input string |
876 | $v = ord($input[$k]); // Extract byte from input string |
877 | if ($v < 128) { // We found an ASCII char - put into stirng as is |
877 | if ($v < 128) { // We found an ASCII char - put into stirng as is |
878 | $output[$out_len] = $v; |
878 | $output[$out_len] = $v; |
879 | ++$out_len; |
879 | ++$out_len; |
880 | if ('add' == $mode) { |
880 | if ('add' == $mode) { |
881 | $this->_error('Conversion from UTF-8 to UCS-4 failed: malformed input at byte ' . $k); |
881 | $this->_error('Conversion from UTF-8 to UCS-4 failed: malformed input at byte ' . $k); |
Line 1002... | Line 1002... | ||
1002 | // Increment output position every 4 input bytes |
1002 | // Increment output position every 4 input bytes |
1003 | if (!($i % 4)) { |
1003 | if (!($i % 4)) { |
1004 | $out_len++; |
1004 | $out_len++; |
1005 | $output[$out_len] = 0; |
1005 | $output[$out_len] = 0; |
1006 | } |
1006 | } |
1007 | $output[$out_len] += ord($input{$i}) << (8 * (3 - ($i % 4) ) ); |
1007 | $output[$out_len] += ord($input[$i]) << (8 * (3 - ($i % 4) ) ); |
1008 | } |
1008 | } |
1009 | return $output; |
1009 | return $output; |
1010 | } |
1010 | } |
1011 | 1011 | ||
1012 | /** |
1012 | /** |